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

ble_app_proximity sample advertising data not exceeding limit?

static void advertising_init(uint8_t adv_flags) { uint32_t err_code; ble_advdata_t advdata; int8_t tx_power_level = TX_POWER_LEVEL;

ble_uuid_t adv_uuids[] = 
{
    {BLE_UUID_TX_POWER_SERVICE,        BLE_UUID_TYPE_BLE}, 
    {BLE_UUID_IMMEDIATE_ALERT_SERVICE, BLE_UUID_TYPE_BLE}, 
    {BLE_UUID_LINK_LOSS_SERVICE,       BLE_UUID_TYPE_BLE}
};

m_advertising_mode = BLE_NO_ADV;

// Build and set advertising data
memset(&advdata, 0, sizeof(advdata));

advdata.name_type               = BLE_ADVDATA_FULL_NAME;
advdata.include_appearance      = true;
advdata.flags.size              = sizeof(adv_flags);
advdata.flags.p_data            = &adv_flags;
advdata.p_tx_power_level        = &tx_power_level;
advdata.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]);
advdata.uuids_complete.p_uuids  = adv_uuids;

err_code = ble_advdata_set(&advdata, NULL);
APP_ERROR_CHECK(err_code);

} the above code is from ble_app_proximity sample, according to Creating Bluetooth low energy applications using nRF51822 v1.0 Page 26 to 27 ble_advdata_set sets advdata and response data, if so, why ble_app_proximity combine it together? I try ble_app_proximity advertising_init in my own project, I get error NRF_ERROR_DATA_SIZE, any reason ble_app_proximity is ok to call ble_advdata_set without NRF_ERROR_DATA_SIZE? some previous setting?

and in ble_app_proximity code, it adds tx_power_level, does that mean by this way, it announce power_level in the advertising stage, then we don't need battery service?

Parents
  • Hi Julian,

    You are free to choose what you want to include in the advertising packet and the scan response packet. In the proximity example we only use advertising packet and set the scan response packet to null. If you want to add data into the response packet you just have to declare and add it into the ble_advdata_set() call as instructed in nAN36 application note.

  • The scan response packet is the extra data packet that the broadcaster can use to send data. On the observer, there are 2 different scan modes, passive scan and active scan. In passive scan mode, the observer will only capture advertising data packet. In active scan mode, the observer will send a scan request packet back to the broadcaster right after the advertising packet is received to ask for more data. The advertiser when receive scan request will reply with the scan response data packet.

    On android it's always active scanning and you will receive one scanRecord packet that includes both advertising data and scan response data.

Reply
  • The scan response packet is the extra data packet that the broadcaster can use to send data. On the observer, there are 2 different scan modes, passive scan and active scan. In passive scan mode, the observer will only capture advertising data packet. In active scan mode, the observer will send a scan request packet back to the broadcaster right after the advertising packet is received to ask for more data. The advertiser when receive scan request will reply with the scan response data packet.

    On android it's always active scanning and you will receive one scanRecord packet that includes both advertising data and scan response data.

Children
No Data
Related