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

How to advertise a "raw payload" of 31 bit in the gap advertiser ?

Hi All,

Since 2 weeks I try to configure a gap with a "raw payload" but it's a Chinese puzzle!
Between different SDK, with different "Soft Devices" and examples dating back over 6 years for some who are of course not compatible with each other, I do not know where to start.
Already it's a first experience with language C.
I think that rather to refer to examples where outdated readings, it would be better to provide examples that work, so we will understand better how it works.
Think of those who start.
If anyone can help me, provide examples or willing to explain how to get there, please I need you.

Best regards,

Jiemde

Parents
  • Hi Jean-Marie, 

    the easiest way to do this is to put the data into the manufacturer specific data section of the advertisment packet. This will allow you to transmit 28 byte of custom data (the remaining 1 byte is used as a type field and two bytes are used for the company identifier). Modifying the ble_app_template example to do this is pretty simple, see below:

    static void advertising_init(void)
    {
        ret_code_t             err_code;
        ble_advertising_init_t init;
        uint8_t data[28] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27};
        ble_advdata_manuf_data_t manuf_data;
        manuf_data.company_identifier = 0x0059;
        manuf_data.data.p_data = data;
        manuf_data.data.size = sizeof(data);
       
    
        memset(&init, 0, sizeof(init));
        
        init.advdata.name_type               = BLE_ADVDATA_NO_NAME;//BLE_ADVDATA_FULL_NAME;
        init.advdata.include_appearance      = false;
        //init.advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
        //init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        //init.advdata.uuids_complete.p_uuids  = m_adv_uuids;
        init.advdata.p_manuf_specific_data   = &manuf_data;
    
        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);
    }

    Here is the screenshot from nRF Connect on Android displaying the data:

    Best regards

    Bjørn

Reply
  • Hi Jean-Marie, 

    the easiest way to do this is to put the data into the manufacturer specific data section of the advertisment packet. This will allow you to transmit 28 byte of custom data (the remaining 1 byte is used as a type field and two bytes are used for the company identifier). Modifying the ble_app_template example to do this is pretty simple, see below:

    static void advertising_init(void)
    {
        ret_code_t             err_code;
        ble_advertising_init_t init;
        uint8_t data[28] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27};
        ble_advdata_manuf_data_t manuf_data;
        manuf_data.company_identifier = 0x0059;
        manuf_data.data.p_data = data;
        manuf_data.data.size = sizeof(data);
       
    
        memset(&init, 0, sizeof(init));
        
        init.advdata.name_type               = BLE_ADVDATA_NO_NAME;//BLE_ADVDATA_FULL_NAME;
        init.advdata.include_appearance      = false;
        //init.advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
        //init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        //init.advdata.uuids_complete.p_uuids  = m_adv_uuids;
        init.advdata.p_manuf_specific_data   = &manuf_data;
    
        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);
    }

    Here is the screenshot from nRF Connect on Android displaying the data:

    Best regards

    Bjørn

Children
No Data
Related