esp-idf-provisioning-android
esp-idf-provisioning-android copied to clipboard
Write to BLE failed
My BLE provisioning flow is as follows:
- I start the provisioning process by scanning for BLE devices.
- I connect to the device.
- I make a request via
provisionManager.getEspDevice().sendDataToCustomEndPoint
and get back some data from the device. - Then I connect to a Wifi network and provision.
Here's my test case:
- I run the provisioning flow listed above once with an incorrect WiFi password.
- The provisioning fails and the ESP32 automatically resets, and I restart the provisioning flow again.
- On the second run-through of the provisioning flow I get the below error on step 3.
2021-08-07 21:01:44.132 29608-29627/com.test W/System.err: java.lang.Exception: Write to BLE failed
2021-08-07 21:01:44.133 29608-29627/com.test W/System.err: at com.espressif.provisioning.transport.BLETransport$1.onCharacteristicWrite(BLETransport.java:354)
2021-08-07 21:01:44.134 29608-29627/com.test W/System.err: at android.bluetooth.BluetoothGatt$1$7.run(BluetoothGatt.java:473)
2021-08-07 21:01:44.134 29608-29627/com.test W/System.err: at android.bluetooth.BluetoothGatt.runOrQueueCallback(BluetoothGatt.java:860)
2021-08-07 21:01:44.135 29608-29627/com.test W/System.err: at android.bluetooth.BluetoothGatt.access$200(BluetoothGatt.java:45)
2021-08-07 21:01:44.135 29608-29627/com.test W/System.err: at android.bluetooth.BluetoothGatt$1.onCharacteristicWrite(BluetoothGatt.java:468)
2021-08-07 21:01:44.136 29608-29627/com.test W/System.err: at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:265)
2021-08-07 21:01:44.138 29608-29627/com.test W/System.err: at android.os.Binder.execTransactInternal(Binder.java:1021)
2021-08-07 21:01:44.139 29608-29627/com.test W/System.err: at android.os.Binder.execTransact(Binder.java:994)
2021-08-07 21:01:44.140 29608-29608/com.test W/System.err: java.lang.Exception: Write to BLE failed
2021-08-07 21:01:44.141 29608-29608/com.test W/System.err: at com.espressif.provisioning.transport.BLETransport$1.onCharacteristicWrite(BLETransport.java:354)
2021-08-07 21:01:44.141 29608-29608/com.test W/System.err: at android.bluetooth.BluetoothGatt$1$7.run(BluetoothGatt.java:473)
2021-08-07 21:01:44.142 29608-29608/com.test W/System.err: at android.bluetooth.BluetoothGatt.runOrQueueCallback(BluetoothGatt.java:860)
2021-08-07 21:01:44.143 29608-29608/com.test W/System.err: at android.bluetooth.BluetoothGatt.access$200(BluetoothGatt.java:45)
2021-08-07 21:01:44.144 29608-29608/com.test W/System.err: at android.bluetooth.BluetoothGatt$1.onCharacteristicWrite(BluetoothGatt.java:468)
2021-08-07 21:01:44.144 29608-29608/com.test W/System.err: at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:265)
2021-08-07 21:01:44.145 29608-29608/com.test W/System.err: at android.os.Binder.execTransactInternal(Binder.java:1021)
2021-08-07 21:01:44.145 29608-29608/com.test W/System.err: at android.os.Binder.execTransact(Binder.java:994)
2021-08-07 21:01:44.145 29608-29608/com.test I/BLELandingViewModel: Write to BLE failed
2021-08-07 21:01:44.167 29608-29974/com.test W/libEGL: EGLNativeWindowType 0x71767b7d10 disconnect failed
2021-08-07 21:01:44.207 29608-29608/com.test I/MultiWindowDecorSupport: updateCaptionType >> DecorView@f010a[], isFloating: true, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: false
I am using implementation 'com.github.espressif:esp-idf-provisioning-android:lib-2.0.9'
in my applications gradle file.
Why does this error occur and how can I fix it? I also tried rescanning for BLE networks again, and it then returned 0 devices. I'm not sure why it returned 1 device on the first scan and then 0 on the second.
Hi @tobyloki , thanks for reporting the issue. Will check this.
@khushbushah2302 Hi. Have you found a solution to this problem?
Hi @tobyloki , I am working on this issue.
@khushbushah2302 After investigating further, I've found that the source of the problem is provisionManager.getEspDevice().sendDataToCustomEndPoint
. It seems to work fine on the first invocation. But when I call it a second time, it gives me the error. Could you verify if this is true on your end?
final String data = "asdf";
provisionManager.getEspDevice().sendDataToCustomEndPoint("custom-data", data.getBytes(), new ResponseListener() {
...
});
Hi @tobyloki , In provisionManager.getEspDevice().sendDataToCustomEndPoint
, first argument is device endpoint name.
You have sent "custom-data" instead of endpoint. Have you used actual endpoint value or data in first argument ?
App will try to find BLE Characteristic whose descriptor value is this endpoint ("custom-data" in your case).
App will give error if it is unable to find Characteristic with the given descriptor value.
We are using this same API in ESP RainMaker project.
@khushbushah2302 In my ESP32's code, I had configured the endpoint as "custom-data". So I think what I've done should be correct.
wifi_prov_mgr_endpoint_create("custom-data");
/* Start provisioning service */
ESP_ERROR_CHECK(wifi_prov_mgr_start_provisioning(security, pop, service_name, service_key));
/* The handler for the optional endpoint created above.
* This call must be made after starting the provisioning, and only if the endpoint
* has already been created above.
*/
wifi_prov_mgr_endpoint_register("custom-data", custom_prov_data_handler, NULL);
@tobyloki You still have the issue or you got it resolved? I have the same issue now.
@tobyloki You still have the issue? I have the same issue now.
@tobyloki You still have the issue? I have the same issue now.
One fix is to switch to security0.
@tobyloki You still have the issue? I have the same issue now.
One fix is to switch to security0.
Already built the firmware and ios app using security1. So want to keep using security1. Is there any way to fix this in security1?
I am also facing issues related to Security1 but it looks like the Espressif team is not interested in working on the provisioning library... @KhushbuShah25 "I am working on this issue." still are you working? How long it will take...