Lizzy project

Dependencies:   aconno_I2C Lis2dh12 adc52832_common aconno_SEGGER_RTT

Branch:
axis_normal
Revision:
15:c0c01188a29b
Parent:
8:7ba4f82de9b6
Child:
16:482d8f81d6f3
--- a/aconno_ble/aconno_ble.cpp	Wed Aug 29 10:52:27 2018 +0000
+++ b/aconno_ble/aconno_ble.cpp	Wed Aug 29 14:48:43 2018 +0000
@@ -9,6 +9,10 @@
 #include "tasks.h"
 #include "lizzy_service.h"
 
+
+/* BLE event queue size */
+#define BLE_EVENT_COUNT         (4)
+
 init_lizzy_t init_lizzy = {
     .buzz = false,
     .leds = {false ,false, false},
@@ -18,6 +22,20 @@
 LizzyService *lizzy_service;
 
 
+static EventQueue eventQueue( BLE_EVENT_COUNT * EVENTS_EVENT_SIZE );
+
+
+void scheduleBleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context)
+{
+    BLE &ble = context->ble;
+    eventQueue.call(Callback<void()>(&ble, &BLE::processEvents));
+}
+
+EventQueue *getBLEEventQueue(void)
+{
+    return &eventQueue;
+}
+
 void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params)
 {
     (lizzy_service->get_ble())->gap().startAdvertising();
@@ -89,6 +107,9 @@
     //ble.gap().onConnection(onConnectionCallback);         
     ble.gattServer().onDataWritten(onDataWrittenCallback);
     
+    // Setup event handling. This is needed only with services.
+    ble.onEventsToProcess(scheduleBleEventsProcessing);
+    
     advertisementPacket.header = APPLICATION_ID;
     advertisementPacket.type = 0x00;
     advertisementPacket.gyroscope[0] = (int16_t)0;