To change the device's name dynamically

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
JaHu_1711326
Level 1
Level 1
First like received First like given Welcome!

In general, the device's name is defined in the field "local_name" of the data structure BLE_PROFILE_CFG and launched by the function "bleapp_set_cfg".

If I will identify the different device's name in the same firmware, how to change the device's name by function call?

Thanks!

Jack Huang

0 Likes
1 Solution
asridharan
Employee
Employee
10 comments on KBA 5 comments on KBA First comment on KBA

See hello_sensor sample app, in particular:

...

    else

    {

        // total length should be less than 31 bytes

        BLE_ADV_FIELD adv[3];

        // flags

        adv[0].len     = 1 + 1;

        adv[0].val     = ADV_FLAGS;

        adv[0].data[0] = LE_LIMITED_DISCOVERABLE | BR_EDR_NOT_SUPPORTED;

        adv[1].len     = 16 + 1;

        adv[1].val     = ADV_SERVICE_UUID128_COMP;

        memcpy(adv[1].data, db_pdu.pdu, 16);

        // name

        adv[2].len      = strlen(bleprofile_p_cfg->local_name) + 1;

        adv[2].val      = ADV_LOCAL_NAME_COMP;

        memcpy(adv[2].data, bleprofile_p_cfg->local_name, adv[2].len - 1);

        bleprofile_GenerateADVData(adv, 3);

    }

you can use your own string instead of bleprofile_p_cfg->local_name. And you may want to write the same string to the local name characteristic too.

View solution in original post

3 Replies