0

I have a Bluetooth module that I'd like to automatically connect with my Android phone. Here's what I've done so far:

  • The phone and Bluetooth module are paired.
  • I have an app which creates a BluetoothServerSocket with listenUsingInescureRfcommWithServiceRecord(<uuid>), and then calls accept() on that socket (this is all done in a service).
  • This works when the Bluetooth module tries connecting to the phone's Bluetooth MAC address.
  • This also works when under "Bluetooth settings" on the phone, I check the box next to my device to make the phone visible to all devices.

This does not work when the phone is not discoverable to everyone. When the check box is unchecked, it says under my phone "Only visible to paired devices" - my understanding of this is that the phone should be visible to my Bluetooth module, since they are indeed paired... Does anyone have any advice as to why this wouldn't be the case?

user693861
  • 339
  • 3
  • 15
  • So you're using your app as the server connection? Is the BT module awake and actively trying to connect with paired devices? You may also want to see Connecting Devices in http://developer.android.com/guide/topics/connectivity/bluetooth.html – sager89 Jan 08 '14 at 17:39
  • Yes, my app is acting as the server. I think the problem is the BT module doesn't keep track of paired devices - in its current mode, it tries to connect to the stored MAC address. If no address is stored, it tries connecting to the first device it finds that matches the configured COD. – user693861 Jan 08 '14 at 17:49
  • I've had issues with certain bluetooth modules being flaky - do you have any others you can try to see if you still get the same issue? – sager89 Jan 08 '14 at 18:03
  • Unfortunately I don't. I saw someone [here](http://stackoverflow.com/questions/4215398/bluetooth-device-not-discoverable?rq=1) had their BT module ignored because it presented a COD of 0 - I'm not sure what that person means by "debugging mode" for Logcat, is that just Logcat set to show debugging messages? Because my BT module does present a COD of 0. – user693861 Jan 08 '14 at 18:45
  • Yeah, I think he means he set logcat to filter on debug-level statements or that he just looked at logcat while debugging. Not sure how/if you can change the Class of Device on a module. – sager89 Jan 08 '14 at 19:31
  • Actually there's a couple different CODs I can choose from when I scan for other devices from the module, but none of them show the Android phone. – user693861 Jan 08 '14 at 20:17
  • From Logcat, it looks like everytime the module connects to the phone, it adds the module's address and keys to a database? I feel like that shouldn't be happening, that once it's paired it should just have those keys stored. Another solution would be if I could somehow force the phone to be visible to devices with a specific address. I suspect that won't be possible though. – user693861 Jan 08 '14 at 20:23
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/44817/discussion-between-sager89-and-user693861) – sager89 Jan 08 '14 at 20:37

0 Answers0