Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
New Developer
Posts: 10
Registered: ‎08-13-2008
My Device: Not Specified

Re: Unable to connect to Bluetooth device

I don't have a solution for you, but I'd just like to say that I have no problems doing what you are trying to do on an 8100 & 9000 using JDE4.2.1.

 

The URL we use is similar...

btspp://<btAddr>:1;authenticate=true;encrypt=true

and the Connector.open() call is the same.

 

The only difference is that we retrieved the btmac using discovery javax.bluetooth.DiscoveryAgent & RemoteDevice.getBluetoothAddress().

 

Can you confirm the same code works to the same device from another type of handset?

 

Developer
Posts: 163
Registered: ‎07-16-2008
My Device: Not Specified
My Carrier: Sprint

Re: Unable to connect to Bluetooth device

As an update, I was able to connect via a small test program using BluetoothSerialPort.  I'm sure this means I was just doing something stupid in the larger program - I'll be sure to update tomorrow when I fix the issue.
Andrew Cowart | Metova
www.metova.com
Developer
Posts: 163
Registered: ‎07-16-2008
My Device: Not Specified
My Carrier: Sprint

Re: Unable to connect to Bluetooth device

I have not yet been able to fix this.

 

Our working example program that uses RIM's BluetoothSerialPort class instead of the connector.open works, and shows:

Pedometer service name: COM1
Pedometer  BluetoothSerialPortInfo.tostring: btspp://1000E86CEABE:1


In the actual application:
Searching for devices, finds Pedometer .
Do a service search on it, receive response "DiscoveryListener.SERVICE_SEARCH_DEVICE_NOT_REACHABLE"

Connection URL is btspp://1000E86CEABE:1
Connector.open(connectionURL, Connector.READ_WRITE) throws exception :  "java.io.IOException: Unable to connect"


Tried bluetoothserialport in the main program, received:
[com.ww.mobile.BTConnector][DEBUG]: Device name is Pedometer
[com.ww.mobile.BTConnector][DEBUG]: Device server id is 1
[com.ww.mobile.BTConnector][DEBUG]: Device service name is COM1
[com.ww.mobile.BTConnector][DEBUG]: Device toString: btspp://1000E86CEABE:1
BT: allocSerialPort 10f6252c
[com.ww.mobile.BTConnector][DEBUG]: Serial port opened
BT: SppWrite-1 failed: 1
[com.ww.mobile.BTConnector][DEBUG]: Exception while transferring BT data: java.io.IOException: BtSppWrite failed

Andrew Cowart | Metova
www.metova.com
BlackBerry Development Advisor
Posts: 15,693
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Unable to connect to Bluetooth device

Have you tried using your Bluetooth implementation to connect to another device, such as a PC with Bluetooth support and simulate some of the data that your Bluetooth device would return?

 

This test would separate any issue with your application versus an issue on the device itself.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 163
Registered: ‎07-16-2008
My Device: Not Specified
My Carrier: Sprint

Re: Unable to connect to Bluetooth device

To update, this is fixed and working now.

 

There were a few issues I was having:

  • Requesting the device's friendlyname (with the boolean set to true) causes a connection to bluetooth, and running service discovery immediately afterwards can fail, since the previous connection may not have disconnected yet.
  • Under device properties it listed "COM1" as the only service. After running service discovery, the device properties showed that the only service was "Serial Port".  Refreshing the services list changed this back to "COM1".
  • Changing the threading around fixed the issue with the device freezing on Connector.open - I had tried this before, but because of the above issues, there was still trouble connecting.

I appreciate everyone's help.
Andrew Cowart | Metova
www.metova.com
New Developer
Posts: 4
Registered: ‎07-03-2009
My Device: Not Specified

Re: Unable to connect to Bluetooth device

Hi All,

 

I am stuck in the same issue,

 

Sample Code:

================================================

connectionURL = services[i].getConnectionURL(
                        ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);

 

ClientSession conn = (ClientSession) Connector.open(connectionURL,
                                Connector.READ_WRITE, true);

================================================

 

Here I am getting proper value of connectionURL, But when Connector.open is called it hangs up for few 30~40 seconds and eventually I get "IOException: Unable to connect".

Also note that when connector.open is called receiving device gets popup saying "Receive data from BB 8310". But eventually there no data been exchanged.

 

Let me know if I have to do any additional settings in device or my code.

 

Thanks

Pathik

 

Contributor
Posts: 10
Registered: ‎04-16-2010
My Device: Blackberry 8320
My Carrier: Tmobile

Re: Unable to connect to Bluetooth device

Hi Pathikdave,

 

Acowart's solution is helpful, and I have addtional ones here:

 

http://supportforums.blackberry.com/t5/Java-Development/Connector-open-cannot-get-through-for-Blueto...

 

I faced the same problem, and got it solved. Hope my thread would help.

 

 

Regards,

Jiahua