How to advertise a special data?

Hi friend,

I use SDK16.0, and the version of softdevice is S140 V7.0.1.  Can I advertise a special data? like 0x08,0xff,0xa6,0x02,0x33,0x09,0x55,0x00,0x0c. 0x08 is packet length and 0xff to 0x0c are data.

Thank you in advance.

Ted Wu

Parents
  • Hello,

    Are you trying to include the "MANUFACTURER SPECIFIC DATA" in your advertisment payload? In that case, you may use the ble_app_beacon example as a reference. It includes this field in the advertisment package.

    Best regards,

    Vidar

  • Hi Vidar,

    Yes, I tried. But I am getting error code in sd_ble_gap_adv_start function. The error code is 5 (NRF_ERROR_NOT_FOUND). My code snippet is below. I don't know know to fix it.

    Best wishes

    Ted Wu

    static uint8_t manufacturing_data_payload_list [] =
    {
        0x33,
        0x09,
        0x55,
        0x00,
        0x0c
    };
    
    void manuf_data_start(void)
    {
    	ret_code_t err_code;
        ble_advdata_manuf_data_t manuf_specific_data;
        ble_advertising_init_t init;
    
        memset(&init, 0, sizeof(init));
    
        init.advdata.name_type               = BLE_ADVDATA_NO_NAME;
        init.advdata.include_appearance      = false;
        init.advdata.flags                   = 0;
        init.advdata.uuids_complete.uuid_cnt = 0;
        init.advdata.uuids_complete.p_uuids  = NULL;
    
        manuf_specific_data.company_identifier = 0x02A6;
        manuf_specific_data.data.size = 5;
        manuf_specific_data.data.p_data = manufacturing_data_payload_list;
    
        init.advdata.p_manuf_specific_data = &manuf_specific_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.config.ble_adv_on_disconnect_disabled = true; //if device disconnect, not needs auto adv again.
    	
        init.evt_handler = on_adv_evt;
    
        err_code = ble_advertising_init(&m_advertising, &init);
        APP_ERROR_CHECK(err_code);
    
        err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
        APP_ERROR_CHECK(err_code);
    }

  • Hi Ted,

    To start connectable advertising, you need to set the connection configuration tag after advertising init with ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);, where APP_BLE_CONN_CFG_TAG should correspond with the tag used by ble_stack_init()->nrf_sdh_ble_default_cfg_set().

    Best regards,

    Vidar 

  • Hi Vidar,

    Could you explain it in more detail? I still don't know how to fix it.

    Thank you very much.

    Ted Wu

  • Hi Ted,

    Are you able to upload a minimal version your project so I can try it here?

Reply Children
Related