espressif / esp-idf-provisioning-ios

Apache License 2.0
134 stars 64 forks source link

Device disconnected but not reporting by bleConnectionStatusHandler #43

Open doraemondavidlai opened 2 years ago

doraemondavidlai commented 2 years ago

My device was manually disconnect after calling espDevice.connect, but bleConnectionStatusHandler did not trigger connectionStatus changing to disconnected.

As shown in line 601 and 602, image

Shouldn't these two lines being place there? .... or I'm misunderstanding the usage?

vikas-chandra-mnnit commented 2 years ago

Hi @doraemondavidlai, In order to get status for BLE connection you need to use the bleDelegate property of the ESPDevice object. First, create a class that conforms to the ESPBleDelegate as shown below:

Screenshot 2022-02-23 at 7 16 10 PM

Then assign the instance of the above class to espDevice.bleDelegate property before calling connect. Make sure your BLEDelegate object remains in scope for the entire duration of provisioning in order to receive the callbacks.

doraemondavidlai commented 2 years ago

@vikas-chandra-mnnit Thanks for your reply. I do use this method to achieve what I need right now. I mean... isn't espDevice.connectionStatus status being update to .disconnected when peripheral is disconnected? Or .disconnected is only use to initialize the variable connectionStatus?

vikas-chandra-mnnit commented 2 years ago

@vikas-chandra-mnnit Thanks for your reply. I do use this method to achieve what I need right now. I mean... isn't espDevice.connectionStatus status being update to .disconnected when peripheral is disconnected? Or .disconnected is only use to initialize the variable connectionStatus?

We use the connectionStatus variable to track the status internally while the user is trying to connect with ESP device. After connection also there are certain steps involved like reading the version information of the device. If the device is disconnected during this stage the espDevice.connect completion handler will return the .disconnected state. However once espDevice.connect returns with any status, it can no longer be used to track the connection status of the ESP device.

doraemondavidlai commented 2 years ago

Ok, got it.

Thank you.

GabrielRobinsonAzevedo commented 8 months ago

Hello, I've grasped that the espDevice.connectionStatus doesn't provide a response when the device is disconnected after providing connection information. I'm wondering how I could receive a callback signaling the completion of the connection?