Using bluetooth command to start program on nxt brick

Post your NXJ projects, project ideas, etc here!

Moderators: 99jonathan, roger, imaqine

Using bluetooth command to start program on nxt brick

Postby mbenz1 » Wed Mar 05, 2008 2:08 am

Hi im current doing a project which requires a program to run on the next brick which communicates with a program running on a mobile phone.

Is there a way to start the program on the brick by using bluetooth commands so i done have to keep starting it on the brick manually.

Thanks
Ben

ps has anyone succesfully navigated back to a bluetooth source using bluetooth.getSignalStrength() as a guide? I tried but found it a bit inconsistent...

tx :idea:
________
Lamborghini Gallardo history
Last edited by mbenz1 on Thu Feb 03, 2011 1:20 pm, edited 1 time in total.
mbenz1
New User
 
Posts: 10
Joined: Mon Oct 08, 2007 5:22 pm

Postby mbenz1 » Wed Mar 05, 2008 6:39 pm

ive been looking at the icommand source code and this is what ive come up with so far:

Code: Select all
   public static String programName = "Main.nxj" ;
   
   public void startProgram() {
      //Create byte array with Direct command and system command byteArray
      byte [] request = {(byte)0x80, (byte)0x81};
      request = appendString(request, programName);
      
      
      
      int LSB = request.length;
      int MSB = request.length >>> 8;

      try {
         // Send length of packet:
         System.out.println("Starting program");
         outputStream.flush();
      
         outputStream.write((byte) LSB);
         outputStream.write((byte) MSB);

         outputStream.write(request);
         outputStream.flush();
      } catch (IOException e) {
         System.err.println(e.getMessage());
         e.printStackTrace();
      }
      
      

   }


Im trying to run Main.nxj which is already stored on the brick.

When it runs the little icon in the top right of the screen moves horizontally like when uploading a program but then nothing happens

any help?

ps when i run it with another file name that file name appears in the file system in the menu dont know if thats any indication of anyhting?

THanks
Ben
________
easy vape vaporizer
Last edited by mbenz1 on Thu Feb 03, 2011 1:20 pm, edited 1 time in total.
mbenz1
New User
 
Posts: 10
Joined: Mon Oct 08, 2007 5:22 pm

Postby bbagnall » Thu Mar 06, 2008 9:08 pm

Hi Ben,

I'm not sure if this helps you, but here is some code for a mobile phone app:
viewtopic.php?t=774

You just need to run that on the phone and it interacts with the NXT brick using normal LEGO Communication Protocol (LCP) commands.
User avatar
bbagnall
Site Admin
 
Posts: 392
Joined: Fri Aug 04, 2006 4:03 pm

Postby mbenz1 » Sun Mar 09, 2008 8:12 pm

Thanks this is basically what i am doing but cant figure out the command to send which will allow me to start the program on the nxt.

anyone know?

tx
Ben
________
Ford Sigma engine picture
Last edited by mbenz1 on Thu Feb 03, 2011 1:20 pm, edited 1 time in total.
mbenz1
New User
 
Posts: 10
Joined: Mon Oct 08, 2007 5:22 pm

Postby lawrie » Mon Mar 10, 2008 1:32 pm

You need to send the STARTPROGRAM command as defined in the LEGO MINDSTORMS NXT Direct Commands document available from the NXT'treme part of the Lego mindstorms web site.

Byte 0: 0x80 (or 0x00 if you want a reply)
Byte 1: 0x00
Byte 2-21 file name padded with 0x00.
lawrie
leJOS Team Member
 
Posts: 918
Joined: Mon Feb 05, 2007 1:27 pm

Postby mbenz1 » Wed Mar 12, 2008 6:23 pm

THanks for your reply.... works fine now although i dont know if i will use it but tx
________
hotels in mexico
mbenz1
New User
 
Posts: 10
Joined: Mon Oct 08, 2007 5:22 pm


Return to NXJ Projects

Who is online

Users browsing this forum: No registered users and 0 guests

more stuff