-
Notifications
You must be signed in to change notification settings - Fork 715
advertisedDevice.getName() always null #599
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
This is my output log:
As you can see 2 devices has given name, the third is my laptop and is not advertising name at all. |
As Ingineerix says "First off: Thanks for your Awesome work Neil!" I have exactly the same issue as Ingineerix, I have to get the "name" of some ble beacon for my project but it always return null... I have made a test with an android application, and it s works (I get a name). BTW, do you now a way to get the complete BLE frame (in hex) ? thank again and best regards |
dear all, I have try to use getPayload() to check if my device name is in the payload or not, I have had this on the toString method on the BLEAdvertisedDevice.h file
And the only stuff on the serial monitor is
I m not familar with java but I have see TX power, name, and other stuff are parsed on BLEAdvertisedDevice::parseAdvertisement. In my case my device name is 17 char long. Is someone have an idea ? For information, I use 1.8.10 arduino |
Hi, I am also seeing a very similar issue, I am surrounded by BLE devices and the scan using ESP32 and the nkolban library is regularly returning 15+ addresses, but very few (maybe 1 or 2) have a name. For info I see name for Tiles, Garmin devices, Bose headphones, Fitbits and other fitness trackers as people walk into range. I am using an active scan with the default interval and window values. I even added this to BLEAdvertisedDevice::parseAdvertisement but it made no difference: If I scan using any BLE scanner on my iPhone I see names for many more devices (but certainly not all), so there must be some advertising data I am not seeing for some reason. I have not completed my investigations yet, so maybe I will find my missing data but any help would be appreciated. |
Hi, |
@chegewara , sorry if I’m being a bit thick, but is that value always 62? Or only 62 if parsing a scan response from an active scan? |
62 bytes max. 31 bytes for advertising and 31 bytes for scan response. Its quick fix now, i will fix it later by sending length value from parameters. |
@chegewara, Thanks for this! At least now I know I'm not going crazy. I'll try my project again. |
@chegewara I changed the value to 62 and now I get back the name of the iBeacon on my desk (but only when it is connectable for some reason) but the many phones (and my apple watch) in my vicinity still return no names, so I assume they do not advertise their names even in the extra active response data. |
You can check this with nRF connect on android or nRF beacon on android. |
@chegewara I think my investigations are pretty much complete. My conclusion is that the library is awesome, I have been messing about with BLE for a while but this library makes it accessible to anyone with some common sense. Your fix in BLEAdvertisedDevice.cpp ::parseAdvertisement sizeConsumed >=62 is definitely required to get the response data. I found some devices (maybe Garmin?) include the null terminator in the device name, which messes up your toString method (as it stops when it reaches \0). In ::setName m_name = name.c_str() fixes this. I found some beacons (Jaalee?) only advertise the short name so I added in ::parseAdvertisment I found many devices don't advertise any name at all or more annoyingly only advertise a single space 0x20 (???) but your amazing method BLEDevice::getValue(address, BLEUUID((uint16_t)0x1800), BLEUUID((uint16_t)0x2A00) ) will get something reasonable back. I am assuming that, if you can connect at all, the Generic Access service will be available but I do get a few hangs from time to time so maybe not! I might add a ::haveService method to your library, also is there a way to tell if a device is connectable before I try to connect? I have found that if you don't get back what you expect (especially from an Apple device) maybe iPad rather than Name's iPad or iPhone rather than Name's iPhone then this is because it isn't being transmitted, I'm sure there is a way but I don't know it yet. Interestingly my household is totally devoid of Android devices which probably indicates that I am giving my kids too much pocket money. On a final note, is there any way to set a timeout on BLEClient::connect as I have found this call can take an absolute age when failing to connect? |
Hi, There is few things i can help you with. First of all, service 0x1800 is obligatory and evry single ble device that you can connect to will have it, also characteristic 0x2A00. But you have to know that value of this characteristic can be empty string or something not printable. If you are brave you can try my latest code: |
parsing scan response fixed by a4e3d43. I will add short name parse when i have time and dont forget about it. |
Hi, I wand to use this to get by the apple mac address randomization. Is this impossible or am I just to stupid to find the way? thanks and best regards |
I'm not sure I understand what you require but you could try something like: |
That's exactly what i meant. |
@chegewara Did you ever get round to also implementing short name parsing? Thanks, |
First of all thanks for fixing the „31/62“ issue. Though it now works in the first scan, all following scans (15 sec delay between scans) do not show any device name. Any solution for that? |
I'm also only seeing the name only on the first scan. I'm just starting to dig into but the data length passed to the |
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). PS scan for 10 or 30 sec, delay 1000ms between scans |
Perhaps a better test would be: don't filter on the devices where the name is there but print all the devices picked up in the scan and see if the name on any of them disappears on subsequent scans. I looked into it a bit but decided to use the service UUID instead. It was happening consistently with me so I might have time to do some testing - if you want to suggest some things to try. My use case is that I am trying to connect to multiple nrf52840s that are running the same code (arduino+adafruit_ble) with the same service UUIDs and the same 5 characteristics (we already know the arduino code doesn't handle multiple characteristics and I've posted a fix for that somewhere). I can't remember whether the problem happens when only a single device is active or whether is requires multiple devices to be active. I'm also using pio+arduino+esp-idf. |
I am using filtering here only to show it is working. This issue title stands that name is ALWAYS null, and i am providing logs that i can scan very quick, multiple times and get peer device name every time, just check timestamps. |
I even thought it may be issue when name is split between advertising packed and scan response packet, but code should handle this case too: |
If I get time later in the week, I'll make a repo with the client and server code that generates the issue (It could be in the adafruit stack or, of course, my own error). Thanks for taking the time to look at it - I do appreciate your hard work. |
Has anyone found a workaround for this issue? Using BLE server and scanner example sketches in Arduino, names are empty even for devices that labelled using BLEDevice::init Example:
|
Hi,
after spending a few work days fiddling around I decided that the current solution is unstable and full
of random behavior. No solution, but a decision. Sorry :(
KS
… Am 22.05.2020 um 08:27 schrieb Ejri ***@***.***>:
Has anyone found a workaround for this issue?
Using BLE server and scanner example sketches in Arduino, names are empty even for devices that labelled using BLEDevice::init
Example:
BLEDevice::init("ESP32 1-18");
BLE Advertised Device: Name: , Address: 76:e9:c4:7d:9b:b2, manufacturer data: 4c0010067119799a1180, txPower: 7
BLE_Address: 76:e9:c4:7d:9b:b2
RSSI: -99
name of device: .
BLE Advertised Device: Name: , Address: 38:0b:84:57:35:3a, manufacturer data: 060001092002cd6159c4eb148b0ed9dfcb3dce2831423c0a99128a30e1
BLE_Address: 38:0b:84:57:35:3a
RSSI: -91
name of device: .
BLE Advertised Device: Name: , Address: 61:9c:64:5f:6d:0a, manufacturer data: 4c00071901022002f58f000000644d70096bec6bd59cccb62465737f4b
BLE_Address: 61:9c:64:5f:6d:0a
RSSI: -93
name of device: .
BLE Advertised Device: Name: , Address: 5e:54:bf:65:ad:b8, manufacturer data: 4c0010050318945f66
BLE_Address: 5e:54:bf:65:ad:b8
RSSI: -95
name of device: .
Devices found: 4
Scan done!
BLE Advertised Device: Name: , Address: 76:e9:c4:7d:9b:b2, manufacturer data: 4c0010067119799a1180, txPower: 7
BLE_Address: 76:e9:c4:7d:9b:b2
RSSI: -90
name of device: .
BLE Advertised Device: Name: , Address: 61:9c:64:5f:6d:0a, manufacturer data: 4c00071901022002f58f0000004b21b5f69a3fcf2050a3a63265892a05
BLE_Address: 61:9c:64:5f:6d:0a
RSSI: -95
name of device: .
Devices found: 2
Scan done!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
I managed to fix this issue, well, sort of... The library isn't using the ESP_BLE_AD_TYPE_NAME_SHORT Advertising Type in the BLEAdvertisedDevice.cpp file in the parseAdvertisement sub... So, I added it in, and hey presto... Problem solved... My fork is here... https://github.com/pjgpetecodes/ESP32_BLE_Arduino. The code is basically... case ESP_BLE_AD_TYPE_NAME_SHORT: { // Adv Data Type: 0x08
setName(std::string(reinterpret_cast<char*>(payload), length));
break;
}// ESP_BLE_AD_TYPE_NAME_SHORT
case ESP_BLE_AD_TYPE_NAME_CMPL: { // Adv Data Type: 0x09
setName(std::string(reinterpret_cast<char*>(payload), length));
break;
} // ESP_BLE_AD_TYPE_NAME_CMPL However, I've left in the full name, which I could possibly cause an issue... Need a way of choosing between them, or perhaps adding in the functions for short name as well as name perhaps? |
Hi, is there any fix for the getName() issue which returns names in the first scan and returns nothing after that. I would highly appriciate if i can be pointed out to resolving the issue. Thanks in advance I am using ESP32 HUZZAH Feather and trying to run BLE_scan sample. |
I found out that name is returned using getName() , it is returned in every scan, but if I call getRSSI() the name will no longer be returned in the next scans. |
I found this article posted which does a BLEDevice::init("myBLEScan"); in the loop and at the end of scan process BLEDevice::deinit(false); espressif/arduino-esp32#3677 (comment) Hope this helps as a quick fix. |
I've submitted this PR to espressif arduino-esp32 which seems to resolve the scan issues described here: |
This is still not registering the name and is quite frustrating. Is there any progress on the matter? When I run the scan it will not populate with my ESP32 device name. |
@chegewara any help would be appreciated. |
Hi, |
Thank you for getting back so quickly @chegewara and I will continue to try to experiment however I have tried all versions of the library and in all circumstances I get: |
Have you applied the changes in the PR I linked above? |
@buxtronix I have I added: On the server ESP32 I tried both the BLE_server and BLE_server_multiconnect and they both allow me to find the device on my phone. I wonder if the BLE_scan example is not actually finding the other device at all. My goal is to simply use a BLE_scan example to find a name of an ESP32 that I can check for. I assume that Or is there another BLEDevice param that I need to set for this to work? |
So.... It turns out I had a bad BLE device in my ESP32. I tested again with @buxtronix code and it works. Sorry for any confusion. |
BLEScan::BLEScan() { but it still does not work:( |
First off: Thanks for your Awesome work Neil!
I never get names returned, I'm running in Arduino IDE, and have tried to make my own app as well as tried several published examples using your library, and none return canonical device names. When I scan using the nRF Android app, it pulls the names every time.
I even tried running a modified version of your sample at: https://pastebin.com/gGXrvg6z:
`#include "BLEUtils.h"
#include "BLEScan.h"
#include
#include "BLEDevice.h"
#include "BLEAdvertisedDevice.h"
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
void onResult(BLEAdvertisedDevice advertisedDevice) {
Serial.println(advertisedDevice.toString().c_str());
}
};
void setup()
{
Serial.begin(115200);
Serial.println("Scanning sample starting");
BLEDevice::init("");
BLEScan* pBLEScan = BLEDevice::getScan();
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
pBLEScan->setInterval(0x120);
pBLEScan->setWindow(0x60);
pBLEScan->setActiveScan(true);
BLEScanResults scanResults = pBLEScan->start(10);
Serial.print("Found devices: ");
Serial.println(scanResults.getCount());
scanResults.dump();
Serial.println("Scanning sample ended");
}
void loop()
{
}
`
Here's the output:
st:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0018,len:4 load:0x3fff001c,len:952 load:0x40078000,len:6084 load:0x40080000,len:7936 entry 0x40080310 Scanning sample starting Name: , Address: 78:94:82:4c:21:aa, manufacturer data: e000017cca712c0e, serviceUUID: 0000fe9f-0000-1000-8000-00805f9b34fb Name: , Address: 6b:b6:f8:eb:75:97, manufacturer data: e00001b6ca808237, serviceUUID: 0000fe9f-0000-1000-8000-00805f9b34fb Name: , Address: 4e:9b:11:3a:af:ae, manufacturer data: e00001a7ca8078bd, serviceUUID: 0000fe9f-0000-1000-8000-00805f9b34fb Found devices: 3 Scanning sample ended
The text was updated successfully, but these errors were encountered: