Degree Computation

Dependencies:   aconno_SEGGER_RTT LSM9DS1 Si7006A20 adc52832_common aconnoMPL115A1 aconno_bsp

Revision:
0:442d98af8cc7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tasks/tasks.cpp	Wed Dec 12 19:28:16 2018 +0100
@@ -0,0 +1,48 @@
+/**
+ * Made by Jurica @ aconno
+ * jurica@aconno.de
+ * More info @ aconno.de
+ */
+
+#include "mbed.h"
+#include "aconnoHelpers.h"
+#include "ble/BLE.h"
+#include "aconnoConfig.h"
+
+#define UPDATE_SENSORS_SIGNAL   (0x10001000)
+#define SEND_DATA_SIGNAL        (0x10001001) 
+extern Thread updateDataThread;
+extern Thread sendDataThread;
+
+void updateDataTask()
+{
+    //printf("updateDataTask started.\r\n");
+    while(1)
+    {
+        
+        ThisThread::flags_wait_any(UPDATE_SENSORS_SIGNAL);
+        //printf("Ulazim\r\n");
+        updateData();
+        sendDataThread.flags_set(SEND_DATA_SIGNAL);
+        //printf("Vrtim se.\r\n");
+    }
+}
+
+void sendDataTask()
+{
+    //printf("sendDataTask started.\r\n");
+    BLE &ble = BLE::Instance();
+    while(1)
+    {
+        updateDataThread.flags_set(UPDATE_SENSORS_SIGNAL);
+        ThisThread::flags_wait_any(SEND_DATA_SIGNAL);
+        //printf("Turning BLE radion on.\r\n");
+        ble.gap().startAdvertising();
+        ThisThread::sleep_for(RADIO_ACTIVE_TIME_MS);
+        //printf("Turining BLE radio off.\r\n");
+        ble.gap().stopAdvertising();
+        MBED_ASSERT((ADV_PERIOD_TIME_MS-RADIO_ACTIVE_TIME_MS) > 0);
+        ThisThread::sleep_for(ADV_PERIOD_TIME_MS-RADIO_ACTIVE_TIME_MS);
+        
+    }
+}
\ No newline at end of file