2 import lejos.nxt.comm.*;
6 * Receive data from another NXT, a PC, a phone,
7 * or another bluetooth device.
9 * Waits for a connection, receives an int and returns
10 * its negative as a reply, 100 times, and then closes
11 * the connection, and waits for a new one.
13 * @author Lawrie Griffiths
16 public class BTReceive {
18 public static void main(String [] args) throws Exception
20 String connected = "Connected";
21 String waiting = "Waiting...";
22 String closing = "Closing...";
26 LCD.drawString(waiting,0,0);
29 BTConnection btc = Bluetooth.waitForConnection();
32 LCD.drawString(connected,0,0);
35 DataInputStream dis = btc.openDataInputStream();
36 DataOutputStream dos = btc.openDataOutputStream();
38 for(int i=0;i<100;i++) {
39 int n = dis.readInt();
48 Thread.sleep(100); // wait for data to drain
50 LCD.drawString(closing,0,0);