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@1140:dd2f69fad8c6, 2016-04-06 (annotated)
- Committer:
- LancasterUniversity
- Date:
- Wed Apr 06 18:40:40 2016 +0100
- Revision:
- 1140:dd2f69fad8c6
- Parent:
- 1137:290d499dd0e8
Synchronized with git rev bbc2dc58
Author: Joe Finney
microbit: Additional callback to indicate to applications when System
Attributes require initialisation from persistent storage.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
LancasterUniversity | 1137:290d499dd0e8 | 1 | /* mbed Microcontroller Library |
LancasterUniversity | 1137:290d499dd0e8 | 2 | * Copyright (c) 2006-2013 ARM Limited |
LancasterUniversity | 1137:290d499dd0e8 | 3 | * |
LancasterUniversity | 1137:290d499dd0e8 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
LancasterUniversity | 1137:290d499dd0e8 | 5 | * you may not use this file except in compliance with the License. |
LancasterUniversity | 1137:290d499dd0e8 | 6 | * You may obtain a copy of the License at |
LancasterUniversity | 1137:290d499dd0e8 | 7 | * |
LancasterUniversity | 1137:290d499dd0e8 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
LancasterUniversity | 1137:290d499dd0e8 | 9 | * |
LancasterUniversity | 1137:290d499dd0e8 | 10 | * Unless required by applicable law or agreed to in writing, software |
LancasterUniversity | 1137:290d499dd0e8 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
LancasterUniversity | 1137:290d499dd0e8 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
LancasterUniversity | 1137:290d499dd0e8 | 13 | * See the License for the specific language governing permissions and |
LancasterUniversity | 1137:290d499dd0e8 | 14 | * limitations under the License. |
LancasterUniversity | 1137:290d499dd0e8 | 15 | */ |
LancasterUniversity | 1137:290d499dd0e8 | 16 | |
LancasterUniversity | 1137:290d499dd0e8 | 17 | #ifndef __BLE_PROTOCOL_H__ |
LancasterUniversity | 1137:290d499dd0e8 | 18 | #define __BLE_PROTOCOL_H__ |
LancasterUniversity | 1137:290d499dd0e8 | 19 | |
LancasterUniversity | 1137:290d499dd0e8 | 20 | #include <stddef.h> |
LancasterUniversity | 1137:290d499dd0e8 | 21 | #include <stdint.h> |
LancasterUniversity | 1137:290d499dd0e8 | 22 | #include <algorithm> |
LancasterUniversity | 1137:290d499dd0e8 | 23 | |
LancasterUniversity | 1137:290d499dd0e8 | 24 | /** |
LancasterUniversity | 1137:290d499dd0e8 | 25 | * A common namespace for types and constants used everywhere in BLE API. |
LancasterUniversity | 1137:290d499dd0e8 | 26 | */ |
LancasterUniversity | 1137:290d499dd0e8 | 27 | namespace BLEProtocol { |
LancasterUniversity | 1137:290d499dd0e8 | 28 | /**< |
LancasterUniversity | 1137:290d499dd0e8 | 29 | * A simple container for the enumeration of address-types for Protocol addresses. |
LancasterUniversity | 1137:290d499dd0e8 | 30 | * |
LancasterUniversity | 1137:290d499dd0e8 | 31 | * Adding a struct to encapsulate the contained enumeration prevents |
LancasterUniversity | 1137:290d499dd0e8 | 32 | * polluting the BLEProtocol namespace with the enumerated values. It also |
LancasterUniversity | 1137:290d499dd0e8 | 33 | * allows type-aliases for the enumeration while retaining the enumerated |
LancasterUniversity | 1137:290d499dd0e8 | 34 | * values. i.e. doing: |
LancasterUniversity | 1137:290d499dd0e8 | 35 | * typedef AddressType AliasedType; |
LancasterUniversity | 1137:290d499dd0e8 | 36 | * |
LancasterUniversity | 1137:290d499dd0e8 | 37 | * would allow the use of AliasedType::PUBLIC in code. |
LancasterUniversity | 1137:290d499dd0e8 | 38 | */ |
LancasterUniversity | 1137:290d499dd0e8 | 39 | struct AddressType { |
LancasterUniversity | 1137:290d499dd0e8 | 40 | /**< Address-types for Protocol addresses. */ |
LancasterUniversity | 1137:290d499dd0e8 | 41 | enum Type { |
LancasterUniversity | 1137:290d499dd0e8 | 42 | PUBLIC = 0, |
LancasterUniversity | 1137:290d499dd0e8 | 43 | RANDOM_STATIC, |
LancasterUniversity | 1137:290d499dd0e8 | 44 | RANDOM_PRIVATE_RESOLVABLE, |
LancasterUniversity | 1137:290d499dd0e8 | 45 | RANDOM_PRIVATE_NON_RESOLVABLE |
LancasterUniversity | 1137:290d499dd0e8 | 46 | }; |
LancasterUniversity | 1137:290d499dd0e8 | 47 | }; |
LancasterUniversity | 1137:290d499dd0e8 | 48 | typedef AddressType::Type AddressType_t; /**< Alias for AddressType::Type */ |
LancasterUniversity | 1137:290d499dd0e8 | 49 | |
LancasterUniversity | 1137:290d499dd0e8 | 50 | static const size_t ADDR_LEN = 6; /**< Length (in octets) of the BLE MAC address. */ |
LancasterUniversity | 1137:290d499dd0e8 | 51 | typedef uint8_t AddressBytes_t[ADDR_LEN]; /**< 48-bit address, in LSB format. */ |
LancasterUniversity | 1137:290d499dd0e8 | 52 | |
LancasterUniversity | 1137:290d499dd0e8 | 53 | /** |
LancasterUniversity | 1137:290d499dd0e8 | 54 | * BLE address. It contains an address-type (@ref AddressType_t) and bytes (@ref AddressBytes_t). |
LancasterUniversity | 1137:290d499dd0e8 | 55 | */ |
LancasterUniversity | 1137:290d499dd0e8 | 56 | struct Address_t { |
LancasterUniversity | 1137:290d499dd0e8 | 57 | AddressType_t type; /**< @ref AddressType_t */ |
LancasterUniversity | 1137:290d499dd0e8 | 58 | AddressBytes_t address; /**< @ref AddressBytes_t */ |
LancasterUniversity | 1137:290d499dd0e8 | 59 | |
LancasterUniversity | 1137:290d499dd0e8 | 60 | Address_t(AddressType_t typeIn, const AddressBytes_t& addressIn) : type(typeIn) { |
LancasterUniversity | 1137:290d499dd0e8 | 61 | std::copy(addressIn, addressIn + ADDR_LEN, address); |
LancasterUniversity | 1137:290d499dd0e8 | 62 | } |
LancasterUniversity | 1137:290d499dd0e8 | 63 | |
LancasterUniversity | 1137:290d499dd0e8 | 64 | Address_t() : type(), address() { |
LancasterUniversity | 1137:290d499dd0e8 | 65 | } |
LancasterUniversity | 1137:290d499dd0e8 | 66 | }; |
LancasterUniversity | 1137:290d499dd0e8 | 67 | }; |
LancasterUniversity | 1137:290d499dd0e8 | 68 | |
LancasterUniversity | 1137:290d499dd0e8 | 69 | #endif /* __BLE_PROTOCOL_H__ */ |