Populating this struct

Hi,
I defined an address in OTP as my Bluetooth name to display to the user.
I used your hw_otpc_read ( ) to read the OTP data into my RAM variable.

I am not sure how to populate this struct :

struct app_device_info device_info = {
{ USER_DEVICE_NAME_LEN, USER_DEVICE_NAME},
0x0000 };

I will keep the Length as a constant, but USER_DEVICE_NAME confuses me.

This supplies : device_info.dev_name.name

I don’t want to make many changes and then I break the Bluetooth Module.
I see a memcpy ( ) where I could make a change.

What would you suggest?
Thanks Gert

Parents
  • H Gert,

    Thank you for posting your questions online.

    Let me check this and will back to you soon.

    BR,

    JH_Renesas

  • Hi Gert,

    There are two place for the device name usage:

    1, the device name in the device info structure you can replace the name(from OTP) here in the memory copy :

    void app_init(void)
    {
        // Reset the environment
        for (int i = 0; i < APP_EASY_MAX_ACTIVE_CONNECTION; i++) { 
            app_env[i] = (struct app_env_tag) {0};
        }
        
        // Initialize device info
        device_info.dev_name.length = (USER_DEVICE_NAME_LEN <= GAP_MAX_NAME_SIZE) ? USER_DEVICE_NAME_LEN : GAP_MAX_NAME_SIZE;
        memcpy(device_info.dev_name.name, USER_DEVICE_NAME, device_info.dev_name.length);
        device_info.appearance = 0x0000;
    
        // Create APP task
        ke_task_create(TASK_APP, &TASK_DESC_APP);
    
        // Initialize Task state
        ke_state_set(TASK_APP, APP_DISABLED);
    }
    

    2,  As I show you with the example prox_report, it has ADV response data contains the device name. So you need change the name here as well:

            // Place the Device Name in the Advertising Data or in the Scan Response Data
            if (USER_DEVICE_NAME_LEN > 0)
            {
                // Get remaining space in the Advertising Data ( plus 2 bytes are used for the length and flag bytes of the Device Name and 3 bytes for the AD type flags)
                uint16_t total_adv_space = 3 + adv_cmd->info.host.adv_data_len + 2 + USER_DEVICE_NAME_LEN;
                // Get remaining space in the Scan Response Data ( plus 2 bytes are used for the length and flag bytes of the Device Name)
                uint16_t total_scan_space = adv_cmd->info.host.scan_rsp_data_len + 2 + USER_DEVICE_NAME_LEN;
    
                if (total_adv_space <= ADV_DATA_LEN)
                {
                    append_device_name(&cmd->info.host.adv_data_len,
                                       USER_DEVICE_NAME_LEN,
                                       &(cmd->info.host.adv_data[cmd->info.host.adv_data_len]),
                                       USER_DEVICE_NAME);
                }
                else if (total_scan_space <= SCAN_RSP_DATA_LEN)
                {
                    append_device_name(&cmd->info.host.scan_rsp_data_len,
                                       USER_DEVICE_NAME_LEN,
                                       &(cmd->info.host.scan_rsp_data[cmd->info.host.scan_rsp_data_len]),
                                       USER_DEVICE_NAME);
                }
             }

    BR,

    JH_Renesas

Reply
  • Hi Gert,

    There are two place for the device name usage:

    1, the device name in the device info structure you can replace the name(from OTP) here in the memory copy :

    void app_init(void)
    {
        // Reset the environment
        for (int i = 0; i < APP_EASY_MAX_ACTIVE_CONNECTION; i++) { 
            app_env[i] = (struct app_env_tag) {0};
        }
        
        // Initialize device info
        device_info.dev_name.length = (USER_DEVICE_NAME_LEN <= GAP_MAX_NAME_SIZE) ? USER_DEVICE_NAME_LEN : GAP_MAX_NAME_SIZE;
        memcpy(device_info.dev_name.name, USER_DEVICE_NAME, device_info.dev_name.length);
        device_info.appearance = 0x0000;
    
        // Create APP task
        ke_task_create(TASK_APP, &TASK_DESC_APP);
    
        // Initialize Task state
        ke_state_set(TASK_APP, APP_DISABLED);
    }
    

    2,  As I show you with the example prox_report, it has ADV response data contains the device name. So you need change the name here as well:

            // Place the Device Name in the Advertising Data or in the Scan Response Data
            if (USER_DEVICE_NAME_LEN > 0)
            {
                // Get remaining space in the Advertising Data ( plus 2 bytes are used for the length and flag bytes of the Device Name and 3 bytes for the AD type flags)
                uint16_t total_adv_space = 3 + adv_cmd->info.host.adv_data_len + 2 + USER_DEVICE_NAME_LEN;
                // Get remaining space in the Scan Response Data ( plus 2 bytes are used for the length and flag bytes of the Device Name)
                uint16_t total_scan_space = adv_cmd->info.host.scan_rsp_data_len + 2 + USER_DEVICE_NAME_LEN;
    
                if (total_adv_space <= ADV_DATA_LEN)
                {
                    append_device_name(&cmd->info.host.adv_data_len,
                                       USER_DEVICE_NAME_LEN,
                                       &(cmd->info.host.adv_data[cmd->info.host.adv_data_len]),
                                       USER_DEVICE_NAME);
                }
                else if (total_scan_space <= SCAN_RSP_DATA_LEN)
                {
                    append_device_name(&cmd->info.host.scan_rsp_data_len,
                                       USER_DEVICE_NAME_LEN,
                                       &(cmd->info.host.scan_rsp_data[cmd->info.host.scan_rsp_data_len]),
                                       USER_DEVICE_NAME);
                }
             }

    BR,

    JH_Renesas

Children
No Data