Version FC

Dependencies:   DmTftLibrary eeprom SX1280Lib filesystem mbed

Fork of MSNV2-Terminal_V1-5 by Francis CHATAIN

Revision:
24:92c30dabfda4
Parent:
22:a5929d3668b6
Child:
27:a1c37c596bfc
--- a/Service.cpp	Tue Sep 11 21:11:35 2018 +0000
+++ b/Service.cpp	Tue Sep 11 21:45:52 2018 +0000
@@ -9,17 +9,25 @@
                  REQUEST_MODE request_mode,
                  UP_MODE up_mode,
                  ACCESS_PIN access_pins[6],
-                 uint32_t subsample_rate,
+         uint32_t subsample_rate,
+         Value& delta_threshold,
+         Value& low_threshold_limit,
+         Value& high_threshold_limit,
                  ACTION action,
                  OUTPUT_MODE output_mode,
                  std::string comment)
         : device_type(type), misnet_code(misnet_code), state(state),
           access_type(access_type), request_mode(request_mode),
-          up_mode(up_mode), action(action), output_mode(output_mode),
-          comment(comment), subsample_rate(subsample_rate), activation_nb(0) {
+          up_mode(up_mode), subsample_rate(subsample_rate), delta_threshold(delta_threshold),
+          low_threshold_limit(low_threshold_limit), high_threshold_limit(high_threshold_limit),
+          action(action), output_mode(output_mode),
+          comment(comment), activation_nb(0) {
     for (int i = 0; i < 6; i++) {
         this->access_pins[i] = access_pins[i];
     }
+
+    this->current_value._value.type = Value::NOT_SET;
+    this->previous_value._value.type = Value::NOT_SET;
 }
 
 
@@ -39,6 +47,9 @@
 
 bool Service::valueToBeSentToGateway() {
   if (this->up_mode == Service::BY_RANGE) {
+    DEBUG("About to compare value %s to low limit (%s) and high limit (%s)\n",
+      this->current_value.toString().c_str(), this->low_threshold_limit.toString().c_str(),
+      this->high_threshold_limit.toString().c_str());
     return ((this->low_threshold_limit.compareTo(this->current_value) > 0)
         || (this->current_value.compareTo(this->high_threshold_limit) > 0));
   }