Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DmTftLibrary eeprom SX1280Lib filesystem mbed
Fork of MSNV2-Terminal_V1-5 by
Diff: Application.cpp
- Revision:
- 8:cd489b7c49a0
- Child:
- 10:1b37e3b41947
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Application.cpp Wed Aug 22 13:03:00 2018 +0000
@@ -0,0 +1,148 @@
+/*
+ * MISNet
+ *
+ * Application.cpp
+ *
+ * Created on: August 17, 2018
+ * Author: Francis CHATAIN
+ *
+ */
+
+#include "main.h"
+#include "Application.h"
+#include "Tftlcd.h"
+#include "Lora.h"
+#include "DataBase.h"
+#include "Messages.h"
+#include "Sensor.h"
+
+static DataBase dataBase ; // Database creation
+//Tftlcd display ; // Display TFT access
+static Messages messages ; // Messages Maker (Sensors, Config, Synchro ...)
+//Sensor sensor ;
+
+
+Application::Application() { // constructeur
+ // Basic instance
+ //this.dataBase = DataBase;
+ //this.messages = Messages ; // Messages Maker (Sensors, Config, Synchro ...)
+}
+
+Application::~Application() { } // delete xxx;
+
+
+void Application::start (){ // @brief Start the Application
+ initInterfaces () ; // Primary interface uart, i2c, spi ...
+ readMemory () ; // Read memory to know the list of sensor availables
+ 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 ;
+ RadioLoRaBandwidths_t bw ;
+ RadioLoRaSpreadingFactors_t sf ;
+ int8_t pwr ;
+ uint8_t bsz ;
+ int16_t time ;
+ dataBase.getRadioParameter ( freq, bw, sf, pwr, bsz, time) ;
+
+ initLora ( freq, bw, sf, pwr ) ; // Initialise the radio module
+
+ updateDisplay ( freq, bw, sf, pwr, bsz, time ) ; // Show information
+
+ printf( "*** APP_ *** Start Application (Send message CONFIG)\r\n");
+ //buildMessageGoodhealth () ;
+ //sendMessageLora () ;
+}
+
+void Application::getScheduling (uint16_t &TimerPayload, uint16_t &TimerGoodhealth, uint16_t &TimerSynchro, uint16_t &TimerListening ) {
+
+ TimerPayload = 1L ; // TODO Dépend de la lecture de la memoire (ici simulé)
+ TimerGoodhealth = 60L ;
+ TimerSynchro = 0L ;
+ TimerListening = 0L ;
+}
+
+void Application::buildMessageSensors () { // read the queue and build the response
+ printf( "*** APP_ *** buildMessageSensors \r\n");
+ messages.buildMessageSensors () ;
+ this->sensor.getTest () ;
+}
+/*
+void Application::buildMessageGoodhealth (uint8_t &message); { // read the queue and build the response
+ printf( "*** APP_ *** BuildMessageConfig \r\n");
+}
+
+
+void Application::buildMessageSynchro (uint8_t &message); { // read the queue and build the response
+ printf( "*** APP_ *** BuildMessageConfig \r\n");
+}
+*/
+
+void Application::sendMessage () {
+ printf( "*** APP_ *** sendMessage \r\n");
+ sendMessageLora () ;
+}
+
+
+
+void Application::initInterfaces () {
+ // Depend of the configuration read on DataBase (memory origin)
+
+ debugSerial = new RawSerial (USBTX,USBRX, 230400); // Debug Link
+
+ display = new Display ; // Display TFT access
+ display.Init () ;
+
+ sensor = new Sensors () ;
+
+}
+
+void Application::setRadioParameterDataBase(){
+ dataBase.setRadioParameter ( (uint32_t)2400000000UL, LORA_BW_0400, LORA_SF7, (int8_t)-18, (uint8_t)100, (uint16_t)2000) ;
+ uint32_t freq ;
+ RadioLoRaBandwidths_t bw ;
+ RadioLoRaSpreadingFactors_t sf ;
+ int8_t pwr ;
+ uint8_t bsz ;
+ int16_t time ;
+ dataBase.getRadioParameter ( freq, bw, sf, pwr, bsz, time) ;
+}
+
+void Application::initSensors(){
+ printf( "*** APPP *** initSensors \r\n");
+ // depend of the list identified (example)
+ //bme280 = new BME280(i2c_rt);
+ // depend of the list identified
+ //bme280->init(config->getBME280_MODE());
+}
+
+void Application::readSensors () {
+ printf( "*** APP_ *** readSensors \r\n");
+ // depend of the list identified
+ // Each sensor send can put a event in the db
+ }
+
+
+void Application::initActuators(){
+ // depend of the list identified (example)
+ //bme280 = new BME280(i2c_rt);
+ // depend of the list identified
+ //bme280->init(config->getBME280_MODE());
+}
+
+
+void Application::writeActuators () {
+ // depend of the list identified
+ // Each sensor send can put a event in the queu
+ }
+
+void Application::updateDisplay (uint32_t freq,
+ RadioLoRaBandwidths_t bw,
+ RadioLoRaSpreadingFactors_t sf,
+ int8_t pwr , uint8_t bsz, int16_t time ){
+ display.Update ( sf, bw, pwr, bsz, freq, time ) ; //( LORA_SF, LORA_BW, TX_OUTPUT_POWER, BUFFER_SIZE_MAX, RF_FREQUENCY, TIMER )
+}
+
+
+
