BLE_API_Tiny_BLE
Fork of BLE_API by
public/UUID.h@106:a20be740075d, 2014-07-23 (annotated)
- Committer:
- Rohit Grover
- Date:
- Wed Jul 23 15:09:23 2014 +0100
- Revision:
- 106:a20be740075d
- Child:
- 116:ca826083980e
initial re-organization of BLE_API directory structure
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rohit Grover |
106:a20be740075d | 1 | /* mbed Microcontroller Library |
Rohit Grover |
106:a20be740075d | 2 | * Copyright (c) 2006-2013 ARM Limited |
Rohit Grover |
106:a20be740075d | 3 | * |
Rohit Grover |
106:a20be740075d | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Rohit Grover |
106:a20be740075d | 5 | * you may not use this file except in compliance with the License. |
Rohit Grover |
106:a20be740075d | 6 | * You may obtain a copy of the License at |
Rohit Grover |
106:a20be740075d | 7 | * |
Rohit Grover |
106:a20be740075d | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Rohit Grover |
106:a20be740075d | 9 | * |
Rohit Grover |
106:a20be740075d | 10 | * Unless required by applicable law or agreed to in writing, software |
Rohit Grover |
106:a20be740075d | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
Rohit Grover |
106:a20be740075d | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Rohit Grover |
106:a20be740075d | 13 | * See the License for the specific language governing permissions and |
Rohit Grover |
106:a20be740075d | 14 | * limitations under the License. |
Rohit Grover |
106:a20be740075d | 15 | */ |
Rohit Grover |
106:a20be740075d | 16 | |
Rohit Grover |
106:a20be740075d | 17 | |
Rohit Grover |
106:a20be740075d | 18 | #ifndef __UUID_H__ |
Rohit Grover |
106:a20be740075d | 19 | #define __UUID_H__ |
Rohit Grover |
106:a20be740075d | 20 | |
Rohit Grover |
106:a20be740075d | 21 | #include "blecommon.h" |
Rohit Grover |
106:a20be740075d | 22 | |
Rohit Grover |
106:a20be740075d | 23 | const unsigned LENGTH_OF_LONG_UUID = 16; |
Rohit Grover |
106:a20be740075d | 24 | typedef uint16_t ShortUUID_t; |
Rohit Grover |
106:a20be740075d | 25 | typedef uint8_t LongUUID_t[LENGTH_OF_LONG_UUID]; |
Rohit Grover |
106:a20be740075d | 26 | |
Rohit Grover |
106:a20be740075d | 27 | class UUID |
Rohit Grover |
106:a20be740075d | 28 | { |
Rohit Grover |
106:a20be740075d | 29 | public: |
Rohit Grover |
106:a20be740075d | 30 | enum { |
Rohit Grover |
106:a20be740075d | 31 | UUID_TYPE_SHORT = 0, // Short BLE UUID |
Rohit Grover |
106:a20be740075d | 32 | UUID_TYPE_LONG = 1 // Full 128-bit UUID |
Rohit Grover |
106:a20be740075d | 33 | }; |
Rohit Grover |
106:a20be740075d | 34 | |
Rohit Grover |
106:a20be740075d | 35 | public: |
Rohit Grover |
106:a20be740075d | 36 | UUID(const LongUUID_t); |
Rohit Grover |
106:a20be740075d | 37 | UUID(ShortUUID_t); |
Rohit Grover |
106:a20be740075d | 38 | virtual ~UUID(void); |
Rohit Grover |
106:a20be740075d | 39 | |
Rohit Grover |
106:a20be740075d | 40 | public: |
Rohit Grover |
106:a20be740075d | 41 | uint8_t shortOrLong(void) const { |
Rohit Grover |
106:a20be740075d | 42 | return type; |
Rohit Grover |
106:a20be740075d | 43 | } |
Rohit Grover |
106:a20be740075d | 44 | const uint8_t* getBaseUUID(void) const { |
Rohit Grover |
106:a20be740075d | 45 | return baseUUID; |
Rohit Grover |
106:a20be740075d | 46 | } |
Rohit Grover |
106:a20be740075d | 47 | ShortUUID_t getShortUUID(void) const { |
Rohit Grover |
106:a20be740075d | 48 | return shortUUID; |
Rohit Grover |
106:a20be740075d | 49 | } |
Rohit Grover |
106:a20be740075d | 50 | |
Rohit Grover |
106:a20be740075d | 51 | private: |
Rohit Grover |
106:a20be740075d | 52 | uint8_t type; // UUID_TYPE_SHORT or UUID_TYPE_LONG |
Rohit Grover |
106:a20be740075d | 53 | LongUUID_t baseUUID; /* the base of the long UUID (if |
Rohit Grover |
106:a20be740075d | 54 | * used). Note: bytes 12 and 13 (counting from LSB) |
Rohit Grover |
106:a20be740075d | 55 | * are zeroed out to allow comparison with other long |
Rohit Grover |
106:a20be740075d | 56 | * UUIDs which differ only in the 16-bit relative |
Rohit Grover |
106:a20be740075d | 57 | * part.*/ |
Rohit Grover |
106:a20be740075d | 58 | ShortUUID_t shortUUID; // 16 bit uuid (byte 2-3 using with base) |
Rohit Grover |
106:a20be740075d | 59 | }; |
Rohit Grover |
106:a20be740075d | 60 | |
Rohit Grover |
106:a20be740075d | 61 | #endif // ifndef __UUID_H__ |