Nordic nrf51 sdk sources. Mirrored from https://github.com/ARMmbed/nrf51-sdk.

Dependents:   nRF51822 nRF51822

Committer:
vcoubard
Date:
Thu Apr 07 17:37:40 2016 +0100
Revision:
19:47192cb9def7
Parent:
10:233fefd8162b
Child:
20:a90c48eb1d30
Synchronized with git rev 9251259f
Author: Liyou Zhou
Copy over coresponding files from nordic-sdk 9.0.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vcoubard 19:47192cb9def7 1 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
vcoubard 19:47192cb9def7 2 *
vcoubard 19:47192cb9def7 3 * The information contained herein is property of Nordic Semiconductor ASA.
vcoubard 19:47192cb9def7 4 * Terms and conditions of usage are described in detail in NORDIC
vcoubard 19:47192cb9def7 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
vcoubard 19:47192cb9def7 6 *
vcoubard 19:47192cb9def7 7 * Licensees are granted free, non-transferable use of the information. NO
vcoubard 19:47192cb9def7 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
vcoubard 19:47192cb9def7 9 * the file.
vcoubard 19:47192cb9def7 10 *
Vincent Coubard 0:f2542974c862 11 */
Vincent Coubard 0:f2542974c862 12
Vincent Coubard 0:f2542974c862 13 /** @file
Vincent Coubard 0:f2542974c862 14 *
Vincent Coubard 0:f2542974c862 15 * @defgroup ble_sdk_lib_advdata Advertising Data Encoder
Vincent Coubard 0:f2542974c862 16 * @{
Vincent Coubard 0:f2542974c862 17 * @ingroup ble_sdk_lib
Vincent Coubard 0:f2542974c862 18 * @brief Function for encoding the advertising data and/or scan response data, and passing them to
Vincent Coubard 0:f2542974c862 19 * the stack.
Vincent Coubard 0:f2542974c862 20 */
Vincent Coubard 0:f2542974c862 21
Vincent Coubard 0:f2542974c862 22 #ifndef BLE_ADVDATA_H__
Vincent Coubard 0:f2542974c862 23 #define BLE_ADVDATA_H__
Vincent Coubard 0:f2542974c862 24
Vincent Coubard 0:f2542974c862 25 #include <stdint.h>
Vincent Coubard 0:f2542974c862 26 #include <stdbool.h>
Vincent Coubard 0:f2542974c862 27 #include <string.h>
Vincent Coubard 0:f2542974c862 28 #include "ble.h"
Vincent Coubard 0:f2542974c862 29 #include "app_util.h"
Vincent Coubard 0:f2542974c862 30
Vincent Coubard 0:f2542974c862 31 /**@brief Advertising data name type. This contains the options available for the device name inside
Vincent Coubard 0:f2542974c862 32 * the advertising data. */
Vincent Coubard 0:f2542974c862 33 typedef enum
Vincent Coubard 0:f2542974c862 34 {
Vincent Coubard 0:f2542974c862 35 BLE_ADVDATA_NO_NAME, /**< Include no device name in advertising data. */
Vincent Coubard 0:f2542974c862 36 BLE_ADVDATA_SHORT_NAME, /**< Include short device name in advertising data. */
Vincent Coubard 0:f2542974c862 37 BLE_ADVDATA_FULL_NAME /**< Include full device name in advertising data. */
Vincent Coubard 0:f2542974c862 38 } ble_advdata_name_type_t;
Vincent Coubard 0:f2542974c862 39
Vincent Coubard 0:f2542974c862 40 /**@brief UUID list type. */
Vincent Coubard 0:f2542974c862 41 typedef struct
Vincent Coubard 0:f2542974c862 42 {
Vincent Coubard 0:f2542974c862 43 uint16_t uuid_cnt; /**< Number of UUID entries. */
Vincent Coubard 0:f2542974c862 44 ble_uuid_t * p_uuids; /**< Pointer to UUID array entries. */
Vincent Coubard 0:f2542974c862 45 } ble_advdata_uuid_list_t;
Vincent Coubard 0:f2542974c862 46
Vincent Coubard 0:f2542974c862 47 /**@brief Connection interval range structure. */
Vincent Coubard 0:f2542974c862 48 typedef struct
Vincent Coubard 0:f2542974c862 49 {
Vincent Coubard 0:f2542974c862 50 uint16_t min_conn_interval; /**< Minimum Connection Interval, in units of 1.25ms, range 6 to 3200 (i.e. 7.5ms to 4s). */
Vincent Coubard 0:f2542974c862 51 uint16_t max_conn_interval; /**< Maximum Connection Interval, in units of 1.25ms, range 6 to 3200 (i.e. 7.5ms to 4s). Value of 0xFFFF indicates no specific maximum. */
Vincent Coubard 0:f2542974c862 52 } ble_advdata_conn_int_t;
Vincent Coubard 0:f2542974c862 53
Vincent Coubard 0:f2542974c862 54 /**@brief Manufacturer specific data structure. */
Vincent Coubard 0:f2542974c862 55 typedef struct
Vincent Coubard 0:f2542974c862 56 {
Vincent Coubard 0:f2542974c862 57 uint16_t company_identifier; /**< Company Identifier Code. */
Vincent Coubard 0:f2542974c862 58 uint8_array_t data; /**< Additional manufacturer specific data. */
Vincent Coubard 0:f2542974c862 59 } ble_advdata_manuf_data_t;
Vincent Coubard 0:f2542974c862 60
Vincent Coubard 0:f2542974c862 61 /**@brief Service data structure. */
Vincent Coubard 0:f2542974c862 62 typedef struct
Vincent Coubard 0:f2542974c862 63 {
Vincent Coubard 0:f2542974c862 64 uint16_t service_uuid; /**< Service UUID. */
Vincent Coubard 0:f2542974c862 65 uint8_array_t data; /**< Additional service data. */
Vincent Coubard 0:f2542974c862 66 } ble_advdata_service_data_t;
Vincent Coubard 0:f2542974c862 67
Vincent Coubard 0:f2542974c862 68 /**@brief Advertising data structure. This contains all options and data needed for encoding and
Vincent Coubard 0:f2542974c862 69 * setting the advertising data. */
Vincent Coubard 0:f2542974c862 70 typedef struct
Vincent Coubard 0:f2542974c862 71 {
Vincent Coubard 0:f2542974c862 72 ble_advdata_name_type_t name_type; /**< Type of device name. */
Vincent Coubard 0:f2542974c862 73 uint8_t short_name_len; /**< Length of short device name (if short type is specified). */
Vincent Coubard 0:f2542974c862 74 bool include_appearance; /**< Determines if Appearance shall be included. */
Vincent Coubard 0:f2542974c862 75 uint8_t flags; /**< Advertising data Flags field. */
Vincent Coubard 0:f2542974c862 76 int8_t * p_tx_power_level; /**< TX Power Level field. */
Vincent Coubard 0:f2542974c862 77 ble_advdata_uuid_list_t uuids_more_available; /**< List of UUIDs in the 'More Available' list. */
Vincent Coubard 0:f2542974c862 78 ble_advdata_uuid_list_t uuids_complete; /**< List of UUIDs in the 'Complete' list. */
Vincent Coubard 0:f2542974c862 79 ble_advdata_uuid_list_t uuids_solicited; /**< List of solcited UUIDs. */
Vincent Coubard 0:f2542974c862 80 ble_advdata_conn_int_t * p_slave_conn_int; /**< Slave Connection Interval Range. */
Vincent Coubard 0:f2542974c862 81 ble_advdata_manuf_data_t * p_manuf_specific_data; /**< Manufacturer specific data. */
Vincent Coubard 0:f2542974c862 82 ble_advdata_service_data_t * p_service_data_array; /**< Array of Service data structures. */
Vincent Coubard 0:f2542974c862 83 uint8_t service_data_count; /**< Number of Service data structures. */
Vincent Coubard 0:f2542974c862 84 } ble_advdata_t;
Vincent Coubard 0:f2542974c862 85
Vincent Coubard 0:f2542974c862 86 /**@brief Function for encoding and setting the advertising data and/or scan response data.
Vincent Coubard 0:f2542974c862 87 *
Vincent Coubard 0:f2542974c862 88 * @details This function encodes advertising data and/or scan response data based on the selections
Vincent Coubard 0:f2542974c862 89 * in the supplied structures, and passes the encoded data to the stack.
Vincent Coubard 0:f2542974c862 90 *
Vincent Coubard 0:f2542974c862 91 * @param[in] p_advdata Structure for specifying the content of the advertising data.
Vincent Coubard 0:f2542974c862 92 * Set to NULL if advertising data is not to be set.
Vincent Coubard 0:f2542974c862 93 * @param[in] p_srdata Structure for specifying the content of the scan response data.
Vincent Coubard 0:f2542974c862 94 * Set to NULL if scan response data is not to be set.
Vincent Coubard 0:f2542974c862 95 *
Vincent Coubard 0:f2542974c862 96 * @return NRF_SUCCESS on success, NRF_ERROR_DATA_SIZE if not all the requested data could fit
Vincent Coubard 0:f2542974c862 97 * into the advertising packet. The maximum size of the advertisement packet is @ref
Vincent Coubard 0:f2542974c862 98 * BLE_GAP_ADV_MAX_SIZE.
Vincent Coubard 0:f2542974c862 99 *
Vincent Coubard 0:f2542974c862 100 * @warning This API may override application's request to use the long name and use a short name
Vincent Coubard 0:f2542974c862 101 * instead. This truncation will occur in case the long name does not fit advertisement data size.
Vincent Coubard 0:f2542974c862 102 * Application is permitted to specify a preferred short name length in case truncation is required.
Vincent Coubard 0:f2542974c862 103 * For example, if the complete device name is ABCD_HRMonitor, application can specify short name
Vincent Coubard 0:f2542974c862 104 * length to 8 such that short device name appears as ABCD_HRM instead of ABCD_HRMo or ABCD_HRMoni
Vincent Coubard 0:f2542974c862 105 * etc if available size for short name is 9 or 12 respectively to have more apporpriate short name.
Vincent Coubard 0:f2542974c862 106 * However, it should be noted that this is just a preference that application can specify and
Vincent Coubard 0:f2542974c862 107 * if the preference too large to fit in Advertisement Data, this can be further truncated.
Vincent Coubard 0:f2542974c862 108 */
Vincent Coubard 0:f2542974c862 109 uint32_t ble_advdata_set(const ble_advdata_t * p_advdata, const ble_advdata_t * p_srdata);
Vincent Coubard 0:f2542974c862 110
Vincent Coubard 0:f2542974c862 111 #endif // BLE_ADVDATA_H__
Vincent Coubard 0:f2542974c862 112
vcoubard 1:ebc0e0ef0a11 113 /** @} */