NimBLE Gap device name limits

adrianolmar
Posts: 5
Joined: Thu Sep 12, 2019 12:14 pm

NimBLE Gap device name limits

Postby adrianolmar » Mon Jun 22, 2020 12:58 pm

Hi, I'm using NimBLE on espressif ESP32 IDF version 4.0 (I've tryed with 4.1beta2 and happens the same problem).

I have problems with the size of name of device (ble_svc_gap_device_name_set). We can put until 19 characters on device name.

Code: Select all

    name = ble_svc_gap_device_name();
    fields.name = (uint8_t *)name;
    fields.name_len = strlen(name);
    fields.name_is_complete = 1;
In SDK config the maximum name of BLE device name is 31. If I put a name of device gather than 19 the application (I use BLE Scanner) can´t find the device. How I can solve this error to allow name gather than 19 octets?

I see in a Nordic forum the maximum lenth of advertisement table is 31. Is it true?

https://devzone.nordicsemi.com/f/nordic ... nt-package

chegewara
Posts: 2306
Joined: Wed Jun 14, 2017 9:00 pm

Re: NimBLE Gap device name limits

Postby chegewara » Mon Jun 22, 2020 8:34 pm

Hi,
i dont know how it looks like in nimble, because i didnt work with it yet, so i will answer other questions.
Yes, you have 31 bytes in advertising packet, but some of it can be used to advertise other data, like TX power etc. If you could try to use nRF connect and check raw advertising data to see if and what is advertised except name, then it may help you.

You can also use scan response, another 31 bytes to put device name, most likely nothing is advertised by stack in it by default.

adrianolmar
Posts: 5
Joined: Thu Sep 12, 2019 12:14 pm

Re: NimBLE Gap device name limits

Postby adrianolmar » Mon Jun 22, 2020 11:36 pm

Thank you Chegewara,

logging these 31 bytes: 3 for flags, 3 for tx power, 4 for service uuid, 2 for name header ...
it lasts 19 bytes for name as I imagine.

I'll try to complement the advertising table with scan response (ble_gap_adv_rsp_set_data) and I give you news.

adrianolmar
Posts: 5
Joined: Thu Sep 12, 2019 12:14 pm

Re: NimBLE Gap device name limits

Postby adrianolmar » Wed Jun 24, 2020 9:15 pm

I can't find a way to implement a "scan response" in NimBLE.
Does any one know how to implement a "scan response" in NimLBE?

slompf
Posts: 15
Joined: Tue Mar 12, 2019 6:55 pm

Re: NimBLE Gap device name limits

Postby slompf » Sun Aug 09, 2020 10:11 am

Hi,

I just did that for my project. The length of the name you can send with regular advertising depends on your advertising data.

Code: Select all

int err = 0;
const char* name = "myAwesomName";
struct ble_hs_adv_fields fields;
memset(&fields, 0, sizeof fields);
size_t name_length = strlen(name);
if (name_length < 8) {
    fields.name = (uint8_t *)name;
    fields.name_len = name_length;
    fields.name_is_complete = 1;
}
else {
    fields.name = (uint8_t *)name;
    fields.name_len = 7;
    fields.name_is_complete = 0;

    struct ble_hs_adv_fields scan_response_fields;
    memset(&scan_response_fields, 0, sizeof scan_response_fields);
    scan_response_fields.name = (uint8_t *)name;
    scan_response_fields.name_len = name_length;
    scan_response_fields.name_is_complete = 1;
    err = ble_gap_adv_rsp_set_fields(&scan_response_fields);
    if (err)
    {
        return err;
    }
}

err = ble_gap_adv_set_fields(&fields);
return err;

Who is online

Users browsing this forum: Google Adsense [Bot], omerfurkan.ipek and 262 guests