nxtCommand.startProgram via Bluetooth

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

nxtCommand.startProgram via Bluetooth

Postby ferwango » Sat Jul 21, 2012 8:56 am

Here is the code that works for me, I added all the jars of lejos except classes.jar, besides I also added bluecove.jar :

Code: Select all

package nxtazul;

import lejos.nxt.remote.NXTCommand;
import lejos.pc.comm.NXTComm;
import lejos.pc.comm.NXTCommFactory;
import lejos.pc.comm.NXTInfo;

public class NXTAzul {

    public static void main(String[] args) {

        try {
            NXTInfo info = new NXTInfo(NXTCommFactory.BLUETOOTH, "NXT", "00:16:53:10:ec:fd");
            NXTComm link = NXTCommFactory.createNXTComm(NXTCommFactory.BLUETOOTH);
            boolean connected = link.open(info, NXTComm.LCP);

            NXTCommand cmd = new NXTCommand(link);

            if (!connected) {
                System.out.println("No se puede establecer la conexion!");
                System.exit(1);
            } else {
                System.out.println("Conexion exitosa!");

                if (cmd.isOpen()) {
                    cmd.startProgram("Robottek2.nxj");
                    link.close();
                } else {
                    System.out.println("Comando Fallido");
                }
            }

        } catch (Exception e) {
            System.out.println("Error.");
            e.printStackTrace();
        }

    }
}



I hope this be useful for someone :D
ferwango
New User
 
Posts: 1
Joined: Sat Jul 21, 2012 8:47 am

Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 1 guest

more stuff