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

◆ ble_adv_data_encode()

uint32_t ble_adv_data_encode ( const struct ble_adv_data * ble_adv_data,
uint8_t * buf,
uint16_t * len )

#include <ble_adv_data.h>

Encode data in the Advertising and Scan Response data format.

This function encodes data into the Advertising and Scan Response data format based on the fields in the supplied structures. This function can be used to create a payload of Advertising packet or Scan Response packet, or a payload of NFC message intended for initiating the Out-of-Band pairing.

Parameters
[in]ble_adv_dataBluetooth LE advertising data context.
[out]bufOutput buffer.
[in,out]lenSize of buf on input, length of encoded data on output.
Return values
NRF_SUCCESSIf the operation was successful.
NRF_ERROR_INVALID_ADDRInvalid address.
NRF_ERROR_INVALID_PARAMInvalid parameter provided in the advertising data context.
NRF_ERROR_NULLble_adv_data, buf or len is NULL.
NRF_ERROR_DATA_SIZEBuffer is too small to encode all data.
Warning
This API may override the application's request to use the long name and use a short name instead. This truncation will occur in case the long name does not fit the provided buffer size. The application can specify a preferred short name length if truncation is required. For example, if the complete device name is ABCD_HRMonitor, the application can specify the short name length to be 8, so that the short device name appears as ABCD_HRM instead of ABCD_HRMo or ABCD_HRMoni if the available size for the short name is 9 or 12 respectively, to have a more appropriate short name. However, it should be noted that this is just a preference that the application can specify, and if the preference is too large to fit in the provided buffer, the name can be truncated further.