High level Bluetooth Low Energy API and radio abstraction layer

Dependencies:   nRF51822

Dependents:   LinkNode_LIS3DH

Fork of BLE_API by Bluetooth Low Energy

Committer:
Rohit Grover
Date:
Fri May 30 09:58:35 2014 +0100
Revision:
60:de30b62ab8c1
Parent:
56:537b8e8f5d60
Child:
61:119faa0dfeee
UUID constructors should zero out relative part of baseUUID

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ktownsend 27:4a83843f04b0 1 /* mbed Microcontroller Library
ktownsend 27:4a83843f04b0 2 * Copyright (c) 2006-2013 ARM Limited
ktownsend 27:4a83843f04b0 3 *
ktownsend 27:4a83843f04b0 4 * Licensed under the Apache License, Version 2.0 (the "License");
ktownsend 27:4a83843f04b0 5 * you may not use this file except in compliance with the License.
ktownsend 27:4a83843f04b0 6 * You may obtain a copy of the License at
ktownsend 27:4a83843f04b0 7 *
ktownsend 27:4a83843f04b0 8 * http://www.apache.org/licenses/LICENSE-2.0
ktownsend 27:4a83843f04b0 9 *
ktownsend 27:4a83843f04b0 10 * Unless required by applicable law or agreed to in writing, software
ktownsend 27:4a83843f04b0 11 * distributed under the License is distributed on an "AS IS" BASIS,
ktownsend 27:4a83843f04b0 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ktownsend 27:4a83843f04b0 13 * See the License for the specific language governing permissions and
ktownsend 27:4a83843f04b0 14 * limitations under the License.
ktownsend 27:4a83843f04b0 15 */
Rohit Grover 34:da2ea8cd6216 16
ktownsend 27:4a83843f04b0 17
ktownsend 0:ace2e8d3ce79 18 #ifndef __UUID_H__
ktownsend 0:ace2e8d3ce79 19 #define __UUID_H__
ktownsend 0:ace2e8d3ce79 20
ktownsend 0:ace2e8d3ce79 21 #include "blecommon.h"
ktownsend 0:ace2e8d3ce79 22
ktownsend 0:ace2e8d3ce79 23 class UUID
ktownsend 0:ace2e8d3ce79 24 {
ktownsend 0:ace2e8d3ce79 25 public:
Rohit Grover 50:9078969e80e4 26 enum {
ktownsend 0:ace2e8d3ce79 27 UUID_TYPE_SHORT = 0, // Short BLE UUID
ktownsend 0:ace2e8d3ce79 28 UUID_TYPE_LONG = 1 // Full 128-bit UUID
ktownsend 0:ace2e8d3ce79 29 };
Rohit Grover 34:da2ea8cd6216 30
Rohit Grover 50:9078969e80e4 31 static const unsigned LENGTH_OF_LONG_UUID = 16;
Rohit Grover 50:9078969e80e4 32
Rohit Grover 50:9078969e80e4 33 public:
Rohit Grover 60:de30b62ab8c1 34 UUID(const uint8_t longUUID[LENGTH_OF_LONG_UUID]);
Rohit Grover 60:de30b62ab8c1 35 UUID(uint16_t shortUUID);
ktownsend 0:ace2e8d3ce79 36 virtual ~UUID(void);
Rohit Grover 34:da2ea8cd6216 37
Rohit Grover 50:9078969e80e4 38 public:
Rohit Grover 56:537b8e8f5d60 39 uint8_t shortOrLong(void) const {
Rohit Grover 56:537b8e8f5d60 40 return type;
Rohit Grover 56:537b8e8f5d60 41 }
Rohit Grover 56:537b8e8f5d60 42 const uint8_t* getBaseUUID(void) const {
Rohit Grover 60:de30b62ab8c1 43 return baseUUID;
Rohit Grover 56:537b8e8f5d60 44 }
Rohit Grover 56:537b8e8f5d60 45 uint16_t get16BitUUID(void) const {
Rohit Grover 56:537b8e8f5d60 46 return value;
Rohit Grover 56:537b8e8f5d60 47 }
Rohit Grover 56:537b8e8f5d60 48
Rohit Grover 56:537b8e8f5d60 49 private:
Rohit Grover 34:da2ea8cd6216 50 uint8_t type; // UUID_TYPE_SHORT or UUID_TYPE_LONG
Rohit Grover 60:de30b62ab8c1 51 uint8_t baseUUID[LENGTH_OF_LONG_UUID]; /* the base of the long UUID (if
Rohit Grover 60:de30b62ab8c1 52 * used). Note: bytes 12 and 13 (counting from LSB)
Rohit Grover 60:de30b62ab8c1 53 * are zeroed out to allow comparison with other long
Rohit Grover 60:de30b62ab8c1 54 * UUIDs which differ only in the 16-bit relative
Rohit Grover 60:de30b62ab8c1 55 * part.*/
Rohit Grover 34:da2ea8cd6216 56 uint16_t value; // 16 bit uuid (byte 2-3 using with base)
ktownsend 0:ace2e8d3ce79 57 };
ktownsend 0:ace2e8d3ce79 58
Rohit Grover 34:da2ea8cd6216 59 #endif // ifndef __UUID_H__