espressif / esp-idf-provisioning-android

Android Provisioning application for ESP-IDF Unified provisioning
Apache License 2.0
197 stars 130 forks source link

Wait for BLE services discovered in ESPDevice.connectBLEDevice #56

Open QuentinFarizon opened 2 years ago

QuentinFarizon commented 2 years ago

It would be nice if ESPDevice.connectBLEDevice would wait for service discovered.

When calling espDevice.scanNetworks just after espDevice.connectBLEDevice, service discovery is not complete and no wifi networks are returned.

KhushbuShah25 commented 2 years ago

Hi @QuentinFarizon , sorry for late reply. App needs to wait for device connection event after calling espDevice.connectBLEDevice function. It will connect to the given BLE peripheral device. After BLE GATT connection success callback, lib will discover services and do some other setup which will be require for further device communication. Once it is completed, lib will send EVENT_DEVICE_CONNECTED event to app. After device connection app can call espDevice.scanNetworks API. It has a listener in which the app will receive list of scanned networks.

QuentinFarizon commented 2 years ago

Hello, @khushbushah2302, yes, that's what I did in the end.
But it could be provided as a synchronous utility method, or as a parameter to connectBLEDevice