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

How to set "Device Information Service" with variables

OS in development environment :Windows10
HARD :(Taiyo Yuden)EBSHSN Series Evaluation Board : Central / Peripherals
CPU :(Nordic) nRF52832 / ARMR Cortex-M4F 32 bit processor 28-pin Land Grid Array / 15GPIOs / SWD
Soft Ver:nRF5_SDK_15.3.0_59ac345
Sample program to use: "ble_app_hrs"

"Device information service" is set with a constant, but please tell me how to set it with a variable.
Information to be set after manufacturing cannot be registered.
Thank you very much.

Parents
  • Hello,

    The Service implementation does not expose any APIs to update the device information. This is of course something that's possible to do through the Softdevice API, but I would rather suggest that you change the service initialization to reference the memory location of the data that will be set in production. That way you don't have to modify DIS service module. Here is a small code snippet to show what I mean:

    typedef struct
    {
        uint32_t fw_rev_str;                                                                   
        uint32_t hw_rev_str;
        ...
    } device_info_t;
    
    #define DEVICE_INFORMATION_START  &NRF_UICR->NRFFW[10]; //@0x1000103c. May also be placed in the regular FLASH region.
    
    
    /**@brief Function for initializing services that will be used by the application.
     *
     * @details Initialize the Heart Rate, Battery and Device Information services.
     */
    static void services_init(void)
    {
        ret_code_t         err_code;
        ble_hrs_init_t     hrs_init;
        ble_bas_init_t     bas_init;
        ble_dis_init_t     dis_init;
        nrf_ble_qwr_init_t qwr_init = {0};
        uint8_t            body_sensor_location;
    
        ...
    
        // DEVICE_INFORMATION_START= address in flash where the device information shall be stored. 
        device_info_t * device_info = (device_info_t *)DEVICE_INFORMATION_START; 
    
        ble_srv_ascii_to_utf8(&dis_init.manufact_name_str, (char *)MANUFACTURER_NAME);
    
        dis_init.dis_char_rd_sec = SEC_OPEN;
        
        /* First check if a valid FW revision string has been programmed  */
        if (device_info->fw_rev_str != 0xFFFFFFFF) 
        {
            dis_init.fw_rev_str.p_str = (uint8_t *) &device_info->fw_rev_str;
            dis_init.fw_rev_str.length = sizeof(device_info->fw_rev_str);
        }
        
        //TODO: Add other optional characteristics such as HW revision, etc.
    
        err_code = ble_dis_init(&dis_init);
        APP_ERROR_CHECK(err_code);
    }

Reply
  • Hello,

    The Service implementation does not expose any APIs to update the device information. This is of course something that's possible to do through the Softdevice API, but I would rather suggest that you change the service initialization to reference the memory location of the data that will be set in production. That way you don't have to modify DIS service module. Here is a small code snippet to show what I mean:

    typedef struct
    {
        uint32_t fw_rev_str;                                                                   
        uint32_t hw_rev_str;
        ...
    } device_info_t;
    
    #define DEVICE_INFORMATION_START  &NRF_UICR->NRFFW[10]; //@0x1000103c. May also be placed in the regular FLASH region.
    
    
    /**@brief Function for initializing services that will be used by the application.
     *
     * @details Initialize the Heart Rate, Battery and Device Information services.
     */
    static void services_init(void)
    {
        ret_code_t         err_code;
        ble_hrs_init_t     hrs_init;
        ble_bas_init_t     bas_init;
        ble_dis_init_t     dis_init;
        nrf_ble_qwr_init_t qwr_init = {0};
        uint8_t            body_sensor_location;
    
        ...
    
        // DEVICE_INFORMATION_START= address in flash where the device information shall be stored. 
        device_info_t * device_info = (device_info_t *)DEVICE_INFORMATION_START; 
    
        ble_srv_ascii_to_utf8(&dis_init.manufact_name_str, (char *)MANUFACTURER_NAME);
    
        dis_init.dis_char_rd_sec = SEC_OPEN;
        
        /* First check if a valid FW revision string has been programmed  */
        if (device_info->fw_rev_str != 0xFFFFFFFF) 
        {
            dis_init.fw_rev_str.p_str = (uint8_t *) &device_info->fw_rev_str;
            dis_init.fw_rev_str.length = sizeof(device_info->fw_rev_str);
        }
        
        //TODO: Add other optional characteristics such as HW revision, etc.
    
        err_code = ble_dis_init(&dis_init);
        APP_ERROR_CHECK(err_code);
    }

Children
No Data
Related