Re: err -5 when change BLE device name


Vikrant More <vikrant8051@...>
 

Hi Johan,

static void bt_le_adv_refresh(void)
{   
    int err,i;

    for(i=0; i<=14; i++)
    {
        name_buffer[i]= '@';   
// it is global array
    }
   
    sd[0].data = name_buffer;
    sd[0].data_len = 15;

    bt_le_adv_stop();

    err = bt_le_adv_start(BT_LE_ADV_CONN, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));

    if (err)
    {
        printk("Advertising failed to start (err %d)\n", err);
        return;
    }

    printk("Refreshed Advertising successfully started\n");
}



I modified my function as per your suggestion, but now
1) device stop advertising after this function get call (previously it was advertising with new Name )
2) plus getting same error as -> Advertising failed to start (err -5)

On Wed, Mar 21, 2018 at 4:14 PM, Johan Hedberg <johan.hedberg@...> wrote:
Hi Vikrant,

On Wed, Mar 21, 2018, Vikrant More wrote:
> *sd[0].data = name_buffer;        err = bt_le_adv_start(BT_LE_ADV_CONN, ad,

You also need to update sd[0].data_len.
E.g. sd[0].data_len = strlen(name_buffer);

> ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));    if (err)     {
> printk("Advertising failed to start (err %d)\n", err);        return;    }*
>
> But when I did it, got an error -> Advertising failed to start (err -5)
>
> Despite this nRF52, successfully advertise itself with new name.
>
> How to update device name in real time scenario without rebooting it ?

Doing bt_le_adv_stop() and bt_le_adv_start() with a new set of
parameters should work.

Johan

Join users@lists.zephyrproject.org to automatically receive all group messages.