High level Bluetooth Low Energy API and radio abstraction layer

Dependents:   BLE_ANCS_SDAPI BLE_temperature BLE_HeartRate BLE_ANCS_SDAPI_IRC ... more

Overview

The BLE_API is a high level abstraction for using Bluetooth Low Energy on multiple platforms. For details and examples using the BLE_API please see the BLE_API Summary Page. Or click on the API Documentation tab above.

Supported Services

Supported services can be found in the BLE_API/services folder.

Committer:
Vincent Coubard
Date:
Wed Sep 14 14:18:00 2016 +0100
Revision:
1208:65474dc93927
Parent:
1183:1589830dbdb7
Sync with 8d97fced5440d78c9557693b6d1632f1ab5d77b7

2016-09-01 08:21:37+01:00: Vincent Coubard
version v2.7.0

Who changed what in which revision?

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