Version FC

Dependencies:   DmTftLibrary eeprom SX1280Lib filesystem mbed

Fork of MSNV2-Terminal_V1-5 by Francis CHATAIN

Revision:
41:5a436163dddf
Parent:
23:d7df2e2d28de
--- a/Controller.cpp	Tue Oct 16 07:29:51 2018 +0000
+++ b/Controller.cpp	Mon Oct 22 09:37:50 2018 +0000
@@ -19,7 +19,6 @@
 
 #ifndef TEST_ENVIRONMENT
 #include "Tftlcd.h"
-#include "Lora.h"
 #endif
 
 
@@ -34,9 +33,9 @@
 using namespace misnet;
 
 
-static DataBase dataBase    ;                   // Database creation 
-static MessageFactory messageFactory    ;       // Messages Maker   (Sensors, Config, Synchro ...)
-static ExtMemory extMemory  ;                   // Memoire externe
+static DataBase         dataBase            ;                   // Database creation 
+static MessageFactory   messageFactory      ;                   // Messages Maker   (Sensors, Config, Synchro ...)
+static ExtMemory        extMemory           ;                   // Memoire externe
 
 #ifndef TEST_ENVIRONMENT
 Tftlcd     tftlcd      ;   // eventuellement a déplacer   (uniquement valable sur les conf nucléo)
@@ -65,10 +64,11 @@
 
 #ifndef TEST_ENVIRONMENT
 void Controller::start (){     // @brief Start the Controller
-    initInterfaces      ()  ;   // Primary interface uart, i2c, spi ...
-    extMemory.read      (&dataBase)  ;   // Read memory to know the list of sensor availables, fill DataBase
-    initSensors         ()  ;   // Depend of the list of sensors  launch each
-    initActuators       ()  ;   // Depend of the list of actuator launch each
+
+    initInterfaces      ()          ;   // Primary interface uart, i2c, spi ...
+    extMemory.read      (&dataBase) ;   // Read memory to know the list of sensor availables, fill DataBase
+    initSensors         ()          ;   // Depend of the list of sensors  launch each
+    initActuators       ()          ;   // Depend of the list of actuator launch each
     
     // Read Radio parameter in Database for Lora interface   (example)
     uint32_t                        freq    ; 
@@ -80,14 +80,16 @@
     int16_t                         payload_heartbeat_period;
     dataBase.getRadioParameter  ( freq, bw, sf, pwr, bsz, terminal_heartbeat_period, payload_heartbeat_period) ; 
      
-    initLora        ( freq, bw, sf, pwr ) ;    // Initialise the radio module 
+    //initLora        ( freq, bw, sf, pwr ) ;    // Initialise the radio module 
     
-    printf( "*** APP ***  start   %ld %d %d %d %d %d \r\n",freq, bw, sf, pwr, bsz, time) ; 
+    printf( "*** CTRL ***  start   %ld %d %d %d %d %d \r\n",freq, bw, sf, pwr, bsz, time) ; 
 
     tftlcd.Update   ( freq, bw, sf, pwr, bsz,  payload_heartbeat_period ) ;     // Show information 
     
-    printf( "*** APP_ ***  Start Controller (Send message GoodHealth)\r\n");
+    printf( "*** CTRL ***  Start Controller (Send message GoodHealth)\r\n");
+    
     messageFactory.buildGoodhealth () ; 
+    
     //sendMessageLora () ; 
 }
 
@@ -97,11 +99,13 @@
     debugSerial = new RawSerial (USBTX,USBRX, 230400);        // Debug Link 
     tftlcd.Init () ;  
     // I2C, SPI, UART .... 
+    
+    printf( "*** CTRL ***  End of Init Interface \r\n");
 }
 
 
 void Controller::initSensors(){
-    printf( "*** APPP ***  initSensors \r\n");  
+    printf( "*** CTRL ***  initSensors \r\n");  
     // depend of the list identified   (example)
     //bme280 = new BME280(i2c_rt);
     // depend of the list identified 
@@ -118,7 +122,7 @@
 
 void Controller::manageSensors     () {
     readSensors                     () ; 
-    messageFactory.buildSensors           () ; 
+    messageFactory.buildSensors     () ; 
     sendMessage                     () ; 
 }
 
@@ -144,23 +148,23 @@
 
 void Controller::getScheduling (uint16_t &TimerPayload,  uint16_t &TimerGoodhealth, uint16_t &TimerSynchro, uint16_t &TimerListening ) {
 
-    TimerPayload        = 3L     ;   // TODO  Dépend de la lecture de la memoire  (ici simulé)
+    TimerPayload        = 5L     ;   // TODO  Dépend de la lecture de la memoire  (ici simulé)
     TimerGoodhealth     = 60L    ; 
     TimerSynchro        = 0L     ;  
     TimerListening      = 0L     ;                  
 }
 
 void Controller::sendMessage       () {
-    printf( "*** APP_ ***  sendMessage \r\n");
-    sendMessageLora () ; 
+    printf( "*** CTRL ***  sendMessage \r\n");
+    //sendMessageLora () ; 
 }
 
 
 void Controller::readSensors       () {
-    printf( "*** APP_ ***  readSensors \r\n");
-    printf("*** APP *** loop on all channels\r\n");
+    printf("*** CTRL ***  readSensors \r\n");
+    printf("*** CTRL ***  loop on all channels\r\n");
     short nbSensors = dataBase.getNbService(Service::SENSOR);
-    printf("*** APP *** there are %d sensors in this payload\r\n", nbSensors);
+    printf("*** CTRL *** there are %d sensors in this payload\r\n", nbSensors);
     // depend of the list identified 
     // Each sensor sends an event in the db
     //iks01a2.read () ;