Hi everyone!
I'm running some tests on a bluetooth adapter for printers.
It works fine when I print from the PC but I'd like to print with my BlackBerry...
So I created a small application which :
-Retrieves the paired devices
-Retrieves the services available for the device
-Connects to the selected service
I am able to retrieve the devices and the services.
There is only one service available for the adapter :
Bluetooth Serial Port
great!
Now I want to send data to the printer...
Code:
String URL = _service.getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT,false);
StreamConnection connection=null;
try
{
connection= (StreamConnection) Connector.open(URL);
}
catch(IOException io)
{
}
try
{
byte[] buffer = new byte[100];
String msg = "hello there";
InputStream din = connection.openInputStream();
OutputStream dout = connection.openOutputStream();
dout.write(msg.getBytes());
dout.flush();
din.read(buffer);
dout.close();
din.close();
connection.close();
}
catch(IOException ie)
{
}
}
I am able to get the URL but nothing happens when I call Connector.open(URL)
It doesn't crash or anything...
it just freezes there.
Any help?
(PS : I know that the printer won't understand "Hello There" ;) It's just a test)