Hi Andy,
ok, then I am a little bit confused why I get these problems with multiple nxts. Firstly, I have to say that I switched to the developer snapshot. That is because as you mentioned in
http://lejos.sourceforge.net/forum/viewtopic.php?t=2019 there are some problems with interfaces in version 0.8.5 which unfortunately affected my project. But I am rather sure that at least the first problem mentioned below did occur with the version 0.8.5.
With the developer snapshot, the following is not working:
I have a controller (called johnny) which firstly connects to a device called crownie and then waits for an inbound connection (from the device jenny). However, the method waitForConnection does not return and for the device jenny the call of connect returns null. Here are the classes I use (I start the device crownie first, then the device controller/johnny and then the device jenny).
- Code: Select all
import lejos.nxt.Button;
import lejos.nxt.comm.BTConnection;
import lejos.nxt.comm.Bluetooth;
import lejos.nxt.comm.NXTConnection;
public class Controller {
public static void main(String[] args) {
BTConnection btcCrownie = Bluetooth.connect("Crownie",
NXTConnection.PACKET);
System.out.println("conn to crownie");
BTConnection btcJenny = Bluetooth.waitForConnection();
System.out.println("conn to jenny");
Button.waitForPress();
btcJenny.close();
btcCrownie.close();
}
}
- Code: Select all
import lejos.nxt.Button;
import lejos.nxt.comm.BTConnection;
import lejos.nxt.comm.Bluetooth;
import lejos.nxt.comm.NXTConnection;
public class Crownie {
public static void main(String[] args) {
BTConnection btc = Bluetooth.waitForConnection(0, NXTConnection.PACKET);
System.out.println("conn");
Button.waitForPress();
btc.close();
}
}
- Code: Select all
import lejos.nxt.Button;
import lejos.nxt.comm.BTConnection;
import lejos.nxt.comm.Bluetooth;
import lejos.nxt.comm.NXTConnection;
public class Jenny {
public static void main(String[] args) {
BTConnection btc = Bluetooth.connect("Johnny", NXTConnection.PACKET);
System.out.println("conn");
Button.waitForPress();
btc.close();
}
}
For three NXTs I have a similar problem. I have a controller which waits at first for an inbound connection (that comes from the device jenny), then connects to a device called crownie, then to a device called josy. The inbound connection and the connection to crownie are initialized correctly, but the third connection to josy is null. The method waitForConnection for the device Josy does not return. Here is the corresponding code:
- Code: Select all
import lejos.nxt.Button;
import lejos.nxt.comm.BTConnection;
import lejos.nxt.comm.Bluetooth;
import lejos.nxt.comm.NXTConnection;
public class Controller {
public static void main(String[] args) {
BTConnection btcJenny = Bluetooth.waitForConnection();
System.out.println("conn to jenny");
BTConnection btcCrownie = Bluetooth.connect("Crownie",
NXTConnection.PACKET);
System.out.println("conn to crownie");
BTConnection btcJosy = Bluetooth.connect("Josy", NXTConnection.PACKET);
System.out.println("conn to josy");
Button.waitForPress();
btcJenny.close();
btcCrownie.close();
btcJosy.close();
}
}
- Code: Select all
import lejos.nxt.Button;
import lejos.nxt.comm.BTConnection;
import lejos.nxt.comm.Bluetooth;
import lejos.nxt.comm.NXTConnection;
public class Jenny {
public static void main(String[] args) {
BTConnection btc = Bluetooth.connect("Johnny", NXTConnection.PACKET);
System.out.println("conn");
Button.waitForPress();
btc.close();
}
}
- Code: Select all
import lejos.nxt.Button;
import lejos.nxt.comm.BTConnection;
import lejos.nxt.comm.Bluetooth;
import lejos.nxt.comm.NXTConnection;
public class Crownie {
public static void main(String[] args) {
BTConnection btc = Bluetooth.waitForConnection(0, NXTConnection.PACKET);
// BTComm btcomm = new BTComm(0);
System.out.println("conn");
Button.waitForPress();
btc.close();
}
}
- Code: Select all
import lejos.nxt.Button;
import lejos.nxt.comm.BTConnection;
import lejos.nxt.comm.Bluetooth;
import lejos.nxt.comm.NXTConnection;
public class Josy {
public static void main(String[] args) {
BTConnection btc = Bluetooth.waitForConnection(0, NXTConnection.PACKET);
System.out.println("conn");
Button.waitForPress();
btc.close();
}
}
I hope I am not annoying you with my never ending post !
