Marco Zecchini
/
Example_RTOS
Rtos API example
mbed-os/features/FEATURE_BLE/ble/blecommon.h@0:9fca2b23d0ba, 2019-02-23 (annotated)
- Committer:
- marcozecchini
- Date:
- Sat Feb 23 12:13:36 2019 +0000
- Revision:
- 0:9fca2b23d0ba
final commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
marcozecchini | 0:9fca2b23d0ba | 1 | /* mbed Microcontroller Library |
marcozecchini | 0:9fca2b23d0ba | 2 | * Copyright (c) 2006-2013 ARM Limited |
marcozecchini | 0:9fca2b23d0ba | 3 | * |
marcozecchini | 0:9fca2b23d0ba | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
marcozecchini | 0:9fca2b23d0ba | 5 | * you may not use this file except in compliance with the License. |
marcozecchini | 0:9fca2b23d0ba | 6 | * You may obtain a copy of the License at |
marcozecchini | 0:9fca2b23d0ba | 7 | * |
marcozecchini | 0:9fca2b23d0ba | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
marcozecchini | 0:9fca2b23d0ba | 9 | * |
marcozecchini | 0:9fca2b23d0ba | 10 | * Unless required by applicable law or agreed to in writing, software |
marcozecchini | 0:9fca2b23d0ba | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
marcozecchini | 0:9fca2b23d0ba | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
marcozecchini | 0:9fca2b23d0ba | 13 | * See the License for the specific language governing permissions and |
marcozecchini | 0:9fca2b23d0ba | 14 | * limitations under the License. |
marcozecchini | 0:9fca2b23d0ba | 15 | */ |
marcozecchini | 0:9fca2b23d0ba | 16 | |
marcozecchini | 0:9fca2b23d0ba | 17 | #ifndef MBED_BLE_COMMON_H__ |
marcozecchini | 0:9fca2b23d0ba | 18 | #define MBED_BLE_COMMON_H__ |
marcozecchini | 0:9fca2b23d0ba | 19 | |
marcozecchini | 0:9fca2b23d0ba | 20 | #ifdef __cplusplus |
marcozecchini | 0:9fca2b23d0ba | 21 | extern "C" { |
marcozecchini | 0:9fca2b23d0ba | 22 | #endif |
marcozecchini | 0:9fca2b23d0ba | 23 | |
marcozecchini | 0:9fca2b23d0ba | 24 | /** |
marcozecchini | 0:9fca2b23d0ba | 25 | * @addtogroup ble |
marcozecchini | 0:9fca2b23d0ba | 26 | * @{ |
marcozecchini | 0:9fca2b23d0ba | 27 | * @addtogroup common |
marcozecchini | 0:9fca2b23d0ba | 28 | * @{ |
marcozecchini | 0:9fca2b23d0ba | 29 | */ |
marcozecchini | 0:9fca2b23d0ba | 30 | |
marcozecchini | 0:9fca2b23d0ba | 31 | /** |
marcozecchini | 0:9fca2b23d0ba | 32 | * Assigned values for BLE UUIDs. |
marcozecchini | 0:9fca2b23d0ba | 33 | */ |
marcozecchini | 0:9fca2b23d0ba | 34 | enum { |
marcozecchini | 0:9fca2b23d0ba | 35 | /** |
marcozecchini | 0:9fca2b23d0ba | 36 | * Reserved UUID. |
marcozecchini | 0:9fca2b23d0ba | 37 | */ |
marcozecchini | 0:9fca2b23d0ba | 38 | BLE_UUID_UNKNOWN = 0x0000, |
marcozecchini | 0:9fca2b23d0ba | 39 | |
marcozecchini | 0:9fca2b23d0ba | 40 | /** |
marcozecchini | 0:9fca2b23d0ba | 41 | * Primary Service. |
marcozecchini | 0:9fca2b23d0ba | 42 | */ |
marcozecchini | 0:9fca2b23d0ba | 43 | BLE_UUID_SERVICE_PRIMARY = 0x2800, |
marcozecchini | 0:9fca2b23d0ba | 44 | |
marcozecchini | 0:9fca2b23d0ba | 45 | /** |
marcozecchini | 0:9fca2b23d0ba | 46 | * Secondary Service. |
marcozecchini | 0:9fca2b23d0ba | 47 | */ |
marcozecchini | 0:9fca2b23d0ba | 48 | BLE_UUID_SERVICE_SECONDARY = 0x2801, |
marcozecchini | 0:9fca2b23d0ba | 49 | |
marcozecchini | 0:9fca2b23d0ba | 50 | /** |
marcozecchini | 0:9fca2b23d0ba | 51 | * Included service. |
marcozecchini | 0:9fca2b23d0ba | 52 | */ |
marcozecchini | 0:9fca2b23d0ba | 53 | BLE_UUID_SERVICE_INCLUDE = 0x2802, |
marcozecchini | 0:9fca2b23d0ba | 54 | |
marcozecchini | 0:9fca2b23d0ba | 55 | /** |
marcozecchini | 0:9fca2b23d0ba | 56 | * Characteristic. |
marcozecchini | 0:9fca2b23d0ba | 57 | */ |
marcozecchini | 0:9fca2b23d0ba | 58 | BLE_UUID_CHARACTERISTIC = 0x2803, |
marcozecchini | 0:9fca2b23d0ba | 59 | |
marcozecchini | 0:9fca2b23d0ba | 60 | /** |
marcozecchini | 0:9fca2b23d0ba | 61 | * Characteristic Extended Properties Descriptor. |
marcozecchini | 0:9fca2b23d0ba | 62 | */ |
marcozecchini | 0:9fca2b23d0ba | 63 | BLE_UUID_DESCRIPTOR_CHAR_EXT_PROP = 0x2900, |
marcozecchini | 0:9fca2b23d0ba | 64 | |
marcozecchini | 0:9fca2b23d0ba | 65 | /** |
marcozecchini | 0:9fca2b23d0ba | 66 | * Characteristic User Description Descriptor. |
marcozecchini | 0:9fca2b23d0ba | 67 | */ |
marcozecchini | 0:9fca2b23d0ba | 68 | BLE_UUID_DESCRIPTOR_CHAR_USER_DESC = 0x2901, |
marcozecchini | 0:9fca2b23d0ba | 69 | |
marcozecchini | 0:9fca2b23d0ba | 70 | /** |
marcozecchini | 0:9fca2b23d0ba | 71 | * Client Characteristic Configuration Descriptor. |
marcozecchini | 0:9fca2b23d0ba | 72 | */ |
marcozecchini | 0:9fca2b23d0ba | 73 | BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG = 0x2902, |
marcozecchini | 0:9fca2b23d0ba | 74 | |
marcozecchini | 0:9fca2b23d0ba | 75 | /** |
marcozecchini | 0:9fca2b23d0ba | 76 | * Server Characteristic Configuration Descriptor. |
marcozecchini | 0:9fca2b23d0ba | 77 | */ |
marcozecchini | 0:9fca2b23d0ba | 78 | BLE_UUID_DESCRIPTOR_SERVER_CHAR_CONFIG = 0x2903, |
marcozecchini | 0:9fca2b23d0ba | 79 | |
marcozecchini | 0:9fca2b23d0ba | 80 | /** |
marcozecchini | 0:9fca2b23d0ba | 81 | * Characteristic Presentation Format Descriptor. |
marcozecchini | 0:9fca2b23d0ba | 82 | */ |
marcozecchini | 0:9fca2b23d0ba | 83 | BLE_UUID_DESCRIPTOR_CHAR_PRESENTATION_FORMAT = 0x2904, |
marcozecchini | 0:9fca2b23d0ba | 84 | |
marcozecchini | 0:9fca2b23d0ba | 85 | /** |
marcozecchini | 0:9fca2b23d0ba | 86 | * Characteristic Aggregate Format Descriptor. |
marcozecchini | 0:9fca2b23d0ba | 87 | */ |
marcozecchini | 0:9fca2b23d0ba | 88 | BLE_UUID_DESCRIPTOR_CHAR_AGGREGATE_FORMAT = 0x2905, |
marcozecchini | 0:9fca2b23d0ba | 89 | |
marcozecchini | 0:9fca2b23d0ba | 90 | /* GATT specific UUIDs */ |
marcozecchini | 0:9fca2b23d0ba | 91 | /** |
marcozecchini | 0:9fca2b23d0ba | 92 | * Generic Attribute Profile. |
marcozecchini | 0:9fca2b23d0ba | 93 | */ |
marcozecchini | 0:9fca2b23d0ba | 94 | BLE_UUID_GATT = 0x1801, |
marcozecchini | 0:9fca2b23d0ba | 95 | |
marcozecchini | 0:9fca2b23d0ba | 96 | /** |
marcozecchini | 0:9fca2b23d0ba | 97 | * Service Changed Characteristic. |
marcozecchini | 0:9fca2b23d0ba | 98 | */ |
marcozecchini | 0:9fca2b23d0ba | 99 | BLE_UUID_GATT_CHARACTERISTIC_SERVICE_CHANGED = 0x2A05, |
marcozecchini | 0:9fca2b23d0ba | 100 | |
marcozecchini | 0:9fca2b23d0ba | 101 | /* GAP specific UUIDs */ |
marcozecchini | 0:9fca2b23d0ba | 102 | |
marcozecchini | 0:9fca2b23d0ba | 103 | /** |
marcozecchini | 0:9fca2b23d0ba | 104 | * Generic Access Profile. |
marcozecchini | 0:9fca2b23d0ba | 105 | */ |
marcozecchini | 0:9fca2b23d0ba | 106 | BLE_UUID_GAP = 0x1800, |
marcozecchini | 0:9fca2b23d0ba | 107 | |
marcozecchini | 0:9fca2b23d0ba | 108 | /** |
marcozecchini | 0:9fca2b23d0ba | 109 | * Device Name Characteristic. |
marcozecchini | 0:9fca2b23d0ba | 110 | */ |
marcozecchini | 0:9fca2b23d0ba | 111 | BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME = 0x2A00, |
marcozecchini | 0:9fca2b23d0ba | 112 | |
marcozecchini | 0:9fca2b23d0ba | 113 | /** |
marcozecchini | 0:9fca2b23d0ba | 114 | * Appearance Characteristic. |
marcozecchini | 0:9fca2b23d0ba | 115 | */ |
marcozecchini | 0:9fca2b23d0ba | 116 | BLE_UUID_GAP_CHARACTERISTIC_APPEARANCE = 0x2A01, |
marcozecchini | 0:9fca2b23d0ba | 117 | |
marcozecchini | 0:9fca2b23d0ba | 118 | /** |
marcozecchini | 0:9fca2b23d0ba | 119 | * Peripheral Privacy Flag Characteristic. |
marcozecchini | 0:9fca2b23d0ba | 120 | */ |
marcozecchini | 0:9fca2b23d0ba | 121 | BLE_UUID_GAP_CHARACTERISTIC_PPF = 0x2A02, |
marcozecchini | 0:9fca2b23d0ba | 122 | |
marcozecchini | 0:9fca2b23d0ba | 123 | /** |
marcozecchini | 0:9fca2b23d0ba | 124 | * Reconnection Address Characteristic. |
marcozecchini | 0:9fca2b23d0ba | 125 | */ |
marcozecchini | 0:9fca2b23d0ba | 126 | BLE_UUID_GAP_CHARACTERISTIC_RECONN_ADDR = 0x2A03, |
marcozecchini | 0:9fca2b23d0ba | 127 | |
marcozecchini | 0:9fca2b23d0ba | 128 | /** |
marcozecchini | 0:9fca2b23d0ba | 129 | * Peripheral Preferred Connection Parameters Characteristic. |
marcozecchini | 0:9fca2b23d0ba | 130 | */ |
marcozecchini | 0:9fca2b23d0ba | 131 | BLE_UUID_GAP_CHARACTERISTIC_PPCP = 0x2A04, |
marcozecchini | 0:9fca2b23d0ba | 132 | }; |
marcozecchini | 0:9fca2b23d0ba | 133 | |
marcozecchini | 0:9fca2b23d0ba | 134 | /** |
marcozecchini | 0:9fca2b23d0ba | 135 | * Error codes for the BLE API. |
marcozecchini | 0:9fca2b23d0ba | 136 | * |
marcozecchini | 0:9fca2b23d0ba | 137 | * The value 0 means that no error was reported; therefore, it allows an API |
marcozecchini | 0:9fca2b23d0ba | 138 | * user to cleanly test for errors. |
marcozecchini | 0:9fca2b23d0ba | 139 | * |
marcozecchini | 0:9fca2b23d0ba | 140 | * @code |
marcozecchini | 0:9fca2b23d0ba | 141 | * ble_error_t error = some_ble_api_function(); |
marcozecchini | 0:9fca2b23d0ba | 142 | * if (error) { |
marcozecchini | 0:9fca2b23d0ba | 143 | * // handle the error |
marcozecchini | 0:9fca2b23d0ba | 144 | * } |
marcozecchini | 0:9fca2b23d0ba | 145 | * @endcode |
marcozecchini | 0:9fca2b23d0ba | 146 | */ |
marcozecchini | 0:9fca2b23d0ba | 147 | enum ble_error_t { |
marcozecchini | 0:9fca2b23d0ba | 148 | /** |
marcozecchini | 0:9fca2b23d0ba | 149 | * No error. |
marcozecchini | 0:9fca2b23d0ba | 150 | */ |
marcozecchini | 0:9fca2b23d0ba | 151 | BLE_ERROR_NONE = 0, |
marcozecchini | 0:9fca2b23d0ba | 152 | |
marcozecchini | 0:9fca2b23d0ba | 153 | /** |
marcozecchini | 0:9fca2b23d0ba | 154 | * The requested action would cause a buffer overflow and has been aborted. |
marcozecchini | 0:9fca2b23d0ba | 155 | */ |
marcozecchini | 0:9fca2b23d0ba | 156 | BLE_ERROR_BUFFER_OVERFLOW = 1, |
marcozecchini | 0:9fca2b23d0ba | 157 | |
marcozecchini | 0:9fca2b23d0ba | 158 | /** |
marcozecchini | 0:9fca2b23d0ba | 159 | * Requested a feature that isn't yet implemented or isn't supported by the |
marcozecchini | 0:9fca2b23d0ba | 160 | * target HW. |
marcozecchini | 0:9fca2b23d0ba | 161 | */ |
marcozecchini | 0:9fca2b23d0ba | 162 | BLE_ERROR_NOT_IMPLEMENTED = 2, |
marcozecchini | 0:9fca2b23d0ba | 163 | |
marcozecchini | 0:9fca2b23d0ba | 164 | /** |
marcozecchini | 0:9fca2b23d0ba | 165 | * One of the supplied parameters is outside the valid range. |
marcozecchini | 0:9fca2b23d0ba | 166 | */ |
marcozecchini | 0:9fca2b23d0ba | 167 | BLE_ERROR_PARAM_OUT_OF_RANGE = 3, |
marcozecchini | 0:9fca2b23d0ba | 168 | |
marcozecchini | 0:9fca2b23d0ba | 169 | /** |
marcozecchini | 0:9fca2b23d0ba | 170 | * One of the supplied parameters is invalid. |
marcozecchini | 0:9fca2b23d0ba | 171 | */ |
marcozecchini | 0:9fca2b23d0ba | 172 | BLE_ERROR_INVALID_PARAM = 4, |
marcozecchini | 0:9fca2b23d0ba | 173 | |
marcozecchini | 0:9fca2b23d0ba | 174 | /** |
marcozecchini | 0:9fca2b23d0ba | 175 | * The stack is busy. |
marcozecchini | 0:9fca2b23d0ba | 176 | */ |
marcozecchini | 0:9fca2b23d0ba | 177 | BLE_STACK_BUSY = 5, |
marcozecchini | 0:9fca2b23d0ba | 178 | |
marcozecchini | 0:9fca2b23d0ba | 179 | /** |
marcozecchini | 0:9fca2b23d0ba | 180 | * Invalid state. |
marcozecchini | 0:9fca2b23d0ba | 181 | */ |
marcozecchini | 0:9fca2b23d0ba | 182 | BLE_ERROR_INVALID_STATE = 6, |
marcozecchini | 0:9fca2b23d0ba | 183 | |
marcozecchini | 0:9fca2b23d0ba | 184 | /** |
marcozecchini | 0:9fca2b23d0ba | 185 | * Out of memory. |
marcozecchini | 0:9fca2b23d0ba | 186 | */ |
marcozecchini | 0:9fca2b23d0ba | 187 | BLE_ERROR_NO_MEM = 7, |
marcozecchini | 0:9fca2b23d0ba | 188 | |
marcozecchini | 0:9fca2b23d0ba | 189 | /** |
marcozecchini | 0:9fca2b23d0ba | 190 | * The operation requested is not permitted. |
marcozecchini | 0:9fca2b23d0ba | 191 | */ |
marcozecchini | 0:9fca2b23d0ba | 192 | BLE_ERROR_OPERATION_NOT_PERMITTED = 8, |
marcozecchini | 0:9fca2b23d0ba | 193 | |
marcozecchini | 0:9fca2b23d0ba | 194 | /** |
marcozecchini | 0:9fca2b23d0ba | 195 | * The BLE subsystem has not completed its initialization. |
marcozecchini | 0:9fca2b23d0ba | 196 | */ |
marcozecchini | 0:9fca2b23d0ba | 197 | BLE_ERROR_INITIALIZATION_INCOMPLETE = 9, |
marcozecchini | 0:9fca2b23d0ba | 198 | |
marcozecchini | 0:9fca2b23d0ba | 199 | /** |
marcozecchini | 0:9fca2b23d0ba | 200 | * The BLE system has already been initialized. |
marcozecchini | 0:9fca2b23d0ba | 201 | */ |
marcozecchini | 0:9fca2b23d0ba | 202 | BLE_ERROR_ALREADY_INITIALIZED = 10, |
marcozecchini | 0:9fca2b23d0ba | 203 | |
marcozecchini | 0:9fca2b23d0ba | 204 | /** |
marcozecchini | 0:9fca2b23d0ba | 205 | * Unknown error. |
marcozecchini | 0:9fca2b23d0ba | 206 | */ |
marcozecchini | 0:9fca2b23d0ba | 207 | BLE_ERROR_UNSPECIFIED = 11, |
marcozecchini | 0:9fca2b23d0ba | 208 | |
marcozecchini | 0:9fca2b23d0ba | 209 | /** |
marcozecchini | 0:9fca2b23d0ba | 210 | * The platform-specific stack failed. |
marcozecchini | 0:9fca2b23d0ba | 211 | */ |
marcozecchini | 0:9fca2b23d0ba | 212 | BLE_ERROR_INTERNAL_STACK_FAILURE = 12, |
marcozecchini | 0:9fca2b23d0ba | 213 | }; |
marcozecchini | 0:9fca2b23d0ba | 214 | |
marcozecchini | 0:9fca2b23d0ba | 215 | /** |
marcozecchini | 0:9fca2b23d0ba | 216 | * Default MTU size. |
marcozecchini | 0:9fca2b23d0ba | 217 | */ |
marcozecchini | 0:9fca2b23d0ba | 218 | static const unsigned BLE_GATT_MTU_SIZE_DEFAULT = 23; |
marcozecchini | 0:9fca2b23d0ba | 219 | |
marcozecchini | 0:9fca2b23d0ba | 220 | /** |
marcozecchini | 0:9fca2b23d0ba | 221 | * Handle Value Notification/Indication event. |
marcozecchini | 0:9fca2b23d0ba | 222 | * |
marcozecchini | 0:9fca2b23d0ba | 223 | * Emmitted when a notification or indication has been received from a GATT |
marcozecchini | 0:9fca2b23d0ba | 224 | * server. |
marcozecchini | 0:9fca2b23d0ba | 225 | */ |
marcozecchini | 0:9fca2b23d0ba | 226 | enum HVXType_t { |
marcozecchini | 0:9fca2b23d0ba | 227 | /** |
marcozecchini | 0:9fca2b23d0ba | 228 | * Handle Value Notification. |
marcozecchini | 0:9fca2b23d0ba | 229 | */ |
marcozecchini | 0:9fca2b23d0ba | 230 | BLE_HVX_NOTIFICATION = 0x01, |
marcozecchini | 0:9fca2b23d0ba | 231 | |
marcozecchini | 0:9fca2b23d0ba | 232 | /** |
marcozecchini | 0:9fca2b23d0ba | 233 | * Handle Value Indication. |
marcozecchini | 0:9fca2b23d0ba | 234 | */ |
marcozecchini | 0:9fca2b23d0ba | 235 | BLE_HVX_INDICATION = 0x02, |
marcozecchini | 0:9fca2b23d0ba | 236 | }; |
marcozecchini | 0:9fca2b23d0ba | 237 | |
marcozecchini | 0:9fca2b23d0ba | 238 | /** |
marcozecchini | 0:9fca2b23d0ba | 239 | * @} |
marcozecchini | 0:9fca2b23d0ba | 240 | * @} |
marcozecchini | 0:9fca2b23d0ba | 241 | */ |
marcozecchini | 0:9fca2b23d0ba | 242 | |
marcozecchini | 0:9fca2b23d0ba | 243 | #ifdef __cplusplus |
marcozecchini | 0:9fca2b23d0ba | 244 | } |
marcozecchini | 0:9fca2b23d0ba | 245 | #endif |
marcozecchini | 0:9fca2b23d0ba | 246 | |
marcozecchini | 0:9fca2b23d0ba | 247 | #endif // ifndef MBED_BLE_COMMON_H__ |