Since bluetooth is a broadcast protocol, is there some way to listen for broadcasts while not discoverable? The idea is to avoid making a device discoverable, and simply listen for broadcasts, check the devices for a particular device name, and then connecting to that device's mac address (followed by handshaking, verification, etc).
Specifically, I have a bluetooth device that uses the AT command set (user manual here), and I want my Android device to au开发者_如何转开发toconnect to it when it gets into range. However, I want a solution that doesn't require my Android to be discoverable all the time, because I expect the Android to not be in range most of the time.
Is there a low-level bluetooth command that I can send from my first device, and listen for using the Android SDK that doesn't require pairing, connecting, or discoverability? Something like and ACL request, perhaps?
(Additionally, my reasons for not making my device discoverable are mainly power, and also slightly user privacy reasons. How significant is the battery drain of device discoverability? Next to nothing? Significant?)
Its called a Bluetooth PAGE command. Not sure how you'd use it from your device though, but it allows a Bluetooth device to (in effect) announce its presence to its configured master. You'd have to look up the Android response to a PAGE to see how well that's supported though.
If the Android is connecting to the device, then the Android never needs to be discoverable. Unless I'm misunderstanding... (The radio on the Android just needs to be powered-up and not "connectable" nor "discoverable")
The Android can just try to connect every so often (sending a PAGE), to see if the remote device has come back into range. Then even the remote device doesn't need to be discoverable, just 'connectable' -- assuming your Android program remembers the remote device's device address.
Or you could have the remote device try to reconnect ot the Android device every so often (presuming the remote device supports making connections). You would need to have the program on the Android be a server/listener, and the Android Bluetooth in 'connectable' mode.
精彩评论