-
Notifications
You must be signed in to change notification settings - Fork 179
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
BLE doesn't work after commissioning has ended (CON-1475) #1207
Comments
Can you check if you have enabled |
Thank you for the answer. It is NOT enabled. I'm aware the BLE stack deinitializes when the option is enable, and can't be reinitialized again. |
@AlexVaq Thanks for the confirmation that BLE is not de-initialized after commissioning is complete. Peripheral use caseI cut-pasted the from the bleprph_advertise() from idf's Central use caseFor scanning purpose, cut-pasted code from blecent_scan() idf's I'm attaching the scan-or-adv-after-commissioning.patch for reference, PTAL! You will have to modify the stuff in this to suit your requirements. |
Thanks for the help. Did you check that this works after matter commissioning? I will try to copy/paste your code and adapt it accordingly, but I'm foreseeing it won't fix the problem, since the code you are attaching is really, really similar to the one I'm already using. To be clear, the problem is not with BLE per se; I tested my just-BLE code previously to make sure I could scan, connect to the device and read the data. The problem is that, for some reason, after matter is done with BLE, it seems I can't use BLE properly, and the code that works standalone won't work after initializing the matter server. But I'll try nonetheless and report back. |
Yes, it works as well after the commissioning complete and on the subsequent boot when the device is already commissioned. I have attached the code snippet for the reference only (no need to start building from there). I know, even I have gone through the tutorials from those examples in order to build this one. Agreed, It would just work, out of the box. Can you please share the sdkconfig, just curious to see if something in there making any difference. |
I'm making progress thanks to your help. I found a mistake in my code that dismissed the device I was scanning, and instead reported zero-length fields. Now I can scan and find the device I wanted to connect. I noticed that ble_gap_security_initiate fails because it seems encryption is disabled at compile time, which might be the reason why I couldn't connect before. Is this a matter feature, or is it possible to enable it? Apart from these questions, I think the issue can be closed, since whatever problems I come across now will be different. |
Matter does not use encryption from the bluetooth stack and relies on the packet encryptions specified in the Matter Specifications. I think you can do that by setting characteristics flags to support encrypted read/write or as per your needs.
Yes, it is supported. In Matter its under CONFIG_ ENABLE_EXTENDED_DISCOVERY and for nimble please check BT_NIMBLE_EXT_ADV I cannot close the issue. If you feel your questions are answered please do it yourself. |
I'm writing a sleepy thread device that, after properly commissioned, connects to a BLE device with a predefined address to get some readings.
For some reason, the connection always fails, i.e., it stays in BLE_HS_EALREADY forever and never finishes. If a timeout is specified, the connection always results in time out.
I also tried a scan before connecting, but the scan returns events of zero length.
I'm using esp-idf 5.4.0 in vscode, and esp-matter is installed over the esp-idf extension. The board is an esp32c6.
The code is the icd_app example, plus at the end of app_main I add:
ble_init() could be a simple connection code:
or a simple scan code, very much like what @jonsmirl suggested in issue #906.
The connect code either times out or does not work, because a subsequent call to ble_gap_conn_find_by_addr fails.
The scan code returns 0 length events, which is absurd.
I have also tried calling ble_gatts_reset() and ble_svc_gap_init() before scanning or connecting, as it was suggested in the aforementioned issue. It didn't make any difference.
I have no idea what is preventing BLE from properly functioning after commissioning. Help would be very much appreciated.
The text was updated successfully, but these errors were encountered: