Lancaster University's fork of the mbed BLE API. Lives on github, https://github.com/lancaster-university/BLE_API
Dependents: microbit-dal microbit-dal microbit-ble-open microbit-dal ... more
Fork of BLE_API by
ble/BLEProtocol.h@1120:85a019284052, 2016-01-11 (annotated)
- Committer:
- vcoubard
- Date:
- Mon Jan 11 08:52:03 2016 +0000
- Revision:
- 1120:85a019284052
- Parent:
- 1119:7a487d506451
Synchronized with git rev c56bc430
Author: Andres Amaya Garcia
Remove unnecessary include in BLEProtocol
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 | 1078:79c089630b38 | 23 | |
vcoubard | 1078:79c089630b38 | 24 | /** |
vcoubard | 1078:79c089630b38 | 25 | * A common namespace for types and constants used everywhere in BLE API. |
vcoubard | 1078:79c089630b38 | 26 | */ |
vcoubard | 1078:79c089630b38 | 27 | namespace BLEProtocol { |
vcoubard | 1119:7a487d506451 | 28 | /**< |
vcoubard | 1119:7a487d506451 | 29 | * A simple container for the enumeration of address-types for Protocol addresses. |
vcoubard | 1119:7a487d506451 | 30 | * |
vcoubard | 1119:7a487d506451 | 31 | * Adding a struct to encapsulate the contained enumeration prevents |
vcoubard | 1119:7a487d506451 | 32 | * polluting the BLEProtocol namespace with the enumerated values. It also |
vcoubard | 1119:7a487d506451 | 33 | * allows type-aliases for the enumeration while retaining the enumerated |
vcoubard | 1119:7a487d506451 | 34 | * values. i.e. doing: |
vcoubard | 1119:7a487d506451 | 35 | * typedef AddressType AliasedType; |
vcoubard | 1119:7a487d506451 | 36 | * |
vcoubard | 1119:7a487d506451 | 37 | * would allow the use of AliasedType::PUBLIC in code. |
vcoubard | 1119:7a487d506451 | 38 | */ |
vcoubard | 1119:7a487d506451 | 39 | struct AddressType { |
vcoubard | 1119:7a487d506451 | 40 | /**< Address-types for Protocol addresses. */ |
vcoubard | 1078:79c089630b38 | 41 | enum Type { |
vcoubard | 1078:79c089630b38 | 42 | PUBLIC = 0, |
vcoubard | 1078:79c089630b38 | 43 | RANDOM_STATIC, |
vcoubard | 1078:79c089630b38 | 44 | RANDOM_PRIVATE_RESOLVABLE, |
vcoubard | 1078:79c089630b38 | 45 | RANDOM_PRIVATE_NON_RESOLVABLE |
vcoubard | 1078:79c089630b38 | 46 | }; |
vcoubard | 1078:79c089630b38 | 47 | }; |
vcoubard | 1119:7a487d506451 | 48 | typedef AddressType::Type AddressType_t; /**< Alias for AddressType::Type */ |
vcoubard | 1078:79c089630b38 | 49 | |
vcoubard | 1119:7a487d506451 | 50 | static const size_t ADDR_LEN = 6; /**< Length (in octets) of the BLE MAC address. */ |
vcoubard | 1119:7a487d506451 | 51 | typedef uint8_t AddressBytes_t[ADDR_LEN]; /**< 48-bit address, in LSB format. */ |
vcoubard | 1115:82d4a8a56d91 | 52 | |
vcoubard | 1115:82d4a8a56d91 | 53 | /** |
vcoubard | 1115:82d4a8a56d91 | 54 | * BLE address. It contains an address-type (@ref AddressType_t) and bytes (@ref AddressBytes_t). |
vcoubard | 1115:82d4a8a56d91 | 55 | */ |
vcoubard | 1115:82d4a8a56d91 | 56 | struct Address_t { |
vcoubard | 1115:82d4a8a56d91 | 57 | AddressType_t type; /**< @ref AddressType_t */ |
vcoubard | 1115:82d4a8a56d91 | 58 | AddressBytes_t address; /**< @ref AddressBytes_t */ |
vcoubard | 1115:82d4a8a56d91 | 59 | |
vcoubard | 1115:82d4a8a56d91 | 60 | Address_t(AddressType_t typeIn, const AddressBytes_t& addressIn) : type(typeIn) { |
vcoubard | 1115:82d4a8a56d91 | 61 | std::copy(addressIn, addressIn + ADDR_LEN, address); |
vcoubard | 1115:82d4a8a56d91 | 62 | } |
vcoubard | 1115:82d4a8a56d91 | 63 | |
vcoubard | 1119:7a487d506451 | 64 | Address_t() : type(), address() { |
vcoubard | 1115:82d4a8a56d91 | 65 | } |
vcoubard | 1115:82d4a8a56d91 | 66 | }; |
vcoubard | 1078:79c089630b38 | 67 | }; |
vcoubard | 1078:79c089630b38 | 68 | |
vcoubard | 1078:79c089630b38 | 69 | #endif /* __BLE_PROTOCOL_H__ */ |