1 of 1 people found this helpful
See hello_sensor sample app, in particular:
// total length should be less than 31 bytes
adv.len = 1 + 1;
adv.val = ADV_FLAGS;
adv.data = LE_LIMITED_DISCOVERABLE | BR_EDR_NOT_SUPPORTED;
adv.len = 16 + 1;
adv.val = ADV_SERVICE_UUID128_COMP;
memcpy(adv.data, db_pdu.pdu, 16);
adv.len = strlen(bleprofile_p_cfg->local_name) + 1;
adv.val = ADV_LOCAL_NAME_COMP;
memcpy(adv.data, bleprofile_p_cfg->local_name, adv.len - 1);
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.
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.
Sorry, I forgot to write back the value to bleprofile_p_cfg->local_name.
This method works well.