ios - How to detect with CoreBluetooth when a peripheral disappears? -


i have list of ble devices ios can connect, refreshes when ble devices appear , disappear.

in order that, created nsmutabledictionnary* peripheralsavailable, , everytime - (void)centralmanager:(cbcentralmanager *)central diddiscoverperipheral:(cbperipheral *)peripheral advertisementdata:(nsdictionary *)advertisementdata rssi:(nsnumber *)rssi; called cbcentralmanager, add peripheral peripheralsavailable dictionnary (and update uitableview). ok here.

however can't find how can update dictionnary if peripheral "disappear". seems can add peripherals in dictionnary when detected, can't remove 1 when shut down example.

could tell me if i'm missing something?

the os cache discovery of devices. i.e. 1 "discovery" event per device.

to continuously discovery events while peripheral advertising, must use following option:

cbcentralmanagerscanoptionallowduplicateskey

a boolean value specifies whether scan should run without duplicate filtering.

the value key nsnumber object. if yes, filtering disabled , discovery event generated each time central receives advertising packet peripheral. disabling filtering can have adverse effect on battery life , should used if necessary. if no, multiple discoveries of same peripheral coalesced single discovery event. if key not specified, default value no.

setting above option yes, keep track of of peripherals advertising , when stops advertising, remove list.

for device you've connected to, there diddisconnectperipheral delegate event.


bluetooth devices don't advertise they're go away, nor advertise you're go out of range. advertisement while they're advertising , you're within range, , nothing when you're out of range or stop advertising. there's no event trigger on when they're gone. have remember devices advertising, , when stop advertising (you haven't received advertisement in awhile), can remove list.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -