Forums Register Login

Bluetooth open problem : Connector.open() blocking..

+Pie Number of slices to send: Send
Hi,

I am developing an application in Motorola iDEN phones for connecting our barcode scanner to iDEN phones via Bluetooth.

My application is built over a custom SDK. The SDK has done all the underlying activities for open the connection with scanner, communication and close the connection. All the UI updates are done in application itself.

I am using the javax.microedition.io.Connector class for open the Bluetooth connection with scanner by calling the Connector.open()method. We are using a separate thread for handle this. If the scanner goes to sleep mode (Bluetooth) for saving the battery life, the connection with the scanner closes automatically. Our requirement is to reconnect to the same scanner, if the scanner wakes up from the sleep mode before the application exits. We are using a reconnection thread to handle this. Reconnection thread calling Connector.open() in a loop.

Our problem:

Connector.open() is a blocking call, and it is calling from a thread of SDK. If we exit from the application after scanner goes to sleep mode, the application exits successfully. We are killing the reconnection thread at the application exiting time but if the Connector.open() is already called , the thread is waiting for the reply of open() call. So after exiting from the application, if we wake up the scanner from sleep mode, the scanner will connect to the device without application. If we wait for the timeout of Connector.open() call (ie; 30-45 seconds) and wakes up the scanner after that , it will not reconnected automatically.

One method to avoid this situation is to wait the main thread (ie; application) for the completion of reconnection thread before exiting the application. But it will take 30-45 seconds to exit the application once we will press the exit button.

There is no close () methods found in Connector class so I need to wait for open() call before exiting from the thread. Is there a method to handle this problem?

Thanks in advance
Jobin
This looks like a job for .... legal tender! It says so right in this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2118 times.
Similar Threads
strange problem with swing based windows
AMS APIs
thread
Marcus Green exam 2
Bluetooth connection not working on US Nokia phones from J2ME Midlet (MIDP 2.0)
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 18:32:01.