Projeto teste do Programa de integracao com biblioteca SGAM_MDW !! Aqui visa um usuario que usa o projeto implementado para a placa NUCLEO F429ZI

Dependencies:   sgam_mdw sgam_mdw_NUCLEOF429ZI_impl Cayenne-LPP

Revision:
29:8251bb11d117
Parent:
28:18a54c786ba9
Child:
31:8b734e4fb89b
--- a/main.cpp	Sat Jul 13 15:22:18 2019 +0000
+++ b/main.cpp	Mon Jul 15 21:41:33 2019 -0300
@@ -9,9 +9,6 @@
 #include "LoRaWANInterface.h"
 #include "lora_radio_helper.h"
 
-
-ControlImpl ctrl;
-
 #define D_LOG(args...)   printf(args) 
 
 // LORA WAN CONFIGS 
@@ -32,14 +29,77 @@
 EventQueue ev_queue;
 static lorawan_app_callbacks_t callbacks;
 
+ControlImpl ctrl;
 Communication<LoraData>* comm = NULL;
 
+int test_temperature(Control* control);
+int test_gyroscope(Control* control);
+int test_lorawan(Control* control);
+
 int main() {
     D_LOG("=============== INICIO ===============\r\n");
 
+    int ret = 0;
     Control* control = ctrl.getControler();
     control->initialize();
 
+
+    //////////////////////////////////////////////////////////////////////////
+    // 1 - Test Temnperature ...
+    // ret = test_temperature(control);
+
+    // 2 - Test Gyroscope ...
+    // ret = test_gyroscope(control);
+
+    // 3 - Test LoRaWAN
+    ret = test_lorawan(control);
+    //////////////////////////////////////////////////////////////////////////
+    
+    control->finalize();
+    D_LOG("=============== FINAL ===============\r\n");
+    return ret;
+}
+
+int test_temperature(Control* control) {
+    D_LOG("=============== TEMPERATURE ===============\r\n");
+    Sensor<float>* temp = (Sensor<float>*) control->getSensor("Temperature");
+
+    int count = 0;
+
+    D_LOG("## GET VALUES ....\r\n");
+    while(count++ < 10) {
+        D_LOG("## Temp -> %f \r\n", *temp->getValue() );
+        wait(1.0); // espera 1 segundo !
+    }
+
+    return 1;
+}
+
+int test_gyroscope(Control* control) {
+    D_LOG("=============== GYROSCOPE ===============\r\n");
+
+    Sensor<GyroscopeData>* gyro = (Sensor<GyroscopeData>*) control->getSensor("Gyroscope");
+
+    int count = 0;
+
+    D_LOG("## GET VALUES ....\r\n");
+    while(count++ < 10) {
+       GyroscopeData* data = gyro->getValue();
+
+        printf("Gyro (X) => %d \r\n", data->gx);
+        printf("Gyro (Y) => %d \r\n", data->gy);
+        printf("Gyro (Z) => %d \r\n", data->gz);
+        printf("***********************************\r\n\r\n");
+
+        wait(1); // espera 1 segundo !
+    }
+
+    return 1;
+}
+
+int test_lorawan(Control* control) {
+    D_LOG("=============== LoRaWAN Comunication ===============\r\n");
+
     comm = (Communication<LoraData>*)control->getCommunication("LoRAWAN");
 
     ////////////////////////////////////////////////////////////////////////////////////////////
@@ -79,9 +139,6 @@
 
     // make your event queue dispatching events forever
     ev_queue.dispatch_forever();
-
-    control->finalize();
-    D_LOG("=============== FINAL ===============\r\n");
     return 1;
 }