简体   繁体   中英

Can BLE Peripheral's advertisements wake up and trigger connection to Master Android device?

I have a paired BLE vitals monitoring device (eg, blood pressure cuff) and an Android app. The peripheral advertises for a few seconds after a measurement, which can happen at any time of the day.

Is it possible for an Android device to NOT scan anything but still have the peripheral's advertisement packet trigger something to happen within an app?

I'm not certain, but perhaps something similar to how bluetooth headphones, once turned on, automatically connect with the device without any user interaction?

I did find this question , but looking at the library , it looks like it's only for beacon peripherals, which isn't the case for the vitals devices that I'm working with (or does it not matter that peripheral is a beacon?).

Because my Google searches didn't give me much hope that this was possible, I did think about scanning endlessly with low power mode. But how do we guarantee that we are able to capture the advertising packets that only happen for a few seconds throughout a day?

Thanks!

Just call connectGatt on your BluetoothDevice object with the autoConnect parameter set to true. See Which correct flag of autoConnect in connectGatt of BLE? for more details. Remember to restart the connection attempt if Bluetooth is restarted (see https://stackoverflow.com/a/36763538/556495 ). You should also have a Foreground Service running in your app process to prevent the process from being killed by Android.

It's good that you have bond the device first (see Android save BLE device to reconnect after app close why).

Since the scanning parameters used for autoConnect have very low duty, you should advertise with a short interval (20 ms) for at minimum 1280 ms, preferably five or ten seconds in case there is a radio scheduling conflict in the phone's Bluetooth chip.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM