Set "Start Discovery" and "End Discovery" #687
-
When using set_ssid_callback there seems to be no way to set a timeout for discovery if no match is found. It just scan indefinitely. On on_discovery_mode_change, there is no a2dp_source.to_str(state) function. I am reporting these here in discussion, because I am not sure if there is a way to end discovery. I tried 'a2dp_source.end' but this does not seem to stop the discovery. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 1 reply
-
I committed a correction: so calling end() should work now. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your prompt attention to this. Really amazing to see a developer so involved in their project. I am trying to wrap my head around this, so hopefully the sketch will adequately illustrate an issue I am having. The sketch is defined to intentionally not find a matching ssid to test discovery initialization and de-initialization. The log indicate towards the discovery successfully scanning for the period of time [esp_bt_gap_start_discovery(ESP_BT_INQ_MODE_GENERAL_INQUIRY, 10, 0);] however on ESP_BT_GAP_DISCOVERY_STOPPED, we call a2dp_source.end() and with your latest commits it exit out of discovery. A timer defined in loop then starts discovery again, but on any subsequent calls, the bluedroid Initialization fails. And this is what I do not understand. Here is some data to reproduce: PLATFORM: Espressif 32 (6.10.0) > Espressif ESP32 Dev Module
Serial Monitor Output: SOURCE CONNECTED: FALSE [ 17781][I][BluetoothA2DPSource.cpp:334] filter_inquiry_scan_result(): [BT_AV] --Result: Target device not found SOURCE CONNECTED: FALSE |
Beta Was this translation helpful? Give feedback.
-
Just call end() instead of end(true)! Calling end(true) will release all resources, but prevent A2DP to start again! |
Beta Was this translation helpful? Give feedback.
-
I actually tried both, with and without setting it 'true' this method: a2dp_source.end(); // End scan and this method: a2dp_source.end(true); // End scan Using the sketch above, I still get a successful scan for the first time, then call a2dp_source.end();, and when trying to run subsequent scans using a2dp_source.start();, I get start initialize bluedroid failed. I even redownloaded the latest files, clean, rebuild and uploaded, but getting the same results. It would be great if this can be reproduced by someone else. |
Beta Was this translation helpful? Give feedback.
-
Legend! It has indeed been solved. The only other thing, which is not a big problem, is there is no logic 'a2dp_source.to_str(state)' for the callback function 'a2dp_source.set_discovery_mode_callback(bt_discovery_mode_change)' Thank you for your attention to this. |
Beta Was this translation helpful? Give feedback.
-
OK, I see: I have added const char *to_str(esp_bt_gap_discovery_state_t state); |
Beta Was this translation helpful? Give feedback.
-
Thanks again, I think we can close this topic. |
Beta Was this translation helpful? Give feedback.
I committed a correction: so calling end() should work now.
The to_str() is part of BluetoothA2DPCommon so, it is also available for BluetoothA2DPSource