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:
Thu Jun 05 08:48:51 2014 +0100
Revision:
67:0fac4e99f29b
Parent:
61:119faa0dfeee
Child:
68:dcadab8a56dd
switch to using LongUUID_t and ShortUUID_t

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
Rohit Grover 67:0fac4e99f29b 23 const unsigned LENGTH_OF_LONG_UUID = 16;
Rohit Grover 67:0fac4e99f29b 24 typedef uint16_t ShortUUID_t;
Rohit Grover 67:0fac4e99f29b 25 typedef uint8_t LongUUID_t[LENGTH_OF_LONG_UUID];
Rohit Grover 67:0fac4e99f29b 26
ktownsend 0:ace2e8d3ce79 27 class UUID
ktownsend 0:ace2e8d3ce79 28 {
ktownsend 0:ace2e8d3ce79 29 public:
Rohit Grover 50:9078969e80e4 30 enum {
ktownsend 0:ace2e8d3ce79 31 UUID_TYPE_SHORT = 0, // Short BLE UUID
ktownsend 0:ace2e8d3ce79 32 UUID_TYPE_LONG = 1 // Full 128-bit UUID
ktownsend 0:ace2e8d3ce79 33 };
Rohit Grover 34:da2ea8cd6216 34
Rohit Grover 50:9078969e80e4 35 public:
Rohit Grover 67:0fac4e99f29b 36 UUID(const LongUUID_t);
Rohit Grover 67:0fac4e99f29b 37 UUID(ShortUUID_t);
ktownsend 0:ace2e8d3ce79 38 virtual ~UUID(void);
Rohit Grover 34:da2ea8cd6216 39
Rohit Grover 50:9078969e80e4 40 public:
Rohit Grover 56:537b8e8f5d60 41 uint8_t shortOrLong(void) const {
Rohit Grover 56:537b8e8f5d60 42 return type;
Rohit Grover 56:537b8e8f5d60 43 }
Rohit Grover 56:537b8e8f5d60 44 const uint8_t* getBaseUUID(void) const {
Rohit Grover 60:de30b62ab8c1 45 return baseUUID;
Rohit Grover 56:537b8e8f5d60 46 }
Rohit Grover 67:0fac4e99f29b 47 ShortUUID_t getShortUUID(void) const {
Rohit Grover 61:119faa0dfeee 48 return shortUUID;
Rohit Grover 56:537b8e8f5d60 49 }
Rohit Grover 56:537b8e8f5d60 50
Rohit Grover 56:537b8e8f5d60 51 private:
Rohit Grover 67:0fac4e99f29b 52 uint8_t type; // UUID_TYPE_SHORT or UUID_TYPE_LONG
Rohit Grover 67:0fac4e99f29b 53 LongUUID_t baseUUID; /* the base of the long UUID (if
Rohit Grover 60:de30b62ab8c1 54 * used). Note: bytes 12 and 13 (counting from LSB)
Rohit Grover 60:de30b62ab8c1 55 * are zeroed out to allow comparison with other long
Rohit Grover 60:de30b62ab8c1 56 * UUIDs which differ only in the 16-bit relative
Rohit Grover 60:de30b62ab8c1 57 * part.*/
Rohit Grover 67:0fac4e99f29b 58 ShortUUID_t shortUUID; // 16 bit uuid (byte 2-3 using with base)
ktownsend 0:ace2e8d3ce79 59 };
ktownsend 0:ace2e8d3ce79 60
Rohit Grover 34:da2ea8cd6216 61 #endif // ifndef __UUID_H__