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
- Committer:
- ktownsend
- Date:
- 2013-12-18
- Revision:
- 19:a6f33421746c
- Parent:
- 7:5e1f0d7f7c7d
- Child:
- 23:f19c60478e1b
File content as of revision 19:a6f33421746c:
#ifndef __BLE_RADIO_H__
#define __BLE_RADIO_H__
#include "blecommon.h"
#include "GattService.h"
#include "GapAdvertisingData.h"
#include "GapAdvertisingParams.h"
/**************************************************************************/
/*!
\brief
The base class used to abstract away BLE capable radio transceivers
or SOCs, to enable this BLE API to work with any radio transparently.
*/
/**************************************************************************/
class BLERadio
{
protected:
FunctionPointer _callback_event;
public:
/******************************************************************/
/*!
\brief
Identifies events generated by the radio HW when an event
callback occurs
*/
/******************************************************************/
typedef enum radio_event_e
{
RADIO_EVENT_CONNECT = 0x01, /**< A BLE connection was established by the radio */
RADIO_EVENT_DISCONNECT = 0x02, /**< The BLE device was disconnected */
RADIO_EVENT_WRITE = 0x03, /**< A BLE write request occured */
RADIO_EVENT_RADIOERROR = 0x80 /**< A low level error occured on the radio */
} radioEvent_t;
uint8_t serviceCount;
/* ToDo: Force constructor with event handler callback */
/* These functions must be defined in the sub-class */
virtual ble_error_t setAdvertising(GapAdvertisingParams &, GapAdvertisingData &, GapAdvertisingData &) = 0;
virtual ble_error_t addService(GattService &) = 0;
virtual ble_error_t readCharacteristic(GattService &, GattCharacteristic &, uint8_t[], uint16_t) = 0;
virtual ble_error_t writeCharacteristic(GattService &, GattCharacteristic &, uint8_t[], uint16_t) = 0;
virtual ble_error_t start(void) = 0;
virtual ble_error_t stop(void) = 0;
virtual ble_error_t reset(void) = 0;
/* BLE event callback (connect, disconnect, etc.) */
void attach(void (*function)(void)) {
_callback_event.attach( function );
}
template<typename T>
void attach(T *object, void (T::*member)(void)) {
_callback_event.attach( object, member );
}
};
#endif
