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

ble_gap_cfg_device_name_t USAGE

Hi,

We have a requirement of reading the BLE Advertising name from flash instead of predefining it in as a MACRO.  I saw in the notes it says to use ble_gap_cfg_device_name_t. But I don't know the actual usage of it. Can you please direct me to an example where this API has been used.  

I have seen the structure reference for this but I am still not sure where and how to use it. 

Shall I remove SVCALL(SD_BLE_GAP_DEVICE_NAME_SET, uint32_t, sd_ble_gap_device_name_set(ble_gap_conn_sec_mode_t const *p_write_perm, uint8_t const *p_dev_name, uint16_t len)); from my code and add ble_gap_cfg_device_name_t ?? 

using nrf52840 and SDK 15.0.0

Please suggest!!

Thanks

Parents
  • Hi,

    What is the purpose of placing the name in flash? If you set it directly in the application, it will still be stored in flash in application code.

    You can find an example in this post.

    Best regards,
    Jørgen

  • If you only want to store the name in a specific address in flash, you can do something like this to set it:

    uint32_t adv_name_address = 0x40000;
    uint8_t adv_name_length = 12;
    char adv_name[adv_name_length];
    memcpy(adv_name, (uint8_t *)adv_name_address, adv_name_length);
    
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
    
    err_code = sd_ble_gap_device_name_set(&sec_mode,
                                          adv_name,
                                          adv_name_length);
    APP_ERROR_CHECK(err_code);

    You can write the data to flash, for instance using nrfjprog:

    nrfjprog -e
    nrfjprog --memwr 0x40000 --val 0x64726F4E
    nrfjprog --memwr 0x40004 --val 0x555F6369
    nrfjprog --memwr 0x40008 --val 0x21545241

    (This is an example from ble_app_uart, the example will advertise with name "Nordic_UART!")

Reply
  • If you only want to store the name in a specific address in flash, you can do something like this to set it:

    uint32_t adv_name_address = 0x40000;
    uint8_t adv_name_length = 12;
    char adv_name[adv_name_length];
    memcpy(adv_name, (uint8_t *)adv_name_address, adv_name_length);
    
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
    
    err_code = sd_ble_gap_device_name_set(&sec_mode,
                                          adv_name,
                                          adv_name_length);
    APP_ERROR_CHECK(err_code);

    You can write the data to flash, for instance using nrfjprog:

    nrfjprog -e
    nrfjprog --memwr 0x40000 --val 0x64726F4E
    nrfjprog --memwr 0x40004 --val 0x555F6369
    nrfjprog --memwr 0x40008 --val 0x21545241

    (This is an example from ble_app_uart, the example will advertise with name "Nordic_UART!")

Children
Related