Version FC

Dependencies:   DmTftLibrary eeprom SX1280Lib filesystem mbed

Fork of MSNV2-Terminal_V1-5 by Francis CHATAIN

Branch:
Integration
Revision:
39:13e66d087ae9
Parent:
38:9b43b2415093
--- a/DataBase.hpp	Fri Oct 19 06:32:59 2018 +0000
+++ b/DataBase.hpp	Fri Oct 19 15:08:35 2018 +0000
@@ -1,7 +1,7 @@
 /*
- * MISNet
+ * MISNet   
  *
- *  DataBase:   Contient les données du terminal
+ *  DataBase:   Contient les données du terminal 
  *
  *  Created on: August 17, 2018         Author: Francis CHATAIN
  *
@@ -19,7 +19,7 @@
 #include "sx1280-hal.h"
 #endif
 
-#include "main.h"
+
 #include "Service.hpp"
 #include "Component.hpp"
 #include "CandidateComponent.hpp"
@@ -31,7 +31,7 @@
 #include "IOTValuesDataMessagePart.hpp"
 
 
-// =======================================  Define
+// =======================================  Define 
 
 #define  MODE_STO   0x0000      //  P2P Smart Tool 
 #define  MODE_GEN   0x4000      //  P2P Generic
@@ -39,26 +39,26 @@
 #define  MODE_BCA   0xC000      //  STAR Broacast mode 
 
 
-namespace misnet
-{
-class DataBase;
+namespace misnet {
+    class DataBase;
 }
 
-// =======================================  Class content
-class misnet::DataBase
-{
+// =======================================  Class content 
+
+class misnet::DataBase {
 public:
+
     enum TERMINAL_TYPE {
-        SMART_TOOL = 0,     // Smart Tool
-        GENERIC = 1,        // Generic tool
-        NORMAL_IOT = 2,     // Normal IOT (the terminal is attached to a gateway)
-        BROADCAST_IOT = 3   // Broadcast IOT (the terminal is not attached to a gateway)
+        SMART_TOOL = 0,         // Smart Tool
+        GENERIC_PEER2PEER = 1,  // Generic tool
+        NORMAL_IOT = 2,         // Normal IOT (the terminal is attached to a gateway)
+        BROADCAST_IOT = 3       // Broadcast IOT (the terminal is not attached to a gateway)
     };
 
     DataBase() {}
     virtual ~DataBase() {}
 
-    void init ();
+    void init();
 
     void setTerminalType(TERMINAL_TYPE terminal_type) {
         this->_terminal_type = terminal_type;
@@ -137,17 +137,20 @@
         return _pending_services;
     }
 
-    short getNbService(Service::DEVICE_TYPE cdt); // return the number of declared channels for the payload
+    short getNbServices(); // return the number of declared channels for the payload 
+    short getNbService(misnet::Service::SERVICE_TYPE service); // return the number of declared channels for the payload 
+    misnet::Service::SERVICE_TYPE getServiceType(short NumService); // Get Service type 
+
 
-    void SetSensorState(short channel_rank, Service::STATE sensorState) ; // Set Sensor State  (Disable/Enable)
-    Service::STATE  GetSensorState(short channel_rank) ;                            // Get Sensor State  (Disable/Enable) know if the device shall requested
+    void SetSensorState(short channel_rank, misnet::Service::STATE sensorState); // Set Sensor State  (Disable/Enable)  
+    misnet::Service::STATE GetSensorState(short channel_rank); // Get Sensor State  (Disable/Enable) know if the device shall requested 
 
-    void SetSensorValue(uint8_t value);             // Set Sensor Value + compute value before storage
-    uint8_t GetSensorMessage(short channel_rank);   // Get Sensor Message  (False si no change no threahold, response formated)
+    void SetSensorValue(uint8_t value); // Set Sensor Value + compute value before storage
+    uint8_t GetSensorMessage(short channel_rank); // Get Sensor Message  (False si no change no threshold, response formated)
 
     short getNbActuator();
     void SetActuatorState();
-    Service::STATE GetActuatorState(short actuator_rank);
+    misnet::Service::STATE GetActuatorState(short actuator_rank);
 
     void setPayload(misnet::Payload* payload) {
         this->_payload = payload;
@@ -157,6 +160,7 @@
         return this->_payload;
     }
 
+    std::list<misnet::CandidateComponent*> * getCandidateSensorsList();
     std::list<misnet::Service*> * getCandidateServicesList();
 
     // Initialise database for a standard IOT terminal
@@ -187,47 +191,37 @@
         this->setIOTValuesDataMessagePart(NULL);
     }
 
-
-    // =============================================================== Radio Parameter (getter/setter)
+    // =============================================================== Radio Parameter (getter/setter) 
 
 
 #ifndef TEST_ENVIRONMENT
-    void getRadioParameter(uint32_t                   &rfFrequency,
-                             RadioLoRaBandwidths_t           &loraBw,
-                             RadioLoRaSpreadingFactors_t     &loraSf ,
-                             int8_t                          &txOutputPower,
-                             uint8_t                         &bufferSizeMax,
-                             int16_t                         &terminal_heartbeat_period,
-                             int16_t                         &payload_heartbeat_period);
+    void getRadioParameter(uint32_t &rfFrequency,
+            RadioLoRaBandwidths_t &loraBw,
+            RadioLoRaSpreadingFactors_t &loraSf,
+            int8_t &txOutputPower,
+            uint8_t &bufferSizeMax,
+            int16_t &terminal_heartbeat_period,
+            int16_t &payload_heartbeat_period);
 
-    void setRadioParameter ( uint32_t                   rfFrequency,
-                             RadioLoRaBandwidths_t           loraBw,
-                             RadioLoRaSpreadingFactors_t     loraSf ,
-                             int8_t                          txOutputPower,
-                             uint8_t                         ufferSizeMax,
-                             int16_t                         terminal_heartbeat_period,
-                             int16_t                         payload_heartbeat_period);
+    void setRadioParameter(uint32_t rfFrequency,
+            RadioLoRaBandwidths_t loraBw,
+            RadioLoRaSpreadingFactors_t loraSf,
+            int8_t txOutputPower,
+            uint8_t ufferSizeMax,
+            int16_t terminal_heartbeat_period,
+            int16_t payload_heartbeat_period);
 #endif
 
-    void setPayload(Payload* payload) {
-        this->_payload = payload;
-    }
-
-    Payload* getPayload() {
-        return this->_payload;
-    }
-
-    std::list<CandidateComponent*> * getCandidateSensorsList();
-
 
     // Private variables /methods
 private:
+
 #ifndef TEST_ENVIRONMENT
-    uint32_t                    _rf_frequency        ;   // HzNominal frequency
-    RadioLoRaBandwidths_t       _lora_bw             ;   /* 200; 400; 800; 1600 */
-    RadioLoRaSpreadingFactors_t _lora_sf             ;   /* SF5; SF6=; SF7; SF8 ; SF9; SF10; SF11 ; SF12 */
-    int8_t                      _tx_output_power     ;   /* Output power in dBm [-18..+13] dBm */
-    uint8_t                     _buffer_size_max     ;   /* Payload size max */
+    uint32_t _rf_frequency; // HzNominal frequency
+    RadioLoRaBandwidths_t _lora_bw; /* 200; 400; 800; 1600 */
+    RadioLoRaSpreadingFactors_t _lora_sf; /* SF5; SF6=; SF7; SF8 ; SF9; SF10; SF11 ; SF12 */
+    int8_t _tx_output_power; /* Output power in dBm [-18..+13] dBm */
+    uint8_t _buffer_size_max; /* Payload size max */
 #endif
 
     // Normal or broadcast IOT terminal
@@ -253,6 +247,6 @@
     // Services whose value must be read (a payload heart beat is ongoing)
     // but their value requests an asynchronous read
     std::vector<misnet::Service *> _pending_services;
-} ;
+};
 
 #endif  // __DATABASE_HPP__