How do I know when readDeviceInformation is done?
I'm using version 1.9.3 of the android api via gradle build file. I realize this is old, but at this point I'm just trying to update my code rather than rewrite it all.
In my scenario I have 2 DeviceCallbacks registered in my MetaWearController. One is just kind of a "catch all" to try to keep a connection open and I set that callback in my base wrapper class. The other callback has the actual logic of doing a readDeviceInformation() and then waiting for the receivedGATTCharacteristic callback. I'm only looking for SERIAL_NUMBER. When I receive the SERIAL_NUMBER characteristic, I then do a close() on the controller.
My issue is that the close() seems to get in at the same time the controller is iterating through the list of DeviceCallbacks to make further receivedGATTCharateristic calls, which causes a ConcurrentModificationException and crashes my app. Obviously, this is because I was only looking for a single characteristic and did a close() while readDeviceInformation() was still looping through all of them.
So... is there a proper way to close the device in this scenario? In other words, is there any way to know when readDeviceInformation is done??
I suppose I could just keep a counter and when I know I've read all the characteristics, then do the close. That feels kinda hacky though...
This discussion has been closed.
Comments