Reputation: 273
I’m trying to develop an Android application for a medical device using Bluetooth (SPP). I’ve used the BluetoothChat as a starting point (also see earlier post). Now I think I’m facing a weird problem and I’m also having trouble describing it. Testing on a Nexus S.
Upon the completion of measurement the medical device checks its memory for the Bluetooth address and other information about the previously paired device. If found it will try to initiate a connection (while the application on the phone is listening for a connection) and then transfer data and otherwise it starts an inquiry procedure.
The first time it works fine: pairing procedure, establishing connection and transferring data. When the data is received the application replies with an ACK package and the connection is terminated.
The rest of the times it does not work: after a measurement I can see in the LogCat that the phone receives a signal (just like the first time) from the device, so I know the device saved the phones Bluetooth address. It seems like the system ignores the signal (or at least nothing happens), no connection is established and thus no data transferred even though I'm using accept
-method of BluetoothServerSocket
the same way as when it works. If I remove the pairing record from the phone this signal starts the pairing procedure and the devices get paired again, BUT they still won’t establish a connection nor transfer data. I guess the message about the signal represents a try to establish a connection but something is wrong. The message in the log is the same as when the connection is successful and can be seen in the LogCat:
03-22 14:21:55.335: ERROR/BluetoothEventLoop.cpp(114): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/4123/hci0/dev_00_A0_96_2D_05_E8
It's rather confusing it's an ERROR message and present in the log when it works as well.
The weird thing is that it works the first time they are successfully paired, but never again afterwards. When the data is transferred and the device receives an ACK it saves the Bluetooth address "and other useful information". The only way I can reproduce the successful ‘first time’ is by pairing the medical device with another device and then afterwards pair it with the application on the phone again.
I’m confused about what is actually causing this problem. Does anyone out there have any clue?
I’m afraid my problem is a bit to specific to be familiar to others if case the problem is caused by the medical device and not the phone. I was thinking it might be related to the Link Key or Channel? But on the other hand, as I said, if I remove the pairing from the phone, I'll get a pairing request again.
The medical device is old, using Bluetooth 1.2. Now it strikes me that I should have a look at if there are any connection-related issues because of this. Could it be that a device using Bluetooth 1.2 have another policy of what information to store when it is paired?
For the moment I feel I'm struggling with a problem I don't fully understand, but if I'll understand later I'll of course get back with my conclusions. I hope I didn't forget important details.
Thanks in advance /F
Upvotes: 1
Views: 2252
Reputation: 11
Hi fredricus My problem is similar to yours i m running a bluetooth service which keeps on listening for data when the bluetooth is on.u have solved the problem of connecting android device to a medical device as u mentioned that u have used reflection.But in case if medical initiates connection will it be able to connect to android device.
Upvotes: 1
Reputation: 6975
Sounds like the problem is with the medical device, that it is not able to re-establish connection (i.e. re-authenticate) with already paired device. I dont think that being being 1.2 should matter. The procedures are designed to be backward compatible so that all bluetooth versions work with each other. You may have to get a bluetooth sniffer trace to check what might be going on over the air that will validate if the issue is on the medical device side.
Another option is to check if android has any way to turn on more detailed logging of the Bluetooth interactions and enable that. Default log of Android messages are very high level and does not provide much detail
Upvotes: 0