Minor temporary patch to allow DFU packet callback

Fork of BLE_API by Bluetooth Low Energy

Committer:
rgrover1
Date:
Mon Mar 02 11:50:47 2015 +0000
Revision:
293:6278354cfd98
Parent:
292:b5ee2ada4f33
Child:
294:ab928e365ea1
Synchronized with git rev eb17caed
Author: Jeremy Brodt
Corrected comparison value and cast.

Who changed what in which revision?

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