High level Bluetooth Low Energy API and radio abstraction layer
Fork of BLE_API by
Revision 424:370d5f1f292f, committed 2015-06-19
- Comitter:
- rgrover1
- Date:
- Fri Jun 19 15:51:54 2015 +0100
- Parent:
- 423:c4436674db7b
- Child:
- 425:554872b84999
- Commit message:
- Synchronized with git rev 8d3e0929
Author: Rohit Grover
add a missing include for GapScanningParams.h
Changed in this revision
--- a/public/BLEDevice.h Mon Jun 08 10:56:27 2015 +0100 +++ b/public/BLEDevice.h Fri Jun 19 15:51:54 2015 +0100 @@ -56,13 +56,13 @@ * Set the BTLE MAC address and type. * @return BLE_ERROR_NONE on success. */ - ble_error_t setAddress(Gap::AddressType_t type, const Gap::Address_t address); + ble_error_t setAddress(Gap::AddressType_t type, const Gap::address_t address); /** * Fetch the BTLE MAC address and type. * @return BLE_ERROR_NONE on success. */ - ble_error_t getAddress(Gap::AddressType_t *typeP, Gap::Address_t address); + ble_error_t getAddress(Gap::AddressType_t *typeP, Gap::address_t address); /** * @param[in] advType @@ -649,13 +649,13 @@ } inline ble_error_t -BLEDevice::setAddress(Gap::AddressType_t type, const Gap::Address_t address) +BLEDevice::setAddress(Gap::AddressType_t type, const Gap::address_t address) { return transport->getGap().setAddress(type, address); } inline ble_error_t -BLEDevice::getAddress(Gap::AddressType_t *typeP, Gap::Address_t address) +BLEDevice::getAddress(Gap::AddressType_t *typeP, Gap::address_t address) { return transport->getGap().getAddress(typeP, address); }
--- a/public/Gap.h Mon Jun 08 10:56:27 2015 +0100 +++ b/public/Gap.h Fri Jun 19 15:51:54 2015 +0100 @@ -19,6 +19,7 @@ #include "GapAdvertisingData.h" #include "GapAdvertisingParams.h" +#include "GapScanningParams.h" #include "GapEvents.h" #include "CallChain.h" #include "FunctionPointerWithContext.h"
--- a/public/GattAttribute.h Mon Jun 08 10:56:27 2015 +0100 +++ b/public/GattAttribute.h Fri Jun 19 15:51:54 2015 +0100 @@ -20,7 +20,6 @@ class GattAttribute { public: typedef uint16_t Handle_t; - static const Handle_t INVALID_HANDLE = 0x0000; public: /**
--- a/public/UUID.h Mon Jun 08 10:56:27 2015 +0100 +++ b/public/UUID.h Fri Jun 19 15:51:54 2015 +0100 @@ -1,141 +1,119 @@ -/* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __UUID_H__ -#define __UUID_H__ - -#include <string.h> - -#include "blecommon.h" - -class UUID { -public: - enum UUID_Type_t { - UUID_TYPE_SHORT = 0, // Short BLE UUID - UUID_TYPE_LONG = 1 // Full 128-bit UUID - }; - - static const unsigned LENGTH_OF_LONG_UUID = 16; - typedef uint16_t ShortUUIDBytes_t; - typedef uint8_t LongUUIDBytes_t[LENGTH_OF_LONG_UUID]; - -public: - /** - * Creates a new 128-bit UUID - * - * @note The UUID is a unique 128-bit (16 byte) ID used to identify - * different service or characteristics on the BLE device. - * - * @param longUUID - * The 128-bit (16-byte) UUID value, MSB first (big-endian). - */ - UUID(const LongUUIDBytes_t longUUID) : type(UUID_TYPE_LONG), baseUUID(), shortUUID(0) { - setupLong(longUUID); - } - - /** - * Creates a new 16-bit UUID - * - * @note The UUID is a unique 16-bit (2 byte) ID used to identify - * different service or characteristics on the BLE device. - * - * For efficiency, and because 16 bytes would take a large chunk of the - * 27-byte data payload length of the Link Layer, the BLE specification adds - * two additional UUID formats: 16-bit and 32-bit UUIDs. These shortened - * formats can be used only with UUIDs that are defined in the Bluetooth - * specification (i.e., that are listed by the Bluetooth SIG as standard - * Bluetooth UUIDs). - * - * To reconstruct the full 128-bit UUID from the shortened version, insert - * the 16-bit short value (indicated by xxxx, including leading zeros) into - * the Bluetooth Base UUID: - * - * 0000xxxx-0000-1000-8000-00805F9B34FB - * - * @note Shortening is not available for UUIDs that are not derived from the - * Bluetooth Base UUID. Such non-standard UUIDs are commonly called - * vendor-specific UUIDs. In these cases, you’ll need to use the full - * 128-bit UUID value at all times. - * - * @note we don't yet support 32-bit shortened UUIDs. - */ - UUID(ShortUUIDBytes_t shortUUID) : type(UUID_TYPE_SHORT), baseUUID(), shortUUID(shortUUID) { - /* empty */ - } - - UUID(const UUID &source) { - type = source.type; - shortUUID = source.shortUUID; - memcpy(baseUUID, source.baseUUID, LENGTH_OF_LONG_UUID); - } - - UUID(void) : type(UUID_TYPE_SHORT), shortUUID(BLE_UUID_UNKNOWN) { - /* empty */ - } - - /** - * Fill in a 128-bit UUID; this is useful when UUID isn't known at the time of object construction. - */ - void setupLong(const LongUUIDBytes_t longUUID) { - type = UUID_TYPE_LONG; - memcpy(baseUUID, longUUID, LENGTH_OF_LONG_UUID); - shortUUID = (uint16_t)((longUUID[2] << 8) | (longUUID[3])); - } - -public: - UUID_Type_t shortOrLong(void) const {return type; } - const uint8_t *getBaseUUID(void) const { - if (type == UUID_TYPE_SHORT) { - return (const uint8_t*)&shortUUID; - } else { - return baseUUID; - } - } - - ShortUUIDBytes_t getShortUUID(void) const {return shortUUID;} - uint8_t getLen(void) const { - return ((type == UUID_TYPE_SHORT) ? sizeof(ShortUUIDBytes_t) : LENGTH_OF_LONG_UUID); - } - - bool operator== (const UUID &other) const { - if ((this->type == UUID_TYPE_SHORT) && (other.type == UUID_TYPE_SHORT) && - (this->shortUUID == other.shortUUID)) { - return true; - } - - if ((this->type == UUID_TYPE_LONG) && (other.type == UUID_TYPE_LONG) && - (memcmp(this->baseUUID, other.baseUUID, LENGTH_OF_LONG_UUID) == 0)) { - return true; - } - - return false; - } - - bool operator!= (const UUID &other) const { - return !(*this == other); - } - -private: - UUID_Type_t type; // UUID_TYPE_SHORT or UUID_TYPE_LONG - LongUUIDBytes_t baseUUID; /* the base of the long UUID (if - * used). Note: bytes 12 and 13 (counting from LSB) - * are zeroed out to allow comparison with other long - * UUIDs which differ only in the 16-bit relative - * part.*/ - ShortUUIDBytes_t shortUUID; // 16 bit uuid (byte 2-3 using with base) -}; - -#endif // ifndef __UUID_H__ \ No newline at end of file +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __UUID_H__ +#define __UUID_H__ + +#include <string.h> + +#include "blecommon.h" + +const unsigned LENGTH_OF_LONG_UUID = 16; +typedef uint16_t ShortUUIDBytes_t; +typedef uint8_t LongUUIDBytes_t[LENGTH_OF_LONG_UUID]; + +class UUID { +public: + enum UUID_Type_t { + UUID_TYPE_SHORT = 0, // Short BLE UUID + UUID_TYPE_LONG = 1 // Full 128-bit UUID + }; + +public: + /** + * Creates a new 128-bit UUID + * + * @note The UUID is a unique 128-bit (16 byte) ID used to identify + * different service or characteristics on the BLE device. + * + * @param longUUID + * The 128-bit (16-byte) UUID value. + */ + UUID(const LongUUIDBytes_t longUUID) : type(UUID_TYPE_LONG), baseUUID(), shortUUID(0) { + memcpy(baseUUID, longUUID, LENGTH_OF_LONG_UUID); + shortUUID = (uint16_t)((longUUID[2] << 8) | (longUUID[3])); + } + + /** + * Creates a new 16-bit UUID + * + * @note The UUID is a unique 16-bit (2 byte) ID used to identify + * different service or characteristics on the BLE device. + * + * For efficiency, and because 16 bytes would take a large chunk of the + * 27-byte data payload length of the Link Layer, the BLE specification adds + * two additional UUID formats: 16-bit and 32-bit UUIDs. These shortened + * formats can be used only with UUIDs that are defined in the Bluetooth + * specification (i.e., that are listed by the Bluetooth SIG as standard + * Bluetooth UUIDs). + * + * To reconstruct the full 128-bit UUID from the shortened version, insert + * the 16-bit short value (indicated by xxxx, including leading zeros) into + * the Bluetooth Base UUID: + * + * 0000xxxx-0000-1000-8000-00805F9B34FB + * + * @note Shortening is not available for UUIDs that are not derived from the + * Bluetooth Base UUID. Such non-standard UUIDs are commonly called + * vendor-specific UUIDs. In these cases, you’ll need to use the full + * 128-bit UUID value at all times. + * + * @note we don't yet support 32-bit shortened UUIDs. + */ + UUID(ShortUUIDBytes_t shortUUID) : type(UUID_TYPE_SHORT), baseUUID(), shortUUID(shortUUID) { + /* empty */ + } + +public: + UUID_Type_t shortOrLong(void) const {return type; } + const uint8_t *getBaseUUID(void) const { + if (type == UUID_TYPE_SHORT) { + return (const uint8_t*)&shortUUID; + } else { + return baseUUID; + } + } + + ShortUUIDBytes_t getShortUUID(void) const {return shortUUID;} + uint8_t getLen(void) const { + return ((type == UUID_TYPE_SHORT) ? sizeof(ShortUUIDBytes_t) : LENGTH_OF_LONG_UUID); + } + + bool operator== (const UUID &other) const { + if ((this->type == UUID_TYPE_SHORT) && (other.type == UUID_TYPE_SHORT) && + (this->shortUUID == other.shortUUID)) { + return true; + } + + if ((this->type == UUID_TYPE_LONG) && (other.type == UUID_TYPE_LONG) && + (memcmp(this->baseUUID, other.baseUUID, LENGTH_OF_LONG_UUID) == 0)) { + return true; + } + + return false; + } + +private: + UUID_Type_t type; // UUID_TYPE_SHORT or UUID_TYPE_LONG + LongUUIDBytes_t baseUUID; /* the base of the long UUID (if + * used). Note: bytes 12 and 13 (counting from LSB) + * are zeroed out to allow comparison with other long + * UUIDs which differ only in the 16-bit relative + * part.*/ + ShortUUIDBytes_t shortUUID; // 16 bit uuid (byte 2-3 using with base) +}; + +#endif // ifndef __UUID_H__ \ No newline at end of file
--- a/services/UARTService.cpp Mon Jun 08 10:56:27 2015 +0100 +++ b/services/UARTService.cpp Fri Jun 19 15:51:54 2015 +0100 @@ -16,26 +16,26 @@ #include "UARTService.h" -const uint8_t UARTServiceBaseUUID[UUID::LENGTH_OF_LONG_UUID] = { +const uint8_t UARTServiceBaseUUID[LENGTH_OF_LONG_UUID] = { 0x6E, 0x40, 0x00, 0x00, 0xB5, 0xA3, 0xF3, 0x93, 0xE0, 0xA9, 0xE5, 0x0E, 0x24, 0xDC, 0xCA, 0x9E, }; const uint16_t UARTServiceShortUUID = 0x0001; const uint16_t UARTServiceTXCharacteristicShortUUID = 0x0002; const uint16_t UARTServiceRXCharacteristicShortUUID = 0x0003; -const uint8_t UARTServiceUUID[UUID::LENGTH_OF_LONG_UUID] = { +const uint8_t UARTServiceUUID[LENGTH_OF_LONG_UUID] = { 0x6E, 0x40, (uint8_t)(UARTServiceShortUUID >> 8), (uint8_t)(UARTServiceShortUUID & 0xFF), 0xB5, 0xA3, 0xF3, 0x93, 0xE0, 0xA9, 0xE5, 0x0E, 0x24, 0xDC, 0xCA, 0x9E, }; -const uint8_t UARTServiceUUID_reversed[UUID::LENGTH_OF_LONG_UUID] = { +const uint8_t UARTServiceUUID_reversed[LENGTH_OF_LONG_UUID] = { 0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, (uint8_t)(UARTServiceShortUUID & 0xFF), (uint8_t)(UARTServiceShortUUID >> 8), 0x40, 0x6E }; -const uint8_t UARTServiceTXCharacteristicUUID[UUID::LENGTH_OF_LONG_UUID] = { +const uint8_t UARTServiceTXCharacteristicUUID[LENGTH_OF_LONG_UUID] = { 0x6E, 0x40, (uint8_t)(UARTServiceTXCharacteristicShortUUID >> 8), (uint8_t)(UARTServiceTXCharacteristicShortUUID & 0xFF), 0xB5, 0xA3, 0xF3, 0x93, 0xE0, 0xA9, 0xE5, 0x0E, 0x24, 0xDC, 0xCA, 0x9E, }; -const uint8_t UARTServiceRXCharacteristicUUID[UUID::LENGTH_OF_LONG_UUID] = { +const uint8_t UARTServiceRXCharacteristicUUID[LENGTH_OF_LONG_UUID] = { 0x6E, 0x40, (uint8_t)(UARTServiceRXCharacteristicShortUUID >> 8), (uint8_t)(UARTServiceRXCharacteristicShortUUID & 0xFF), 0xB5, 0xA3, 0xF3, 0x93, 0xE0, 0xA9, 0xE5, 0x0E, 0x24, 0xDC, 0xCA, 0x9E, }; \ No newline at end of file
--- a/services/UARTService.h Mon Jun 08 10:56:27 2015 +0100 +++ b/services/UARTService.h Fri Jun 19 15:51:54 2015 +0100 @@ -23,16 +23,16 @@ #include "UUID.h" #include "BLEDevice.h" -extern const uint8_t UARTServiceBaseUUID[UUID::LENGTH_OF_LONG_UUID]; +extern const uint8_t UARTServiceBaseUUID[LENGTH_OF_LONG_UUID]; extern const uint16_t UARTServiceShortUUID; extern const uint16_t UARTServiceTXCharacteristicShortUUID; extern const uint16_t UARTServiceRXCharacteristicShortUUID; -extern const uint8_t UARTServiceUUID[UUID::LENGTH_OF_LONG_UUID]; -extern const uint8_t UARTServiceUUID_reversed[UUID::LENGTH_OF_LONG_UUID]; +extern const uint8_t UARTServiceUUID[LENGTH_OF_LONG_UUID]; +extern const uint8_t UARTServiceUUID_reversed[LENGTH_OF_LONG_UUID]; -extern const uint8_t UARTServiceTXCharacteristicUUID[UUID::LENGTH_OF_LONG_UUID]; -extern const uint8_t UARTServiceRXCharacteristicUUID[UUID::LENGTH_OF_LONG_UUID]; +extern const uint8_t UARTServiceTXCharacteristicUUID[LENGTH_OF_LONG_UUID]; +extern const uint8_t UARTServiceRXCharacteristicUUID[LENGTH_OF_LONG_UUID]; /** * @class UARTService
--- a/services/URIBeaconConfigService.cpp Mon Jun 08 10:56:27 2015 +0100 +++ b/services/URIBeaconConfigService.cpp Fri Jun 19 15:51:54 2015 +0100 @@ -21,15 +21,15 @@ 0xab, 0x96, 0x99, 0xb9, 0x1a, 0xc9, 0x81, 0xd8, \ } -const uint8_t UUID_URI_BEACON_SERVICE[UUID::LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x80); -const uint8_t UUID_LOCK_STATE_CHAR[UUID::LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x81); -const uint8_t UUID_LOCK_CHAR[UUID::LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x82); -const uint8_t UUID_UNLOCK_CHAR[UUID::LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x83); -const uint8_t UUID_URI_DATA_CHAR[UUID::LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x84); -const uint8_t UUID_FLAGS_CHAR[UUID::LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x85); -const uint8_t UUID_ADV_POWER_LEVELS_CHAR[UUID::LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x86); -const uint8_t UUID_TX_POWER_MODE_CHAR[UUID::LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x87); -const uint8_t UUID_BEACON_PERIOD_CHAR[UUID::LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x88); -const uint8_t UUID_RESET_CHAR[UUID::LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x89); +const uint8_t UUID_URI_BEACON_SERVICE[LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x80); +const uint8_t UUID_LOCK_STATE_CHAR[LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x81); +const uint8_t UUID_LOCK_CHAR[LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x82); +const uint8_t UUID_UNLOCK_CHAR[LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x83); +const uint8_t UUID_URI_DATA_CHAR[LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x84); +const uint8_t UUID_FLAGS_CHAR[LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x85); +const uint8_t UUID_ADV_POWER_LEVELS_CHAR[LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x86); +const uint8_t UUID_TX_POWER_MODE_CHAR[LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x87); +const uint8_t UUID_BEACON_PERIOD_CHAR[LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x88); +const uint8_t UUID_RESET_CHAR[LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x89); -const uint8_t BEACON_UUID[sizeof(UUID::ShortUUIDBytes_t)] = {0xD8, 0xFE}; \ No newline at end of file +const uint8_t BEACON_UUID[sizeof(ShortUUIDBytes_t)] = {0xD8, 0xFE}; \ No newline at end of file
--- a/services/URIBeaconConfigService.h Mon Jun 08 10:56:27 2015 +0100 +++ b/services/URIBeaconConfigService.h Fri Jun 19 15:51:54 2015 +0100 @@ -20,18 +20,18 @@ #include "BLEDevice.h" #include "mbed.h" -extern const uint8_t UUID_URI_BEACON_SERVICE[UUID::LENGTH_OF_LONG_UUID]; -extern const uint8_t UUID_LOCK_STATE_CHAR[UUID::LENGTH_OF_LONG_UUID]; -extern const uint8_t UUID_LOCK_CHAR[UUID::LENGTH_OF_LONG_UUID]; -extern const uint8_t UUID_UNLOCK_CHAR[UUID::LENGTH_OF_LONG_UUID]; -extern const uint8_t UUID_URI_DATA_CHAR[UUID::LENGTH_OF_LONG_UUID]; -extern const uint8_t UUID_FLAGS_CHAR[UUID::LENGTH_OF_LONG_UUID]; -extern const uint8_t UUID_ADV_POWER_LEVELS_CHAR[UUID::LENGTH_OF_LONG_UUID]; -extern const uint8_t UUID_TX_POWER_MODE_CHAR[UUID::LENGTH_OF_LONG_UUID]; -extern const uint8_t UUID_BEACON_PERIOD_CHAR[UUID::LENGTH_OF_LONG_UUID]; -extern const uint8_t UUID_RESET_CHAR[UUID::LENGTH_OF_LONG_UUID]; +extern const uint8_t UUID_URI_BEACON_SERVICE[LENGTH_OF_LONG_UUID]; +extern const uint8_t UUID_LOCK_STATE_CHAR[LENGTH_OF_LONG_UUID]; +extern const uint8_t UUID_LOCK_CHAR[LENGTH_OF_LONG_UUID]; +extern const uint8_t UUID_UNLOCK_CHAR[LENGTH_OF_LONG_UUID]; +extern const uint8_t UUID_URI_DATA_CHAR[LENGTH_OF_LONG_UUID]; +extern const uint8_t UUID_FLAGS_CHAR[LENGTH_OF_LONG_UUID]; +extern const uint8_t UUID_ADV_POWER_LEVELS_CHAR[LENGTH_OF_LONG_UUID]; +extern const uint8_t UUID_TX_POWER_MODE_CHAR[LENGTH_OF_LONG_UUID]; +extern const uint8_t UUID_BEACON_PERIOD_CHAR[LENGTH_OF_LONG_UUID]; +extern const uint8_t UUID_RESET_CHAR[LENGTH_OF_LONG_UUID]; -extern const uint8_t BEACON_UUID[sizeof(UUID::ShortUUIDBytes_t)]; +extern const uint8_t BEACON_UUID[sizeof(ShortUUIDBytes_t)]; /** * @class URIBeaconConfigService