static void gap_params_init(void)
{
const uint8_t name[]={"Scanner:"};
uint8_t device_name[12];
uint32_t ID_num= m_device_info.Device_UNI_ID % 100000;
uint32_t err_code;
ble_gap_conn_params_t gap_conn_params;
ble_gap_conn_sec_mode_t sec_mode;
memcpy(device_name,name,8);
device_name[8] = (ID_num%10000)/1000 + 48;
device_name[9] = (ID_num%1000)/100 + 48;
device_name[10] = (ID_num%100)/10 + 48;
device_name[11] = ID_num%10 + 48;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
err_code = sd_ble_gap_device_name_set(&sec_mode,
(const uint8_t *) device_name,
sizeof(device_name));
APP_ERROR_CHECK(err_code);
memset(&gap_conn_params, 0, sizeof(gap_conn_params));
gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
gap_conn_params.slave_latency = SLAVE_LATENCY;
gap_conn_params.conn_sup_timeout = CONN_SUP_TIMEOUT;
err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
APP_ERROR_CHECK(err_code);
}
Device:Nrf51822
SDK:SDK12.3
Device name consists of "scanner:" and four digits。But sometimes the device name display error。An extra character appears in the device name string。 As shown below:
