jgh
Fork of BLE_API by
ble/blecommon.h@993:4d62b7967c11, 2015-12-02 (annotated)
- Committer:
- rgrover1
- Date:
- Wed Dec 02 10:29:44 2015 +0000
- Revision:
- 993:4d62b7967c11
- Parent:
- 992:ca834f7ae8ed
- Child:
- 1042:21a86ac7f5b1
Synchronized with git rev 12e27cd4
Author: Rohit Grover
Release 2.1.3
=============
* Improvements to CallChainOfFunctionPointerswithContext:
- add a `detach` function to be able to remove callbacks.
- detach function now return true if a function has been detached and
false otherwise.
- add a function call operator.
- use safe-bool idiom. see : http://www.artima.com/cppsource/safebool.html
* Add SafeBool class which allow to easily declare a safe bool operator in
c++03.
* Improvements to FunctionPointerWithContext:
- fix call propagation
- use safe bool idiom
* Add config file for generating Doxygen.
* Setup for onRadioNotification callback does not call initRadioNotification
anymore.
* GapAdvertisementData now handles replacement and appending of data fields
based on type. Some fields can be replaced with new values, and others
require the payload to be appended.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rgrover1 | 710:b2e1a2660ec2 | 1 | /* mbed Microcontroller Library |
rgrover1 | 710:b2e1a2660ec2 | 2 | * Copyright (c) 2006-2013 ARM Limited |
rgrover1 | 710:b2e1a2660ec2 | 3 | * |
rgrover1 | 710:b2e1a2660ec2 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
rgrover1 | 710:b2e1a2660ec2 | 5 | * you may not use this file except in compliance with the License. |
rgrover1 | 710:b2e1a2660ec2 | 6 | * You may obtain a copy of the License at |
rgrover1 | 710:b2e1a2660ec2 | 7 | * |
rgrover1 | 710:b2e1a2660ec2 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
rgrover1 | 710:b2e1a2660ec2 | 9 | * |
rgrover1 | 710:b2e1a2660ec2 | 10 | * Unless required by applicable law or agreed to in writing, software |
rgrover1 | 710:b2e1a2660ec2 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
rgrover1 | 710:b2e1a2660ec2 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
rgrover1 | 710:b2e1a2660ec2 | 13 | * See the License for the specific language governing permissions and |
rgrover1 | 710:b2e1a2660ec2 | 14 | * limitations under the License. |
rgrover1 | 710:b2e1a2660ec2 | 15 | */ |
rgrover1 | 710:b2e1a2660ec2 | 16 | |
rgrover1 | 710:b2e1a2660ec2 | 17 | #ifndef __BLE_COMMON_H__ |
rgrover1 | 710:b2e1a2660ec2 | 18 | #define __BLE_COMMON_H__ |
rgrover1 | 710:b2e1a2660ec2 | 19 | |
rgrover1 | 710:b2e1a2660ec2 | 20 | #ifdef __cplusplus |
rgrover1 | 710:b2e1a2660ec2 | 21 | extern "C" { |
rgrover1 | 710:b2e1a2660ec2 | 22 | #endif |
rgrover1 | 710:b2e1a2660ec2 | 23 | |
rgrover1 | 710:b2e1a2660ec2 | 24 | |
rgrover1 | 993:4d62b7967c11 | 25 | /*! @brief Assigned values for BLE UUIDs. */ |
rgrover1 | 710:b2e1a2660ec2 | 26 | enum { |
rgrover1 | 710:b2e1a2660ec2 | 27 | BLE_UUID_UNKNOWN = 0x0000, /**< Reserved UUID. */ |
rgrover1 | 710:b2e1a2660ec2 | 28 | BLE_UUID_SERVICE_PRIMARY = 0x2800, /**< Primary Service. */ |
rgrover1 | 710:b2e1a2660ec2 | 29 | BLE_UUID_SERVICE_SECONDARY = 0x2801, /**< Secondary Service. */ |
rgrover1 | 710:b2e1a2660ec2 | 30 | BLE_UUID_SERVICE_INCLUDE = 0x2802, /**< Include. */ |
rgrover1 | 710:b2e1a2660ec2 | 31 | BLE_UUID_CHARACTERISTIC = 0x2803, /**< Characteristic. */ |
rgrover1 | 710:b2e1a2660ec2 | 32 | BLE_UUID_DESCRIPTOR_CHAR_EXT_PROP = 0x2900, /**< Characteristic Extended Properties Descriptor. */ |
rgrover1 | 710:b2e1a2660ec2 | 33 | BLE_UUID_DESCRIPTOR_CHAR_USER_DESC = 0x2901, /**< Characteristic User Description Descriptor. */ |
rgrover1 | 710:b2e1a2660ec2 | 34 | BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG = 0x2902, /**< Client Characteristic Configuration Descriptor. */ |
rgrover1 | 710:b2e1a2660ec2 | 35 | BLE_UUID_DESCRIPTOR_SERVER_CHAR_CONFIG = 0x2903, /**< Server Characteristic Configuration Descriptor. */ |
rgrover1 | 710:b2e1a2660ec2 | 36 | BLE_UUID_DESCRIPTOR_CHAR_PRESENTATION_FORMAT = 0x2904, /**< Characteristic Presentation Format Descriptor. */ |
rgrover1 | 710:b2e1a2660ec2 | 37 | BLE_UUID_DESCRIPTOR_CHAR_AGGREGATE_FORMAT = 0x2905, /**< Characteristic Aggregate Format Descriptor. */ |
rgrover1 | 710:b2e1a2660ec2 | 38 | |
rgrover1 | 710:b2e1a2660ec2 | 39 | /* GATT specific UUIDs */ |
rgrover1 | 710:b2e1a2660ec2 | 40 | BLE_UUID_GATT = 0x1801, /**< Generic Attribute Profile. */ |
rgrover1 | 710:b2e1a2660ec2 | 41 | BLE_UUID_GATT_CHARACTERISTIC_SERVICE_CHANGED = 0x2A05, /**< Service Changed Characteristic. */ |
rgrover1 | 710:b2e1a2660ec2 | 42 | |
rgrover1 | 710:b2e1a2660ec2 | 43 | /* GAP specific UUIDs */ |
rgrover1 | 710:b2e1a2660ec2 | 44 | BLE_UUID_GAP = 0x1800, /**< Generic Access Profile. */ |
rgrover1 | 710:b2e1a2660ec2 | 45 | BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME = 0x2A00, /**< Device Name Characteristic. */ |
rgrover1 | 710:b2e1a2660ec2 | 46 | BLE_UUID_GAP_CHARACTERISTIC_APPEARANCE = 0x2A01, /**< Appearance Characteristic. */ |
rgrover1 | 710:b2e1a2660ec2 | 47 | BLE_UUID_GAP_CHARACTERISTIC_PPF = 0x2A02, /**< Peripheral Privacy Flag Characteristic. */ |
rgrover1 | 710:b2e1a2660ec2 | 48 | BLE_UUID_GAP_CHARACTERISTIC_RECONN_ADDR = 0x2A03, /**< Reconnection Address Characteristic. */ |
rgrover1 | 710:b2e1a2660ec2 | 49 | BLE_UUID_GAP_CHARACTERISTIC_PPCP = 0x2A04, /**< Peripheral Preferred Connection Parameters Characteristic. */ |
rgrover1 | 710:b2e1a2660ec2 | 50 | }; |
rgrover1 | 710:b2e1a2660ec2 | 51 | |
rgrover1 | 993:4d62b7967c11 | 52 | /*! Bluetooth appearance values. |
rgrover1 | 710:b2e1a2660ec2 | 53 | * @note Retrieved from http://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml |
rgrover1 | 993:4d62b7967c11 | 54 | */ |
rgrover1 | 710:b2e1a2660ec2 | 55 | enum { |
rgrover1 | 710:b2e1a2660ec2 | 56 | BLE_APPEARANCE_UNKNOWN = 0, /**< Unknown. */ |
rgrover1 | 710:b2e1a2660ec2 | 57 | BLE_APPEARANCE_GENERIC_PHONE = 64, /**< Generic Phone. */ |
rgrover1 | 710:b2e1a2660ec2 | 58 | BLE_APPEARANCE_GENERIC_COMPUTER = 128, /**< Generic Computer. */ |
rgrover1 | 710:b2e1a2660ec2 | 59 | BLE_APPEARANCE_GENERIC_WATCH = 192, /**< Generic Watch. */ |
rgrover1 | 710:b2e1a2660ec2 | 60 | BLE_APPEARANCE_WATCH_SPORTS_WATCH = 193, /**< Watch: Sports Watch. */ |
rgrover1 | 710:b2e1a2660ec2 | 61 | BLE_APPEARANCE_GENERIC_CLOCK = 256, /**< Generic Clock. */ |
rgrover1 | 710:b2e1a2660ec2 | 62 | BLE_APPEARANCE_GENERIC_DISPLAY = 320, /**< Generic Display. */ |
rgrover1 | 710:b2e1a2660ec2 | 63 | BLE_APPEARANCE_GENERIC_REMOTE_CONTROL = 384, /**< Generic Remote Control. */ |
rgrover1 | 710:b2e1a2660ec2 | 64 | BLE_APPEARANCE_GENERIC_EYE_GLASSES = 448, /**< Generic Eye-glasses. */ |
rgrover1 | 710:b2e1a2660ec2 | 65 | BLE_APPEARANCE_GENERIC_TAG = 512, /**< Generic Tag. */ |
rgrover1 | 710:b2e1a2660ec2 | 66 | BLE_APPEARANCE_GENERIC_KEYRING = 576, /**< Generic Keyring. */ |
rgrover1 | 710:b2e1a2660ec2 | 67 | BLE_APPEARANCE_GENERIC_MEDIA_PLAYER = 640, /**< Generic Media Player. */ |
rgrover1 | 710:b2e1a2660ec2 | 68 | BLE_APPEARANCE_GENERIC_BARCODE_SCANNER = 704, /**< Generic Barcode Scanner. */ |
rgrover1 | 710:b2e1a2660ec2 | 69 | BLE_APPEARANCE_GENERIC_THERMOMETER = 768, /**< Generic Thermometer. */ |
rgrover1 | 710:b2e1a2660ec2 | 70 | BLE_APPEARANCE_THERMOMETER_EAR = 769, /**< Thermometer: Ear. */ |
rgrover1 | 993:4d62b7967c11 | 71 | BLE_APPEARANCE_GENERIC_HEART_RATE_SENSOR = 832, /**< Generic Heart Rate Sensor. */ |
rgrover1 | 710:b2e1a2660ec2 | 72 | BLE_APPEARANCE_HEART_RATE_SENSOR_HEART_RATE_BELT = 833, /**< Heart Rate Sensor: Heart Rate Belt. */ |
rgrover1 | 710:b2e1a2660ec2 | 73 | BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE = 896, /**< Generic Blood Pressure. */ |
rgrover1 | 710:b2e1a2660ec2 | 74 | BLE_APPEARANCE_BLOOD_PRESSURE_ARM = 897, /**< Blood Pressure: Arm. */ |
rgrover1 | 710:b2e1a2660ec2 | 75 | BLE_APPEARANCE_BLOOD_PRESSURE_WRIST = 898, /**< Blood Pressure: Wrist. */ |
rgrover1 | 710:b2e1a2660ec2 | 76 | BLE_APPEARANCE_GENERIC_HID = 960, /**< Human Interface Device (HID). */ |
rgrover1 | 993:4d62b7967c11 | 77 | BLE_APPEARANCE_HID_KEYBOARD = 961, /**< Keyboard (HID subtype). */ |
rgrover1 | 993:4d62b7967c11 | 78 | BLE_APPEARANCE_HID_MOUSE = 962, /**< Mouse (HID subtype). */ |
rgrover1 | 993:4d62b7967c11 | 79 | BLE_APPEARANCE_HID_JOYSTICK = 963, /**< Joystick (HID subtype). */ |
rgrover1 | 993:4d62b7967c11 | 80 | BLE_APPEARANCE_HID_GAMEPAD = 964, /**< Gamepad (HID subtype). */ |
rgrover1 | 993:4d62b7967c11 | 81 | BLE_APPEARANCE_HID_DIGITIZERSUBTYPE = 965, /**< Digitizer Tablet (HID subtype). */ |
rgrover1 | 993:4d62b7967c11 | 82 | BLE_APPEARANCE_HID_CARD_READER = 966, /**< Card Reader (HID subtype). */ |
rgrover1 | 993:4d62b7967c11 | 83 | BLE_APPEARANCE_HID_DIGITAL_PEN = 967, /**< Digital Pen (HID subtype). */ |
rgrover1 | 993:4d62b7967c11 | 84 | BLE_APPEARANCE_HID_BARCODE = 968, /**< Barcode Scanner (HID subtype). */ |
rgrover1 | 710:b2e1a2660ec2 | 85 | BLE_APPEARANCE_GENERIC_GLUCOSE_METER = 1024, /**< Generic Glucose Meter. */ |
rgrover1 | 710:b2e1a2660ec2 | 86 | BLE_APPEARANCE_GENERIC_RUNNING_WALKING_SENSOR = 1088, /**< Generic Running Walking Sensor. */ |
rgrover1 | 710:b2e1a2660ec2 | 87 | BLE_APPEARANCE_RUNNING_WALKING_SENSOR_IN_SHOE = 1089, /**< Running Walking Sensor: In-Shoe. */ |
rgrover1 | 710:b2e1a2660ec2 | 88 | BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_SHOE = 1090, /**< Running Walking Sensor: On-Shoe. */ |
rgrover1 | 710:b2e1a2660ec2 | 89 | BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_HIP = 1091, /**< Running Walking Sensor: On-Hip. */ |
rgrover1 | 710:b2e1a2660ec2 | 90 | BLE_APPEARANCE_GENERIC_CYCLING = 1152, /**< Generic Cycling. */ |
rgrover1 | 710:b2e1a2660ec2 | 91 | BLE_APPEARANCE_CYCLING_CYCLING_COMPUTER = 1153, /**< Cycling: Cycling Computer. */ |
rgrover1 | 710:b2e1a2660ec2 | 92 | BLE_APPEARANCE_CYCLING_SPEED_SENSOR = 1154, /**< Cycling: Speed Sensor. */ |
rgrover1 | 710:b2e1a2660ec2 | 93 | BLE_APPEARANCE_CYCLING_CADENCE_SENSOR = 1155, /**< Cycling: Cadence Sensor. */ |
rgrover1 | 710:b2e1a2660ec2 | 94 | BLE_APPEARANCE_CYCLING_POWER_SENSOR = 1156, /**< Cycling: Power Sensor. */ |
rgrover1 | 710:b2e1a2660ec2 | 95 | BLE_APPEARANCE_CYCLING_SPEED_CADENCE_SENSOR = 1157, /**< Cycling: Speed and Cadence Sensor. */ |
rgrover1 | 710:b2e1a2660ec2 | 96 | BLE_APPEARANCE_GENERIC_PULSE_OXIMETER = 3136, /**< Generic Pulse Oximeter. */ |
rgrover1 | 710:b2e1a2660ec2 | 97 | BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP = 3137, /**< Fingertip (Pulse Oximeter subtype). */ |
rgrover1 | 993:4d62b7967c11 | 98 | BLE_APPEARANCE_PULSE_OXIMETER_WRIST_WORN = 3138, /**< Wrist Worn (Pulse Oximeter subtype). */ |
rgrover1 | 710:b2e1a2660ec2 | 99 | BLE_APPEARANCE_GENERIC_WEIGHT_SCALE = 3200, /**< Generic Weight Scale. */ |
rgrover1 | 710:b2e1a2660ec2 | 100 | BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS_ACT = 5184, /**< Generic Outdoor Sports Activity. */ |
rgrover1 | 710:b2e1a2660ec2 | 101 | BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_DISP = 5185, /**< Location Display Device (Outdoor Sports Activity subtype). */ |
rgrover1 | 710:b2e1a2660ec2 | 102 | BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_AND_NAV_DISP = 5186, /**< Location and Navigation Display Device (Outdoor Sports Activity subtype). */ |
rgrover1 | 710:b2e1a2660ec2 | 103 | BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_POD = 5187, /**< Location Pod (Outdoor Sports Activity subtype). */ |
rgrover1 | 710:b2e1a2660ec2 | 104 | BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_AND_NAV_POD = 5188, /**< Location and Navigation Pod (Outdoor Sports Activity subtype). */ |
rgrover1 | 710:b2e1a2660ec2 | 105 | }; |
rgrover1 | 993:4d62b7967c11 | 106 | |
rgrover1 | 710:b2e1a2660ec2 | 107 | |
rgrover1 | 993:4d62b7967c11 | 108 | /*! @brief Error codes for the BLE API. */ |
rgrover1 | 710:b2e1a2660ec2 | 109 | enum ble_error_t { |
rgrover1 | 993:4d62b7967c11 | 110 | BLE_ERROR_NONE = 0, /**< No error. */ |
rgrover1 | 993:4d62b7967c11 | 111 | BLE_ERROR_BUFFER_OVERFLOW = 1, /**< The requested action would cause a buffer overflow and has been aborted. */ |
rgrover1 | 993:4d62b7967c11 | 112 | BLE_ERROR_NOT_IMPLEMENTED = 2, /**< Requested a feature that isn't yet implemented or isn't supported by the target HW. */ |
rgrover1 | 993:4d62b7967c11 | 113 | BLE_ERROR_PARAM_OUT_OF_RANGE = 3, /**< One of the supplied parameters is outside the valid range. */ |
rgrover1 | 993:4d62b7967c11 | 114 | BLE_ERROR_INVALID_PARAM = 4, /**< One of the supplied parameters is invalid. */ |
rgrover1 | 993:4d62b7967c11 | 115 | BLE_STACK_BUSY = 5, /**< The stack is busy. */ |
rgrover1 | 891:96514cb1c4c1 | 116 | BLE_ERROR_INVALID_STATE = 6, /**< Invalid state. */ |
rgrover1 | 993:4d62b7967c11 | 117 | BLE_ERROR_NO_MEM = 7, /**< Out of memory */ |
rgrover1 | 891:96514cb1c4c1 | 118 | BLE_ERROR_OPERATION_NOT_PERMITTED = 8, |
rgrover1 | 891:96514cb1c4c1 | 119 | BLE_ERROR_INITIALIZATION_INCOMPLETE = 9, |
rgrover1 | 891:96514cb1c4c1 | 120 | BLE_ERROR_ALREADY_INITIALIZED = 10, |
rgrover1 | 891:96514cb1c4c1 | 121 | BLE_ERROR_UNSPECIFIED = 11, /**< Unknown error. */ |
rgrover1 | 710:b2e1a2660ec2 | 122 | }; |
rgrover1 | 710:b2e1a2660ec2 | 123 | |
rgrover1 | 728:997ba5e7b3b6 | 124 | /** @brief Default MTU size. */ |
rgrover1 | 728:997ba5e7b3b6 | 125 | static const unsigned BLE_GATT_MTU_SIZE_DEFAULT = 23; |
rgrover1 | 728:997ba5e7b3b6 | 126 | |
rgrover1 | 737:79d95f9b93be | 127 | enum HVXType_t { |
rgrover1 | 737:79d95f9b93be | 128 | BLE_HVX_NOTIFICATION = 0x01, /**< Handle Value Notification. */ |
rgrover1 | 737:79d95f9b93be | 129 | BLE_HVX_INDICATION = 0x02, /**< Handle Value Indication. */ |
rgrover1 | 737:79d95f9b93be | 130 | }; |
rgrover1 | 737:79d95f9b93be | 131 | |
rgrover1 | 710:b2e1a2660ec2 | 132 | #ifdef __cplusplus |
rgrover1 | 710:b2e1a2660ec2 | 133 | } |
rgrover1 | 710:b2e1a2660ec2 | 134 | #endif |
rgrover1 | 710:b2e1a2660ec2 | 135 | |
rgrover1 | 710:b2e1a2660ec2 | 136 | #endif // ifndef __BLE_COMMON_H__ |