Toyomasa Watarai / nRF51822

Dependencies:   nrf51-sdk

Fork of nRF51822 by Nordic Semiconductor

Committer:
rgrover1
Date:
Fri Jun 19 15:55:34 2015 +0100
Revision:
343:6675661fa600
Parent:
112:737b08b3b995
Child:
345:dfde56236c36
Synchronized with git rev 6d1bf116
Author: Rohit Grover
fix #1: update license headers for all sources obtained from nordic-SDK using a new template obtained from Nordic.

Who changed what in which revision?

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