test

Fork of nRF51822 by Nordic Semiconductor

Committer:
GlimwormBeacons
Date:
Sat Oct 10 09:19:50 2015 +0000
Revision:
448:b71e96a821de
Parent:
387:b13ab9a7ddb9
test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rgrover1 371:8f7d2137727a 1 /*
rgrover1 371:8f7d2137727a 2 * Copyright (c) Nordic Semiconductor ASA
rgrover1 371:8f7d2137727a 3 * All rights reserved.
rgrover1 371:8f7d2137727a 4 *
rgrover1 371:8f7d2137727a 5 * Redistribution and use in source and binary forms, with or without modification,
rgrover1 371:8f7d2137727a 6 * are permitted provided that the following conditions are met:
rgrover1 371:8f7d2137727a 7 *
rgrover1 371:8f7d2137727a 8 * 1. Redistributions of source code must retain the above copyright notice, this
rgrover1 371:8f7d2137727a 9 * list of conditions and the following disclaimer.
rgrover1 371:8f7d2137727a 10 *
rgrover1 371:8f7d2137727a 11 * 2. Redistributions in binary form must reproduce the above copyright notice, this
rgrover1 371:8f7d2137727a 12 * list of conditions and the following disclaimer in the documentation and/or
rgrover1 371:8f7d2137727a 13 * other materials provided with the distribution.
rgrover1 371:8f7d2137727a 14 *
rgrover1 371:8f7d2137727a 15 * 3. Neither the name of Nordic Semiconductor ASA nor the names of other
rgrover1 371:8f7d2137727a 16 * contributors to this software may be used to endorse or promote products
rgrover1 371:8f7d2137727a 17 * derived from this software without specific prior written permission.
rgrover1 371:8f7d2137727a 18 *
rgrover1 371:8f7d2137727a 19 *
rgrover1 371:8f7d2137727a 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
rgrover1 371:8f7d2137727a 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
rgrover1 371:8f7d2137727a 22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
rgrover1 371:8f7d2137727a 23 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
rgrover1 371:8f7d2137727a 24 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
rgrover1 371:8f7d2137727a 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
rgrover1 371:8f7d2137727a 26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
rgrover1 371:8f7d2137727a 27 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
rgrover1 371:8f7d2137727a 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
rgrover1 371:8f7d2137727a 29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
rgrover1 371:8f7d2137727a 30 *
rgrover1 371:8f7d2137727a 31 */
rgrover1 371:8f7d2137727a 32
rgrover1 371:8f7d2137727a 33 /** @file
rgrover1 371:8f7d2137727a 34 *
rgrover1 371:8f7d2137727a 35 * @defgroup ble_sdk_lib_advdata Advertising Data Encoder
rgrover1 371:8f7d2137727a 36 * @{
rgrover1 371:8f7d2137727a 37 * @ingroup ble_sdk_lib
rgrover1 371:8f7d2137727a 38 * @brief Function for encoding the advertising data and/or scan response data, and passing them to
rgrover1 371:8f7d2137727a 39 * the stack.
rgrover1 371:8f7d2137727a 40 */
rgrover1 371:8f7d2137727a 41
rgrover1 371:8f7d2137727a 42 #ifndef BLE_ADVDATA_H__
rgrover1 371:8f7d2137727a 43 #define BLE_ADVDATA_H__
rgrover1 371:8f7d2137727a 44
rgrover1 371:8f7d2137727a 45 #include <stdint.h>
rgrover1 371:8f7d2137727a 46 #include <stdbool.h>
rgrover1 371:8f7d2137727a 47 #include <string.h>
rgrover1 371:8f7d2137727a 48 #include "ble.h"
rgrover1 371:8f7d2137727a 49 #include "app_util.h"
rgrover1 371:8f7d2137727a 50
rgrover1 371:8f7d2137727a 51 /**@brief Advertising data name type. This contains the options available for the device name inside
rgrover1 371:8f7d2137727a 52 * the advertising data. */
rgrover1 371:8f7d2137727a 53 typedef enum
rgrover1 371:8f7d2137727a 54 {
rgrover1 371:8f7d2137727a 55 BLE_ADVDATA_NO_NAME, /**< Include no device name in advertising data. */
rgrover1 371:8f7d2137727a 56 BLE_ADVDATA_SHORT_NAME, /**< Include short device name in advertising data. */
rgrover1 371:8f7d2137727a 57 BLE_ADVDATA_FULL_NAME /**< Include full device name in advertising data. */
rgrover1 371:8f7d2137727a 58 } ble_advdata_name_type_t;
rgrover1 371:8f7d2137727a 59
rgrover1 371:8f7d2137727a 60 /**@brief UUID list type. */
rgrover1 371:8f7d2137727a 61 typedef struct
rgrover1 371:8f7d2137727a 62 {
rgrover1 371:8f7d2137727a 63 uint16_t uuid_cnt; /**< Number of UUID entries. */
rgrover1 371:8f7d2137727a 64 ble_uuid_t * p_uuids; /**< Pointer to UUID array entries. */
rgrover1 371:8f7d2137727a 65 } ble_advdata_uuid_list_t;
rgrover1 371:8f7d2137727a 66
rgrover1 371:8f7d2137727a 67 /**@brief Connection interval range structure. */
rgrover1 371:8f7d2137727a 68 typedef struct
rgrover1 371:8f7d2137727a 69 {
rgrover1 371:8f7d2137727a 70 uint16_t min_conn_interval; /**< Minimum Connection Interval, in units of 1.25ms, range 6 to 3200 (i.e. 7.5ms to 4s). */
rgrover1 371:8f7d2137727a 71 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. */
rgrover1 371:8f7d2137727a 72 } ble_advdata_conn_int_t;
rgrover1 371:8f7d2137727a 73
rgrover1 371:8f7d2137727a 74 /**@brief Manufacturer specific data structure. */
rgrover1 371:8f7d2137727a 75 typedef struct
rgrover1 371:8f7d2137727a 76 {
rgrover1 371:8f7d2137727a 77 uint16_t company_identifier; /**< Company Identifier Code. */
rgrover1 371:8f7d2137727a 78 uint8_array_t data; /**< Additional manufacturer specific data. */
rgrover1 371:8f7d2137727a 79 } ble_advdata_manuf_data_t;
rgrover1 371:8f7d2137727a 80
rgrover1 371:8f7d2137727a 81 /**@brief Service data structure. */
rgrover1 371:8f7d2137727a 82 typedef struct
rgrover1 371:8f7d2137727a 83 {
rgrover1 371:8f7d2137727a 84 uint16_t service_uuid; /**< Service UUID. */
rgrover1 371:8f7d2137727a 85 uint8_array_t data; /**< Additional service data. */
rgrover1 371:8f7d2137727a 86 } ble_advdata_service_data_t;
rgrover1 371:8f7d2137727a 87
rgrover1 371:8f7d2137727a 88 /**@brief Advertising data structure. This contains all options and data needed for encoding and
rgrover1 371:8f7d2137727a 89 * setting the advertising data. */
rgrover1 371:8f7d2137727a 90 typedef struct
rgrover1 371:8f7d2137727a 91 {
rgrover1 371:8f7d2137727a 92 ble_advdata_name_type_t name_type; /**< Type of device name. */
rgrover1 371:8f7d2137727a 93 uint8_t short_name_len; /**< Length of short device name (if short type is specified). */
rgrover1 371:8f7d2137727a 94 bool include_appearance; /**< Determines if Appearance shall be included. */
rgrover1 371:8f7d2137727a 95 uint8_t flags; /**< Advertising data Flags field. */
rgrover1 371:8f7d2137727a 96 int8_t * p_tx_power_level; /**< TX Power Level field. */
rgrover1 371:8f7d2137727a 97 ble_advdata_uuid_list_t uuids_more_available; /**< List of UUIDs in the 'More Available' list. */
rgrover1 371:8f7d2137727a 98 ble_advdata_uuid_list_t uuids_complete; /**< List of UUIDs in the 'Complete' list. */
rgrover1 371:8f7d2137727a 99 ble_advdata_uuid_list_t uuids_solicited; /**< List of solcited UUIDs. */
rgrover1 371:8f7d2137727a 100 ble_advdata_conn_int_t * p_slave_conn_int; /**< Slave Connection Interval Range. */
rgrover1 371:8f7d2137727a 101 ble_advdata_manuf_data_t * p_manuf_specific_data; /**< Manufacturer specific data. */
rgrover1 371:8f7d2137727a 102 ble_advdata_service_data_t * p_service_data_array; /**< Array of Service data structures. */
rgrover1 371:8f7d2137727a 103 uint8_t service_data_count; /**< Number of Service data structures. */
rgrover1 371:8f7d2137727a 104 } ble_advdata_t;
rgrover1 371:8f7d2137727a 105
rgrover1 371:8f7d2137727a 106 /**@brief Function for encoding and setting the advertising data and/or scan response data.
rgrover1 371:8f7d2137727a 107 *
rgrover1 371:8f7d2137727a 108 * @details This function encodes advertising data and/or scan response data based on the selections
rgrover1 371:8f7d2137727a 109 * in the supplied structures, and passes the encoded data to the stack.
rgrover1 371:8f7d2137727a 110 *
rgrover1 371:8f7d2137727a 111 * @param[in] p_advdata Structure for specifying the content of the advertising data.
rgrover1 371:8f7d2137727a 112 * Set to NULL if advertising data is not to be set.
rgrover1 371:8f7d2137727a 113 * @param[in] p_srdata Structure for specifying the content of the scan response data.
rgrover1 371:8f7d2137727a 114 * Set to NULL if scan response data is not to be set.
rgrover1 371:8f7d2137727a 115 *
rgrover1 371:8f7d2137727a 116 * @return NRF_SUCCESS on success, NRF_ERROR_DATA_SIZE if not all the requested data could fit
rgrover1 371:8f7d2137727a 117 * into the advertising packet. The maximum size of the advertisement packet is @ref
rgrover1 371:8f7d2137727a 118 * BLE_GAP_ADV_MAX_SIZE.
rgrover1 371:8f7d2137727a 119 *
rgrover1 371:8f7d2137727a 120 * @warning This API may override application's request to use the long name and use a short name
rgrover1 371:8f7d2137727a 121 * instead. This truncation will occur in case the long name does not fit advertisement data size.
rgrover1 371:8f7d2137727a 122 * Application is permitted to specify a preferred short name length in case truncation is required.
rgrover1 371:8f7d2137727a 123 * For example, if the complete device name is ABCD_HRMonitor, application can specify short name
rgrover1 371:8f7d2137727a 124 * length to 8 such that short device name appears as ABCD_HRM instead of ABCD_HRMo or ABCD_HRMoni
rgrover1 371:8f7d2137727a 125 * etc if available size for short name is 9 or 12 respectively to have more apporpriate short name.
rgrover1 371:8f7d2137727a 126 * However, it should be noted that this is just a preference that application can specify and
rgrover1 371:8f7d2137727a 127 * if the preference too large to fit in Advertisement Data, this can be further truncated.
rgrover1 371:8f7d2137727a 128 */
rgrover1 371:8f7d2137727a 129 uint32_t ble_advdata_set(const ble_advdata_t * p_advdata, const ble_advdata_t * p_srdata);
rgrover1 371:8f7d2137727a 130
rgrover1 371:8f7d2137727a 131 #endif // BLE_ADVDATA_H__
rgrover1 371:8f7d2137727a 132
rgrover1 371:8f7d2137727a 133 /** @} */