nRF Connect SDK Bare Metal API 2.0.99
Loading...
Searching...
No Matches

◆ ble_adv_data_search()

uint16_t ble_adv_data_search ( const uint8_t * buf,
uint16_t len,
uint16_t * offset,
uint8_t ad_type )

#include <ble_adv_data.h>

Search Advertising or Scan Response data for specific data types.

This function searches through encoded data e.g. the data produced by ble_adv_data_encode, or the data found in Advertising reports (BLE_GAP_EVT_ADV_REPORT), and returns the offset of the data within the data buffer.

The data with type ad_type can be found at buf[*offset] after calling the function. This function can iterate through multiple instances of data of one type by calling it again with the offset provided by the previous call.

Example code for finding multiple instances of one type of data: offset = 0; ble_advdata_search(&data, len, &offset, AD_TYPE); first_instance_of_data = data[offset]; ble_advdata_search(&data, len, &offset, AD_TYPE); second_instance_of_data = data[offset];

Parameters
[in]bufEncoded advertising data.
[in]lenBuffer length.
[in,out]offsetThe offset to start searching from, on input. The offset the data type can be found at, on output.
[in]ad_typeThe type of data to search for.
Returns
The length of the data if found, or 0 if no data was found with the type ad_type, or if buf or offset were NULL.