Hey

I have the same problem now, but i have a presentation next saturday.
can you please show me your code?
how did you solve the problem?
and the method .elementAt won't work here. (it's a method to connect two nxts, isn't it?)
- Code: Select all
public DataOutputStream connectMyNxt() throws Exception {
LCD.drawString("Connecting...", 0, 0);
RemoteDevice btrd = (RemoteDevice)Bluetooth.getKnownDevicesList().elementAt(0);
LCD.drawString("Device: " + btrd, 0, 1);
BTConnection connection = Bluetooth.connect(btrd);
LCD.drawString("Connected to: " + connection,0,2);
DataOutputStream output = connection.openDataOutputStream();
Thread.sleep(2000);
Sound.twoBeeps();
return output;
}
when i compile it it says: cannot find symbol- medhod elementAt(int)
i've imported this:
- Code: Select all
import java.io.*;
import javax.bluetooth.*;
import lejos.nxt.comm.*;
import lejos.nxt.remote.*;
import lejos.nxt.*;
can i use get() here?
- Code: Select all
RemoteDevice btrd = (RemoteDevice)Bluetooth.getKnownDevicesList().get(0);
when i start the btsend of the pcsamples it shows this error (but no error after compiling):
Exception in thread "Thread-1" java.lang.UnsatisfiedLinkError: lejos.nxt.NXT.getUserPages()I
at lejos.nxt.NXT.getUserPages(Native Method)
at lejos.nxt.Flash.<clinit>(Flash.java:16)
at lejos.nxt.SystemSettings.<clinit>(SystemSettings.java:32)
at lejos.nxt.comm.NXTCommDevice.loadSettings(NXTCommDevice.java:165)
at lejos.nxt.comm.NXTCommDevice.<clinit>(NXTCommDevice.java:20)
at javax.bluetooth.DiscoveryAgent$1.run(DiscoveryAgent.java:194)
code:
- Code: Select all
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import lejos.pc.comm.NXTCommLogListener;
import lejos.pc.comm.NXTConnector;
/**
* This is a PC sample. It connects to the NXT, and then
* sends an integer and waits for a reply, 100 times.
*
* Compile this program with javac (not nxjc), and run it
* with java.
*
* You need pccomm.jar and bluecove.jar on the CLASSPATH.
* On Linux, you will also need bluecove-gpl.jar on the CLASSPATH.
*
* Run the program by:
*
* java BTSend
*
* Your NXT should be running a sample such as BTReceive or
* SignalTest. Run the NXT program first until it is
* waiting for a connection, and then run the PC program.
*
* @author Lawrie Griffiths
*
*/
public class BTSend {
public static void main(String[] args) {
NXTConnector conn = new NXTConnector();
conn.addLogListener(new NXTCommLogListener(){
public void logEvent(String message) {
System.out.println("BTSend Log.listener: "+message);
}
public void logEvent(Throwable throwable) {
System.out.println("BTSend Log.listener - stack trace: ");
throwable.printStackTrace();
}
}
);
// Connect to any NXT over Bluetooth
boolean connected = conn.connectTo("btspp://");
if (!connected) {
System.err.println("Failed to connect to any NXT");
System.exit(1);
}
DataOutputStream dos = new DataOutputStream(conn.getOutputStream());
DataInputStream dis = new DataInputStream(conn.getInputStream());
for(int i=0;i<100;i++) {
try {
System.out.println("Sending " + (i*30000));
dos.writeInt((i*30000));
dos.flush();
} catch (IOException ioe) {
System.out.println("IO Exception writing bytes:");
System.out.println(ioe.getMessage());
break;
}
try {
System.out.println("Received " + dis.readInt());
} catch (IOException ioe) {
System.out.println("IO Exception reading bytes:");
System.out.println(ioe.getMessage());
break;
}
}
try {
dis.close();
dos.close();
conn.close();
} catch (IOException ioe) {
System.out.println("IOException closing connection:");
System.out.println(ioe.getMessage());
}
}
}
thanks,
pcProfie