High level Bluetooth Low Energy API and radio abstraction layer

Dependencies:   nRF51822

Dependents:   LinkNode_LIS3DH

Fork of BLE_API by Bluetooth Low Energy

Committer:
ktownsend
Date:
Wed Dec 18 20:11:45 2013 +0000
Revision:
19:a6f33421746c
Parent:
7:5e1f0d7f7c7d
Child:
23:f19c60478e1b
A few more doxygen improvements

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ktownsend 0:ace2e8d3ce79 1 #ifndef __BLE_RADIO_H__
ktownsend 0:ace2e8d3ce79 2 #define __BLE_RADIO_H__
ktownsend 0:ace2e8d3ce79 3
ktownsend 0:ace2e8d3ce79 4 #include "blecommon.h"
ktownsend 2:ffc5216bd2cc 5 #include "GattService.h"
ktownsend 2:ffc5216bd2cc 6 #include "GapAdvertisingData.h"
ktownsend 2:ffc5216bd2cc 7 #include "GapAdvertisingParams.h"
ktownsend 0:ace2e8d3ce79 8
ktownsend 19:a6f33421746c 9 /**************************************************************************/
ktownsend 19:a6f33421746c 10 /*!
ktownsend 19:a6f33421746c 11 \brief
ktownsend 19:a6f33421746c 12 The base class used to abstract away BLE capable radio transceivers
ktownsend 19:a6f33421746c 13 or SOCs, to enable this BLE API to work with any radio transparently.
ktownsend 19:a6f33421746c 14 */
ktownsend 19:a6f33421746c 15 /**************************************************************************/
ktownsend 0:ace2e8d3ce79 16 class BLERadio
ktownsend 0:ace2e8d3ce79 17 {
ktownsend 2:ffc5216bd2cc 18 protected:
ktownsend 2:ffc5216bd2cc 19 FunctionPointer _callback_event;
ktownsend 2:ffc5216bd2cc 20
ktownsend 0:ace2e8d3ce79 21 public:
ktownsend 19:a6f33421746c 22 /******************************************************************/
ktownsend 19:a6f33421746c 23 /*!
ktownsend 19:a6f33421746c 24 \brief
ktownsend 19:a6f33421746c 25 Identifies events generated by the radio HW when an event
ktownsend 19:a6f33421746c 26 callback occurs
ktownsend 19:a6f33421746c 27 */
ktownsend 19:a6f33421746c 28 /******************************************************************/
ktownsend 0:ace2e8d3ce79 29 typedef enum radio_event_e
ktownsend 0:ace2e8d3ce79 30 {
ktownsend 19:a6f33421746c 31 RADIO_EVENT_CONNECT = 0x01, /**< A BLE connection was established by the radio */
ktownsend 19:a6f33421746c 32 RADIO_EVENT_DISCONNECT = 0x02, /**< The BLE device was disconnected */
ktownsend 19:a6f33421746c 33 RADIO_EVENT_WRITE = 0x03, /**< A BLE write request occured */
ktownsend 19:a6f33421746c 34 RADIO_EVENT_RADIOERROR = 0x80 /**< A low level error occured on the radio */
ktownsend 0:ace2e8d3ce79 35 } radioEvent_t;
ktownsend 0:ace2e8d3ce79 36
ktownsend 0:ace2e8d3ce79 37 uint8_t serviceCount;
ktownsend 0:ace2e8d3ce79 38
ktownsend 0:ace2e8d3ce79 39 /* ToDo: Force constructor with event handler callback */
ktownsend 0:ace2e8d3ce79 40
ktownsend 0:ace2e8d3ce79 41 /* These functions must be defined in the sub-class */
ktownsend 7:5e1f0d7f7c7d 42 virtual ble_error_t setAdvertising(GapAdvertisingParams &, GapAdvertisingData &, GapAdvertisingData &) = 0;
ktownsend 2:ffc5216bd2cc 43 virtual ble_error_t addService(GattService &) = 0;
ktownsend 2:ffc5216bd2cc 44 virtual ble_error_t readCharacteristic(GattService &, GattCharacteristic &, uint8_t[], uint16_t) = 0;
ktownsend 2:ffc5216bd2cc 45 virtual ble_error_t writeCharacteristic(GattService &, GattCharacteristic &, uint8_t[], uint16_t) = 0;
ktownsend 0:ace2e8d3ce79 46 virtual ble_error_t start(void) = 0;
ktownsend 0:ace2e8d3ce79 47 virtual ble_error_t stop(void) = 0;
ktownsend 0:ace2e8d3ce79 48 virtual ble_error_t reset(void) = 0;
ktownsend 2:ffc5216bd2cc 49
ktownsend 2:ffc5216bd2cc 50 /* BLE event callback (connect, disconnect, etc.) */
ktownsend 2:ffc5216bd2cc 51 void attach(void (*function)(void)) {
ktownsend 2:ffc5216bd2cc 52 _callback_event.attach( function );
ktownsend 2:ffc5216bd2cc 53 }
ktownsend 2:ffc5216bd2cc 54
ktownsend 2:ffc5216bd2cc 55 template<typename T>
ktownsend 2:ffc5216bd2cc 56 void attach(T *object, void (T::*member)(void)) {
ktownsend 2:ffc5216bd2cc 57 _callback_event.attach( object, member );
ktownsend 2:ffc5216bd2cc 58 }
ktownsend 0:ace2e8d3ce79 59 };
ktownsend 0:ace2e8d3ce79 60
ktownsend 0:ace2e8d3ce79 61 #endif