-
Build a custom BLE service and enable the write attribute
-
Configure the characteristic "attr_char_value.max_len = MAX_LEN"; max_len should be larger than your device name
-
In the BLE event handler, read back the data like below
if ((write_evt->handle == m_custom_service_char.value_handle) && (write_evt->data[0] == RENAME)) { //device name limited to 10bytes for (uint8_t i = 0; i < MAX_DEVICE_NAME_LEN; i++){ device_name[i] = write_evt->data[i+1]; } ble_gap_conn_sec_mode_t sec_mode; BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); err_code = sd_ble_gap_device_name_set(&sec_mode,(const uint8_t *)device_name,MAX_DEVICE_NAME_LEN); APP_ERROR_CHECK(err_code); }