Forum Archive

Crash in cb discover_characteristics()

rlmalisz

I'm working on a script that gathers readings from Xiaomi plant sensors. Using LightBlue I know that there's essentially a serial number whose value can be gotten through service UUID FE95, and thence through characteristic 0014.

I'm able to access data (and even write settings) through other service UUID/char UUID sets. I'm adding this code so I can maintain a mapping of sensors to locations that will work across multiple iOS devices.

discover_services() does a callback to did_discover_services() with an object that has the right UUID. Calling discover_characteristics() with that object crashes Pythonista 100% of the time on my iPad. Irrespective of any oddities about this device (and LightBlue reads it just fine), this seems like a serious bug.

Help/suggestions?

--Richard

JonB

Have you installed the fault_handler? It will provide info on exactly what is failing.

omz

One thing you could try would be to keep a reference to the discovered peripheral as a property on your delegate. That way, the peripheral object won't be garbage-collected prematurely (this is basically a workaround, the crash shouldn't happen).