I would like to connect to my mindstorms nxt robot over bluetooth with java. Also keep in mind that I have lejos installed. Lejos includes classes to connect with the robot. Thank you so much I have spent weeks trying to figure this out and would really appreciate your help!
I would like my mac to initiate the connection.
Thank you post a comment if you don't understand what I am asking. Thank you!
The code running on the mac:
//package
package bluetoothtest;
//imports
import lejos.nxt.LCD;
import lejos.pc.comm.*;
import lejos.pc.*;
//main class
public class test {
//main method
public static void main(String[] args) throws Exception
{
//establish a connection...
NXTComm nxtComm = NXTCommFactory.createNXTComm(NXTCommFactory.BLUETOOTH);
NXTInfo nxtInfo = new NXTInfo(NXTCommFactory.BLUETOOTH, "NXT", "00:16:53:0B:9C:CA");
}
}
code on robot:
//package
package bluetoothrobottest;
//imports
import java.io.DataInputStream;
import java.io.DataOutputStream;
import lejos.nxt.comm.Bluetooth;
import lejos.nxt.comm.NXTConnection;
//main class
public class test {
//main method
public static void main(String[] args)
{
//wait for connection...
System.out.println("waiting for bluetooth connection...");
NXTConnection connection = Bluetooth.waitForConnection();
System.out.println("connected...");
//create streams
DataInputStream dis = connection.openDataInputStream();
DataOutputStream dos = connection.openDataOutputStream();
}
}
When I put this line of code in it gives me an error saying that the bluecove library isn't available:
nxtComm.open(nxtInfo,NXTComm.PACKET);