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

nRF52840 SDK16 - Passing unique ID DEVICEID in advertising data

Hi everyone,

I want instead of MAC address to advertise my device using its 64bit unique ID. What I am considering, is to use the p_data array for that purpose and more specific to advertise using scan responce format as follows

ble_advertising_init_t init;

uint8_t uniqueID[]={01,02,03,04,05,06,07,08};

init.srdata.p_manuf_specific_data->data.size = sizeof(uniqueID) / sizeof(uniqueID[0]);
init.srdata.p_manuf_specific_data->data.p_data = uniqueID;

My problem is that it isn't work.. I do not see the uniqueID while advertising

So my questions are:

1. Is it possible and wise to advertise the unique ID?

2. What it the best method of doing this?

Thanks in advance

Nick

Parents
  • I don't see any obvious errors from the short code snippet, are you getting any error code? Have you tried to do this change in for instance the \ble_app_blinky example which for instance are using scan response data?

    Also make sure that you set manuf_data.company_identifier before calling ble_advdata_encode().

    Best regards,
    Kenneth

  • Hi Kenneth and thank you for your responce,

    I've just saw the \ble_app_blinky example and I realized that the structure of my advertising_init() function differs. However, is similar with the \ble_app_hrs example

    The \ble_app_blinky example uses the ble_advdata_encode & sd_ble_gap_adv_set_configure functions, while \ble_app_hrs example uses the ble_advertising_initble_advertising_conn_cfg_tag_set to setup the advertising_init 

    Could you provide me some clarifications?

    This is my advertising_init() function. Should I follow the blinky example?

    static void advertising_init(void) {
      
      ret_code_t err_code;
      ble_advertising_init_t init; // configuration structure
      uint8_t uniqueID[]={01,02,03};
    
      memset(&init, 0, sizeof(init));
    
      init.advdata.name_type = BLE_ADVDATA_FULL_NAME;
      init.advdata.include_appearance = false;
    
      init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
      init.advdata.uuids_complete.uuid_cnt = 1;              
      init.advdata.uuids_complete.p_uuids = &m_adv_uuids[0];
      
      init.srdata.p_manuf_specific_data->data.size = sizeof(uniqueID) / sizeof(uniqueID[0]);
      init.srdata.p_manuf_specific_data->data.p_data = uniqueID;
    
      init.config.ble_adv_fast_enabled = true;
      init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
      init.config.ble_adv_fast_timeout = APP_ADV_DURATION;
    
      init.evt_handler = on_adv_evt;
    
      err_code = ble_advertising_init(&m_advertising, &init);
      APP_ERROR_CHECK(err_code);
    
      ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    }

    Nick

  • Nikosant03 said:
    Could you provide me some clarifications?

    You can choose either. It's just two different engineers making each example. One is using a ble advertising module to setup the advertisement, while the other is using the softdevice api directly.

    If you open the ble_app_hids_mouse example you can for instance see how it is setting up manufacturer packet in the advertisement by searching for SWIFT_PAIR_SUPPORTED in main.c

    Best regards,
    Kenneth

  • Thank you Kenneth,

    I will also try the softdevice API and will look the ble_app_hids_mouse example and will return with a feedback.

    In the meanwhile, can you spot any error with my advertising_init funciton that prevents from advertising scan responce data?

    static void advertising_init(void) {
      
      ret_code_t err_code;
      ble_advertising_init_t init; // configuration structure
      uint8_t uniqueID[]={01,02,03};
    
      memset(&init, 0, sizeof(init));
    
      init.advdata.name_type = BLE_ADVDATA_FULL_NAME;
      init.advdata.include_appearance = false;
    
      init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
      init.advdata.uuids_complete.uuid_cnt = 1;              
      init.advdata.uuids_complete.p_uuids = &m_adv_uuids[0];
      
      init.srdata.p_manuf_specific_data->data.size = sizeof(uniqueID) / sizeof(uniqueID[0]);
      init.srdata.p_manuf_specific_data->data.p_data = uniqueID;
    
      init.config.ble_adv_fast_enabled = true;
      init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
      init.config.ble_adv_fast_timeout = APP_ADV_DURATION;
    
      init.evt_handler = on_adv_evt;
    
      err_code = ble_advertising_init(&m_advertising, &init);
      APP_ERROR_CHECK(err_code);
    
      ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    }

Reply
  • Thank you Kenneth,

    I will also try the softdevice API and will look the ble_app_hids_mouse example and will return with a feedback.

    In the meanwhile, can you spot any error with my advertising_init funciton that prevents from advertising scan responce data?

    static void advertising_init(void) {
      
      ret_code_t err_code;
      ble_advertising_init_t init; // configuration structure
      uint8_t uniqueID[]={01,02,03};
    
      memset(&init, 0, sizeof(init));
    
      init.advdata.name_type = BLE_ADVDATA_FULL_NAME;
      init.advdata.include_appearance = false;
    
      init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
      init.advdata.uuids_complete.uuid_cnt = 1;              
      init.advdata.uuids_complete.p_uuids = &m_adv_uuids[0];
      
      init.srdata.p_manuf_specific_data->data.size = sizeof(uniqueID) / sizeof(uniqueID[0]);
      init.srdata.p_manuf_specific_data->data.p_data = uniqueID;
    
      init.config.ble_adv_fast_enabled = true;
      init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
      init.config.ble_adv_fast_timeout = APP_ADV_DURATION;
    
      init.evt_handler = on_adv_evt;
    
      err_code = ble_advertising_init(&m_advertising, &init);
      APP_ERROR_CHECK(err_code);
    
      ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    }

Children
Related