BLE_API_Tiny_BLE
Fork of BLE_API by
public/UUID.h@294:ab928e365ea1, 2015-03-02 (annotated)
- Committer:
- rgrover1
- Date:
- Mon Mar 02 11:50:47 2015 +0000
- Revision:
- 294:ab928e365ea1
- Parent:
- 293:6278354cfd98
- Child:
- 302:8f4348c2b6b5
Synchronized with git rev 48ffb7dd
Author: Jeremy Brodt
Added ble_error_t return type for onDataRead.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rgrover1 | 294:ab928e365ea1 | 1 | /* mbed Microcontroller Library |
rgrover1 | 294:ab928e365ea1 | 2 | * Copyright (c) 2006-2013 ARM Limited |
rgrover1 | 294:ab928e365ea1 | 3 | * |
rgrover1 | 294:ab928e365ea1 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
rgrover1 | 294:ab928e365ea1 | 5 | * you may not use this file except in compliance with the License. |
rgrover1 | 294:ab928e365ea1 | 6 | * You may obtain a copy of the License at |
rgrover1 | 294:ab928e365ea1 | 7 | * |
rgrover1 | 294:ab928e365ea1 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
rgrover1 | 294:ab928e365ea1 | 9 | * |
rgrover1 | 294:ab928e365ea1 | 10 | * Unless required by applicable law or agreed to in writing, software |
rgrover1 | 294:ab928e365ea1 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
rgrover1 | 294:ab928e365ea1 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
rgrover1 | 294:ab928e365ea1 | 13 | * See the License for the specific language governing permissions and |
rgrover1 | 294:ab928e365ea1 | 14 | * limitations under the License. |
rgrover1 | 294:ab928e365ea1 | 15 | */ |
rgrover1 | 294:ab928e365ea1 | 16 | |
rgrover1 | 294:ab928e365ea1 | 17 | #ifndef __UUID_H__ |
rgrover1 | 294:ab928e365ea1 | 18 | #define __UUID_H__ |
rgrover1 | 294:ab928e365ea1 | 19 | |
rgrover1 | 294:ab928e365ea1 | 20 | #include "blecommon.h" |
rgrover1 | 294:ab928e365ea1 | 21 | |
rgrover1 | 294:ab928e365ea1 | 22 | const unsigned LENGTH_OF_LONG_UUID = 16; |
rgrover1 | 294:ab928e365ea1 | 23 | typedef uint16_t ShortUUIDBytes_t; |
rgrover1 | 294:ab928e365ea1 | 24 | typedef uint8_t LongUUIDBytes_t[LENGTH_OF_LONG_UUID]; |
rgrover1 | 294:ab928e365ea1 | 25 | |
rgrover1 | 294:ab928e365ea1 | 26 | class UUID { |
rgrover1 | 294:ab928e365ea1 | 27 | public: |
rgrover1 | 294:ab928e365ea1 | 28 | enum { |
rgrover1 | 294:ab928e365ea1 | 29 | UUID_TYPE_SHORT = 0, // Short BLE UUID |
rgrover1 | 294:ab928e365ea1 | 30 | UUID_TYPE_LONG = 1 // Full 128-bit UUID |
rgrover1 | 294:ab928e365ea1 | 31 | }; |
rgrover1 | 294:ab928e365ea1 | 32 | |
rgrover1 | 294:ab928e365ea1 | 33 | public: |
rgrover1 | 294:ab928e365ea1 | 34 | UUID(const LongUUIDBytes_t); |
rgrover1 | 294:ab928e365ea1 | 35 | UUID(ShortUUIDBytes_t); |
rgrover1 | 294:ab928e365ea1 | 36 | |
rgrover1 | 294:ab928e365ea1 | 37 | public: |
rgrover1 | 294:ab928e365ea1 | 38 | uint8_t shortOrLong(void) const {return type; } |
rgrover1 | 294:ab928e365ea1 | 39 | const uint8_t *getBaseUUID(void) const {return baseUUID; } |
rgrover1 | 294:ab928e365ea1 | 40 | ShortUUIDBytes_t getShortUUID(void) const {return shortUUID;} |
rgrover1 | 294:ab928e365ea1 | 41 | |
rgrover1 | 294:ab928e365ea1 | 42 | private: |
rgrover1 | 294:ab928e365ea1 | 43 | uint8_t type; // UUID_TYPE_SHORT or UUID_TYPE_LONG |
rgrover1 | 294:ab928e365ea1 | 44 | LongUUIDBytes_t baseUUID; /* the base of the long UUID (if |
rgrover1 | 294:ab928e365ea1 | 45 | * used). Note: bytes 12 and 13 (counting from LSB) |
rgrover1 | 294:ab928e365ea1 | 46 | * are zeroed out to allow comparison with other long |
rgrover1 | 294:ab928e365ea1 | 47 | * UUIDs which differ only in the 16-bit relative |
rgrover1 | 294:ab928e365ea1 | 48 | * part.*/ |
rgrover1 | 294:ab928e365ea1 | 49 | ShortUUIDBytes_t shortUUID; // 16 bit uuid (byte 2-3 using with base) |
rgrover1 | 294:ab928e365ea1 | 50 | }; |
rgrover1 | 294:ab928e365ea1 | 51 | |
rgrover1 | 294:ab928e365ea1 | 52 | #endif // ifndef __UUID_H__ |