Includes library modifications to allow access to AIN_4 (AIN_0 / 5)

Committer:
bryantaylor
Date:
Tue Sep 20 21:26:12 2016 +0000
Revision:
0:eafc3fd41f75
hackathon

Who changed what in which revision?

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