Michael Galis / nRF51822

Fork of nRF51822 by Nordic Semiconductor

Committer:
rgrover1
Date:
Thu Jul 02 09:08:44 2015 +0100
Revision:
362:6fa0d4d555f6
Parent:
361:d2405f5a4853
Child:
370:295f76db798e
Synchronized with git rev 2716309c
Author: Rohit Grover
Release 0.4.0
=============

This is a major release which introduces the GATT Client functionality. It
aligns with release 0.4.0 of BLE_API.

Enhancements
~~~~~~~~~~~~

* Introduce GattClient. This includes functionality for service-discovery,
connections, and attribute-reads and writes. You'll find a demo program for
LEDBlinker on the mbed.org Bluetooth team page to use the new APIs. Some of
the GATT client functionality hasn't been implemented yet, but the APIs have
been added.

* We've added an implementation for the abstract base class for
SecurityManager. All security related APIs have been moved into that.

* There has been a major cleanup of APIs under BLE. APIs have now been
categorized as belonging to Gap, GattServer, GattClient, or SecurityManager.
There are accessors to get references for Gap, GattServer, GattClient, and
SecurityManager. A former call to ble.setAddress(...) is now expected to be
achieved with ble.gap().setAddress(...).

* We've cleaned up our APIs, and this has resulted in dropping some APIs like
BLE::reset().

* We've also dropped GattServer::initializeGattDatabase(). THis was added at
some point to support controllers where a commit point was needed to
indicate when the application had finished constructing the GATT database.
This API would get called internally before Gap::startAdvertising(). We now
expect the underlying port to do the equivalent of initializeGattDatabase()
implicitly upon Gap::startAdvertising().

* We've added a version of Gap::disconnect() which takes a connection handle.
The previous API (which did not take a connection handle) has been
deprecated; it will still work for situations where there's only a single
active connection. We hold on to that API to allow existing code to migrate
to the new API.

Bugfixes
~~~~~~~~

* None.

Who changed what in which revision?

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