Glimworm Beacons / nRF51822

Fork of nRF51822 by Nordic Semiconductor

Committer:
rgrover1
Date:
Mon Jul 06 10:13:26 2015 +0100
Revision:
370:295f76db798e
Parent:
363:e24cce47e2cd
Child:
371:8f7d2137727a
Synchronized with git rev 9f72c4ba
Author: Rohit Grover
Release 0.3.7
=============

This is a minor set of enhancements mostly around reduce our global static
memory footprint.

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

* Reduce the maximum number of CHARACTERISTICS and DESCRIPTORS that can be
handled. This has memory implications for static global memory. It should
be possible to re-architect our solution for add_characteristic() to not
require these limits; hopefully we'll get there soon.

* Move nRF51GattServer::getInstance() into a .cpp file; same for nRF51Gap::getInstance().

* Reduce max bonds to managed by device-manager to 4; this has memory implications for static global memory.

* Reduce pStorage command queue size to 2; this has memory implications for static global memory.

* Replace uses of deprecated Gap::addr_type_t with Gap::AddressType_t.

* Some UUID-related types have moved into UUID class. Minor changes were needed to work around build errors.

Bugfixes
~~~~~~~~

* None.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rgrover1 370:295f76db798e 1 /*
rgrover1 370:295f76db798e 2 * Copyright (c) Nordic Semiconductor ASA
rgrover1 370:295f76db798e 3 * All rights reserved.
rgrover1 370:295f76db798e 4 *
rgrover1 370:295f76db798e 5 * Redistribution and use in source and binary forms, with or without modification,
rgrover1 370:295f76db798e 6 * are permitted provided that the following conditions are met:
rgrover1 370:295f76db798e 7 *
rgrover1 370:295f76db798e 8 * 1. Redistributions of source code must retain the above copyright notice, this
rgrover1 370:295f76db798e 9 * list of conditions and the following disclaimer.
rgrover1 370:295f76db798e 10 *
rgrover1 370:295f76db798e 11 * 2. Redistributions in binary form must reproduce the above copyright notice, this
rgrover1 370:295f76db798e 12 * list of conditions and the following disclaimer in the documentation and/or
rgrover1 370:295f76db798e 13 * other materials provided with the distribution.
rgrover1 370:295f76db798e 14 *
rgrover1 370:295f76db798e 15 * 3. Neither the name of Nordic Semiconductor ASA nor the names of other
rgrover1 370:295f76db798e 16 * contributors to this software may be used to endorse or promote products
rgrover1 370:295f76db798e 17 * derived from this software without specific prior written permission.
rgrover1 370:295f76db798e 18 *
rgrover1 370:295f76db798e 19 * 4. This software must only be used in a processor manufactured by Nordic
rgrover1 370:295f76db798e 20 * Semiconductor ASA, or in a processor manufactured by a third party that
rgrover1 370:295f76db798e 21 * is used in combination with a processor manufactured by Nordic Semiconductor.
rgrover1 370:295f76db798e 22 *
rgrover1 370:295f76db798e 23 *
rgrover1 370:295f76db798e 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
rgrover1 370:295f76db798e 25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
rgrover1 370:295f76db798e 26 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
rgrover1 370:295f76db798e 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
rgrover1 370:295f76db798e 28 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
rgrover1 370:295f76db798e 29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
rgrover1 370:295f76db798e 30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
rgrover1 370:295f76db798e 31 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
rgrover1 370:295f76db798e 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
rgrover1 370:295f76db798e 33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
rgrover1 370:295f76db798e 34 *
rgrover1 370:295f76db798e 35 */
rgrover1 370:295f76db798e 36
rgrover1 370:295f76db798e 37 /**
rgrover1 370:295f76db798e 38 @addtogroup BLE_COMMON
rgrover1 370:295f76db798e 39 @{
rgrover1 370:295f76db798e 40 @defgroup ble_types Common types and macro definitions
rgrover1 370:295f76db798e 41 @{
rgrover1 370:295f76db798e 42
rgrover1 370:295f76db798e 43 @brief Common types and macro definitions for the BLE SoftDevice.
rgrover1 370:295f76db798e 44 */
rgrover1 370:295f76db798e 45
rgrover1 370:295f76db798e 46 #ifndef BLE_TYPES_H__
rgrover1 370:295f76db798e 47 #define BLE_TYPES_H__
rgrover1 370:295f76db798e 48
rgrover1 370:295f76db798e 49 #include <stdint.h>
rgrover1 370:295f76db798e 50
rgrover1 370:295f76db798e 51 /** @addtogroup BLE_TYPES_DEFINES Defines
rgrover1 370:295f76db798e 52 * @{ */
rgrover1 370:295f76db798e 53
rgrover1 370:295f76db798e 54 /** @defgroup BLE_CONN_HANDLES BLE Connection Handles
rgrover1 370:295f76db798e 55 * @{ */
rgrover1 370:295f76db798e 56 #define BLE_CONN_HANDLE_INVALID 0xFFFF /**< Invalid Connection Handle. */
rgrover1 370:295f76db798e 57 #define BLE_CONN_HANDLE_ALL 0xFFFE /**< Applies to all Connection Handles. */
rgrover1 370:295f76db798e 58 /** @} */
rgrover1 370:295f76db798e 59
rgrover1 370:295f76db798e 60
rgrover1 370:295f76db798e 61 /** @defgroup BLE_UUID_VALUES Assigned Values for BLE UUIDs
rgrover1 370:295f76db798e 62 * @{ */
rgrover1 370:295f76db798e 63 /* Generic UUIDs, applicable to all services */
rgrover1 370:295f76db798e 64 #define BLE_UUID_UNKNOWN 0x0000 /**< Reserved UUID. */
rgrover1 370:295f76db798e 65 #define BLE_UUID_SERVICE_PRIMARY 0x2800 /**< Primary Service. */
rgrover1 370:295f76db798e 66 #define BLE_UUID_SERVICE_SECONDARY 0x2801 /**< Secondary Service. */
rgrover1 370:295f76db798e 67 #define BLE_UUID_SERVICE_INCLUDE 0x2802 /**< Include. */
rgrover1 370:295f76db798e 68 #define BLE_UUID_CHARACTERISTIC 0x2803 /**< Characteristic. */
rgrover1 370:295f76db798e 69 #define BLE_UUID_DESCRIPTOR_CHAR_EXT_PROP 0x2900 /**< Characteristic Extended Properties Descriptor. */
rgrover1 370:295f76db798e 70 #define BLE_UUID_DESCRIPTOR_CHAR_USER_DESC 0x2901 /**< Characteristic User Description Descriptor. */
rgrover1 370:295f76db798e 71 #define BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG 0x2902 /**< Client Characteristic Configuration Descriptor. */
rgrover1 370:295f76db798e 72 #define BLE_UUID_DESCRIPTOR_SERVER_CHAR_CONFIG 0x2903 /**< Server Characteristic Configuration Descriptor. */
rgrover1 370:295f76db798e 73 #define BLE_UUID_DESCRIPTOR_CHAR_PRESENTATION_FORMAT 0x2904 /**< Characteristic Presentation Format Descriptor. */
rgrover1 370:295f76db798e 74 #define BLE_UUID_DESCRIPTOR_CHAR_AGGREGATE_FORMAT 0x2905 /**< Characteristic Aggregate Format Descriptor. */
rgrover1 370:295f76db798e 75 /* GATT specific UUIDs */
rgrover1 370:295f76db798e 76 #define BLE_UUID_GATT 0x1801 /**< Generic Attribute Profile. */
rgrover1 370:295f76db798e 77 #define BLE_UUID_GATT_CHARACTERISTIC_SERVICE_CHANGED 0x2A05 /**< Service Changed Characteristic. */
rgrover1 370:295f76db798e 78 /* GAP specific UUIDs */
rgrover1 370:295f76db798e 79 #define BLE_UUID_GAP 0x1800 /**< Generic Access Profile. */
rgrover1 370:295f76db798e 80 #define BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME 0x2A00 /**< Device Name Characteristic. */
rgrover1 370:295f76db798e 81 #define BLE_UUID_GAP_CHARACTERISTIC_APPEARANCE 0x2A01 /**< Appearance Characteristic. */
rgrover1 370:295f76db798e 82 #define BLE_UUID_GAP_CHARACTERISTIC_PPF 0x2A02 /**< Peripheral Privacy Flag Characteristic. */
rgrover1 370:295f76db798e 83 #define BLE_UUID_GAP_CHARACTERISTIC_RECONN_ADDR 0x2A03 /**< Reconnection Address Characteristic. */
rgrover1 370:295f76db798e 84 #define BLE_UUID_GAP_CHARACTERISTIC_PPCP 0x2A04 /**< Peripheral Preferred Connection Parameters Characteristic. */
rgrover1 370:295f76db798e 85 /** @} */
rgrover1 370:295f76db798e 86
rgrover1 370:295f76db798e 87
rgrover1 370:295f76db798e 88 /** @defgroup BLE_UUID_TYPES Types of UUID
rgrover1 370:295f76db798e 89 * @{ */
rgrover1 370:295f76db798e 90 #define BLE_UUID_TYPE_UNKNOWN 0x00 /**< Invalid UUID type. */
rgrover1 370:295f76db798e 91 #define BLE_UUID_TYPE_BLE 0x01 /**< Bluetooth SIG UUID (16-bit). */
rgrover1 370:295f76db798e 92 #define BLE_UUID_TYPE_VENDOR_BEGIN 0x02 /**< Vendor UUID types start at this index (128-bit). */
rgrover1 370:295f76db798e 93 /** @} */
rgrover1 370:295f76db798e 94
rgrover1 370:295f76db798e 95
rgrover1 370:295f76db798e 96 /** @defgroup BLE_APPEARANCES Bluetooth Appearance values
rgrover1 370:295f76db798e 97 * @note Retrieved from http://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml
rgrover1 370:295f76db798e 98 * @{ */
rgrover1 370:295f76db798e 99 #define BLE_APPEARANCE_UNKNOWN 0 /**< Unknown. */
rgrover1 370:295f76db798e 100 #define BLE_APPEARANCE_GENERIC_PHONE 64 /**< Generic Phone. */
rgrover1 370:295f76db798e 101 #define BLE_APPEARANCE_GENERIC_COMPUTER 128 /**< Generic Computer. */
rgrover1 370:295f76db798e 102 #define BLE_APPEARANCE_GENERIC_WATCH 192 /**< Generic Watch. */
rgrover1 370:295f76db798e 103 #define BLE_APPEARANCE_WATCH_SPORTS_WATCH 193 /**< Watch: Sports Watch. */
rgrover1 370:295f76db798e 104 #define BLE_APPEARANCE_GENERIC_CLOCK 256 /**< Generic Clock. */
rgrover1 370:295f76db798e 105 #define BLE_APPEARANCE_GENERIC_DISPLAY 320 /**< Generic Display. */
rgrover1 370:295f76db798e 106 #define BLE_APPEARANCE_GENERIC_REMOTE_CONTROL 384 /**< Generic Remote Control. */
rgrover1 370:295f76db798e 107 #define BLE_APPEARANCE_GENERIC_EYE_GLASSES 448 /**< Generic Eye-glasses. */
rgrover1 370:295f76db798e 108 #define BLE_APPEARANCE_GENERIC_TAG 512 /**< Generic Tag. */
rgrover1 370:295f76db798e 109 #define BLE_APPEARANCE_GENERIC_KEYRING 576 /**< Generic Keyring. */
rgrover1 370:295f76db798e 110 #define BLE_APPEARANCE_GENERIC_MEDIA_PLAYER 640 /**< Generic Media Player. */
rgrover1 370:295f76db798e 111 #define BLE_APPEARANCE_GENERIC_BARCODE_SCANNER 704 /**< Generic Barcode Scanner. */
rgrover1 370:295f76db798e 112 #define BLE_APPEARANCE_GENERIC_THERMOMETER 768 /**< Generic Thermometer. */
rgrover1 370:295f76db798e 113 #define BLE_APPEARANCE_THERMOMETER_EAR 769 /**< Thermometer: Ear. */
rgrover1 370:295f76db798e 114 #define BLE_APPEARANCE_GENERIC_HEART_RATE_SENSOR 832 /**< Generic Heart rate Sensor. */
rgrover1 370:295f76db798e 115 #define BLE_APPEARANCE_HEART_RATE_SENSOR_HEART_RATE_BELT 833 /**< Heart Rate Sensor: Heart Rate Belt. */
rgrover1 370:295f76db798e 116 #define BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE 896 /**< Generic Blood Pressure. */
rgrover1 370:295f76db798e 117 #define BLE_APPEARANCE_BLOOD_PRESSURE_ARM 897 /**< Blood Pressure: Arm. */
rgrover1 370:295f76db798e 118 #define BLE_APPEARANCE_BLOOD_PRESSURE_WRIST 898 /**< Blood Pressure: Wrist. */
rgrover1 370:295f76db798e 119 #define BLE_APPEARANCE_GENERIC_HID 960 /**< Human Interface Device (HID). */
rgrover1 370:295f76db798e 120 #define BLE_APPEARANCE_HID_KEYBOARD 961 /**< Keyboard (HID Subtype). */
rgrover1 370:295f76db798e 121 #define BLE_APPEARANCE_HID_MOUSE 962 /**< Mouse (HID Subtype). */
rgrover1 370:295f76db798e 122 #define BLE_APPEARANCE_HID_JOYSTICK 963 /**< Joystiq (HID Subtype). */
rgrover1 370:295f76db798e 123 #define BLE_APPEARANCE_HID_GAMEPAD 964 /**< Gamepad (HID Subtype). */
rgrover1 370:295f76db798e 124 #define BLE_APPEARANCE_HID_DIGITIZERSUBTYPE 965 /**< Digitizer Tablet (HID Subtype). */
rgrover1 370:295f76db798e 125 #define BLE_APPEARANCE_HID_CARD_READER 966 /**< Card Reader (HID Subtype). */
rgrover1 370:295f76db798e 126 #define BLE_APPEARANCE_HID_DIGITAL_PEN 967 /**< Digital Pen (HID Subtype). */
rgrover1 370:295f76db798e 127 #define BLE_APPEARANCE_HID_BARCODE 968 /**< Barcode Scanner (HID Subtype). */
rgrover1 370:295f76db798e 128 #define BLE_APPEARANCE_GENERIC_GLUCOSE_METER 1024 /**< Generic Glucose Meter. */
rgrover1 370:295f76db798e 129 #define BLE_APPEARANCE_GENERIC_RUNNING_WALKING_SENSOR 1088 /**< Generic Running Walking Sensor. */
rgrover1 370:295f76db798e 130 #define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_IN_SHOE 1089 /**< Running Walking Sensor: In-Shoe. */
rgrover1 370:295f76db798e 131 #define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_SHOE 1090 /**< Running Walking Sensor: On-Shoe. */
rgrover1 370:295f76db798e 132 #define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_HIP 1091 /**< Running Walking Sensor: On-Hip. */
rgrover1 370:295f76db798e 133 #define BLE_APPEARANCE_GENERIC_CYCLING 1152 /**< Generic Cycling. */
rgrover1 370:295f76db798e 134 #define BLE_APPEARANCE_CYCLING_CYCLING_COMPUTER 1153 /**< Cycling: Cycling Computer. */
rgrover1 370:295f76db798e 135 #define BLE_APPEARANCE_CYCLING_SPEED_SENSOR 1154 /**< Cycling: Speed Sensor. */
rgrover1 370:295f76db798e 136 #define BLE_APPEARANCE_CYCLING_CADENCE_SENSOR 1155 /**< Cycling: Cadence Sensor. */
rgrover1 370:295f76db798e 137 #define BLE_APPEARANCE_CYCLING_POWER_SENSOR 1156 /**< Cycling: Power Sensor. */
rgrover1 370:295f76db798e 138 #define BLE_APPEARANCE_CYCLING_SPEED_CADENCE_SENSOR 1157 /**< Cycling: Speed and Cadence Sensor. */
rgrover1 370:295f76db798e 139 #define BLE_APPEARANCE_GENERIC_PULSE_OXIMETER 3136 /**< Generic Pulse Oximeter. */
rgrover1 370:295f76db798e 140 #define BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 3137 /**< Fingertip (Pulse Oximeter subtype). */
rgrover1 370:295f76db798e 141 #define BLE_APPEARANCE_PULSE_OXIMETER_WRIST_WORN 3138 /**< Wrist Worn(Pulse Oximeter subtype). */
rgrover1 370:295f76db798e 142 #define BLE_APPEARANCE_GENERIC_WEIGHT_SCALE 3200 /**< Generic Weight Scale. */
rgrover1 370:295f76db798e 143 #define BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS_ACT 5184 /**< Generic Outdoor Sports Activity. */
rgrover1 370:295f76db798e 144 #define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_DISP 5185 /**< Location Display Device (Outdoor Sports Activity subtype). */
rgrover1 370:295f76db798e 145 #define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_AND_NAV_DISP 5186 /**< Location and Navigation Display Device (Outdoor Sports Activity subtype). */
rgrover1 370:295f76db798e 146 #define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_POD 5187 /**< Location Pod (Outdoor Sports Activity subtype). */
rgrover1 370:295f76db798e 147 #define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_AND_NAV_POD 5188 /**< Location and Navigation Pod (Outdoor Sports Activity subtype). */
rgrover1 370:295f76db798e 148 /** @} */
rgrover1 370:295f76db798e 149
rgrover1 370:295f76db798e 150 /** @brief Set .type and .uuid fields of ble_uuid_struct to specified uuid value. */
rgrover1 370:295f76db798e 151 #define BLE_UUID_BLE_ASSIGN(instance, value) do {\
rgrover1 370:295f76db798e 152 instance.type = BLE_UUID_TYPE_BLE; \
rgrover1 370:295f76db798e 153 instance.uuid = value;} while(0)
rgrover1 370:295f76db798e 154
rgrover1 370:295f76db798e 155 /** @brief Copy type and uuid members from src to dst ble_uuid_t pointer. Both pointers must be valid/non-null. */
rgrover1 370:295f76db798e 156 #define BLE_UUID_COPY_PTR(dst, src) do {\
rgrover1 370:295f76db798e 157 (dst)->type = (src)->type; \
rgrover1 370:295f76db798e 158 (dst)->uuid = (src)->uuid;} while(0)
rgrover1 370:295f76db798e 159
rgrover1 370:295f76db798e 160 /** @brief Copy type and uuid members from src to dst ble_uuid_t struct. */
rgrover1 370:295f76db798e 161 #define BLE_UUID_COPY_INST(dst, src) do {\
rgrover1 370:295f76db798e 162 (dst).type = (src).type; \
rgrover1 370:295f76db798e 163 (dst).uuid = (src).uuid;} while(0)
rgrover1 370:295f76db798e 164
rgrover1 370:295f76db798e 165 /** @brief Compare for equality both type and uuid members of two (valid, non-null) ble_uuid_t pointers. */
rgrover1 370:295f76db798e 166 #define BLE_UUID_EQ(p_uuid1, p_uuid2) \
rgrover1 370:295f76db798e 167 (((p_uuid1)->type == (p_uuid2)->type) && ((p_uuid1)->uuid == (p_uuid2)->uuid))
rgrover1 370:295f76db798e 168
rgrover1 370:295f76db798e 169 /** @brief Compare for difference both type and uuid members of two (valid, non-null) ble_uuid_t pointers. */
rgrover1 370:295f76db798e 170 #define BLE_UUID_NEQ(p_uuid1, p_uuid2) \
rgrover1 370:295f76db798e 171 (((p_uuid1)->type != (p_uuid2)->type) || ((p_uuid1)->uuid != (p_uuid2)->uuid))
rgrover1 370:295f76db798e 172
rgrover1 370:295f76db798e 173 /** @} */
rgrover1 370:295f76db798e 174
rgrover1 370:295f76db798e 175 /** @addtogroup BLE_TYPES_STRUCTURES Structures
rgrover1 370:295f76db798e 176 * @{ */
rgrover1 370:295f76db798e 177
rgrover1 370:295f76db798e 178 /** @brief 128 bit UUID values. */
rgrover1 370:295f76db798e 179 typedef struct
rgrover1 370:295f76db798e 180 {
rgrover1 370:295f76db798e 181 unsigned char uuid128[16]; /**< Little-Endian UUID bytes. */
rgrover1 370:295f76db798e 182 } ble_uuid128_t;
rgrover1 370:295f76db798e 183
rgrover1 370:295f76db798e 184 /** @brief Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs. */
rgrover1 370:295f76db798e 185 typedef struct
rgrover1 370:295f76db798e 186 {
rgrover1 370:295f76db798e 187 uint16_t uuid; /**< 16-bit UUID value or octets 12-13 of 128-bit UUID. */
rgrover1 370:295f76db798e 188 uint8_t type; /**< UUID type, see @ref BLE_UUID_TYPES. If type is @ref BLE_UUID_TYPE_UNKNOWN, the value of uuid is undefined. */
rgrover1 370:295f76db798e 189 } ble_uuid_t;
rgrover1 370:295f76db798e 190
rgrover1 370:295f76db798e 191 /** @} */
rgrover1 370:295f76db798e 192
rgrover1 370:295f76db798e 193 #endif /* BLE_TYPES_H__ */
rgrover1 370:295f76db798e 194
rgrover1 370:295f76db798e 195 /**
rgrover1 370:295f76db798e 196 @}
rgrover1 370:295f76db798e 197 @}
rgrover1 370:295f76db798e 198 */