Well ive tried coding the NXT as the initiator for the bluetooth connection however im having trouble with connecting it to the specific MIDlet program.
The NXT connects to the mobile phone(as the phone flashes the bluetooth logo) but does not connect and react to the specific MIDlet program.
The java ME Midlet code for the bluetooth server program is as follows :
public class Server {
private LocalDevice local;
private myForm form;
private UUID uuid;
private String connectionString;
private StreamConnectionNotifier streamConnNotifier;
private StreamConnection con;
private final int SERIALID = 0x1101;
private DiscoveryAgent agent;
private DataOutputStream dos;
private DataInputStream dis;
public Server(myForm form)
{
this.form = form;
uuid = new UUID(1101);
connectionString = "btspp://localhost:" + uuid +";name=Sample SPP Server";
}
public void startServer() throws IOException
{
LocalDevice localDevice = LocalDevice.getLocalDevice();
//localDevice.setDiscoverable(DiscoveryAgent.GIAC);
//agent = localDevice.getDiscoveryAgent();
form.append("Address: "+localDevice.getBluetoothAddress());
form.append("Name: "+localDevice.getFriendlyName());
form.append("Waiting for connection");
streamConnNotifier = (StreamConnectionNotifier)Connector.open( connectionString );
con = streamConnNotifier.acceptAndOpen();
form.append("Connection done");
RemoteDevice dev = RemoteDevice.getRemoteDevice(con);
form.append("Remote device address: "+dev.getBluetoothAddress());
form.append("Remote device name: "+dev.getFriendlyName(true));
readData read = new readData(form,con);
read.start();
}
}
The code for the NXT is as follows.. where W995 is the phone name.
BTConnection btc;
LCD.drawString("Connecting...", 0, 2);
// RemoteDevice con2 = Bluetooth.getKnownDevice("W995");
btc = Bluetooth.connect("W995", NXTConnection.RAW);
DataInputStream dis = btc.openDataInputStream();
DataOutputStream dos = btc.openDataOutputStream();
LCD.drawString("DONE...", 0, 2);
HelloWorld start = new HelloWorld(btc, dis, dos);
start.runProgram();
Anyone have any idea why the connection occurs but not to the specific MIDlet program?
This is driving me nuts
