BluetoothPeer error

6 views
Skip to first unread message

Shehab

unread,
May 4, 2007, 1:09:08 PM5/4/07
to bluecove-users
In my code (the whole code is at the bottom of this post), I wrote

StreamConnectionNotifier server = (StreamConnectionNotifier) Connector
.open("btspp://0013eff14556:5"
+ ";name="
+ TEST_SERVERNAME
+ ";authorize=false;authenticate=false;encrypt=false");

But it gives the following error:

BlueCove version 1.2.2
Local btaddr is 0013eff14556
Local name is SHEHAB
java.io.IOException: Failed to connect socket [10051] A socket
operation was attempted to an unreachable network.
at com.intel.bluetooth.BluetoothPeer.connect(Native Method)
at
com.intel.bluetooth.BluetoothConnection.<init>(BluetoothConnection.java:
59)
at
com.intel.bluetooth.MicroeditionConnector.openImpl(MicroeditionConnector.java:
138)
at
com.intel.bluetooth.MicroeditionConnector.open(MicroeditionConnector.java:
74)
at javax.microedition.io.Connector.open(Connector.java:79)
at test.Server.listen(Server.java:54)
at test.Server.main(Server.java:47)

When I use:
StreamConnectionNotifier server = (StreamConnectionNotifier) Connector
.open("btspp://localhost:"
+ uuid
+ ";name="
+ TEST_SERVERNAME
+ ";authorize=false;authenticate=false;encrypt=false");

It works fine. The output of
System.out.println(sr.getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT,
false)); is

btspp://0013eff14556:5;authenticate=false;encrypt=false

But when I use:
StreamConnectionNotifier server = (StreamConnectionNotifier) Connector
.open("btspp://0013eff14556:5;authenticate=false;encrypt=false");

It says:
BlueCove version 1.2.2
Local btaddr is 0013eff14556
Local name is SHEHAB
java.io.IOException: Failed to connect socket [10051] A socket
operation was attempted to an unreachable network.
at com.intel.bluetooth.BluetoothPeer.connect(Native Method)
at
com.intel.bluetooth.BluetoothConnection.<init>(BluetoothConnection.java:
59)
at
com.intel.bluetooth.MicroeditionConnector.openImpl(MicroeditionConnector.java:
138)
at
com.intel.bluetooth.MicroeditionConnector.open(MicroeditionConnector.java:
74)
at javax.microedition.io.Connector.open(Connector.java:79)
at test.Server.listen(Server.java:59)
at test.Server.main(Server.java:47)


Would any body please help me out? I am using the latest version of
Bluecove, Windows XP SP 2. The dll file is copied into the system32
directory and it is a Silicon Wave Dongle. I work in Eclipse. For your
reference here is my java file:

Server.java
========
/**
*
*/
package test;

import java.io.DataInputStream;
import java.io.IOException;

import javax.bluetooth.BluetoothStateException;
import javax.bluetooth.LocalDevice;
import javax.bluetooth.ServiceRecord;
import javax.bluetooth.UUID;
import javax.microedition.io.Connector;
import javax.microedition.io.StreamConnection;
import javax.microedition.io.StreamConnectionNotifier;

import com.sun.corba.se.internal.iiop.ListenerThread;


/**
* @author Administrator
*
*/
public class Server {

private final int MAX_CLIENTS = 10;
public static final String TEST_UUID =
"27012f0c68af4fbf8dbe6bbaf7ab651b";
public static final String TEST_SERVERNAME = "Server";
public static final UUID uuid = new UUID(TEST_UUID, false);
static LocalDevice l;

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
l = LocalDevice.getLocalDevice();
} catch (BluetoothStateException e) {
System.err.println("Cannot get local device: " + e);
return;
}

System.out.println("Local btaddr is " + l.getBluetoothAddress());
System.out.println("Local name is " + l.getFriendlyName());

listen();

}

public static void listen(){
try {
// StreamConnectionNotifier server = (StreamConnectionNotifier)
Connector
// .open("btspp://0013eff14556:5"
// + ";name="
// + TEST_SERVERNAME
// + ";authorize=false;authenticate=false;encrypt=false");
StreamConnectionNotifier server = (StreamConnectionNotifier)
Connector
.open("btspp://0013eff14556:5;authenticate=false;encrypt=false");
// StreamConnectionNotifier server = (StreamConnectionNotifier)
Connector
// .open("btspp://localhost:"
// + uuid
// + ";name="
// + TEST_SERVERNAME
// + ";authorize=false;authenticate=false;encrypt=false");

System.out.println("Server started " + TEST_SERVERNAME);
ServiceRecord sr = LocalDevice.getLocalDevice().getRecord(server);

System.out.println(sr.getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT,
false));
StreamConnection conn = server.acceptAndOpen();

conn.close();

server.close();
} catch (IOException e) {
e.printStackTrace();
}

}

}

Vlad Skarzhevskyy

unread,
May 4, 2007, 1:40:01 PM5/4/07
to bluecov...@googlegroups.com
You should start server using  this line: "btspp://localhost: ....." This is JSR-82  Nothing else.

When you are using open("btspp://0013eff14556:5.. ) you are connecting to the server on remote device

--
Vlad
Reply all
Reply to author
Forward
0 new messages