Bill Schilit / BLE_API

Fork of BLE_API by Bluetooth Low Energy

Committer:
ktownsend
Date:
Tue Dec 10 07:32:12 2013 +0000
Revision:
2:ffc5216bd2cc
Parent:
1:fd3ec64b2345
Child:
7:5e1f0d7f7c7d
UART Tests

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 0:ace2e8d3ce79 9 class BLERadio
ktownsend 0:ace2e8d3ce79 10 {
ktownsend 2:ffc5216bd2cc 11 protected:
ktownsend 2:ffc5216bd2cc 12 FunctionPointer _callback_event;
ktownsend 2:ffc5216bd2cc 13
ktownsend 0:ace2e8d3ce79 14 public:
ktownsend 0:ace2e8d3ce79 15 typedef enum radio_event_e
ktownsend 0:ace2e8d3ce79 16 {
ktownsend 0:ace2e8d3ce79 17 RADIO_EVENT_CONNECT = 0x01,
ktownsend 0:ace2e8d3ce79 18 RADIO_EVENT_DISCONNECT = 0x02,
ktownsend 0:ace2e8d3ce79 19 RADIO_EVENT_WRITE = 0x03,
ktownsend 0:ace2e8d3ce79 20 RADIO_EVENT_RADIOERROR = 0x80
ktownsend 0:ace2e8d3ce79 21 } radioEvent_t;
ktownsend 0:ace2e8d3ce79 22
ktownsend 0:ace2e8d3ce79 23 uint8_t serviceCount;
ktownsend 0:ace2e8d3ce79 24
ktownsend 0:ace2e8d3ce79 25 /* ToDo: Force constructor with event handler callback */
ktownsend 0:ace2e8d3ce79 26
ktownsend 0:ace2e8d3ce79 27 /* These functions must be defined in the sub-class */
ktownsend 2:ffc5216bd2cc 28 virtual ble_error_t setAdvertising(GapAdvertisingParams &, GapAdvertisingData &) = 0;
ktownsend 2:ffc5216bd2cc 29 virtual ble_error_t addService(GattService &) = 0;
ktownsend 2:ffc5216bd2cc 30 virtual ble_error_t readCharacteristic(GattService &, GattCharacteristic &, uint8_t[], uint16_t) = 0;
ktownsend 2:ffc5216bd2cc 31 virtual ble_error_t writeCharacteristic(GattService &, GattCharacteristic &, uint8_t[], uint16_t) = 0;
ktownsend 0:ace2e8d3ce79 32 virtual ble_error_t start(void) = 0;
ktownsend 0:ace2e8d3ce79 33 virtual ble_error_t stop(void) = 0;
ktownsend 0:ace2e8d3ce79 34 virtual ble_error_t reset(void) = 0;
ktownsend 2:ffc5216bd2cc 35
ktownsend 2:ffc5216bd2cc 36 /* BLE event callback (connect, disconnect, etc.) */
ktownsend 2:ffc5216bd2cc 37 void attach(void (*function)(void)) {
ktownsend 2:ffc5216bd2cc 38 _callback_event.attach( function );
ktownsend 2:ffc5216bd2cc 39 }
ktownsend 2:ffc5216bd2cc 40
ktownsend 2:ffc5216bd2cc 41 template<typename T>
ktownsend 2:ffc5216bd2cc 42 void attach(T *object, void (T::*member)(void)) {
ktownsend 2:ffc5216bd2cc 43 _callback_event.attach( object, member );
ktownsend 2:ffc5216bd2cc 44 }
ktownsend 0:ace2e8d3ce79 45 };
ktownsend 0:ace2e8d3ce79 46
ktownsend 0:ace2e8d3ce79 47 #endif