Toyomasa Watarai / nRF51822

Dependencies:   nrf51-sdk

Fork of nRF51822 by Nordic Semiconductor

Committer:
rgrover1
Date:
Fri Jun 19 15:55:35 2015 +0100
Revision:
346:14b090482fd2
Parent:
345:dfde56236c36
Child:
361:d2405f5a4853
Synchronized with git rev bb88aaad
Author: Rohit Grover
renamed BLEDevice to BLE

Who changed what in which revision?

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