Announcements
IMPORTANT: Cypress Developer Community is transitioning on October 20th. To learn more and be prepared for this change, check out our latest announcement.
cancel
Showing results for 
Search instead for 
Did you mean: 

WICED Smart Bluetooth

JaHu_1711326
New Contributor II

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
ArvindS_76
Employee

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
ArvindS_76
Employee

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

JaHu_1711326
New Contributor II

I had tried this way to set the device's name.

But, the result is still the original value of the declared config table, bleprofile_p_cfg->local_name.

0 Likes
JaHu_1711326
New Contributor II

Sorry, I forgot to write back the value to bleprofile_p_cfg->local_name.

This method works well.

Thanks!