Microbug / BLE_API

Fork of BLE_API by Bluetooth Low Energy

Committer:
Rohit Grover
Date:
Thu May 22 13:30:05 2014 +0100
Revision:
38:02cf26a2a4db
Parent:
37:7e8de07642e0
Child:
39:a57137537521
add consts to the declaration of BLEDevice::setAddress()

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ktownsend 29:011e95ce78b8 1 /* mbed Microcontroller Library
ktownsend 29:011e95ce78b8 2 * Copyright (c) 2006-2013 ARM Limited
ktownsend 29:011e95ce78b8 3 *
ktownsend 29:011e95ce78b8 4 * Licensed under the Apache License, Version 2.0 (the "License");
ktownsend 29:011e95ce78b8 5 * you may not use this file except in compliance with the License.
ktownsend 29:011e95ce78b8 6 * You may obtain a copy of the License at
ktownsend 29:011e95ce78b8 7 *
ktownsend 29:011e95ce78b8 8 * http://www.apache.org/licenses/LICENSE-2.0
ktownsend 29:011e95ce78b8 9 *
ktownsend 29:011e95ce78b8 10 * Unless required by applicable law or agreed to in writing, software
ktownsend 29:011e95ce78b8 11 * distributed under the License is distributed on an "AS IS" BASIS,
ktownsend 29:011e95ce78b8 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ktownsend 29:011e95ce78b8 13 * See the License for the specific language governing permissions and
ktownsend 29:011e95ce78b8 14 * limitations under the License.
ktownsend 29:011e95ce78b8 15 */
Rohit Grover 34:da2ea8cd6216 16
ktownsend 29:011e95ce78b8 17 #ifndef __BLE_DEVICE_H__
ktownsend 29:011e95ce78b8 18 #define __BLE_DEVICE_H__
ktownsend 29:011e95ce78b8 19
ktownsend 29:011e95ce78b8 20 #include "mbed.h"
ktownsend 29:011e95ce78b8 21 #include "blecommon.h"
ktownsend 29:011e95ce78b8 22 #include "hw/Gap.h"
ktownsend 29:011e95ce78b8 23 #include "hw/GattServer.h"
ktownsend 29:011e95ce78b8 24
ktownsend 29:011e95ce78b8 25 /**************************************************************************/
ktownsend 29:011e95ce78b8 26 /*!
ktownsend 29:011e95ce78b8 27 \brief
ktownsend 29:011e95ce78b8 28 The base class used to abstract away BLE capable radio transceivers
ktownsend 29:011e95ce78b8 29 or SOCs, to enable this BLE API to work with any radio transparently.
ktownsend 29:011e95ce78b8 30 */
ktownsend 29:011e95ce78b8 31 /**************************************************************************/
ktownsend 29:011e95ce78b8 32 class BLEDevice
ktownsend 29:011e95ce78b8 33 {
Rohit Grover 34:da2ea8cd6216 34 public:
Rohit Grover 35:f3b0c1192cf7 35 virtual ble_error_t init() = 0;
Rohit Grover 35:f3b0c1192cf7 36 virtual ble_error_t reset(void) = 0;
Rohit Grover 35:f3b0c1192cf7 37
Rohit Grover 35:f3b0c1192cf7 38 /* GAP specific APIs */
Rohit Grover 35:f3b0c1192cf7 39 public:
Rohit Grover 37:7e8de07642e0 40 /**
Rohit Grover 37:7e8de07642e0 41 * Set the BTLE MAC address and type.
Rohit Grover 37:7e8de07642e0 42 * @return
Rohit Grover 37:7e8de07642e0 43 */
Rohit Grover 38:02cf26a2a4db 44 ble_error_t setAddress(Gap::addr_type_t type, const uint8_t address[6]);
Rohit Grover 35:f3b0c1192cf7 45
Rohit Grover 35:f3b0c1192cf7 46 ble_error_t setAdvertisingData(GapAdvertisingData &ADStructures,
Rohit Grover 36:9ec94579bb78 47 GapAdvertisingData &scanResponse);
Rohit Grover 36:9ec94579bb78 48 ble_error_t setAdvertisingData(GapAdvertisingData &ADStructures);
Rohit Grover 36:9ec94579bb78 49 ble_error_t startAdvertising(GapAdvertisingParams &advParams);
Rohit Grover 36:9ec94579bb78 50 ble_error_t stopAdvertising(void);
Rohit Grover 36:9ec94579bb78 51 ble_error_t disconnect(void);
Rohit Grover 35:f3b0c1192cf7 52
Rohit Grover 35:f3b0c1192cf7 53 public: /* TODO: to be made private soon */
Rohit Grover 34:da2ea8cd6216 54 virtual Gap& getGap() = 0;
Rohit Grover 34:da2ea8cd6216 55 virtual GattServer& getGattServer() = 0;
ktownsend 29:011e95ce78b8 56 };
ktownsend 29:011e95ce78b8 57
Rohit Grover 38:02cf26a2a4db 58 inline ble_error_t BLEDevice::setAddress(Gap::addr_type_t type, const uint8_t address[6]) {
Rohit Grover 36:9ec94579bb78 59 return getGap().setAddress(type, address);
Rohit Grover 36:9ec94579bb78 60 }
Rohit Grover 36:9ec94579bb78 61
Rohit Grover 36:9ec94579bb78 62 inline ble_error_t BLEDevice::setAdvertisingData(GapAdvertisingData &ADStructures,
Rohit Grover 36:9ec94579bb78 63 GapAdvertisingData &scanResponse) {
Rohit Grover 36:9ec94579bb78 64 return getGap().setAdvertisingData(ADStructures, scanResponse);
Rohit Grover 36:9ec94579bb78 65 }
Rohit Grover 36:9ec94579bb78 66
Rohit Grover 36:9ec94579bb78 67 inline ble_error_t BLEDevice::setAdvertisingData(GapAdvertisingData &ADStructures) {
Rohit Grover 36:9ec94579bb78 68 GapAdvertisingData scanResponse;
Rohit Grover 36:9ec94579bb78 69 return getGap().setAdvertisingData(ADStructures, scanResponse);
Rohit Grover 36:9ec94579bb78 70 }
Rohit Grover 36:9ec94579bb78 71
Rohit Grover 36:9ec94579bb78 72 inline ble_error_t BLEDevice::startAdvertising(GapAdvertisingParams &advParams) {
Rohit Grover 36:9ec94579bb78 73 return getGap().startAdvertising(advParams);
Rohit Grover 36:9ec94579bb78 74 }
Rohit Grover 36:9ec94579bb78 75
Rohit Grover 36:9ec94579bb78 76 inline ble_error_t BLEDevice::stopAdvertising(void) {
Rohit Grover 36:9ec94579bb78 77 return getGap().stopAdvertising();
Rohit Grover 36:9ec94579bb78 78 }
Rohit Grover 36:9ec94579bb78 79
Rohit Grover 36:9ec94579bb78 80 inline ble_error_t BLEDevice::disconnect(void) {
Rohit Grover 36:9ec94579bb78 81 return getGap().disconnect();
Rohit Grover 36:9ec94579bb78 82 }
Rohit Grover 36:9ec94579bb78 83
Rohit Grover 34:da2ea8cd6216 84 #endif // ifndef __BLE_DEVICE_H__