add "LE Device Address" 0x1B to advertising data types

Fork of BLE_API by Bluetooth Low Energy

Committer:
vcoubard
Date:
Mon Jan 11 08:52:01 2016 +0000
Revision:
1115:82d4a8a56d91
Parent:
1078:79c089630b38
Child:
1119:7a487d506451
Synchronized with git rev f7570e8b
Author: Andres Amaya Garcia
Early whitelisting API

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vcoubard 1078:79c089630b38 1 /* mbed Microcontroller Library
vcoubard 1078:79c089630b38 2 * Copyright (c) 2006-2013 ARM Limited
vcoubard 1078:79c089630b38 3 *
vcoubard 1078:79c089630b38 4 * Licensed under the Apache License, Version 2.0 (the "License");
vcoubard 1078:79c089630b38 5 * you may not use this file except in compliance with the License.
vcoubard 1078:79c089630b38 6 * You may obtain a copy of the License at
vcoubard 1078:79c089630b38 7 *
vcoubard 1078:79c089630b38 8 * http://www.apache.org/licenses/LICENSE-2.0
vcoubard 1078:79c089630b38 9 *
vcoubard 1078:79c089630b38 10 * Unless required by applicable law or agreed to in writing, software
vcoubard 1078:79c089630b38 11 * distributed under the License is distributed on an "AS IS" BASIS,
vcoubard 1078:79c089630b38 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
vcoubard 1078:79c089630b38 13 * See the License for the specific language governing permissions and
vcoubard 1078:79c089630b38 14 * limitations under the License.
vcoubard 1078:79c089630b38 15 */
vcoubard 1078:79c089630b38 16
vcoubard 1078:79c089630b38 17 #ifndef __BLE_PROTOCOL_H__
vcoubard 1078:79c089630b38 18 #define __BLE_PROTOCOL_H__
vcoubard 1078:79c089630b38 19
vcoubard 1078:79c089630b38 20 #include <stddef.h>
vcoubard 1078:79c089630b38 21 #include <stdint.h>
vcoubard 1115:82d4a8a56d91 22 #include <algorithm>
vcoubard 1115:82d4a8a56d91 23 #include <string.h>
vcoubard 1078:79c089630b38 24
vcoubard 1078:79c089630b38 25 /**
vcoubard 1078:79c089630b38 26 * A common namespace for types and constants used everywhere in BLE API.
vcoubard 1078:79c089630b38 27 */
vcoubard 1078:79c089630b38 28 namespace BLEProtocol {
vcoubard 1078:79c089630b38 29 /**< Address-type for Protocol addresses. */
vcoubard 1078:79c089630b38 30 struct AddressType { /* Adding a struct to encapsulate the contained enumeration
vcoubard 1078:79c089630b38 31 * prevents polluting the BLEProtocol namespace with the
vcoubard 1078:79c089630b38 32 * enumerated values. It also allows type-aliases for the
vcoubard 1078:79c089630b38 33 * enumeration while retaining the enumerated values. i.e.
vcoubard 1078:79c089630b38 34 *
vcoubard 1078:79c089630b38 35 * doing:
vcoubard 1078:79c089630b38 36 * typedef AddressType_t AliasedType_t;
vcoubard 1078:79c089630b38 37 * would allow the use of AliasedType_t::PUBLIC in code. */
vcoubard 1078:79c089630b38 38 enum Type {
vcoubard 1078:79c089630b38 39 PUBLIC = 0,
vcoubard 1078:79c089630b38 40 RANDOM_STATIC,
vcoubard 1078:79c089630b38 41 RANDOM_PRIVATE_RESOLVABLE,
vcoubard 1078:79c089630b38 42 RANDOM_PRIVATE_NON_RESOLVABLE
vcoubard 1078:79c089630b38 43 };
vcoubard 1078:79c089630b38 44 };
vcoubard 1078:79c089630b38 45 typedef AddressType::Type AddressType_t; /**< Alias for AddressType::Type */
vcoubard 1078:79c089630b38 46
vcoubard 1078:79c089630b38 47 static const size_t ADDR_LEN = 6; /**< Length (in octets) of the BLE MAC address. */
vcoubard 1115:82d4a8a56d91 48 typedef uint8_t AddressBytes_t[ADDR_LEN]; /**< 48-bit address, in LSB format. */
vcoubard 1115:82d4a8a56d91 49
vcoubard 1115:82d4a8a56d91 50 /**
vcoubard 1115:82d4a8a56d91 51 * BLE address. It contains an address-type (@ref AddressType_t) and bytes (@ref AddressBytes_t).
vcoubard 1115:82d4a8a56d91 52 */
vcoubard 1115:82d4a8a56d91 53 struct Address_t {
vcoubard 1115:82d4a8a56d91 54 AddressType_t type; /**< @ref AddressType_t */
vcoubard 1115:82d4a8a56d91 55 AddressBytes_t address; /**< @ref AddressBytes_t */
vcoubard 1115:82d4a8a56d91 56
vcoubard 1115:82d4a8a56d91 57 Address_t(AddressType_t typeIn, const AddressBytes_t& addressIn) : type(typeIn) {
vcoubard 1115:82d4a8a56d91 58 std::copy(addressIn, addressIn + ADDR_LEN, address);
vcoubard 1115:82d4a8a56d91 59 }
vcoubard 1115:82d4a8a56d91 60
vcoubard 1115:82d4a8a56d91 61 Address_t(void) : type(AddressType::PUBLIC), address() {
vcoubard 1115:82d4a8a56d91 62 }
vcoubard 1115:82d4a8a56d91 63
vcoubard 1115:82d4a8a56d91 64 bool operator<(const Address_t &rhs) const {
vcoubard 1115:82d4a8a56d91 65 if (type < rhs.type) {
vcoubard 1115:82d4a8a56d91 66 return true;
vcoubard 1115:82d4a8a56d91 67 } else if (type > rhs.type) {
vcoubard 1115:82d4a8a56d91 68 return false;
vcoubard 1115:82d4a8a56d91 69 }
vcoubard 1115:82d4a8a56d91 70 return (memcmp(address, rhs.address, sizeof(AddressBytes_t)) < 0) ? true : false;
vcoubard 1115:82d4a8a56d91 71 }
vcoubard 1115:82d4a8a56d91 72 };
vcoubard 1078:79c089630b38 73 };
vcoubard 1078:79c089630b38 74
vcoubard 1078:79c089630b38 75 #endif /* __BLE_PROTOCOL_H__ */