Skip to content

Commit

Permalink
feat: first implementation of leaf wetness module
Browse files Browse the repository at this point in the history
  • Loading branch information
csouzapaz committed Nov 18, 2024
1 parent 75d7bcf commit 21a40a9
Show file tree
Hide file tree
Showing 57 changed files with 15,741 additions and 0 deletions.
1 change: 1 addition & 0 deletions platformio/stima_v4/libraries/RmapCommon/stima_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define STIMA_RPC_SENSOR_NAME_DSA ("DSA")
#define STIMA_RPC_SENSOR_NAME_LVM ("LEV")
#define STIMA_RPC_SENSOR_NAME_VWC ("SVW")
#define STIMA_RPC_SENSOR_NAME_BFT ("BFT")

/*!
\brief LCD descriptions list
Expand Down
2 changes: 2 additions & 0 deletions platformio/stima_v4/master/include/canard_class_master.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
#include <rmap/service/_module/Power_1_0.h>
#include <rmap/_module/Radiation_1_0.h>
#include <rmap/service/_module/Radiation_1_0.h>
#include <rmap/_module/Leaf_1_0.h>
#include <rmap/service/_module/Leaf_1_0.h>
#include <rmap/_module/RiverLevel_1_0.h>
#include <rmap/service/_module/RiverLevel_1_0.h>
#include <rmap/_module/VWC_1_0.h>
Expand Down
5 changes: 5 additions & 0 deletions platformio/stima_v4/master/include/canard_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
#define PORT_RMAP_MPPT 54
#define PORT_RMAP_VWC 55
#define PORT_RMAP_LEVEL 56
#define PORT_RMAP_LEAF 57
#define PORT_RMAP_MASTER 100

/// @brief Parametri default per Modulo Slave (INIT_PARAMETER)
Expand All @@ -98,6 +99,7 @@
#define USE_MODULE_FIXED_RAIN
#define USE_MODULE_FIXED_WIND
#define USE_MODULE_FIXED_RADIATION
#define USE_MODULE_FIXED_LEAF
#define USE_MODULE_FIXED_VWC
#define USE_MODULE_FIXED_LEVEL
#define USE_MODULE_FIXED_POWER
Expand Down Expand Up @@ -172,6 +174,9 @@
// Radiation
#define SENSOR_METADATA_DSA 0
#define SENSOR_METADATA_RADIATION_COUNT 1
// Leaf
#define SENSOR_METADATA_BFT 0
#define SENSOR_METADATA_LEAF_COUNT 1
// VWC
#define SENSOR_METADATA_VWC1 0
#define SENSOR_METADATA_VWC2 1
Expand Down
3 changes: 3 additions & 0 deletions platformio/stima_v4/master/include/sensors_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define USE_WIND_SENSORS (USE_SENSOR_DWA + USE_SENSOR_DWB + USE_SENSOR_DWC + USE_SENSOR_DWD + USE_SENSOR_DWE + USE_SENSOR_DWF)
#define USE_POWER_MPPT_SENSORS (USE_SENSOR_DEP)
#define USE_LEVEL_SENSOR (USE_SENSOR_LVM)
#define USE_LEAF_SENSOR (USE_SENSOR_LWT)

#if (USE_TH_SENSORS && (USE_RAIN_SENSORS == 0))
#define USE_MODULE_TH (true)
Expand All @@ -230,6 +231,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define USE_MODULE_POWER_MPPT (true)
#elif (USE_LEVEL_SENSOR)
#define USE_MODULE_LEVEL (true)
#elif (USE_LEAF_SENSOR)
#define USE_MODULE_LEAF (true)
#endif

/// @brief Max count of all used sensor.
Expand Down
2 changes: 2 additions & 0 deletions platformio/stima_v4/master/include/tasks/lcd_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
#define MIN_VALID_WIND_DIR (0.0)
#define MAX_VALID_RADIATION (2000.0)
#define MIN_VALID_RADIATION (0.0)
#define MAX_VALID_LEAF (100.0)
#define MIN_VALID_LEAF (0.0)
#define MAX_VALID_LEVEL (60000.0)
#define MIN_VALID_LEVEL (0.0)
#define MAX_VALID_RAIN (1000.0)
Expand Down
5 changes: 5 additions & 0 deletions platformio/stima_v4/master/include/tasks/mqtt_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@
#include <rmap/service/_module/Power_1_0.h>
#include <rmap/_module/Radiation_1_0.h>
#include <rmap/service/_module/Radiation_1_0.h>
#include <rmap/_module/Leaf_1_0.h>
#include <rmap/service/_module/Leaf_1_0.h>
#include <rmap/_module/RiverLevel_1_0.h>
#include <rmap/service/_module/RiverLevel_1_0.h>
#include <rmap/_module/VWC_1_0.h>
Expand Down Expand Up @@ -286,6 +288,9 @@ class MqttTask : public cpp_freertos::Thread {
error_t publishSensorRadiation(MqttClientContext *context, MqttQosLevel qos, rmap_sensors_Radiation_1_0 sensor, DateTime dateTime, configuration_t *configuration, char *topic, size_t topic_length, char *sensors_topic, size_t sensors_topic_length, char *message, size_t message_length);
error_t makeSensorMessageRadiation(rmap_measures_Radiation_1_0 radiation, DateTime dateTime, char *message, size_t message_length);

error_t publishSensorLeaf(MqttClientContext *context, MqttQosLevel qos, rmap_sensors_Leaf_1_0 sensor, DateTime dateTime, configuration_t *configuration, char *topic, size_t topic_length, char *sensors_topic, size_t sensors_topic_length, char *message, size_t message_length);
error_t makeSensorMessageLeaf(rmap_measures_Leaf_1_0 leaf, DateTime dateTime, char *message, size_t message_length);

error_t publishSensorLevel(MqttClientContext *context, MqttQosLevel qos, rmap_sensors_RiverLevel_1_0 sensor, DateTime dateTime, configuration_t *configuration, char *topic, size_t topic_length, char *sensors_topic, size_t sensors_topic_length, char *message, size_t message_length);
error_t makeSensorMessageLevel(rmap_measures_RiverLevel_1_0 level, DateTime dateTime, char *message, size_t message_length);

Expand Down
3 changes: 3 additions & 0 deletions platformio/stima_v4/master/src/canard_class_master.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,9 @@ void canardClass::slave::rmap_service::set_module_type(Module_Type module_type)
case Module_Type::radiation:
_response = malloc(sizeof(rmap_service_module_Radiation_Response_1_0));
break;
case Module_Type::leaf:
_response = malloc(sizeof(rmap_service_module_Leaf_Response_1_0));
break;
case Module_Type::level:
_response = malloc(sizeof(rmap_service_module_RiverLevel_Response_1_0));
break;
Expand Down
18 changes: 18 additions & 0 deletions platformio/stima_v4/master/src/rpc_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ int RegisterRPC::configure(JsonObject params, JsonObject result)
case STIMA_MODULE_TYPE_TH:
case STIMA_MODULE_TYPE_WIND:
case STIMA_MODULE_TYPE_SOLAR_RADIATION:
case STIMA_MODULE_TYPE_LEAF:
case STIMA_MODULE_TYPE_LEVEL:
case STIMA_MODULE_TYPE_POWER_MPPT:
// Set module index (defualt START from 0xFF to point 0 index at start)
Expand Down Expand Up @@ -493,6 +494,9 @@ int RegisterRPC::configure(JsonObject params, JsonObject result)
case STIMA_MODULE_TYPE_SOLAR_RADIATION:
param.configuration->board_slave[slaveId].can_port_id = PORT_RMAP_RADIATION;
break;
case STIMA_MODULE_TYPE_LEAF:
param.configuration->board_slave[slaveId].can_port_id = PORT_RMAP_LEAF;
break;
case STIMA_MODULE_TYPE_LEVEL:
param.configuration->board_slave[slaveId].can_port_id = PORT_RMAP_LEVEL;
break;
Expand Down Expand Up @@ -564,6 +568,14 @@ int RegisterRPC::configure(JsonObject params, JsonObject result)
}
else error_command = true;
break;
case Module_Type::leaf:
if(strcmp(subject, "node.leaf") == 0) {
param.configurationLock->Take();
param.configuration->board_slave[slaveId].can_publish_id = it.value().as<unsigned int>();
param.configurationLock->Give();
}
else error_command = true;
break;
case Module_Type::level:
if(strcmp(subject, "node.lev") == 0) {
param.configurationLock->Take();
Expand Down Expand Up @@ -683,6 +695,12 @@ int RegisterRPC::configure(JsonObject params, JsonObject result)
}
else error_command = true;
break;
case Module_Type::leaf:
if (strcmp(it.value().as<const char *>(), STIMA_RPC_SENSOR_NAME_BFT) == 0) {
sensorId = SENSOR_METADATA_BFT;
}
else error_command = true;
break;
case Module_Type::level:
if (strcmp(it.value().as<const char *>(), STIMA_RPC_SENSOR_NAME_LVM) == 0) {
sensorId = SENSOR_METADATA_LVM;
Expand Down
Loading

0 comments on commit 21a40a9

Please sign in to comment.