-
Notifications
You must be signed in to change notification settings - Fork 7.6k
BLEScan first scan ok, next no name, no service UUID #3677
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
Comments
Its hard to do anything if i cant reproduce issue:
My peer device is android smartphone running nRF connect with advertising.
I can only say that i am running this code on platformio with arduino + esp-idf, wifi and mqtt (code omitted). |
With the original arduino BLE_scan.ino, just modified the callback as below. Still no luck. I have tried haveName() too in the callback, but then I got back nothing after the first scan. Hardware: ESP32 Wrover Module, default settings.
Results:
|
Comet Blue looses its name, while SENSOR_PRO looses its UUID after the first scan. See results and full code below: Results:
I edited the serial print format in the code to make it readable:
|
Can I produce some debug info for you? (raw data print or something) |
You can print raw advertising data for each device in onResult() callback with: This way we can investigate it. Remember to print hex values. |
I switched also on Warnings and printed heap size. Here it is:
|
Don't ask me how, but one version of the code worked, but only once. Then I changed one character in the code (printf format), uploaded it and failed again. Change back to the working one, fail again. Now I changed the hardware to a completely different board: NodeMcu ESP32. Same error. I switced on verbose level debug. Does this help you? See below first and second scans. I put *** what is printed from code. The first scan ends at *** Scan done!. What is your ESP board settings? I updated every board and library. You?
|
Can you try this before scan start, with value true:
|
I have tried. No change. :-( Any other what I can try? |
Only thing i can say is that i never found similar issue and it is very strange. |
I am using 2 boards:
I am getting close... I used to use Arduino's ESP32 Wrover Module board settings in tools menu. Changing to ESP32 Dev Module solved the problem on board 1, but not on board 2. Confusing... Any idea? I've got this warning for both of them:
But I do not find any other BLEDevice.h anywhere. Can be a problem? |
I scanned my whole c drive. No other BLEDevice.h. |
If i remember this board is using XTAL 26MHz: |
I've tried Interestingly when I changed back to ESP Dev board, it worked. Then put in 2 Serial.println("Done") lines just to change the code, and fails again! I removed them, works. Changed back and forth, now it does not work anyome. I am really confused. Once one compilation works, even after reset and 20+ scans. But some compilation just does not work. I 've checked the Arduino comp messages. The BLE library compilation sequence is a bit different. That is all. Any idea? |
I dont have explanation for that. What you can do is to see if you are not short on heap, or experiment with different boards selected in arduino. |
I have checked 3 other boards:
All worked with ESP Dev board settings. But...
|
So, this looks like esp-idf or in arduino-esp32 boards.txt problem. |
Might be. I still not understand why it does work in some cases and don't in the other. As always, this is the worst type of bug ever. :-D I will keep you informed when I find out something. |
Hi guys, Looks that I am able to receive temperature data with this settings:
but no idea how to decode it. |
I found out that all of the can boards can fail, even in ESP Dev board settings. When I restart the ESP it can fail from or work randomly. In other words, when it works for 2 sans, then it keeps working forever until I reboot. When it fails the second scan, it keeps failing until I reboot. I cannot see any pattern unfortunately. |
Hi Patrik, this is what I found out on my device:
Let me know if you find out more. |
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions. |
Hi, I think I had exactly the same problem: first scan was always different from following scans (from the 2nd scan it ommited name & manufacturer), which made me impossible to get desired data from 3 temp/hum IBS TH1 Plus Inkbird sensors. void loop() { cnt=cnt+1; if (cnt >= 5) { cnt=0; } client.loop(); Now some expert could tell me why was this happening and why this solved things out... |
I use this BLE fork instead. Does not solve this problem, but generally more stable: Might this be a solution? Can you try @luisgodelmo ? |
This value is uninitialised and as such can be a random (and invalid) value. It's needs to be set per the espressif documentation here: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/bluetooth/esp_gap_ble.html#_CPPv4N21esp_ble_scan_params_t14scan_duplicateE This PR sets it to DUPLICATE_DISABLE. Chosen as this is needed to ensure all scan data is populated in the scan callback, per this comment in the IDF: https://github.com/espressif/esp-idf/blob/master/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c#L3591 "//if scan duplicate is enabled, the adv packet without scan response is allowed to report to higher layer" We **don't** want it to report to the higher layer (ie BLEScan.cpp) **unless** it has the active scan response. Seems to resolve #3770 #3677 and possibly others.
For me the solution was: void loop() { |
@Nagymadar ist getName there working? |
I am using BLE_scan.ino example. Unfortunately only the first scan gives valid device serviceUUID and Name. From the second scan onward SENSOR_PRO device gives no serviceUUID the HMSoft device gives empty string as Name. It seems it is an old bug, but still no solution? Serial data from boot:
Scanning...
Advertised Device: Name: SENSOR_PRO, Address: ed:3d:9a:96:86:a3, serviceUUID: 6a800001-b5a3-f393-e0a9-e50e24dcca9e
Advertised Device: Name: HMSoft, Address: 90:9a:77:27:65:15, manufacturer data: 484d909a77276515, serviceUUID: 0000ffe0-0000-1000-8000-00805f9b34fb, txPower: 0
Devices found: 2
Scan done!
Advertised Device: Name: SENSOR_PRO, Address: ed:3d:9a:96:86:a3
Advertised Device: Name: , Address: 90:9a:77:27:65:15, manufacturer data: 484d909a77276515, serviceUUID: 0000ffe0-0000-1000-8000-00805f9b34fb, txPower: 0
Devices found: 2
Scan done!
Advertised Device: Name: SENSOR_PRO, Address: ed:3d:9a:96:86:a3
Advertised Device: Name: , Address: 90:9a:77:27:65:15, manufacturer data: 484d909a77276515, serviceUUID: 0000ffe0-0000-1000-8000-00805f9b34fb, txPower: 0
Devices found: 2
Scan done!
etc...
The text was updated successfully, but these errors were encountered: