Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BLE_API by
hw/bleradio.h@7:5e1f0d7f7c7d, 2013-12-16 (annotated)
- Committer:
- ktownsend
- Date:
- Mon Dec 16 12:46:12 2013 +0000
- Revision:
- 7:5e1f0d7f7c7d
- Parent:
- 2:ffc5216bd2cc
- Child:
- 19:a6f33421746c
More GAP cleanup (Scan Response, etc.)
Who changed what in which revision?
| User | Revision | Line number | New 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 | 7:5e1f0d7f7c7d | 28 | virtual ble_error_t setAdvertising(GapAdvertisingParams &, GapAdvertisingData &, 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 |
