Changed the device name.

Dependents:   BLE_Health_Thermometer_HeartRateMonitor

Fork of BLE_API_Native_IRC by Yoshihiro TSUBOI

Committer:
ghz2000
Date:
Mon Jun 16 15:06:48 2014 +0000
Revision:
20:a58a51c92075
Parent:
13:1800682b5703
Add HeartRateMonitor

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ktownsend 0:4c3097c65247 1 /* mbed Microcontroller Library
ktownsend 0:4c3097c65247 2 * Copyright (c) 2006-2013 ARM Limited
ktownsend 0:4c3097c65247 3 *
ktownsend 0:4c3097c65247 4 * Licensed under the Apache License, Version 2.0 (the "License");
ktownsend 0:4c3097c65247 5 * you may not use this file except in compliance with the License.
ktownsend 0:4c3097c65247 6 * You may obtain a copy of the License at
ktownsend 0:4c3097c65247 7 *
ktownsend 0:4c3097c65247 8 * http://www.apache.org/licenses/LICENSE-2.0
ktownsend 0:4c3097c65247 9 *
ktownsend 0:4c3097c65247 10 * Unless required by applicable law or agreed to in writing, software
ktownsend 0:4c3097c65247 11 * distributed under the License is distributed on an "AS IS" BASIS,
ktownsend 0:4c3097c65247 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ktownsend 0:4c3097c65247 13 * See the License for the specific language governing permissions and
ktownsend 0:4c3097c65247 14 * limitations under the License.
ktownsend 0:4c3097c65247 15 */
ktownsend 0:4c3097c65247 16
ktownsend 0:4c3097c65247 17 #ifndef __GAP_ADVERTISING_DATA_H__
ktownsend 0:4c3097c65247 18 #define __GAP_ADVERTISING_DATA_H__
ktownsend 0:4c3097c65247 19
ktownsend 0:4c3097c65247 20 #include "blecommon.h"
ktownsend 0:4c3097c65247 21
ktownsend 0:4c3097c65247 22 #define GAP_ADVERTISING_DATA_MAX_PAYLOAD (31)
ktownsend 0:4c3097c65247 23
ktownsend 0:4c3097c65247 24 /**************************************************************************/
ktownsend 0:4c3097c65247 25 /*!
ktownsend 0:4c3097c65247 26 \brief
ktownsend 0:4c3097c65247 27 This class provides several helper functions to generate properly
ktownsend 0:4c3097c65247 28 formatted GAP Advertising and Scan Response data payloads
ktownsend 0:4c3097c65247 29
ktownsend 0:4c3097c65247 30 \note
ktownsend 0:4c3097c65247 31 See Bluetooth Specification 4.0 (Vol. 3), Part C, Section 11 and 18
ktownsend 0:4c3097c65247 32 for further information on Advertising and Scan Response data.
ktownsend 0:4c3097c65247 33
ktownsend 0:4c3097c65247 34 \par Advertising and Scan Response Payloads
ktownsend 0:4c3097c65247 35 Advertising data and Scan Response data are organized around a set of
ktownsend 0:4c3097c65247 36 data types called 'AD types' in Bluetooth 4.0 (see the Bluetooth Core
ktownsend 0:4c3097c65247 37 Specification v4.0, Vol. 3, Part C, Sections 11 and 18).
ktownsend 0:4c3097c65247 38
ktownsend 0:4c3097c65247 39 \par
ktownsend 0:4c3097c65247 40 Each AD type has it's own standardized 'assigned number', as defined
ktownsend 0:4c3097c65247 41 by the Bluetooth SIG:
ktownsend 0:4c3097c65247 42 https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile
ktownsend 0:4c3097c65247 43
ktownsend 0:4c3097c65247 44 \par
ktownsend 0:4c3097c65247 45 For convenience sake, all appropriate AD types have been encapsulated
ktownsend 0:4c3097c65247 46 into GapAdvertisingData::DataType.
ktownsend 0:4c3097c65247 47
ktownsend 0:4c3097c65247 48 \par
ktownsend 0:4c3097c65247 49 Before the AD Types and their payload (if any) can be inserted into
ktownsend 0:4c3097c65247 50 the Advertising or Scan Response frames, they need to be formatted as
ktownsend 0:4c3097c65247 51 follows:
ktownsend 0:4c3097c65247 52
ktownsend 0:4c3097c65247 53 \li \c Record length (1 byte)
ktownsend 0:4c3097c65247 54 \li \c AD Type (1 byte)
ktownsend 0:4c3097c65247 55 \li \c AD payload (optional, only present if record length > 1)
ktownsend 0:4c3097c65247 56
ktownsend 0:4c3097c65247 57 \par
ktownsend 0:4c3097c65247 58 This class takes care of properly formatting the payload, performs
ktownsend 0:4c3097c65247 59 some basic checks on the payload length, and tries to avoid common
ktownsend 0:4c3097c65247 60 errors like adding an exclusive AD field twice in the Advertising
ktownsend 0:4c3097c65247 61 or Scan Response payload.
ktownsend 0:4c3097c65247 62
ktownsend 0:4c3097c65247 63 \par EXAMPLE
ktownsend 0:4c3097c65247 64
ktownsend 0:4c3097c65247 65 \code
ktownsend 0:4c3097c65247 66
ktownsend 0:4c3097c65247 67 // ToDo
ktownsend 0:4c3097c65247 68
ktownsend 0:4c3097c65247 69 \endcode
ktownsend 0:4c3097c65247 70 */
ktownsend 0:4c3097c65247 71 /**************************************************************************/
ktownsend 0:4c3097c65247 72 class GapAdvertisingData
ktownsend 0:4c3097c65247 73 {
ktownsend 0:4c3097c65247 74 public:
ktownsend 0:4c3097c65247 75 /**********************************************************************/
ktownsend 0:4c3097c65247 76 /*!
ktownsend 0:4c3097c65247 77 \brief
ktownsend 0:4c3097c65247 78 A list of Advertising Data types commonly used by peripherals.
ktownsend 0:4c3097c65247 79 These AD types are used to describe the capabilities of the
ktownsend 0:4c3097c65247 80 peripheral, and get inserted inside the advertising or scan
ktownsend 0:4c3097c65247 81 response payloads.
ktownsend 0:4c3097c65247 82
ktownsend 0:4c3097c65247 83 \par Source
ktownsend 0:4c3097c65247 84 \li \c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 11, 18
ktownsend 0:4c3097c65247 85 \li \c https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile
ktownsend 0:4c3097c65247 86 */
ktownsend 0:4c3097c65247 87 /**********************************************************************/
ktownsend 0:4c3097c65247 88 enum DataType
ktownsend 0:4c3097c65247 89 {
ktownsend 0:4c3097c65247 90 FLAGS = 0x01, /**< \ref Flags */
ktownsend 0:4c3097c65247 91 INCOMPLETE_LIST_16BIT_SERVICE_IDS = 0x02, /**< Incomplete list of 16-bit Service IDs */
ktownsend 0:4c3097c65247 92 COMPLETE_LIST_16BIT_SERVICE_IDS = 0x03, /**< Complete list of 16-bit Service IDs */
ktownsend 0:4c3097c65247 93 INCOMPLETE_LIST_32BIT_SERVICE_IDS = 0x04, /**< Incomplete list of 32-bit Service IDs (not relevant for Bluetooth 4.0) */
ktownsend 0:4c3097c65247 94 COMPLETE_LIST_32BIT_SERVICE_IDS = 0x05, /**< Complete list of 32-bit Service IDs (not relevant for Bluetooth 4.0) */
ktownsend 0:4c3097c65247 95 INCOMPLETE_LIST_128BIT_SERVICE_IDS = 0x06, /**< Incomplete list of 128-bit Service IDs */
ktownsend 0:4c3097c65247 96 COMPLETE_LIST_128BIT_SERVICE_IDS = 0x07, /**< Complete list of 128-bit Service IDs */
ktownsend 0:4c3097c65247 97 SHORTENED_LOCAL_NAME = 0x08, /**< Shortened Local Name */
ktownsend 0:4c3097c65247 98 COMPLETE_LOCAL_NAME = 0x09, /**< Complete Local Name */
ktownsend 0:4c3097c65247 99 TX_POWER_LEVEL = 0x0A, /**< TX Power Level (in dBm) */
ktownsend 0:4c3097c65247 100 DEVICE_ID = 0x10, /**< Device ID */
ktownsend 0:4c3097c65247 101 SLAVE_CONNECTION_INTERVAL_RANGE = 0x12, /**< Slave Connection Interval Range */
ktownsend 0:4c3097c65247 102 SERVICE_DATA = 0x16, /**< Service Data */
ktownsend 0:4c3097c65247 103 APPEARANCE = 0x19, /**< \ref Appearance */
ktownsend 0:4c3097c65247 104 ADVERTISING_INTERVAL = 0x1A, /**< Advertising Interval */
ktownsend 0:4c3097c65247 105 MANUFACTURER_SPECIFIC_DATA = 0xFF /**< Manufacturer Specific Data */
ktownsend 0:4c3097c65247 106 };
ktownsend 0:4c3097c65247 107
ktownsend 0:4c3097c65247 108 /**********************************************************************/
ktownsend 0:4c3097c65247 109 /*!
ktownsend 0:4c3097c65247 110 \brief
ktownsend 0:4c3097c65247 111 A list of values for the FLAGS AD Type
ktownsend 0:4c3097c65247 112
ktownsend 0:4c3097c65247 113 \note
ktownsend 0:4c3097c65247 114 You can use more than one value in the FLAGS AD Type (ex.
ktownsend 0:4c3097c65247 115 LE_GENERAL_DISCOVERABLE and BREDR_NOT_SUPPORTED).
ktownsend 0:4c3097c65247 116
ktownsend 0:4c3097c65247 117 \par Source
ktownsend 0:4c3097c65247 118 \li \c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 18.1
ktownsend 0:4c3097c65247 119 */
ktownsend 0:4c3097c65247 120 /**********************************************************************/
ktownsend 0:4c3097c65247 121 enum Flags
ktownsend 0:4c3097c65247 122 {
ktownsend 0:4c3097c65247 123 LE_LIMITED_DISCOVERABLE = 0x01, /**< Peripheral device is discoverable for a limited period of time */
ktownsend 0:4c3097c65247 124 LE_GENERAL_DISCOVERABLE = 0x02, /**< Peripheral device is discoverable at any moment */
ktownsend 0:4c3097c65247 125 BREDR_NOT_SUPPORTED = 0x04, /**< Peripheral device is LE only */
ktownsend 0:4c3097c65247 126 SIMULTANEOUS_LE_BREDR_C = 0x08, /**< Not relevant - central mode only */
ktownsend 0:4c3097c65247 127 SIMULTANEOUS_LE_BREDR_H = 0x10 /**< Not relevant - central mode only */
ktownsend 0:4c3097c65247 128 };
ktownsend 0:4c3097c65247 129
ktownsend 0:4c3097c65247 130 /**********************************************************************/
ktownsend 0:4c3097c65247 131 /*!
ktownsend 0:4c3097c65247 132 \brief
ktownsend 0:4c3097c65247 133 A list of values for the APPEARANCE AD Type, which describes the
ktownsend 0:4c3097c65247 134 physical shape or appearance of the device
ktownsend 0:4c3097c65247 135
ktownsend 0:4c3097c65247 136 \par Source
ktownsend 0:4c3097c65247 137 \li \c Bluetooth Core Specification Supplement, Part A, Section 1.12
ktownsend 0:4c3097c65247 138 \li \c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 12.2
ktownsend 0:4c3097c65247 139 \li \c https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml
ktownsend 0:4c3097c65247 140 */
ktownsend 0:4c3097c65247 141 /**********************************************************************/
ktownsend 0:4c3097c65247 142 enum Appearance
ktownsend 0:4c3097c65247 143 {
ktownsend 0:4c3097c65247 144 UNKNOWN = 0, /**< Unknown of unspecified appearance type */
ktownsend 0:4c3097c65247 145 GENERIC_PHONE = 64, /**< Generic Phone */
ktownsend 0:4c3097c65247 146 GENERIC_COMPUTER = 128, /**< Generic Computer */
ktownsend 0:4c3097c65247 147 GENERIC_WATCH = 192, /**< Generic Watch */
ktownsend 0:4c3097c65247 148 WATCH_SPORTS_WATCH = 193, /**< Sports Watch */
ktownsend 0:4c3097c65247 149 GENERIC_CLOCK = 256, /**< Generic Clock */
ktownsend 0:4c3097c65247 150 GENERIC_DISPLAY = 320, /**< Generic Display */
ktownsend 0:4c3097c65247 151 GENERIC_REMOTE_CONTROL = 384, /**< Generic Remote Control */
ktownsend 0:4c3097c65247 152 GENERIC_EYE_GLASSES = 448, /**< Generic Eye Glasses */
ktownsend 0:4c3097c65247 153 GENERIC_TAG = 512, /**< Generic Tag */
ktownsend 0:4c3097c65247 154 GENERIC_KEYRING = 576, /**< Generic Keyring */
ktownsend 0:4c3097c65247 155 GENERIC_MEDIA_PLAYER = 640, /**< Generic Media Player */
ktownsend 0:4c3097c65247 156 GENERIC_BARCODE_SCANNER = 704, /**< Generic Barcode Scanner */
ktownsend 0:4c3097c65247 157 GENERIC_THERMOMETER = 768, /**< Generic Thermometer */
ktownsend 0:4c3097c65247 158 THERMOMETER_EAR = 769, /**< Ear Thermometer */
ktownsend 0:4c3097c65247 159 GENERIC_HEART_RATE_SENSOR = 832, /**< Generic Heart Rate Sensor */
ktownsend 0:4c3097c65247 160 HEART_RATE_SENSOR_HEART_RATE_BELT = 833, /**< Belt Heart Rate Sensor */
ktownsend 0:4c3097c65247 161 GENERIC_BLOOD_PRESSURE = 896, /**< Generic Blood Pressure */
ktownsend 0:4c3097c65247 162 BLOOD_PRESSURE_ARM = 897, /**< Arm Blood Pressure */
ktownsend 0:4c3097c65247 163 BLOOD_PRESSURE_WRIST = 898, /**< Wrist Blood Pressure */
ktownsend 0:4c3097c65247 164 HUMAN_INTERFACE_DEVICE_HID = 960, /**< Human Interface Device (HID) */
ktownsend 0:4c3097c65247 165 KEYBOARD = 961, /**< Keyboard */
ktownsend 0:4c3097c65247 166 MOUSE = 962, /**< Mouse */
ktownsend 0:4c3097c65247 167 JOYSTICK = 963, /**< Joystick */
ktownsend 0:4c3097c65247 168 GAMEPAD = 964, /**< Gamepad */
ktownsend 0:4c3097c65247 169 DIGITIZER_TABLET = 965, /**< Digitizer Tablet */
ktownsend 0:4c3097c65247 170 CARD_READER = 966, /**< Card Read */
ktownsend 0:4c3097c65247 171 DIGITAL_PEN = 967, /**< Digital Pen */
ktownsend 0:4c3097c65247 172 BARCODE_SCANNER = 968, /**< Barcode Scanner */
ktownsend 0:4c3097c65247 173 GENERIC_GLUCOSE_METER = 1024, /**< Generic Glucose Meter */
ktownsend 0:4c3097c65247 174 GENERIC_RUNNING_WALKING_SENSOR = 1088, /**< Generic Running/Walking Sensor */
ktownsend 0:4c3097c65247 175 RUNNING_WALKING_SENSOR_IN_SHOE = 1089, /**< In Shoe Running/Walking Sensor */
ktownsend 0:4c3097c65247 176 RUNNING_WALKING_SENSOR_ON_SHOE = 1090, /**< On Shoe Running/Walking Sensor */
ktownsend 0:4c3097c65247 177 RUNNING_WALKING_SENSOR_ON_HIP = 1091, /**< On Hip Running/Walking Sensor */
ktownsend 0:4c3097c65247 178 GENERIC_CYCLING = 1152, /**< Generic Cycling */
ktownsend 0:4c3097c65247 179 CYCLING_CYCLING_COMPUTER = 1153, /**< Cycling Computer */
ktownsend 0:4c3097c65247 180 CYCLING_SPEED_SENSOR = 1154, /**< Cycling Speed Senspr */
ktownsend 0:4c3097c65247 181 CYCLING_CADENCE_SENSOR = 1155, /**< Cycling Cadence Sensor */
ktownsend 0:4c3097c65247 182 CYCLING_POWER_SENSOR = 1156, /**< Cycling Power Sensor */
ktownsend 0:4c3097c65247 183 CYCLING_SPEED_AND_CADENCE_SENSOR = 1157, /**< Cycling Speed and Cadence Sensor */
ktownsend 0:4c3097c65247 184 PULSE_OXIMETER_GENERIC = 3136, /**< Generic Pulse Oximeter */
ktownsend 0:4c3097c65247 185 PULSE_OXIMETER_FINGERTIP = 3137, /**< Fingertip Pulse Oximeter */
ktownsend 0:4c3097c65247 186 PULSE_OXIMETER_WRIST_WORN = 3138, /**< Wrist Worn Pulse Oximeter */
ktownsend 0:4c3097c65247 187 OUTDOOR_GENERIC = 5184, /**< Generic Outdoor */
ktownsend 0:4c3097c65247 188 OUTDOOR_LOCATION_DISPLAY_DEVICE = 5185, /**< Outdoor Location Display Device */
ktownsend 0:4c3097c65247 189 OUTDOOR_LOCATION_AND_NAVIGATION_DISPLAY_DEVICE = 5186, /**< Outdoor Location and Navigation Display Device */
ktownsend 0:4c3097c65247 190 OUTDOOR_LOCATION_POD = 5187, /**< Outdoor Location Pod */
ktownsend 0:4c3097c65247 191 OUTDOOR_LOCATION_AND_NAVIGATION_POD = 5188 /**< Outdoor Location and Navigation Pod */
ktownsend 0:4c3097c65247 192 };
ktownsend 0:4c3097c65247 193
ktownsend 0:4c3097c65247 194 GapAdvertisingData(void);
ktownsend 0:4c3097c65247 195 virtual ~GapAdvertisingData(void);
ktownsend 0:4c3097c65247 196
ktownsend 0:4c3097c65247 197 ble_error_t addData(DataType, uint8_t *, uint8_t);
ktownsend 13:1800682b5703 198 ble_error_t addAppearance(Appearance appearance = GENERIC_TAG);
ktownsend 0:4c3097c65247 199 ble_error_t addFlags(Flags flag = LE_GENERAL_DISCOVERABLE);
ktownsend 0:4c3097c65247 200 ble_error_t addTxPower(int8_t txPower);
ktownsend 0:4c3097c65247 201 void clear(void);
ktownsend 0:4c3097c65247 202 uint8_t * getPayload(void);
ktownsend 0:4c3097c65247 203 uint8_t getPayloadLen(void);
ktownsend 13:1800682b5703 204 uint16_t getAppearance(void);
ktownsend 0:4c3097c65247 205
ktownsend 0:4c3097c65247 206 private:
ktownsend 13:1800682b5703 207 uint8_t _payload[GAP_ADVERTISING_DATA_MAX_PAYLOAD];
ktownsend 13:1800682b5703 208 uint8_t _payloadLen;
ktownsend 13:1800682b5703 209 uint16_t _appearance;
ktownsend 0:4c3097c65247 210 };
ktownsend 0:4c3097c65247 211
ktownsend 0:4c3097c65247 212 #endif