Added Gap and GattServer event definitions

This commit is contained in:
ktownsend 2014-01-17 14:25:29 +00:00
parent 88fc64ded8
commit 496a607f88
3 changed files with 16 additions and 6 deletions

View file

@ -44,7 +44,9 @@ class Gap
/******************************************************************/
typedef enum gap_event_e
{
GAP_EVENT_TODO = 0x01 /**< ... */
GAP_EVENT_ADVERTISING_STARTED = 1,
GAP_EVENT_CONNECTED = 2,
GAP_EVENT_DISCONNECTED = 3
} gapEvent_t;
/* These functions must be defined in the sub-class */
@ -52,8 +54,7 @@ class Gap
virtual ble_error_t startAdvertising(void) = 0;
virtual ble_error_t stopAdvertising(void) = 0;
uint8_t advertising;
uint8_t connected;
uint16_t state; /* Initialising, Advertising, Scanning, Connected, etc. ... more than one bit can be set at a time! */
/* Event callback */
void attach(void (*function)(void)) {

View file

@ -44,13 +44,22 @@ class GattServer
/******************************************************************/
typedef enum gatt_event_e
{
GATT_EVENT_TODO = 0x01 /**< ... */
GATT_EVENT_DATA_SENT = 1, /* Fired when a msg was successfully sent out */
GATT_EVENT_DATA_WRITTEN = 2, /* Client wrote data to Server (separate into char and descriptor writes?) */
GATT_EVENT_UPDATES_ENABLED = 3, /* Notify/Indicate Enabled in CCCD */
GATT_EVENT_UPDATES_DISABLED = 4, /* Notify/Indicate Disnabled in CCCD */
GATT_EVENT_CONFIRMATION_RECEIVED = 5 /* Response received from Indicate message */
} gattEvent_t;
/* These functions must be defined in the sub-class */
virtual ble_error_t addService(GattService &) = 0;
virtual ble_error_t readValue(uint8_t, uint8_t[], uint16_t) = 0;
virtual ble_error_t updateValue(uint8_t, uint8_t[], uint16_t) = 0;
// ToDo: For updateValue, check the CCCD to see if the value we are
// updating has the notify or indicate bits sent, and if BOTH are set
// be sure to call sd_ble_gatts_hvx() twice with notify then indicate!
// Strange use case, but valid and must be covered!
uint8_t serviceCount;
uint8_t characteristicCount;

View file

@ -24,8 +24,8 @@
/**************************************************************************/
nRF51Gap::nRF51Gap(RawSerial &serial) : Gap(), uart(serial)
{
/* Reset the service and characteristic counters */
connected = 0;
/* ToDo: Reset the service and characteristic counters */
/* ToDo: Set state variable to an appropriate value */
}
/**************************************************************************/