cvb

Fork of nrf51-sdk by Lancaster University

Committer:
Jonathan Austin
Date:
Wed Apr 06 23:55:04 2016 +0100
Revision:
0:bc2961fa1ef0
Synchronized with git rev 90647e3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jonathan Austin 0:bc2961fa1ef0 1 /*
Jonathan Austin 0:bc2961fa1ef0 2 * Copyright (c) Nordic Semiconductor ASA
Jonathan Austin 0:bc2961fa1ef0 3 * All rights reserved.
Jonathan Austin 0:bc2961fa1ef0 4 *
Jonathan Austin 0:bc2961fa1ef0 5 * Redistribution and use in source and binary forms, with or without modification,
Jonathan Austin 0:bc2961fa1ef0 6 * are permitted provided that the following conditions are met:
Jonathan Austin 0:bc2961fa1ef0 7 *
Jonathan Austin 0:bc2961fa1ef0 8 * 1. Redistributions of source code must retain the above copyright notice, this
Jonathan Austin 0:bc2961fa1ef0 9 * list of conditions and the following disclaimer.
Jonathan Austin 0:bc2961fa1ef0 10 *
Jonathan Austin 0:bc2961fa1ef0 11 * 2. Redistributions in binary form must reproduce the above copyright notice, this
Jonathan Austin 0:bc2961fa1ef0 12 * list of conditions and the following disclaimer in the documentation and/or
Jonathan Austin 0:bc2961fa1ef0 13 * other materials provided with the distribution.
Jonathan Austin 0:bc2961fa1ef0 14 *
Jonathan Austin 0:bc2961fa1ef0 15 * 3. Neither the name of Nordic Semiconductor ASA nor the names of other
Jonathan Austin 0:bc2961fa1ef0 16 * contributors to this software may be used to endorse or promote products
Jonathan Austin 0:bc2961fa1ef0 17 * derived from this software without specific prior written permission.
Jonathan Austin 0:bc2961fa1ef0 18 *
Jonathan Austin 0:bc2961fa1ef0 19 *
Jonathan Austin 0:bc2961fa1ef0 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
Jonathan Austin 0:bc2961fa1ef0 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Jonathan Austin 0:bc2961fa1ef0 22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Jonathan Austin 0:bc2961fa1ef0 23 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
Jonathan Austin 0:bc2961fa1ef0 24 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Jonathan Austin 0:bc2961fa1ef0 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
Jonathan Austin 0:bc2961fa1ef0 26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
Jonathan Austin 0:bc2961fa1ef0 27 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Jonathan Austin 0:bc2961fa1ef0 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Jonathan Austin 0:bc2961fa1ef0 29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Jonathan Austin 0:bc2961fa1ef0 30 *
Jonathan Austin 0:bc2961fa1ef0 31 */
Jonathan Austin 0:bc2961fa1ef0 32
Jonathan Austin 0:bc2961fa1ef0 33 /** @file
Jonathan Austin 0:bc2961fa1ef0 34 *
Jonathan Austin 0:bc2961fa1ef0 35 * @defgroup ble_sdk_lib_advdata Advertising and Scan Response Data Encoder
Jonathan Austin 0:bc2961fa1ef0 36 * @{
Jonathan Austin 0:bc2961fa1ef0 37 * @ingroup ble_sdk_lib
Jonathan Austin 0:bc2961fa1ef0 38 * @brief Functions for encoding data in the Advertising and Scan Response Data format,
Jonathan Austin 0:bc2961fa1ef0 39 * and for passing the data to the stack.
Jonathan Austin 0:bc2961fa1ef0 40 */
Jonathan Austin 0:bc2961fa1ef0 41
Jonathan Austin 0:bc2961fa1ef0 42 #ifndef BLE_ADVDATA_H__
Jonathan Austin 0:bc2961fa1ef0 43 #define BLE_ADVDATA_H__
Jonathan Austin 0:bc2961fa1ef0 44
Jonathan Austin 0:bc2961fa1ef0 45 #include <stdint.h>
Jonathan Austin 0:bc2961fa1ef0 46 #include <stdbool.h>
Jonathan Austin 0:bc2961fa1ef0 47 #include <string.h>
Jonathan Austin 0:bc2961fa1ef0 48 #include "ble.h"
Jonathan Austin 0:bc2961fa1ef0 49 #include "app_util.h"
Jonathan Austin 0:bc2961fa1ef0 50
Jonathan Austin 0:bc2961fa1ef0 51
Jonathan Austin 0:bc2961fa1ef0 52 #define ADV_LENGTH_FIELD_SIZE 1UL /**< Advertising Data and Scan Response format contains 1 octet for the length. */
Jonathan Austin 0:bc2961fa1ef0 53 #define ADV_AD_TYPE_FIELD_SIZE 1UL /**< Advertising Data and Scan Response format contains 1 octet for the AD type. */
Jonathan Austin 0:bc2961fa1ef0 54 #define ADV_AD_DATA_OFFSET (ADV_LENGTH_FIELD_SIZE + \
Jonathan Austin 0:bc2961fa1ef0 55 ADV_AD_TYPE_FIELD_SIZE) /**< Offset for the AD data field of the Advertising Data and Scan Response format. */
Jonathan Austin 0:bc2961fa1ef0 56 #define AD_TYPE_TK_VALUE_DATA_SIZE (sizeof(ble_advdata_tk_value_t)) /**< Data size (in octets) of the Security Manager TK value AD type. */
Jonathan Austin 0:bc2961fa1ef0 57 #define AD_TYPE_TK_VALUE_SIZE (ADV_AD_DATA_OFFSET + \
Jonathan Austin 0:bc2961fa1ef0 58 AD_TYPE_TK_VALUE_DATA_SIZE) /**< Size (in octets) of the Security Manager TK value AD type. */
Jonathan Austin 0:bc2961fa1ef0 59 #define AD_TYPE_LE_ROLE_DATA_SIZE 1UL /**< Data size (in octets) of the LE Bluetooth Device Address AD type. */
Jonathan Austin 0:bc2961fa1ef0 60 #define AD_TYPE_LE_ROLE_SIZE (ADV_AD_DATA_OFFSET + \
Jonathan Austin 0:bc2961fa1ef0 61 AD_TYPE_LE_ROLE_DATA_SIZE) /**< Size (in octets) of the LE Bluetooth Device Address AD type. */
Jonathan Austin 0:bc2961fa1ef0 62 #define AD_TYPE_BLE_DEVICE_ADDR_TYPE_SIZE 1UL /**< Data size (in octets) of the Address type of the LE Bluetooth Device Address AD type. */
Jonathan Austin 0:bc2961fa1ef0 63 #define AD_TYPE_BLE_DEVICE_ADDR_DATA_SIZE (BLE_GAP_ADDR_LEN + \
Jonathan Austin 0:bc2961fa1ef0 64 AD_TYPE_BLE_DEVICE_ADDR_TYPE_SIZE) /**< Data size (in octets) of the LE Bluetooth Device Address AD type. */
Jonathan Austin 0:bc2961fa1ef0 65 #define AD_TYPE_BLE_DEVICE_ADDR_SIZE (ADV_AD_DATA_OFFSET + \
Jonathan Austin 0:bc2961fa1ef0 66 AD_TYPE_BLE_DEVICE_ADDR_DATA_SIZE) /**< Size (in octets) of the LE Bluetooth Device Address AD type. */
Jonathan Austin 0:bc2961fa1ef0 67 #define AD_TYPE_APPEARANCE_DATA_SIZE 2UL /**< Data size (in octets) of the Appearance AD type. */
Jonathan Austin 0:bc2961fa1ef0 68 #define AD_TYPE_APPEARANCE_SIZE (ADV_AD_DATA_OFFSET + \
Jonathan Austin 0:bc2961fa1ef0 69 AD_TYPE_APPEARANCE_DATA_SIZE) /**< Size (in octets) of the Appearance AD type. */
Jonathan Austin 0:bc2961fa1ef0 70 #define AD_TYPE_FLAGS_DATA_SIZE 1UL /**< Data size (in octets) of the Flags AD type. */
Jonathan Austin 0:bc2961fa1ef0 71 #define AD_TYPE_FLAGS_SIZE (ADV_AD_DATA_OFFSET + \
Jonathan Austin 0:bc2961fa1ef0 72 AD_TYPE_FLAGS_DATA_SIZE) /**< Size (in octets) of the Flags AD type. */
Jonathan Austin 0:bc2961fa1ef0 73 #define AD_TYPE_TX_POWER_LEVEL_DATA_SIZE 1UL /**< Data size (in octets) of the TX Power Level AD type. */
Jonathan Austin 0:bc2961fa1ef0 74 #define AD_TYPE_TX_POWER_LEVEL_SIZE (ADV_AD_DATA_OFFSET + \
Jonathan Austin 0:bc2961fa1ef0 75 AD_TYPE_TX_POWER_LEVEL_DATA_SIZE) /**< Size (in octets) of the TX Power Level AD type. */
Jonathan Austin 0:bc2961fa1ef0 76 #define AD_TYPE_CONN_INT_DATA_SIZE 4UL /**< Data size (in octets) of the Slave Connection Interval Range AD type. */
Jonathan Austin 0:bc2961fa1ef0 77 #define AD_TYPE_CONN_INT_SIZE (ADV_AD_DATA_OFFSET + \
Jonathan Austin 0:bc2961fa1ef0 78 AD_TYPE_CONN_INT_DATA_SIZE) /**< Data size (in octets) of the Slave Connection Interval Range AD type. */
Jonathan Austin 0:bc2961fa1ef0 79 #define AD_TYPE_MANUF_SPEC_DATA_ID_SIZE 2UL /**< Size (in octets) of the Company Identifier Code, which is a part of the Manufacturer Specific Data AD type. */
Jonathan Austin 0:bc2961fa1ef0 80 #define AD_TYPE_SERV_DATA_16BIT_UUID_SIZE 2UL /**< Size (in octets) of the 16-bit UUID, which is a part of the Service Data AD type. */
Jonathan Austin 0:bc2961fa1ef0 81 #define AD_TYPE_OOB_FLAGS_DATA_SIZE 1UL /**< Data size (in octets) of the Security Manager OOB Flags AD type. */
Jonathan Austin 0:bc2961fa1ef0 82 #define AD_TYPE_OOB_FLAGS_SIZE (ADV_AD_DATA_OFFSET + \
Jonathan Austin 0:bc2961fa1ef0 83 AD_TYPE_OOB_FLAGS_DATA_SIZE) /**< Size (in octets) of the Security Manager OOB Flags AD type. */
Jonathan Austin 0:bc2961fa1ef0 84
Jonathan Austin 0:bc2961fa1ef0 85 #define AD_TYPE_SEC_MGR_OOB_FLAG_SET 1U /**< Security Manager OOB Flag set. Flag selection is done using _POS defines */
Jonathan Austin 0:bc2961fa1ef0 86 #define AD_TYPE_SEC_MGR_OOB_FLAG_CLEAR 0U /**< Security Manager OOB Flag clear. Flag selection is done using _POS defines */
Jonathan Austin 0:bc2961fa1ef0 87 #define AD_TYPE_SEC_MGR_OOB_FLAG_OOB_DATA_PRESENT_POS 0UL /**< Security Manager OOB Data Present Flag position. */
Jonathan Austin 0:bc2961fa1ef0 88 #define AD_TYPE_SEC_MGR_OOB_FLAG_OOB_LE_SUPPORTED_POS 1UL /**< Security Manager OOB Low Energy Supported Flag position. */
Jonathan Austin 0:bc2961fa1ef0 89 #define AD_TYPE_SEC_MGR_OOB_FLAG_SIM_LE_AND_EP_POS 2UL /**< Security Manager OOB Simultaneous LE and BR/EDR to Same Device Capable Flag position. */
Jonathan Austin 0:bc2961fa1ef0 90 #define AD_TYPE_SEC_MGR_OOB_ADDRESS_TYPE_PUBLIC 0UL /**< Security Manager OOB Public Address type. */
Jonathan Austin 0:bc2961fa1ef0 91 #define AD_TYPE_SEC_MGR_OOB_ADDRESS_TYPE_RANDOM 1UL /**< Security Manager OOB Random Address type. */
Jonathan Austin 0:bc2961fa1ef0 92 #define AD_TYPE_SEC_MGR_OOB_FLAG_ADDRESS_TYPE_POS 3UL /**< Security Manager OOB Address type Flag (0 = Public Address, 1 = Random Address) position. */
Jonathan Austin 0:bc2961fa1ef0 93
Jonathan Austin 0:bc2961fa1ef0 94
Jonathan Austin 0:bc2961fa1ef0 95 /**@brief Security Manager TK value. */
Jonathan Austin 0:bc2961fa1ef0 96 typedef struct
Jonathan Austin 0:bc2961fa1ef0 97 {
Jonathan Austin 0:bc2961fa1ef0 98 uint8_t tk[BLE_GAP_SEC_KEY_LEN]; /**< Array containing TK value. */
Jonathan Austin 0:bc2961fa1ef0 99 } ble_advdata_tk_value_t;
Jonathan Austin 0:bc2961fa1ef0 100
Jonathan Austin 0:bc2961fa1ef0 101 /**@brief Advertising data LE Role types. This enumeration contains the options available for the LE role inside
Jonathan Austin 0:bc2961fa1ef0 102 * the advertising data. */
Jonathan Austin 0:bc2961fa1ef0 103 typedef enum
Jonathan Austin 0:bc2961fa1ef0 104 {
Jonathan Austin 0:bc2961fa1ef0 105 BLE_ADVDATA_ROLE_NOT_PRESENT = 0, /**< LE Role AD structure not present. */
Jonathan Austin 0:bc2961fa1ef0 106 BLE_ADVDATA_ROLE_ONLY_PERIPH, /**< Only Peripheral Role supported. */
Jonathan Austin 0:bc2961fa1ef0 107 BLE_ADVDATA_ROLE_ONLY_CENTRAL, /**< Only Central Role supported. */
Jonathan Austin 0:bc2961fa1ef0 108 BLE_ADVDATA_ROLE_BOTH_PERIPH_PREFERRED, /**< Peripheral and Central Role supported. Peripheral Role preferred for connection establishment. */
Jonathan Austin 0:bc2961fa1ef0 109 BLE_ADVDATA_ROLE_BOTH_CENTRAL_PREFERRED /**< Peripheral and Central Role supported. Central Role preferred for connection establishment */
Jonathan Austin 0:bc2961fa1ef0 110 } ble_advdata_le_role_t;
Jonathan Austin 0:bc2961fa1ef0 111
Jonathan Austin 0:bc2961fa1ef0 112 /**@brief Advertising data name type. This enumeration contains the options available for the device name inside
Jonathan Austin 0:bc2961fa1ef0 113 * the advertising data. */
Jonathan Austin 0:bc2961fa1ef0 114 typedef enum
Jonathan Austin 0:bc2961fa1ef0 115 {
Jonathan Austin 0:bc2961fa1ef0 116 BLE_ADVDATA_NO_NAME, /**< Include no device name in advertising data. */
Jonathan Austin 0:bc2961fa1ef0 117 BLE_ADVDATA_SHORT_NAME, /**< Include short device name in advertising data. */
Jonathan Austin 0:bc2961fa1ef0 118 BLE_ADVDATA_FULL_NAME /**< Include full device name in advertising data. */
Jonathan Austin 0:bc2961fa1ef0 119 } ble_advdata_name_type_t;
Jonathan Austin 0:bc2961fa1ef0 120
Jonathan Austin 0:bc2961fa1ef0 121 /**@brief UUID list type. */
Jonathan Austin 0:bc2961fa1ef0 122 typedef struct
Jonathan Austin 0:bc2961fa1ef0 123 {
Jonathan Austin 0:bc2961fa1ef0 124 uint16_t uuid_cnt; /**< Number of UUID entries. */
Jonathan Austin 0:bc2961fa1ef0 125 ble_uuid_t * p_uuids; /**< Pointer to UUID array entries. */
Jonathan Austin 0:bc2961fa1ef0 126 } ble_advdata_uuid_list_t;
Jonathan Austin 0:bc2961fa1ef0 127
Jonathan Austin 0:bc2961fa1ef0 128 /**@brief Connection interval range structure. */
Jonathan Austin 0:bc2961fa1ef0 129 typedef struct
Jonathan Austin 0:bc2961fa1ef0 130 {
Jonathan Austin 0:bc2961fa1ef0 131 uint16_t min_conn_interval; /**< Minimum connection interval, in units of 1.25 ms, range 6 to 3200 (7.5 ms to 4 s). */
Jonathan Austin 0:bc2961fa1ef0 132 uint16_t max_conn_interval; /**< Maximum connection interval, in units of 1.25 ms, range 6 to 3200 (7.5 ms to 4 s). The value 0xFFFF indicates no specific maximum. */
Jonathan Austin 0:bc2961fa1ef0 133 } ble_advdata_conn_int_t;
Jonathan Austin 0:bc2961fa1ef0 134
Jonathan Austin 0:bc2961fa1ef0 135 /**@brief Manufacturer specific data structure. */
Jonathan Austin 0:bc2961fa1ef0 136 typedef struct
Jonathan Austin 0:bc2961fa1ef0 137 {
Jonathan Austin 0:bc2961fa1ef0 138 uint16_t company_identifier; /**< Company identifier code. */
Jonathan Austin 0:bc2961fa1ef0 139 uint8_array_t data; /**< Additional manufacturer specific data. */
Jonathan Austin 0:bc2961fa1ef0 140 } ble_advdata_manuf_data_t;
Jonathan Austin 0:bc2961fa1ef0 141
Jonathan Austin 0:bc2961fa1ef0 142 /**@brief Service data structure. */
Jonathan Austin 0:bc2961fa1ef0 143 typedef struct
Jonathan Austin 0:bc2961fa1ef0 144 {
Jonathan Austin 0:bc2961fa1ef0 145 uint16_t service_uuid; /**< Service UUID. */
Jonathan Austin 0:bc2961fa1ef0 146 uint8_array_t data; /**< Additional service data. */
Jonathan Austin 0:bc2961fa1ef0 147 } ble_advdata_service_data_t;
Jonathan Austin 0:bc2961fa1ef0 148
Jonathan Austin 0:bc2961fa1ef0 149 /**@brief Advertising data structure. This structure contains all options and data needed for encoding and
Jonathan Austin 0:bc2961fa1ef0 150 * setting the advertising data. */
Jonathan Austin 0:bc2961fa1ef0 151 typedef struct
Jonathan Austin 0:bc2961fa1ef0 152 {
Jonathan Austin 0:bc2961fa1ef0 153 ble_advdata_name_type_t name_type; /**< Type of device name. */
Jonathan Austin 0:bc2961fa1ef0 154 uint8_t short_name_len; /**< Length of short device name (if short type is specified). */
Jonathan Austin 0:bc2961fa1ef0 155 bool include_appearance; /**< Determines if Appearance shall be included. */
Jonathan Austin 0:bc2961fa1ef0 156 uint8_t flags; /**< Advertising data Flags field. */
Jonathan Austin 0:bc2961fa1ef0 157 int8_t * p_tx_power_level; /**< TX Power Level field. */
Jonathan Austin 0:bc2961fa1ef0 158 ble_advdata_uuid_list_t uuids_more_available; /**< List of UUIDs in the 'More Available' list. */
Jonathan Austin 0:bc2961fa1ef0 159 ble_advdata_uuid_list_t uuids_complete; /**< List of UUIDs in the 'Complete' list. */
Jonathan Austin 0:bc2961fa1ef0 160 ble_advdata_uuid_list_t uuids_solicited; /**< List of solicited UUIDs. */
Jonathan Austin 0:bc2961fa1ef0 161 ble_advdata_conn_int_t * p_slave_conn_int; /**< Slave Connection Interval Range. */
Jonathan Austin 0:bc2961fa1ef0 162 ble_advdata_manuf_data_t * p_manuf_specific_data; /**< Manufacturer specific data. */
Jonathan Austin 0:bc2961fa1ef0 163 ble_advdata_service_data_t * p_service_data_array; /**< Array of Service data structures. */
Jonathan Austin 0:bc2961fa1ef0 164 uint8_t service_data_count; /**< Number of Service data structures. */
Jonathan Austin 0:bc2961fa1ef0 165 bool include_ble_device_addr; /**< Determines if LE Bluetooth Device Address shall be included. */
Jonathan Austin 0:bc2961fa1ef0 166 ble_advdata_le_role_t le_role; /**< LE Role field. Included when different from @ref BLE_ADVDATA_ROLE_NOT_PRESENT.*/
Jonathan Austin 0:bc2961fa1ef0 167 ble_advdata_tk_value_t * p_tk_value; /**< Security Manager TK value field. Included when different from NULL.*/
Jonathan Austin 0:bc2961fa1ef0 168 uint8_t * p_sec_mgr_oob_flags; /**< Security Manager Out Of Band Flags field. Included when different from NULL.*/
Jonathan Austin 0:bc2961fa1ef0 169 } ble_advdata_t;
Jonathan Austin 0:bc2961fa1ef0 170
Jonathan Austin 0:bc2961fa1ef0 171 /**@brief Function for encoding data in the Advertising and Scan Response data format
Jonathan Austin 0:bc2961fa1ef0 172 * (AD structures).
Jonathan Austin 0:bc2961fa1ef0 173 *
Jonathan Austin 0:bc2961fa1ef0 174 * @details This function encodes data into the Advertising and Scan Response data format
Jonathan Austin 0:bc2961fa1ef0 175 * (AD structures) based on the selections in the supplied structures. This function can be used to
Jonathan Austin 0:bc2961fa1ef0 176 * create a payload of Advertising packet or Scan Response packet, or a payload of NFC
Jonathan Austin 0:bc2961fa1ef0 177 * message intended for initiating the Out-of-Band pairing.
Jonathan Austin 0:bc2961fa1ef0 178 *
Jonathan Austin 0:bc2961fa1ef0 179 * @param[in] p_advdata Pointer to the structure for specifying the content of encoded data.
Jonathan Austin 0:bc2961fa1ef0 180 * @param[out] p_encoded_data Pointer to the buffer where encoded data will be returned.
Jonathan Austin 0:bc2961fa1ef0 181 * @param[in,out] p_len \c in: Size of \p p_encoded_data buffer.
Jonathan Austin 0:bc2961fa1ef0 182 * \c out: Length of encoded data.
Jonathan Austin 0:bc2961fa1ef0 183 *
Jonathan Austin 0:bc2961fa1ef0 184 * @retval NRF_SUCCESS If the operation was successful.
Jonathan Austin 0:bc2961fa1ef0 185 * @retval NRF_ERROR_INVALID_PARAM If the operation failed because a wrong parameter was provided in \p p_advdata.
Jonathan Austin 0:bc2961fa1ef0 186 * @retval NRF_ERROR_DATA_SIZE If the operation failed because not all the requested data could fit into the
Jonathan Austin 0:bc2961fa1ef0 187 * provided buffer or some encoded AD structure is too long and its
Jonathan Austin 0:bc2961fa1ef0 188 * length cannot be encoded with one octet.
Jonathan Austin 0:bc2961fa1ef0 189 *
Jonathan Austin 0:bc2961fa1ef0 190 * @warning This API may override the application's request to use the long name and use a short name
Jonathan Austin 0:bc2961fa1ef0 191 * instead. This truncation will occur in case the long name does not fit the provided buffer size.
Jonathan Austin 0:bc2961fa1ef0 192 * The application can specify a preferred short name length if truncation is required.
Jonathan Austin 0:bc2961fa1ef0 193 * For example, if the complete device name is ABCD_HRMonitor, the application can specify the short name
Jonathan Austin 0:bc2961fa1ef0 194 * length to be 8, so that the short device name appears as ABCD_HRM instead of ABCD_HRMo or ABCD_HRMoni
Jonathan Austin 0:bc2961fa1ef0 195 * if the available size for the short name is 9 or 12 respectively, to have a more appropriate short name.
Jonathan Austin 0:bc2961fa1ef0 196 * However, it should be noted that this is just a preference that the application can specify, and
Jonathan Austin 0:bc2961fa1ef0 197 * if the preference is too large to fit in the provided buffer, the name can be truncated further.
Jonathan Austin 0:bc2961fa1ef0 198 */
Jonathan Austin 0:bc2961fa1ef0 199 uint32_t adv_data_encode(ble_advdata_t const * const p_advdata,
Jonathan Austin 0:bc2961fa1ef0 200 uint8_t * const p_encoded_data,
Jonathan Austin 0:bc2961fa1ef0 201 uint16_t * const p_len);
Jonathan Austin 0:bc2961fa1ef0 202
Jonathan Austin 0:bc2961fa1ef0 203 /**@brief Function for encoding and setting the advertising data and/or scan response data.
Jonathan Austin 0:bc2961fa1ef0 204 *
Jonathan Austin 0:bc2961fa1ef0 205 * @details This function encodes advertising data and/or scan response data based on the selections
Jonathan Austin 0:bc2961fa1ef0 206 * in the supplied structures, and passes the encoded data to the stack.
Jonathan Austin 0:bc2961fa1ef0 207 *
Jonathan Austin 0:bc2961fa1ef0 208 * @param[in] p_advdata Structure for specifying the content of the advertising data.
Jonathan Austin 0:bc2961fa1ef0 209 * Set to NULL if advertising data is not to be set.
Jonathan Austin 0:bc2961fa1ef0 210 * @param[in] p_srdata Structure for specifying the content of the scan response data.
Jonathan Austin 0:bc2961fa1ef0 211 * Set to NULL if scan response data is not to be set.
Jonathan Austin 0:bc2961fa1ef0 212 *
Jonathan Austin 0:bc2961fa1ef0 213 * @retval NRF_SUCCESS If the operation was successful.
Jonathan Austin 0:bc2961fa1ef0 214 * @retval NRF_ERROR_INVALID_PARAM If the operation failed because a wrong parameter was provided in \p p_advdata.
Jonathan Austin 0:bc2961fa1ef0 215 * @retval NRF_ERROR_DATA_SIZE If the operation failed because not all the requested data could fit into the
Jonathan Austin 0:bc2961fa1ef0 216 * advertising packet. The maximum size of the advertisement packet
Jonathan Austin 0:bc2961fa1ef0 217 * is @ref BLE_GAP_ADV_MAX_SIZE.
Jonathan Austin 0:bc2961fa1ef0 218 *
Jonathan Austin 0:bc2961fa1ef0 219 * @warning This API may override the application's request to use the long name and use a short name
Jonathan Austin 0:bc2961fa1ef0 220 * instead. This truncation will occur in case the long name does not fit the provided buffer size.
Jonathan Austin 0:bc2961fa1ef0 221 * The application can specify a preferred short name length if truncation is required.
Jonathan Austin 0:bc2961fa1ef0 222 * For example, if the complete device name is ABCD_HRMonitor, the application can specify the short name
Jonathan Austin 0:bc2961fa1ef0 223 * length to be 8, so that the short device name appears as ABCD_HRM instead of ABCD_HRMo or ABCD_HRMoni
Jonathan Austin 0:bc2961fa1ef0 224 * if the available size for the short name is 9 or 12 respectively, to have a more appropriate short name.
Jonathan Austin 0:bc2961fa1ef0 225 * However, it should be noted that this is just a preference that the application can specify, and
Jonathan Austin 0:bc2961fa1ef0 226 * if the preference is too large to fit in the provided buffer, the name can be truncated further.
Jonathan Austin 0:bc2961fa1ef0 227 */
Jonathan Austin 0:bc2961fa1ef0 228 uint32_t ble_advdata_set(const ble_advdata_t * p_advdata, const ble_advdata_t * p_srdata);
Jonathan Austin 0:bc2961fa1ef0 229
Jonathan Austin 0:bc2961fa1ef0 230 #endif // BLE_ADVDATA_H__
Jonathan Austin 0:bc2961fa1ef0 231
Jonathan Austin 0:bc2961fa1ef0 232 /** @} */