Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device disconnected but not reporting by bleConnectionStatusHandler #43

Open
doraemondavidlai opened this issue Feb 17, 2022 · 5 comments

Comments

@doraemondavidlai
Copy link

doraemondavidlai commented Feb 17, 2022

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
Copy link
Contributor

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
Copy link
Author

@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
Copy link
Contributor

@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
Copy link
Author

Ok, got it.

Thank you.

@GabrielRobinsonAzevedo
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants