High level Bluetooth Low Energy API and radio abstraction layer

Dependencies:   nRF51822

Dependents:   LinkNode_LIS3DH

Fork of BLE_API by Bluetooth Low Energy

Files at this revision

API Documentation at this revision

Comitter:
ktownsend
Date:
Fri Jan 17 14:25:29 2014 +0000
Parent:
29:011e95ce78b8
Child:
31:2c94f0501807
Commit message:
Added Gap and GattServer event definitions

Changed in this revision

hw/Gap.h Show annotated file Show diff for this revision Revisions of this file
hw/GattServer.h Show annotated file Show diff for this revision Revisions of this file
hw/nRF51822s/nRF51Gap.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/hw/Gap.h	Thu Jan 16 22:29:53 2014 +0000
+++ b/hw/Gap.h	Fri Jan 17 14:25:29 2014 +0000
@@ -44,7 +44,9 @@
         /******************************************************************/
         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 @@
         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)) { 
--- a/hw/GattServer.h	Thu Jan 16 22:29:53 2014 +0000
+++ b/hw/GattServer.h	Fri Jan 17 14:25:29 2014 +0000
@@ -44,13 +44,22 @@
         /******************************************************************/
         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;
--- a/hw/nRF51822s/nRF51Gap.cpp	Thu Jan 16 22:29:53 2014 +0000
+++ b/hw/nRF51822s/nRF51Gap.cpp	Fri Jan 17 14:25:29 2014 +0000
@@ -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 */
 }
 
 /**************************************************************************/