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

Bond and change dev name

Hi: I want to bond and change dev name and storage. This is my storage dev name init code:

void my_flash_init(void)
{

    uint32_t err_code;

    pstorage_module_param_t param;

    param.block_count = 1;
    param.block_size = NAME_SIZE;
    param.cb = my_cb;
  
    err_code = pstorage_init();
    err_code = pstorage_register(&param, &my_name_addr);

    err_code = pstorage_load(device_name, &my_name_addr, NAME_SIZE, 0);

}

This is my bond init code:

static void device_manager_init(bool erase_bonds)  
{  
    uint32_t               err_code;  
    dm_init_param_t        init_param = {.clear_persistent_data = erase_bonds};  
    dm_application_param_t register_param;  
  
    // Initialize persistent storage module.  
    err_code = pstorage_init();  
    APP_ERROR_CHECK(err_code);  
  
    err_code = dm_init(&init_param);  
    APP_ERROR_CHECK(err_code);  
  
    memset(&register_param.sec_param, 0, sizeof(ble_gap_sec_params_t));  
  
    register_param.sec_param.bond         = SEC_PARAM_BOND;  
    register_param.sec_param.mitm         = SEC_PARAM_MITM;  
    register_param.sec_param.io_caps      = SEC_PARAM_IO_CAPABILITIES;  
    register_param.sec_param.oob          = SEC_PARAM_OOB;  
    register_param.sec_param.min_key_size = SEC_PARAM_MIN_KEY_SIZE;  
    register_param.sec_param.max_key_size = SEC_PARAM_MAX_KEY_SIZE;  
    register_param.evt_handler            = device_manager_evt_handler;  
    register_param.service_type           = DM_PROTOCOL_CNTXT_GATT_SRVR_ID;  
  
    err_code = dm_register(&m_app_handle, &register_param);  
    APP_ERROR_CHECK(err_code);  
}  

int main(void)
{
    uint32_t err_code=0;
    bool erase_bonds=0;
    timers_init();
    my_flash_init();

    ble_stack_init();
    gap_params_init();
    services_init();

    device_manager_init(erase_bonds);
    advertising_init();
    conn_params_init();
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);
}

Bond is work,but dev name is no storage .

Related