1 import java.io.IOException;
\r
4 import lejos.nxt.comm.*;
\r
7 public class BTConnectTest {
\r
8 public static void main(String[] args) throws Exception {
\r
11 LCD.drawString("Try to connect...", 0, 0);
\r
14 BTRemoteDevice btrd = Bluetooth.getKnownDevice(name);
\r
16 BTConnection btc = Bluetooth.connect(btrd);
\r
19 LCD.drawString("Connected", 0, 0);
\r
22 DataInputStream dis = btc.openDataInputStream();
\r
23 DataOutputStream dos = btc.openDataOutputStream();
\r
25 for(int i=0;i<100;i++) {
\r
27 LCD.drawInt(i*30000, 0, 2);
\r
29 dos.writeInt(i*30000);
\r
31 } catch (IOException ioe) {
\r
32 LCD.drawString("Exception", 0, 0);
\r
37 LCD.drawInt(dis.readInt(),0,3);
\r
39 } catch (IOException ioe) {
\r
47 } catch (IOException ioe) {
\r
50 Button.ESCAPE.waitForPressAndRelease();
\r