1 /* 2 * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef __UUID_H__ 18 #define __UUID_H__ 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 //#pragma pack(1) 25 26 #define BLE_BIT(n) (1UL << (n)) 27 28 typedef enum { 29 UUID_TYPE_16, 30 UUID_TYPE_32, 31 UUID_TYPE_128, 32 } uuid_type_en; 33 34 typedef struct _uuid_t { 35 uint8_t type; 36 } uuid_t; 37 38 39 struct ut_uuid_16 { 40 uuid_t uuid; 41 uint16_t val; 42 }; 43 44 struct ut_uuid_32 { 45 uuid_t uuid; 46 uint32_t val; 47 }; 48 49 struct ut_uuid_128 { 50 uuid_t uuid; 51 uint8_t val[16]; 52 }; 53 54 #define UUID16_INIT(value) \ 55 { \ 56 .uuid.type = UUID_TYPE_16, \ 57 .val = (value) \ 58 } 59 60 #define UUID32_INIT(value) \ 61 { \ 62 .uuid.type = UUID_TYPE_32, \ 63 .val = (value)\ 64 } 65 66 #define UUID128_INIT(value...) \ 67 { \ 68 .uuid.type = UUID_TYPE_128, \ 69 .val = {value},\ 70 } 71 72 #define UUID16_DECLARE(value) \ 73 ((uuid_t *) (&((struct ut_uuid_16)UUID16_INIT(value)))) 74 #define UUID32_DECLARE(value) \ 75 ((uuid_t *) (&((struct ut_uuid_32)UUID32_INIT(value)))) 76 #define UUID128_DECLARE(value...) \ 77 ((uuid_t *) (&((struct ut_uuid_128)UUID128_INIT(value)))) 78 79 #define UUID16(__u) (((struct ut_uuid_16 *)(__u))->val) 80 #define UUID32(__u) (((struct ut_uuid_32 *)(__u))->val) 81 #define UUID128(__u) (((struct ut_uuid_128 *)(__u))->val) 82 83 84 85 int uuid_compare(const uuid_t *uuid1, const uuid_t *uuid2); 86 uint8_t *get_uuid_val(uuid_t *uuid); 87 uint8_t UUID_EQUAL(uuid_t *uuid1 , uuid_t *uuid2); 88 89 #define UUID_TYPE(__u) ((__u)->type) 90 #define UUID_LEN(__u) (UUID_TYPE(__u) == UUID_TYPE_16?2: (UUID_TYPE(__u) == UUID_TYPE_32?4:16)) 91 92 /** @def UUID_GAP 93 * @brief Generic Access 94 */ 95 #define UUID_GAP UUID16_DECLARE(0x1800) 96 /** @def UUID_GATT 97 * @brief Generic Attribute 98 */ 99 #define UUID_GATT UUID16_DECLARE(0x1801) 100 /** @def UUID_CTS 101 * @brief Current Time Service 102 */ 103 #define UUID_CTS UUID16_DECLARE(0x1805) 104 /** @def UUID_DIS 105 * @brief Device Information Service 106 */ 107 #define UUID_DIS UUID16_DECLARE(0x180a) 108 /** @def UUID_HRS 109 * @brief Heart Rate Service 110 */ 111 #define UUID_HRS UUID16_DECLARE(0x180d) 112 /** @def UUID_BAS 113 * @brief Battery Service 114 */ 115 #define UUID_BAS UUID16_DECLARE(0x180f) 116 /** @def UUID_HIDS 117 * @brief HID Service 118 */ 119 #define UUID_HIDS UUID16_DECLARE(0x1812) 120 /** @def UUID_CSC 121 * @brief Cycling Speed and Cadence Service 122 */ 123 #define UUID_CSC UUID16_DECLARE(0x1816) 124 /** @def UUID_ESS 125 * @brief Environmental Sensing Service 126 */ 127 #define UUID_ESS UUID16_DECLARE(0x181a) 128 /** @def UUID_IPSS 129 * @brief IP Support Service 130 */ 131 #define UUID_IPSS UUID16_DECLARE(0x1820) 132 /** @def UUID_MESH_PROV 133 * @brief Mesh Provisioning Service 134 */ 135 #define UUID_MESH_PROV UUID16_DECLARE(0x1827) 136 /** @def UUID_MESH_PROXY 137 * @brief Mesh Proxy Service 138 */ 139 #define UUID_MESH_PROXY UUID16_DECLARE(0x1828) 140 /** @def UUID_GATT_PRIMARY 141 * @brief GATT Primary Service 142 */ 143 #define UUID_GATT_PRIMARY UUID16_DECLARE(0x2800) 144 /** @def UUID_GATT_SECONDARY 145 * @brief GATT Secondary Service 146 */ 147 #define UUID_GATT_SECONDARY UUID16_DECLARE(0x2801) 148 /** @def UUID_GATT_INCLUDE 149 * @brief GATT Include Service 150 */ 151 #define UUID_GATT_INCLUDE UUID16_DECLARE(0x2802) 152 /** @def UUID_GATT_CHRC 153 * @brief GATT Characteristic 154 */ 155 #define UUID_GATT_CHRC UUID16_DECLARE(0x2803) 156 /** @def UUID_GATT_CEP 157 * @brief GATT Characteristic Extended Properties 158 */ 159 #define UUID_GATT_CEP UUID16_DECLARE(0x2900) 160 /** @def UUID_GATT_CUD 161 * @brief GATT Characteristic User Description 162 */ 163 #define UUID_GATT_CUD UUID16_DECLARE(0x2901) 164 /** @def UUID_GATT_CCC 165 * @brief GATT Client Characteristic Configuration 166 */ 167 #define UUID_GATT_CCC UUID16_DECLARE(0x2902) 168 /** @def UUID_GATT_SCC 169 * @brief GATT Server Characteristic Configuration 170 */ 171 #define UUID_GATT_SCC UUID16_DECLARE(0x2903) 172 /** @def UUID_GATT_CPF 173 * @brief GATT Characteristic Presentation Format 174 */ 175 #define UUID_GATT_CPF UUID16_DECLARE(0x2904) 176 /** @def UUID_VALID_RANGE 177 * @brief Valid Range Descriptor 178 */ 179 #define UUID_VALID_RANGE UUID16_DECLARE(0x2906) 180 /** @def UUID_HIDS_EXT_REPORT 181 * @brief HID External Report Descriptor 182 */ 183 #define UUID_HIDS_EXT_REPORT UUID16_DECLARE(0x2907) 184 /** @def UUID_HIDS_REPORT_REF 185 * @brief HID Report Reference Descriptor 186 */ 187 #define UUID_HIDS_REPORT_REF UUID16_DECLARE(0x2908) 188 /** @def UUID_ES_CONFIGURATION 189 * @brief Environmental Sensing Configuration Descriptor 190 */ 191 #define UUID_ES_CONFIGURATION UUID16_DECLARE(0x290b) 192 /** @def UUID_ES_MEASUREMENT 193 * @brief Environmental Sensing Measurement Descriptor 194 */ 195 #define UUID_ES_MEASUREMENT UUID16_DECLARE(0x290c) 196 /** @def UUID_ES_TRIGGER_SETTING 197 * @brief Environmental Sensing Trigger Setting Descriptor 198 */ 199 #define UUID_ES_TRIGGER_SETTING UUID16_DECLARE(0x290d) 200 /** @def UUID_GAP_DEVICE_NAME 201 * @brief GAP Characteristic Device Name 202 */ 203 #define UUID_GAP_DEVICE_NAME UUID16_DECLARE(0x2a00) 204 /** @def UUID_GAP_APPEARANCE 205 * @brief GAP Characteristic Appearance 206 */ 207 #define UUID_GAP_APPEARANCE UUID16_DECLARE(0x2a01) 208 /** @def UUID_GAP_PPCP 209 * @brief GAP Characteristic Peripheral Preferred Connection Parameters 210 */ 211 #define UUID_GAP_PPCP UUID16_DECLARE(0x2a04) 212 /** @def UUID_GATT_SC 213 * @brief GATT Characteristic Service Changed 214 */ 215 #define UUID_GATT_SC UUID16_DECLARE(0x2a05) 216 /** @def UUID_BAS_BATTERY_LEVEL 217 * @brief BAS Characteristic Battery Level 218 */ 219 #define UUID_BAS_BATTERY_LEVEL UUID16_DECLARE(0x2a19) 220 /** @def UUID_HIDS_BOOT_KB_IN_REPORT 221 * @brief HID Characteristic Boot Keyboard Input Report 222 */ 223 #define UUID_HIDS_BOOT_KB_IN_REPORT UUID16_DECLARE(0x2a22) 224 /** @def UUID_DIS_SYSTEM_ID 225 * @brief DIS Characteristic System ID 226 */ 227 #define UUID_DIS_SYSTEM_ID UUID16_DECLARE(0x2a23) 228 /** @def UUID_DIS_MODEL_NUMBER 229 * @brief DIS Characteristic Model Number String 230 */ 231 #define UUID_DIS_MODEL_NUMBER UUID16_DECLARE(0x2a24) 232 /** @def UUID_DIS_SERIAL_NUMBER 233 * @brief DIS Characteristic Serial Number String 234 */ 235 #define UUID_DIS_SERIAL_NUMBER UUID16_DECLARE(0x2a25) 236 /** @def UUID_DIS_FIRMWARE_REVISION 237 * @brief DIS Characteristic Firmware Revision String 238 */ 239 #define UUID_DIS_FIRMWARE_REVISION UUID16_DECLARE(0x2a26) 240 /** @def UUID_DIS_HARDWARE_REVISION 241 * @brief DIS Characteristic Hardware Revision String 242 */ 243 #define UUID_DIS_HARDWARE_REVISION UUID16_DECLARE(0x2a27) 244 /** @def UUID_DIS_SOFTWARE_REVISION 245 * @brief DIS Characteristic Software Revision String 246 */ 247 #define UUID_DIS_SOFTWARE_REVISION UUID16_DECLARE(0x2a28) 248 /** @def UUID_DIS_MANUFACTURER_NAME 249 * @brief DIS Characteristic Manufacturer Name String 250 */ 251 #define UUID_DIS_MANUFACTURER_NAME UUID16_DECLARE(0x2a29) 252 /** @def UUID_IEEE_REGULATORY_CERTIFICATION_DATA_LIST 253 * @brief IEEE Regulatory Certification Data List characteristic UUID. 254 */ 255 #define UUID_IEEE_REGULATORY_CERTIFICATION_DATA_LIST UUID16_DECLARE(0x2a2a) 256 /** @def UUID_DIS_PNP_ID 257 * @brief DIS Characteristic PnP ID 258 */ 259 #define UUID_DIS_PNP_ID UUID16_DECLARE(0x2a50) 260 /** @def UUID_CTS_CURRENT_TIME 261 * @brief CTS Characteristic Current Time 262 */ 263 #define UUID_CTS_CURRENT_TIME UUID16_DECLARE(0x2a2b) 264 /** @def UUID_MAGN_DECLINATION 265 * @brief Magnetic Declination Characteristic 266 */ 267 #define UUID_MAGN_DECLINATION UUID16_DECLARE(0x2a2c) 268 /** @def UUID_HIDS_BOOT_KB_OUT_REPORT 269 * @brief HID Boot Keyboard Output Report Characteristic 270 */ 271 #define UUID_HIDS_BOOT_KB_OUT_REPORT UUID16_DECLARE(0x2a32) 272 /** @def UUID_HIDS_BOOT_MOUSE_IN_REPORT 273 * @brief HID Boot Mouse Input Report Characteristic 274 */ 275 #define UUID_HIDS_BOOT_MOUSE_IN_REPORT UUID16_DECLARE(0x2a33) 276 /** @def UUID_HRS_MEASUREMENT 277 * @brief HRS Characteristic Measurement Interval 278 */ 279 #define UUID_HRS_MEASUREMENT UUID16_DECLARE(0x2a37) 280 /** @def UUID_HRS_BODY_SENSOR 281 * @brief HRS Characteristic Body Sensor Location 282 */ 283 #define UUID_HRS_BODY_SENSOR UUID16_DECLARE(0x2a38) 284 /** @def UUID_HRS_CONTROL_POINT 285 * @brief HRS Characteristic Control Point 286 */ 287 #define UUID_HRS_CONTROL_POINT UUID16_DECLARE(0x2a39) 288 /** @def UUID_HIDS_INFO 289 * @brief HID Information Characteristic 290 */ 291 #define UUID_HIDS_INFO UUID16_DECLARE(0x2a4a) 292 /** @def UUID_HIDS_REPORT_MAP 293 * @brief HID Report Map Characteristic 294 */ 295 #define UUID_HIDS_REPORT_MAP UUID16_DECLARE(0x2a4b) 296 /** @def UUID_HIDS_CTRL_POINT 297 * @brief HID Control Point Characteristic 298 */ 299 #define UUID_HIDS_CTRL_POINT UUID16_DECLARE(0x2a4c) 300 /** @def UUID_HIDS_REPORT 301 * @brief HID Report Characteristic 302 */ 303 #define UUID_HIDS_REPORT UUID16_DECLARE(0x2a4d) 304 /** @def UUID_HIDS_PROTOCOL_MODE 305 * @brief HID Protocol Mode Characteristic 306 */ 307 #define UUID_HIDS_PROTOCOL_MODE UUID16_DECLARE(0x2a4e) 308 /** @def UUID_CSC_MEASUREMENT 309 * @brief CSC Measurement Characteristic 310 */ 311 #define UUID_CSC_MEASUREMENT UUID16_DECLARE(0x2a5b) 312 /** @def UUID_CSC_FEATURE 313 * @brief CSC Feature Characteristic 314 */ 315 #define UUID_CSC_FEATURE UUID16_DECLARE(0x2a5c) 316 /** @def UUID_SENSOR_LOCATION 317 * @brief Sensor Location Characteristic 318 */ 319 #define UUID_SENSOR_LOCATION UUID16_DECLARE(0x2a5d) 320 /** @def UUID_SC_CONTROL_POINT 321 * @brief SC Control Point Characteristic 322 */ 323 #define UUID_SC_CONTROL_POINT UUID16_DECLARE(0x2a55) 324 /** @def UUID_ELEVATION 325 * @brief Elevation Characteristic 326 */ 327 #define UUID_ELEVATION UUID16_DECLARE(0x2a6c) 328 /** @def UUID_PRESSURE 329 * @brief Pressure Characteristic 330 */ 331 #define UUID_PRESSURE UUID16_DECLARE(0x2a6d) 332 /** @def UUID_TEMPERATURE 333 * @brief Temperature Characteristic 334 */ 335 #define UUID_TEMPERATURE UUID16_DECLARE(0x2a6e) 336 /** @def UUID_HUMIDITY 337 * @brief Humidity Characteristic 338 */ 339 #define UUID_HUMIDITY UUID16_DECLARE(0x2a6f) 340 /** @def UUID_TRUE_WIND_SPEED 341 * @brief True Wind Speed Characteristic 342 */ 343 #define UUID_TRUE_WIND_SPEED UUID16_DECLARE(0x2a70) 344 /** @def UUID_TRUE_WIND_DIR 345 * @brief True Wind Direction Characteristic 346 */ 347 #define UUID_TRUE_WIND_DIR UUID16_DECLARE(0x2a71) 348 /** @def UUID_APPARENT_WIND_SPEED 349 * @brief Apparent Wind Speed Characteristic 350 */ 351 #define UUID_APPARENT_WIND_SPEED UUID16_DECLARE(0x2a72) 352 /** @def UUID_APPARENT_WIND_DIR 353 * @brief Apparent Wind Direction Characteristic 354 */ 355 #define UUID_APPARENT_WIND_DIR UUID16_DECLARE(0x2a73) 356 /** @def UUID_GUST_FACTOR 357 * @brief Gust Factor Characteristic 358 */ 359 #define UUID_GUST_FACTOR UUID16_DECLARE(0x2a74) 360 /** @def UUID_POLLEN_CONCENTRATION 361 * @brief Pollen Concentration Characteristic 362 */ 363 #define UUID_POLLEN_CONCENTRATION UUID16_DECLARE(0x2a75) 364 /** @def UUID_UV_INDEX 365 * @brief UV Index Characteristic 366 */ 367 #define UUID_UV_INDEX UUID16_DECLARE(0x2a76) 368 /** @def UUID_IRRADIANCE 369 * @brief Irradiance Characteristic 370 */ 371 #define UUID_IRRADIANCE UUID16_DECLARE(0x2a77) 372 /** @def UUID_RAINFALL 373 * @brief Rainfall Characteristic 374 */ 375 #define UUID_RAINFALL UUID16_DECLARE(0x2a78) 376 /** @def UUID_WIND_CHILL 377 * @brief Wind Chill Characteristic 378 */ 379 #define UUID_WIND_CHILL UUID16_DECLARE(0x2a79) 380 /** @def UUID_HEAT_INDEX 381 * @brief Heat Index Characteristic 382 */ 383 #define UUID_HEAT_INDEX UUID16_DECLARE(0x2a7a) 384 /** @def UUID_DEW_POINT 385 * @brief Dew Point Characteristic 386 */ 387 #define UUID_DEW_POINT UUID16_DECLARE(0x2a7b) 388 /** @def UUID_DESC_VALUE_CHANGED 389 * @brief Descriptor Value Changed Characteristic 390 */ 391 #define UUID_DESC_VALUE_CHANGED UUID16_DECLARE(0x2a7d) 392 /** @def UUID_MAGN_FLUX_DENSITY_2D 393 * @brief Magnetic Flux Density - 2D Characteristic 394 */ 395 #define UUID_MAGN_FLUX_DENSITY_2D UUID16_DECLARE(0x2aa0) 396 /** @def UUID_MAGN_FLUX_DENSITY_3D 397 * @brief Magnetic Flux Density - 3D Characteristic 398 */ 399 #define UUID_MAGN_FLUX_DENSITY_3D UUID16_DECLARE(0x2aa1) 400 /** @def UUID_BAR_PRESSURE_TREND 401 * @brief Barometric Pressure Trend Characteristic 402 */ 403 #define UUID_BAR_PRESSURE_TREND UUID16_DECLARE(0x2aa3) 404 /** @def UUID_CENTRAL_ADDR_RES 405 * @brief Central Address Resolution Characteristic 406 */ 407 #define UUID_CENTRAL_ADDR_RES UUID16_DECLARE(0x2aa6) 408 /** @def UUID_MESH_PROV_DATA_IN 409 * @brief Mesh Provisioning Data In 410 */ 411 #define UUID_MESH_PROV_DATA_IN UUID16_DECLARE(0x2adb) 412 /** @def UUID_MESH_PROV_DATA_OUT 413 * @brief Mesh Provisioning Data Out 414 */ 415 #define UUID_MESH_PROV_DATA_OUT UUID16_DECLARE(0x2adc) 416 /** @def UUID_MESH_PROXY_DATA_IN 417 * @brief Mesh Proxy Data In 418 */ 419 #define UUID_MESH_PROXY_DATA_IN UUID16_DECLARE(0x2add) 420 /** @def UUID_MESH_PROXY_DATA_OUT 421 * @brief Mesh Proxy Data Out 422 */ 423 #define UUID_MESH_PROXY_DATA_OUT UUID16_DECLARE(0x2ade) 424 425 /* 426 * Protocol UUIDs 427 */ 428 #define UUID_SDP UUID16_DECLARE(0x0001) 429 #define UUID_UDP UUID16_DECLARE(0x0002) 430 #define UUID_RFCOMM UUID16_DECLARE(0x0003) 431 #define UUID_TCP UUID16_DECLARE(0x0004) 432 #define UUID_TCS_BIN UUID16_DECLARE(0x0005) 433 #define UUID_TCS_AT UUID16_DECLARE(0x0006) 434 #define UUID_ATT UUID16_DECLARE(0x0007) 435 #define UUID_OBEX UUID16_DECLARE(0x0008) 436 #define UUID_IP UUID16_DECLARE(0x0009) 437 #define UUID_FTP UUID16_DECLARE(0x000a) 438 #define UUID_HTTP UUID16_DECLARE(0x000c) 439 #define UUID_BNEP UUID16_DECLARE(0x000f) 440 #define UUID_UPNP UUID16_DECLARE(0x0010) 441 #define UUID_HIDP UUID16_DECLARE(0x0011) 442 #define UUID_HCRP_CTRL UUID16_DECLARE(0x0012) 443 #define UUID_HCRP_DATA UUID16_DECLARE(0x0014) 444 #define UUID_HCRP_NOTE UUID16_DECLARE(0x0016) 445 #define UUID_AVCTP UUID16_DECLARE(0x0017) 446 #define UUID_AVDTP UUID16_DECLARE(0x0019) 447 #define UUID_CMTP UUID16_DECLARE(0x001b) 448 #define UUID_UDI UUID16_DECLARE(0x001d) 449 #define UUID_MCAP_CTRL UUID16_DECLARE(0x001e) 450 #define UUID_MCAP_DATA UUID16_DECLARE(0x001f) 451 #define UUID_L2CAP UUID16_DECLARE(0x0100) 452 453 #ifdef __cplusplus 454 } 455 #endif 456 457 #endif /* __UUID_H__ */ 458 459