I have written an iOS app that reads data from a TI SensorTag. Following the advice Apple provides in the "Core Bluetooth Programming Guide", I have subscribed to the service characteristic's value by calling the peripheral object's setNotifyValue:forCharacteristic:
method. Periodically, the peripheral calls the peripheral:didUpdateValueForCharacteristic:error:
method to inform me the value of interest has changed, and I read it, as described in the documentation.
When I move the iOS device a certain distance from the SensorTag, the didUpdateValueForCharacteristic
method stops being called (apparently) because the two are "out-of-range". But when I move the devices back "in-range", updating does not resume. Somehow, my "peripheral" object no longer represents the real peripheral device.
What steps can I follow to 1) programmatically "notice" the peripheral is no longer "valid", and 2) re-connect to my device without user intervention?
Thanks!
--Bill
When your peripheral disconnects, the centralManager:didDisconnectPeripheral:error
callback is called. In this callback you can immediately start a connection request to the same peripheral with the connectPeripheral:options:
method. This request will stay active until the connection happens. It doesn't require any user interaction.
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.