About device peer manager

SDK:11.0
Example:ble_app_hrs\pca10040\ s132_with_dfu

Hi 

The product we are selling wants to add some new features and can only be upgraded through DFU. But we currently don't have enough IROM to build new features. Then we realized that our peer manager feature was not being used, and we could save a lot of space(aboout 1kb) if we didn't use it. Can I disable device_manager_init() directly?

/**@brief Function for the Device Manager initialization.
 *
 * @param[in] erase_bonds  Indicates whether bonding information should be cleared from
 *                         persistent storage during initialization of the Device Manager.
 */
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.lesc         = SEC_PARAM_LESC;
    register_param.sec_param.keypress     = SEC_PARAM_KEYPRESS;
    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);
}


Best regard
Kenyon

  • Hi Kenyon

    Is there a specific reason you're using the nRF5 SDK v11.0.0 for your application? This SDK version is older than the nRF52810 which it seems like you're developing for, so I'd strongly recommend you to move to a newer version as the nRF52810 didn't get added functionality until SDK v14.0.0. SDK 17.1.0 is the recommended one for use now, unless you move to the nRF Connect SDK.

    That being said, just not using the device manager should be fine if you don't do pairing/bonding and don't need these features.

    Best regards,

    Simon

  • Hi Simonr
    These products have already been sold, so this generation of products cannot update the SDK and can only continue to develop on SDK11.
    The odd thing is that when I disable device_manager_init(), the program will not run properly and will die in the bootloader program after the key wakes up.What configuration changes do I need to make for the program to work properly?

    Best regards.
    Kenyon

  • Hi

    I will need some more information on what exactly is happening here to answer that. What do you mean by "die" exactly, and what does "after the key wakes up" mean? And how do you disable the "device_manager_init()"? Do you see any kinds of error codes when trying to remove the device_manager_init() from your application. Some debugging will be required in order to get to the bottom of this I think.

    If they're already sold and out on the market it might be difficult to do something with it if they already have the device manager embedded within the project and it is used by the BLE stack to manage connections etc.

    Best regards,

    Simon

  • Hi Simonr

    1. After debugging, I find that dfu_app_dm_appl_instance_set(m_app_handle) is masked from service_init. It can work normally!

    static void services_init(void)
    {
        uint32_t       err_code;
    //  ble_hrs_init_t hrs_init;
        ble_bas_init_t bas_init;
        ble_dis_init_t dis_init;
    //  uint8_t        body_sensor_location;
    
        ble_nus_init_t nus_init;
        memset(&nus_init, 0, sizeof(nus_init));
        nus_init.data_handler = nus_data_handler;
        err_code = ble_nus_init(&m_nus, &nus_init);
        APP_ERROR_CHECK(err_code);    
    
        // Initialize Battery Service.
        memset(&bas_init, 0, sizeof(bas_init));
    
        // Here the sec level for the Battery Service can be changed/increased.
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_char_attr_md.cccd_write_perm);
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_char_attr_md.read_perm);
        BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&bas_init.battery_level_char_attr_md.write_perm);
    
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_report_read_perm);
    
        bas_init.evt_handler          = NULL;
        bas_init.support_notification = true;
        bas_init.p_report_ref         = NULL;
        bas_init.initial_batt_level   = 100;
    
        err_code = ble_bas_init(&m_bas, &bas_init);
        APP_ERROR_CHECK(err_code);
    
        // Initialize Device Information Service.
        memset(&dis_init, 0, sizeof(dis_init));
    
        ble_srv_ascii_to_utf8( &dis_init.manufact_name_str , (char *)MANUFACTURER_NAME );
        ble_srv_ascii_to_utf8( &dis_init.fw_rev_str        , (char *)LL_VER_BLE_DIS    );
    
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&dis_init.dis_attr_md.read_perm);
        BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&dis_init.dis_attr_md.write_perm);
    
        err_code = ble_dis_init(&dis_init);
        APP_ERROR_CHECK(err_code);
    
    #ifdef BLE_DFU_APP_SUPPORT
        /** @snippet [DFU BLE Service initialization] */
        ble_dfu_init_t   dfus_init;
    
        // Initialize the Device Firmware Update Service.
        memset(&dfus_init, 0, sizeof(dfus_init));
    
        dfus_init.evt_handler   = dfu_app_on_dfu_evt;
        dfus_init.error_handler = NULL;
        dfus_init.evt_handler   = dfu_app_on_dfu_evt;
        dfus_init.revision      = DFU_REVISION;
    
        err_code = ble_dfu_init(&m_dfus, &dfus_init);
        APP_ERROR_CHECK(err_code);
    
        dfu_app_reset_prepare_set(reset_prepare);
    //    dfu_app_dm_appl_instance_set(m_app_handle); 
    
    }

    2. Yes.Our product is currently on sale, so will the measure of 'remove the peer manager to increase the space'  have any risk when we upgrade the customer's device through DFU in the future?
    Our Ble application scenario: Connect to our self-developed App, simple interactive Ble commands.

    Best Regard
    Kenyon

  • Hi again

    Glad you were able to get it back to a working state! As long as you don't do pairing/bonding of your connection, or have to manage multiple connections on the nRF device, it should be fine to remove the device/peer manager from your application.

    Best regards,

    Simon

Related