|
|
|
|
Re: Using bluecove with kura [message #1693521 is a reply to message #1693514] |
Fri, 24 April 2015 17:15 |
|
I am not quite sure about the Bluecove issue in Raspberry Pi as I haven't even deployed it to check but after having a look in the error log that you have pasted before seems to be a problem with creating StreamConnectionNotifier connection using Connector directly.
The Bluetooth Connection Factory implements the org.osgi.service.io.ConnectionFactory so as to be used through the OSGi IO Connector Service implemented by the Connector Service Bundle (Framework Module).
Have a glance at the code below.
public class BluetoothSPPServer extends Thread implements BundleActivator {
private ServiceReference connRef;
private ConnectorService connService;
private StreamConnection connection;
private StreamConnectionNotifier server;
private static final UUID _IDENTIFIER = new UUID("1101", true);
private static final String URL = "btspp://localhost:" + _IDENTIFIER + ";name=BluetoothServer";
public void start(BundleContext bc) {
connRef = bc.getServiceReference(ConnectorService.class.getName());
if (connRef != null) {
connService = (ConnectorService)bc.getService(connRef);
try {
server = (StreamConnectionNotifier)connService.open(URL,
ConnectorService.READ);
} catch(ConnectionNotFoundException ce) {
ce.printStackTrace();
} catch(IOException ioe) {
ioe.printStackTrace();
}
}
start();
}
public void run() {
try {
connection = server.acceptAndOpen();
DataInputStream inputStream = connection.openDataInputStream();
while(true) {
String input = inputStream.readUTF();
while(input != null) {
System.out.println(input);
input = inputStream.readUTF();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void stop(BundleContext bc) {
try {
connection.close();
} catch(IOException ioe) {
ioe.printStackTrace();
}
bc.ungetService(connRef);
}
}
Amit Kumar Mondal
Email: admin@amitinside.com
Skype: arsenalnerk Blog: blog.amitinside.com
|
|
|
Powered by
FUDForum. Page generated in 0.04227 seconds