Hi,
I am trying to implement this following little example:
public class EchoServer {
public static void main(String args[]) {
try {
LocalDevice.getLocalDevice().setDiscoverable(DiscoveryAgent.GIAC);
// 001583B3D0CC
StreamConnectionNotifier notifier = (StreamConnectionNotifier) Connector
.open("btspp://localhost:1231242432434AAAABB;name=EchoServer");
displayConnectionString(notifier);
while(true) {
StreamConnection conn = notifier.acceptAndOpen();
OutputStream output = conn.openOutputStream();
InputStream input = conn.openInputStream();
byte[] data = new byte[10];
int length = 0;
while ((length = input.read(data)) != -1) {
System.out.println(new String(data, 0, length));
output.write(data, 0, length);
output.flush();
}
output.close();
input.close();
conn.close();
}
} catch (IOException e) {
System.out.println("IOException: " + e.getMessage());
e.printStackTrace();
}
}
private static void displayConnectionString(StreamConnectionNotifier notifier) {
try {
LocalDevice device = LocalDevice.getLocalDevice();
ServiceRecord record = device.getRecord(notifier);
String connString = record.getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);
int index = connString.indexOf(';');
connString = connString.substring(0, index);
// Display the connection string on the Form
System.out.println("Connection String: " + connString);
} catch (BluetoothStateException e) {
System.out.println("BluetoothStateException: " + e.getMessage());
}
}
}
However, it keeps throwing an error at the line
StreamConnectionNotifier notifier = (StreamConnectionNotifier) Connector.open("btspp://localhost:1231242432434AAAABB;name=EchoServer");
Follows the error:
BlueCove version 2.0.3 on bluesoleil
IOException: Can't create Service [General fail]
java.io.IOException: Can't create Service [General fail]
at com.intel.bluetooth.BluetoothStackBlueSoleil.rfServerOpenImpl(Native Method)
at com.intel.bluetooth.BluetoothStackBlueSoleil.rfServerOpen(BluetoothStackBlueSoleil.java:367)
at com.intel.bluetooth.BluetoothRFCommConnectionNotifier.<init>(BluetoothRFCommConnectionNotifier.java:39)
at com.intel.bluetooth.MicroeditionConnector.openImpl(MicroeditionConnector.java:383)
at com.intel.bluetooth.MicroeditionConnector.open(MicroeditionConnector.java:163)
at javax.microedition.io.Connector.open(Connector.java:81)
at com.jabwt.book.EchoServer.main(EchoServer.java:25)
This "General fail" doesn´t means anything for me. Could anyone help me with this?
Thanks.
--
Felipe Gabriel Somolinos Fernandes
--------------------------------------------------------------------
http://www.mjv.com.brhttp://www.maino-geosistemas.com
21 8869-1782
Skype: felipe.somolinos