Good news!

I got it working at last, and I needed two things to get there: reboot the computer (haven't done that for a month, and I don't really know what difference it makes) and install bluez-gnome (to run bluetooth-applet). Finally I got the PIN window instead of the error, and immediately tested some functions of nxjbrowse with success.
Now I noticed another problem: I tried to do a rapid test with BTSend/BTReceive, and the PC seems to be stuck at the dis.readInt() call. After adding extra messages to display on both sides I can see that they run their flush() successfully, but the echoed data apparently doesn't reach BTSend (perhaps only on a higher level).
Edit: I implemented a simple echo application in C which should behave the same way as BTReceive except for not multiplying the number by -1, and it turns out that I can't send individual bytes without waiting about 5 ms between each. At the same time, I don't see anything in the Java stream handling code that suggests the need for such a delay. Is this a limitation of bt_send()? Here's the loop after accepting the connection:
- Code: Select all
while (!(buttons_get() & 0x08)) {
U8 buf[128];
int i;
memset(buf, 0, 128);
bt_receive(buf);
display_clear(0);
display_goto_xy(0, 0);
display_unsigned((buf[2] << 24) + (buf[3] << 16) + (buf[4] << 8) + buf[5], 0);
display_update();
while (!(buttons_get() & 0x01));
for (i = 0; i < buf[0]; i++) {
bt_send(buf + i + 2, 1);
systick_wait_ms(5);
}
while (buttons_get() & 0x01);
}