Hi,
I've successfully got the sample projects BTSend and BTReceive working, and I'm trying to move the BTSend application to Android instead of the PC.
In SVN there is a sample LeJOS-Droid project, so I'm trying this and finding that although it connects to the NXT the data sent from Android to the NXT never arrives...
If I add some LCD.drawString calls on the NXT side before and after the call to dis.readInt() I can see that this method blocks forever.
On the Android side dos.writeInt() is called, and after this it calls dis.readInt() and this blocks forever...
Deadlock.
The last output in the Android logcat window shows this:
------------------------------------------------------------------------------------------------------------------------------------
06-20 17:53:16.559: E/LeJOSDroid NXJ log:(18825): Connected to NXT
06-20 17:53:16.559: D/ASOCKWRP(18825): asocket_write
06-20 17:53:16.559: I/BLZ20_WRAPPER(18825): blz20_wrp_poll: nfds 2, timeout -1 ms
06-20 17:53:16.559: D/BLZ20_WRAPPER(18825): blz20_wrp_poll: transp poll : (fd 52) returned r_ev [POLLOUT ] (0x4)
06-20 17:53:16.559: D/BLZ20_WRAPPER(18825): blz20_wrp_poll: return 1
06-20 17:53:16.569: D/BLZ20_WRAPPER(18825): blz20_wrp_write: wrote 6 bytes out of 6 on fd 52
06-20 17:53:16.569: D/ASOCKWRP(18825): asocket_read
06-20 17:53:16.569: I/BLZ20_WRAPPER(18825): blz20_wrp_poll: nfds 2, timeout -1 ms
------------------------------------------------------------------------------------------------------------------------------------
I've seen other people posting example Android bluetooth to NXT code, that does not use the NXT* classes in LeJOS-Droid, using the native Bluetooth classes instead. I've tried code like this on the Android side too, and get the same results.
I've also found an Android application called nxtcontrolv2, available with source code from here:
https://sites.google.com/site/ghoelzl/nxtcontrolv2
When this connects to the example NXT program supplied with the source code, the Android side enters a loop sending a command "0" with argument of "0" using dos.writeInt(). While it is doing this the NXT side blocks, seemingly forever, calling dis.readInt(). This behavior is consistent with that of the sample programs supplied with LeJOS. However, if you pick up and tilt the phone it then starts sending values other that "0" to the NXT (move / speed / etc), at which point the NXT side crashes. I put try/catch calls in the NXT side and found that dis.readInt() was throwing an EOFException. The Android side still seemed to be connected to the NXT though and was continuing to send data to the NXT...
My phone is a HTC Desire, running Android 2.2.2. I have seen some threads on other sites saying that Bluetooth SPP is broken in some phones, possibly including mine - I'm not sure how accurate that is though as I can run the NXT Remote and MINDdroid applications on the same phone without any problem.
All my testing was done with LeJOS 0.9.1-beta2 on the NXT, and I'm running OpenSuse / Eclipse as my development platform.
I'm sure there is something real simple I'm missing here ?

