High level Bluetooth Low Energy API and radio abstraction layer
Fork of BLE_API by
ble/BLEProtocol.h@1119:7a487d506451, 2016-01-11 (annotated)
- Committer:
- vcoubard
- Date:
- Mon Jan 11 08:52:03 2016 +0000
- Revision:
- 1119:7a487d506451
- Parent:
- 1115:82d4a8a56d91
- Child:
- 1120:85a019284052
Synchronized with git rev 819a0ca7
Author: Andres Amaya Garcia
Fix comments and add Address_t empty constructor
Add an empty constructor to BLEProtocol::Address_t and fixed comments with
regards to BLEProtocol::Address_t.
Who changed what in which revision?
User | Revision | Line number | New 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 | 1119:7a487d506451 | 29 | /**< |
vcoubard | 1119:7a487d506451 | 30 | * A simple container for the enumeration of address-types for Protocol addresses. |
vcoubard | 1119:7a487d506451 | 31 | * |
vcoubard | 1119:7a487d506451 | 32 | * Adding a struct to encapsulate the contained enumeration prevents |
vcoubard | 1119:7a487d506451 | 33 | * polluting the BLEProtocol namespace with the enumerated values. It also |
vcoubard | 1119:7a487d506451 | 34 | * allows type-aliases for the enumeration while retaining the enumerated |
vcoubard | 1119:7a487d506451 | 35 | * values. i.e. doing: |
vcoubard | 1119:7a487d506451 | 36 | * typedef AddressType AliasedType; |
vcoubard | 1119:7a487d506451 | 37 | * |
vcoubard | 1119:7a487d506451 | 38 | * would allow the use of AliasedType::PUBLIC in code. |
vcoubard | 1119:7a487d506451 | 39 | */ |
vcoubard | 1119:7a487d506451 | 40 | struct AddressType { |
vcoubard | 1119:7a487d506451 | 41 | /**< Address-types for Protocol addresses. */ |
vcoubard | 1078:79c089630b38 | 42 | enum Type { |
vcoubard | 1078:79c089630b38 | 43 | PUBLIC = 0, |
vcoubard | 1078:79c089630b38 | 44 | RANDOM_STATIC, |
vcoubard | 1078:79c089630b38 | 45 | RANDOM_PRIVATE_RESOLVABLE, |
vcoubard | 1078:79c089630b38 | 46 | RANDOM_PRIVATE_NON_RESOLVABLE |
vcoubard | 1078:79c089630b38 | 47 | }; |
vcoubard | 1078:79c089630b38 | 48 | }; |
vcoubard | 1119:7a487d506451 | 49 | typedef AddressType::Type AddressType_t; /**< Alias for AddressType::Type */ |
vcoubard | 1078:79c089630b38 | 50 | |
vcoubard | 1119:7a487d506451 | 51 | static const size_t ADDR_LEN = 6; /**< Length (in octets) of the BLE MAC address. */ |
vcoubard | 1119:7a487d506451 | 52 | typedef uint8_t AddressBytes_t[ADDR_LEN]; /**< 48-bit address, in LSB format. */ |
vcoubard | 1115:82d4a8a56d91 | 53 | |
vcoubard | 1115:82d4a8a56d91 | 54 | /** |
vcoubard | 1115:82d4a8a56d91 | 55 | * BLE address. It contains an address-type (@ref AddressType_t) and bytes (@ref AddressBytes_t). |
vcoubard | 1115:82d4a8a56d91 | 56 | */ |
vcoubard | 1115:82d4a8a56d91 | 57 | struct Address_t { |
vcoubard | 1115:82d4a8a56d91 | 58 | AddressType_t type; /**< @ref AddressType_t */ |
vcoubard | 1115:82d4a8a56d91 | 59 | AddressBytes_t address; /**< @ref AddressBytes_t */ |
vcoubard | 1115:82d4a8a56d91 | 60 | |
vcoubard | 1115:82d4a8a56d91 | 61 | Address_t(AddressType_t typeIn, const AddressBytes_t& addressIn) : type(typeIn) { |
vcoubard | 1115:82d4a8a56d91 | 62 | std::copy(addressIn, addressIn + ADDR_LEN, address); |
vcoubard | 1115:82d4a8a56d91 | 63 | } |
vcoubard | 1115:82d4a8a56d91 | 64 | |
vcoubard | 1119:7a487d506451 | 65 | Address_t() : type(), address() { |
vcoubard | 1115:82d4a8a56d91 | 66 | } |
vcoubard | 1115:82d4a8a56d91 | 67 | }; |
vcoubard | 1078:79c089630b38 | 68 | }; |
vcoubard | 1078:79c089630b38 | 69 | |
vcoubard | 1078:79c089630b38 | 70 | #endif /* __BLE_PROTOCOL_H__ */ |