This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Error in sd_ble_gap_device_name_set

Hi everyone, 

I'm using the nrf5_SDK_for_Mesh_v4.1.0 and i'm having troubles by trying to change the BLE name. 

In the function gap_params_init i added a code to concatenate a the GAP_DEVICE_NAME with the DEVICEID so that i can have a unique name for each DK. My code is below

#if MESH_FEATURE_GATT_ENABLED
void gap_params_init(void)
{
    uint32_t                err_code;
    ble_gap_conn_sec_mode_t sec_mode;
    ble_gap_conn_params_t  gap_conn_params;

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);

    /*******/

    char device_name[15];
    uint8_t name_size; 

    name_size = strlen(GAP_DEVICE_NAME);
    memcpy(device_name, GAP_DEVICE_NAME, name_size);

    sprintf(&device_name[name_size], "%X", NRF_FICR->DEVICEID[0]);

    uint32_t errCode= sd_ble_gap_device_name_set(&sec_mode, (const uint8_t *) device_name, strlen(device_name));
    APP_ERROR_CHECK(errCode);

    /******/

    memset(&gap_conn_params, 0, sizeof(gap_conn_params));
    GAP_CONN_PARAMS_INIT(gap_conn_params);

    err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
    APP_ERROR_CHECK(err_code);
}
 

My problem is that the function sd_ble_gap_device_name_set returns en error 0x000003. 

Can somebody help me please?

Thank you

  • Hi,

    Error code 3 from sd_ble_gap_device_name_set() is NRF_ERROR_INTERNAL. It is not directly documented why this would happen, but there might be issues with the arguments that you send in, that was not detected before they caused an issue.

    Suggestions for how to start debugging this:

    • Figure out what device_name looks like, and whether it is actually a UTF-8 encoded, non NULL-terminated string.
    • Check that it does not get too long to fit in the char array of size 15 that you use for it, as if not you do have a buffer overflow error in your code. In this case, it would mean some of the other local variables in that function are overwritten/corrupted.

    Regards,
    Terje

Related