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