diff --git a/src/ButtonThread.h b/src/ButtonThread.h index 3fc11bc3b..49243a93d 100644 --- a/src/ButtonThread.h +++ b/src/ButtonThread.h @@ -118,8 +118,8 @@ class ButtonThread : public concurrency::OSThread { // DEBUG_MSG("press!\n"); #ifdef BUTTON_PIN - if ((BUTTON_PIN != moduleConfig.payloadVariant.canned_message.inputbroker_pin_press) || - !moduleConfig.payloadVariant.canned_message.enabled) { + if ((BUTTON_PIN != moduleConfig.canned_message.inputbroker_pin_press) || + !moduleConfig.canned_message.enabled) { powerFSM.trigger(EVENT_PRESS); } #endif diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index d3bb500f3..dc1b0108a 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -353,8 +353,8 @@ static void drawCriticalFaultFrame(OLEDDisplay *display, OLEDDisplayUiState *sta // Ignore messages orginating from phone (from the current node 0x0) unless range test or store and forward module are enabled static bool shouldDrawMessage(const MeshPacket *packet) { - return packet->from != 0 && !moduleConfig.payloadVariant.range_test.enabled && - !moduleConfig.payloadVariant.store_forward.enabled; + return packet->from != 0 && !moduleConfig.range_test.enabled && + !moduleConfig.store_forward.enabled; } /// Draw the last text message we received diff --git a/src/input/RotaryEncoderInterruptImpl1.cpp b/src/input/RotaryEncoderInterruptImpl1.cpp index c53d2d0d4..bc897deef 100644 --- a/src/input/RotaryEncoderInterruptImpl1.cpp +++ b/src/input/RotaryEncoderInterruptImpl1.cpp @@ -7,19 +7,19 @@ RotaryEncoderInterruptImpl1::RotaryEncoderInterruptImpl1() : RotaryEncoderInterr void RotaryEncoderInterruptImpl1::init() { - if (!moduleConfig.payloadVariant.canned_message.rotary1_enabled) { + if (!moduleConfig.canned_message.rotary1_enabled) { // Input device is disabled. return; } - uint8_t pinA = moduleConfig.payloadVariant.canned_message.inputbroker_pin_a; - uint8_t pinB = moduleConfig.payloadVariant.canned_message.inputbroker_pin_b; - uint8_t pinPress = moduleConfig.payloadVariant.canned_message.inputbroker_pin_press; - char eventCw = static_cast(moduleConfig.payloadVariant.canned_message.inputbroker_event_cw); - char eventCcw = static_cast(moduleConfig.payloadVariant.canned_message.inputbroker_event_ccw); - char eventPressed = static_cast(moduleConfig.payloadVariant.canned_message.inputbroker_event_press); + uint8_t pinA = moduleConfig.canned_message.inputbroker_pin_a; + uint8_t pinB = moduleConfig.canned_message.inputbroker_pin_b; + uint8_t pinPress = moduleConfig.canned_message.inputbroker_pin_press; + char eventCw = static_cast(moduleConfig.canned_message.inputbroker_event_cw); + char eventCcw = static_cast(moduleConfig.canned_message.inputbroker_event_ccw); + char eventPressed = static_cast(moduleConfig.canned_message.inputbroker_event_press); - // moduleConfig.payloadVariant.canned_message.ext_notification_module_output + // moduleConfig.canned_message.ext_notification_module_output RotaryEncoderInterruptBase::init(pinA, pinB, pinPress, eventCw, eventCcw, eventPressed, RotaryEncoderInterruptImpl1::handleIntA, RotaryEncoderInterruptImpl1::handleIntB, RotaryEncoderInterruptImpl1::handleIntPressed); diff --git a/src/input/UpDownInterruptImpl1.cpp b/src/input/UpDownInterruptImpl1.cpp index 76e664d76..fc04a8628 100644 --- a/src/input/UpDownInterruptImpl1.cpp +++ b/src/input/UpDownInterruptImpl1.cpp @@ -8,14 +8,14 @@ UpDownInterruptImpl1::UpDownInterruptImpl1() : UpDownInterruptBase("upDown1") {} void UpDownInterruptImpl1::init() { - if (!moduleConfig.payloadVariant.canned_message.updown1_enabled) { + if (!moduleConfig.canned_message.updown1_enabled) { // Input device is disabled. return; } - uint8_t pinUp = moduleConfig.payloadVariant.canned_message.inputbroker_pin_a; - uint8_t pinDown = moduleConfig.payloadVariant.canned_message.inputbroker_pin_b; - uint8_t pinPress = moduleConfig.payloadVariant.canned_message.inputbroker_pin_press; + uint8_t pinUp = moduleConfig.canned_message.inputbroker_pin_a; + uint8_t pinDown = moduleConfig.canned_message.inputbroker_pin_b; + uint8_t pinPress = moduleConfig.canned_message.inputbroker_pin_press; char eventDown = static_cast(ModuleConfig_CannedMessageConfig_InputEventChar_KEY_DOWN); char eventUp = static_cast(ModuleConfig_CannedMessageConfig_InputEventChar_KEY_UP); diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 71952ac56..d804aa8e1 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -35,7 +35,7 @@ NodeDB nodeDB; EXT_RAM_ATTR DeviceState devicestate; MyNodeInfo &myNodeInfo = devicestate.my_node; LocalConfig config; -ModuleConfig moduleConfig; +LocalModuleConfig moduleConfig; ChannelFile channelFile; /** The current change # for radio settings. Starts at 0 on boot and any time the radio settings diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 3a3f3834f..e2ec49a9f 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -12,7 +12,7 @@ extern DeviceState devicestate; extern ChannelFile channelFile; extern MyNodeInfo &myNodeInfo; extern LocalConfig config; -extern ModuleConfig moduleConfig; +extern LocalModuleConfig moduleConfig; extern User &owner; /// Given a node, return how many seconds in the past (vs now) that we last heard from it diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index a82e2f872..87e319d83 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -227,7 +227,7 @@ ErrorCode Router::send(MeshPacket *p) */ bool shouldActuallyEncrypt = true; - if (*moduleConfig.payloadVariant.mqtt.address && !moduleConfig.payloadVariant.mqtt.encryption_enabled) { + if (*moduleConfig.mqtt.address && !moduleConfig.mqtt.encryption_enabled) { shouldActuallyEncrypt = false; } diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 903086139..decce0291 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -208,31 +208,31 @@ void AdminModule::handleSetModuleConfig(const ModuleConfig &c) switch (c.which_payloadVariant) { case ModuleConfig_mqtt_tag: DEBUG_MSG("Setting module config: MQTT\n"); - moduleConfig.payloadVariant.mqtt = c.payloadVariant.mqtt; + moduleConfig.mqtt = c.payloadVariant.mqtt; break; case ModuleConfig_serial_tag: DEBUG_MSG("Setting module config: Serial\n"); - moduleConfig.payloadVariant.serial = c.payloadVariant.serial; + moduleConfig.serial = c.payloadVariant.serial; break; case ModuleConfig_external_notification_tag: DEBUG_MSG("Setting module config: External Notification\n"); - moduleConfig.payloadVariant.external_notification = c.payloadVariant.external_notification; + moduleConfig.external_notification = c.payloadVariant.external_notification; break; case ModuleConfig_store_forward_tag: DEBUG_MSG("Setting module config: Store & Forward\n"); - moduleConfig.payloadVariant.store_forward = c.payloadVariant.store_forward; + moduleConfig.store_forward = c.payloadVariant.store_forward; break; case ModuleConfig_range_test_tag: DEBUG_MSG("Setting module config: Range Test\n"); - moduleConfig.payloadVariant.range_test = c.payloadVariant.range_test; + moduleConfig.range_test = c.payloadVariant.range_test; break; case ModuleConfig_telemetry_tag: DEBUG_MSG("Setting module config: Telemetry\n"); - moduleConfig.payloadVariant.telemetry = c.payloadVariant.telemetry; + moduleConfig.telemetry = c.payloadVariant.telemetry; break; case ModuleConfig_canned_message_tag: DEBUG_MSG("Setting module config: Canned Message\n"); - moduleConfig.payloadVariant.canned_message = c.payloadVariant.canned_message; + moduleConfig.canned_message = c.payloadVariant.canned_message; break; } @@ -323,38 +323,38 @@ void AdminModule::handleGetModuleConfig(const MeshPacket &req, const uint32_t co case AdminMessage_ModuleConfigType_MQTT_CONFIG: DEBUG_MSG("Getting module config: MQTT\n"); res.get_module_config_response.which_payloadVariant = ModuleConfig_mqtt_tag; - res.get_module_config_response.payloadVariant.mqtt = moduleConfig.payloadVariant.mqtt; + res.get_module_config_response.payloadVariant.mqtt = moduleConfig.mqtt; break; case AdminMessage_ModuleConfigType_SERIAL_CONFIG: DEBUG_MSG("Getting module config: Serial\n"); res.get_module_config_response.which_payloadVariant = ModuleConfig_serial_tag; - res.get_module_config_response.payloadVariant.serial = moduleConfig.payloadVariant.serial; + res.get_module_config_response.payloadVariant.serial = moduleConfig.serial; break; case AdminMessage_ModuleConfigType_EXTNOTIF_CONFIG: DEBUG_MSG("Getting module config: External Notification\n"); res.get_module_config_response.which_payloadVariant = ModuleConfig_external_notification_tag; res.get_module_config_response.payloadVariant.external_notification = - moduleConfig.payloadVariant.external_notification; + moduleConfig.external_notification; break; case AdminMessage_ModuleConfigType_STOREFORWARD_CONFIG: DEBUG_MSG("Getting module config: Store & Forward\n"); res.get_module_config_response.which_payloadVariant = ModuleConfig_store_forward_tag; - res.get_module_config_response.payloadVariant.store_forward = moduleConfig.payloadVariant.store_forward; + res.get_module_config_response.payloadVariant.store_forward = moduleConfig.store_forward; break; case AdminMessage_ModuleConfigType_RANGETEST_CONFIG: DEBUG_MSG("Getting module config: Range Test\n"); res.get_module_config_response.which_payloadVariant = ModuleConfig_range_test_tag; - res.get_module_config_response.payloadVariant.range_test = moduleConfig.payloadVariant.range_test; + res.get_module_config_response.payloadVariant.range_test = moduleConfig.range_test; break; case AdminMessage_ModuleConfigType_TELEMETRY_CONFIG: DEBUG_MSG("Getting module config: Telemetry\n"); res.get_module_config_response.which_payloadVariant = ModuleConfig_telemetry_tag; - res.get_module_config_response.payloadVariant.telemetry = moduleConfig.payloadVariant.telemetry; + res.get_module_config_response.payloadVariant.telemetry = moduleConfig.telemetry; break; case AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG: DEBUG_MSG("Getting module config: Canned Message\n"); res.get_module_config_response.which_payloadVariant = ModuleConfig_canned_message_tag; - res.get_module_config_response.payloadVariant.canned_message = moduleConfig.payloadVariant.canned_message; + res.get_module_config_response.payloadVariant.canned_message = moduleConfig.canned_message; break; } diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 5f2eb4307..6d7064c25 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -28,7 +28,7 @@ extern bool saveProto(const char *filename, size_t protoSize, size_t objSize, co CannedMessageModule::CannedMessageModule() : SinglePortModule("canned", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread("CannedMessageModule") { - if (moduleConfig.payloadVariant.canned_message.enabled) { + if (moduleConfig.canned_message.enabled) { this->loadProtoForModule(); if (this->splitConfiguredMessages() <= 0) { DEBUG_MSG("CannedMessageModule: No messages are configured. Module is disabled\n"); @@ -91,9 +91,9 @@ int CannedMessageModule::splitConfiguredMessages() int CannedMessageModule::handleInputEvent(const InputEvent *event) { - if ((strlen(moduleConfig.payloadVariant.canned_message.allow_input_source) > 0) && - (strcmp(moduleConfig.payloadVariant.canned_message.allow_input_source, event->source) != 0) && - (strcmp(moduleConfig.payloadVariant.canned_message.allow_input_source, "_any") != 0)) { + if ((strlen(moduleConfig.canned_message.allow_input_source) > 0) && + (strcmp(moduleConfig.canned_message.allow_input_source, event->source) != 0) && + (strcmp(moduleConfig.canned_message.allow_input_source, "_any") != 0)) { // Event source is not accepted. // Event only accepted if source matches the configured one, or // the configured one is "_any" (or if there is no configured @@ -138,7 +138,7 @@ void CannedMessageModule::sendText(NodeNum dest, const char *message, bool wantR p->want_ack = true; p->decoded.payload.size = strlen(message); memcpy(p->decoded.payload.bytes, message, p->decoded.payload.size); - if (moduleConfig.payloadVariant.canned_message.send_bell) { + if (moduleConfig.canned_message.send_bell) { p->decoded.payload.bytes[p->decoded.payload.size - 1] = 7; // Bell character p->decoded.payload.bytes[p->decoded.payload.size] = '\0'; // Bell character p->decoded.payload.size++; @@ -151,7 +151,7 @@ void CannedMessageModule::sendText(NodeNum dest, const char *message, bool wantR int32_t CannedMessageModule::runOnce() { - if ((!moduleConfig.payloadVariant.canned_message.enabled) || (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED) || + if ((!moduleConfig.canned_message.enabled) || (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED) || (this->runState == CANNED_MESSAGE_RUN_STATE_INACTIVE)) { return 30000; // TODO: should return MAX_VAL } @@ -214,7 +214,7 @@ const char *CannedMessageModule::getNextMessage() } bool CannedMessageModule::shouldDraw() { - if (!moduleConfig.payloadVariant.canned_message.enabled) { + if (!moduleConfig.canned_message.enabled) { return false; } return (currentMessageIndex != -1) || (this->runState != CANNED_MESSAGE_RUN_STATE_INACTIVE); diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 58c261048..b9e946823 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -19,26 +19,26 @@ Quick reference: - moduleConfig.payloadVariant.external_notification.enabled + moduleConfig.external_notification.enabled 0 = Disabled (Default) 1 = Enabled - moduleConfig.payloadVariant.external_notification.active + moduleConfig.external_notification.active 0 = Active Low (Default) 1 = Active High - moduleConfig.payloadVariant.external_notification.alert_message + moduleConfig.external_notification.alert_message 0 = Disabled (Default) 1 = Alert when a text message comes - moduleConfig.payloadVariant.external_notification.alert_bell + moduleConfig.external_notification.alert_bell 0 = Disabled (Default) 1 = Alert when the bell character is received - moduleConfig.payloadVariant.external_notification.output + moduleConfig.external_notification.output GPIO of the output. (Default = 13) - moduleConfig.payloadVariant.external_notification.output_ms + moduleConfig.external_notification.output_ms Amount of time in ms for the alert. Default is 1000. */ @@ -59,19 +59,19 @@ int32_t ExternalNotificationModule::runOnce() without having to configure it from the PythonAPI or WebUI. */ - // moduleConfig.payloadVariant.external_notification.enabled = 1; - // moduleConfig.payloadVariant.external_notification.alert_message = 1; + // moduleConfig.external_notification.enabled = 1; + // moduleConfig.external_notification.alert_message = 1; - // moduleConfig.payloadVariant.external_notification.active = 1; - // moduleConfig.payloadVariant.external_notification.alert_bell = 1; - // moduleConfig.payloadVariant.external_notification.output_ms = 1000; - // moduleConfig.payloadVariant.external_notification.output = 13; + // moduleConfig.external_notification.active = 1; + // moduleConfig.external_notification.alert_bell = 1; + // moduleConfig.external_notification.output_ms = 1000; + // moduleConfig.external_notification.output = 13; if (externalCurrentState) { // If the output is turned on, turn it back off after the given period of time. - if (externalTurnedOn + (moduleConfig.payloadVariant.external_notification.output_ms - ? moduleConfig.payloadVariant.external_notification.output_ms + if (externalTurnedOn + (moduleConfig.external_notification.output_ms + ? moduleConfig.external_notification.output_ms : EXT_NOTIFICATION_MODULE_OUTPUT_MS) < millis()) { DEBUG_MSG("Turning off external notification\n"); @@ -88,10 +88,10 @@ void ExternalNotificationModule::setExternalOn() externalCurrentState = 1; externalTurnedOn = millis(); - digitalWrite((moduleConfig.payloadVariant.external_notification.output - ? moduleConfig.payloadVariant.external_notification.output + digitalWrite((moduleConfig.external_notification.output + ? moduleConfig.external_notification.output : EXT_NOTIFICATION_MODULE_OUTPUT), - (moduleConfig.payloadVariant.external_notification.active ? true : false)); + (moduleConfig.external_notification.active ? true : false)); #endif } @@ -100,10 +100,10 @@ void ExternalNotificationModule::setExternalOff() #ifdef EXT_NOTIFY_OUT externalCurrentState = 0; - digitalWrite((moduleConfig.payloadVariant.external_notification.output - ? moduleConfig.payloadVariant.external_notification.output + digitalWrite((moduleConfig.external_notification.output + ? moduleConfig.external_notification.output : EXT_NOTIFICATION_MODULE_OUTPUT), - (moduleConfig.payloadVariant.external_notification.active ? false : true)); + (moduleConfig.external_notification.active ? false : true)); #endif } @@ -124,21 +124,21 @@ ExternalNotificationModule::ExternalNotificationModule() without having to configure it from the PythonAPI or WebUI. */ - // moduleConfig.payloadVariant.external_notification.enabled = 1; - // moduleConfig.payloadVariant.external_notification.alert_message = 1; + // moduleConfig.external_notification.enabled = 1; + // moduleConfig.external_notification.alert_message = 1; - // moduleConfig.payloadVariant.external_notification.active = 1; - // moduleConfig.payloadVariant.external_notification.alert_bell = 1; - // moduleConfig.payloadVariant.external_notification.output_ms = 1000; - // moduleConfig.payloadVariant.external_notification.output = 13; + // moduleConfig.external_notification.active = 1; + // moduleConfig.external_notification.alert_bell = 1; + // moduleConfig.external_notification.output_ms = 1000; + // moduleConfig.external_notification.output = 13; - if (moduleConfig.payloadVariant.external_notification.enabled) { + if (moduleConfig.external_notification.enabled) { DEBUG_MSG("Initializing External Notification Module\n"); // Set the direction of a pin - pinMode((moduleConfig.payloadVariant.external_notification.output - ? moduleConfig.payloadVariant.external_notification.output + pinMode((moduleConfig.external_notification.output + ? moduleConfig.external_notification.output : EXT_NOTIFICATION_MODULE_OUTPUT), OUTPUT); @@ -157,13 +157,13 @@ ProcessMessage ExternalNotificationModule::handleReceived(const MeshPacket &mp) #ifndef NO_ESP32 #ifdef EXT_NOTIFY_OUT - if (moduleConfig.payloadVariant.external_notification.enabled) { + if (moduleConfig.external_notification.enabled) { if (getFrom(&mp) != nodeDB.getNodeNum()) { // TODO: This may be a problem if messages are sent in unicide, but I'm not sure if it will. // Need to know if and how this could be a problem. - if (moduleConfig.payloadVariant.external_notification.alert_bell) { + if (moduleConfig.external_notification.alert_bell) { auto &p = mp.decoded; DEBUG_MSG("externalNotificationModule - Notification Bell\n"); for (int i = 0; i < p.payload.size; i++) { @@ -173,7 +173,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const MeshPacket &mp) } } - if (moduleConfig.payloadVariant.external_notification.alert_message) { + if (moduleConfig.external_notification.alert_message) { DEBUG_MSG("externalNotificationModule - Notification Module\n"); setExternalOn(); } diff --git a/src/modules/Telemetry/DeviceTelemetry.cpp b/src/modules/Telemetry/DeviceTelemetry.cpp index 903747b9e..b58441bf7 100644 --- a/src/modules/Telemetry/DeviceTelemetry.cpp +++ b/src/modules/Telemetry/DeviceTelemetry.cpp @@ -21,7 +21,7 @@ int32_t DeviceTelemetryModule::runOnce() sendOurTelemetry(); // OSThread library. Multiply the preference value by 1000 to convert seconds to miliseconds - return getIntervalOrDefaultMs(moduleConfig.payloadVariant.telemetry.device_update_interval); + return getIntervalOrDefaultMs(moduleConfig.telemetry.device_update_interval); #endif } diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index ce66cc034..534819d86 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -50,17 +50,17 @@ int32_t EnvironmentTelemetryModule::runOnce() without having to configure it from the PythonAPI or WebUI. */ /* - moduleConfig.payloadVariant.telemetry.environment_measurement_enabled = 1; - moduleConfig.payloadVariant.telemetry.environment_screen_enabled = 1; - moduleConfig.payloadVariant.telemetry.environment_read_error_count_threshold = 5; - moduleConfig.payloadVariant.telemetry.environment_update_interval = 600; - moduleConfig.payloadVariant.telemetry.environment_recovery_interval = 60; - moduleConfig.payloadVariant.telemetry.environment_sensor_pin = 13; // If one-wire - moduleConfig.payloadVariant.telemetry.environment_sensor_type = TelemetrySensorType::TelemetrySensorType_BME280; + moduleConfig.telemetry.environment_measurement_enabled = 1; + moduleConfig.telemetry.environment_screen_enabled = 1; + moduleConfig.telemetry.environment_read_error_count_threshold = 5; + moduleConfig.telemetry.environment_update_interval = 600; + moduleConfig.telemetry.environment_recovery_interval = 60; + moduleConfig.telemetry.environment_sensor_pin = 13; // If one-wire + moduleConfig.telemetry.environment_sensor_type = TelemetrySensorType::TelemetrySensorType_BME280; */ - if (!(moduleConfig.payloadVariant.telemetry.environment_measurement_enabled || - moduleConfig.payloadVariant.telemetry.environment_screen_enabled)) { + if (!(moduleConfig.telemetry.environment_measurement_enabled || + moduleConfig.telemetry.environment_screen_enabled)) { // If this module is not enabled, and the user doesn't want the display screen don't waste any OSThread time on it return (INT32_MAX); } @@ -69,11 +69,11 @@ int32_t EnvironmentTelemetryModule::runOnce() // This is the first time the OSThread library has called this function, so do some setup firstTime = 0; - if (moduleConfig.payloadVariant.telemetry.environment_measurement_enabled) { + if (moduleConfig.telemetry.environment_measurement_enabled) { DEBUG_MSG("Environment Telemetry: Initializing\n"); // it's possible to have this module enabled, only for displaying values on the screen. // therefore, we should only enable the sensor loop if measurement is also enabled - switch (moduleConfig.payloadVariant.telemetry.environment_sensor_type) { + switch (moduleConfig.telemetry.environment_sensor_type) { case TelemetrySensorType_DHT11: case TelemetrySensorType_DHT12: @@ -97,35 +97,35 @@ int32_t EnvironmentTelemetryModule::runOnce() return (INT32_MAX); } else { // if we somehow got to a second run of this module with measurement disabled, then just wait forever - if (!moduleConfig.payloadVariant.telemetry.environment_measurement_enabled) + if (!moduleConfig.telemetry.environment_measurement_enabled) return (INT32_MAX); // this is not the first time OSThread library has called this function // so just do what we intend to do on the interval - if (sensor_read_error_count > moduleConfig.payloadVariant.telemetry.environment_read_error_count_threshold) { - if (moduleConfig.payloadVariant.telemetry.environment_recovery_interval > 0) { + if (sensor_read_error_count > moduleConfig.telemetry.environment_read_error_count_threshold) { + if (moduleConfig.telemetry.environment_recovery_interval > 0) { DEBUG_MSG("Environment Telemetry: TEMPORARILY DISABLED; The " "telemetry_module_environment_read_error_count_threshold has been exceed: %d. Will retry reads in " "%d seconds\n", - moduleConfig.payloadVariant.telemetry.environment_read_error_count_threshold, - moduleConfig.payloadVariant.telemetry.environment_recovery_interval); + moduleConfig.telemetry.environment_read_error_count_threshold, + moduleConfig.telemetry.environment_recovery_interval); sensor_read_error_count = 0; - return (moduleConfig.payloadVariant.telemetry.environment_recovery_interval * 1000); + return (moduleConfig.telemetry.environment_recovery_interval * 1000); } DEBUG_MSG("Environment Telemetry: DISABLED; The telemetry_module_environment_read_error_count_threshold has " "been exceed: %d. Reads will not be retried until after device reset\n", - moduleConfig.payloadVariant.telemetry.environment_read_error_count_threshold); + moduleConfig.telemetry.environment_read_error_count_threshold); return (INT32_MAX); } else if (sensor_read_error_count > 0) { DEBUG_MSG("Environment Telemetry: There have been %d sensor read failures. Will retry %d more times\n", sensor_read_error_count, sensor_read_error_count, sensor_read_error_count, - moduleConfig.payloadVariant.telemetry.environment_read_error_count_threshold - sensor_read_error_count); + moduleConfig.telemetry.environment_read_error_count_threshold - sensor_read_error_count); } if (!sendOurTelemetry()) { // if we failed to read the sensor, then try again // as soon as we can according to the maximum polling frequency - switch (moduleConfig.payloadVariant.telemetry.environment_sensor_type) { + switch (moduleConfig.telemetry.environment_sensor_type) { case TelemetrySensorType_DHT11: case TelemetrySensorType_DHT12: case TelemetrySensorType_DHT21: @@ -143,7 +143,7 @@ int32_t EnvironmentTelemetryModule::runOnce() } } } - return getIntervalOrDefaultMs(moduleConfig.payloadVariant.telemetry.environment_update_interval); + return getIntervalOrDefaultMs(moduleConfig.telemetry.environment_update_interval); #endif } @@ -161,7 +161,7 @@ uint32_t GetTimeSinceMeshPacket(const MeshPacket *mp) bool EnvironmentTelemetryModule::wantUIFrame() { - return moduleConfig.payloadVariant.telemetry.environment_screen_enabled; + return moduleConfig.telemetry.environment_screen_enabled; } float EnvironmentTelemetryModule::CelsiusToFahrenheit(float c) @@ -195,7 +195,7 @@ void EnvironmentTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiSt display->setFont(FONT_SMALL); String last_temp = String(lastMeasurement.variant.environment_metrics.temperature, 0) + "°C"; - if (moduleConfig.payloadVariant.telemetry.environment_display_fahrenheit) { + if (moduleConfig.telemetry.environment_display_fahrenheit) { last_temp = String(CelsiusToFahrenheit(lastMeasurement.variant.environment_metrics.temperature), 0) + "°F"; } display->drawString(x, y += fontHeight(FONT_MEDIUM) - 2, "From: " + String(lastSender) + "(" + String(agoSecs) + "s)"); @@ -244,7 +244,7 @@ bool EnvironmentTelemetryModule::sendOurTelemetry(NodeNum dest, bool wantReplies DEBUG_MSG("-----------------------------------------\n"); DEBUG_MSG("Environment Telemetry: Read data\n"); - switch (moduleConfig.payloadVariant.telemetry.environment_sensor_type) { + switch (moduleConfig.telemetry.environment_sensor_type) { case TelemetrySensorType_DS18B20: if (!dallasSensor.getMeasurement(&m)) sensor_read_error_count++; diff --git a/src/modules/Telemetry/Sensor/DHTSensor.cpp b/src/modules/Telemetry/Sensor/DHTSensor.cpp index 05950fa45..5ccb8b0e1 100644 --- a/src/modules/Telemetry/Sensor/DHTSensor.cpp +++ b/src/modules/Telemetry/Sensor/DHTSensor.cpp @@ -10,14 +10,14 @@ DHTSensor::DHTSensor() : TelemetrySensor{} {} int32_t DHTSensor::runOnce() { if (TelemetrySensorType_DHT11 || TelemetrySensorType_DHT12) { - dht = new DHT(moduleConfig.payloadVariant.telemetry.environment_sensor_pin, DHT11); + dht = new DHT(moduleConfig.telemetry.environment_sensor_pin, DHT11); } else { - dht = new DHT(moduleConfig.payloadVariant.telemetry.environment_sensor_pin, DHT22); + dht = new DHT(moduleConfig.telemetry.environment_sensor_pin, DHT22); } dht->begin(); dht->read(); - DEBUG_MSG("Telemetry: Opened DHT11/DHT12 on pin: %d\n", moduleConfig.payloadVariant.telemetry.environment_sensor_pin); + DEBUG_MSG("Telemetry: Opened DHT11/DHT12 on pin: %d\n", moduleConfig.telemetry.environment_sensor_pin); return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); } diff --git a/src/modules/Telemetry/Sensor/DallasSensor.cpp b/src/modules/Telemetry/Sensor/DallasSensor.cpp index de14fe0c6..23fc57cfb 100644 --- a/src/modules/Telemetry/Sensor/DallasSensor.cpp +++ b/src/modules/Telemetry/Sensor/DallasSensor.cpp @@ -10,12 +10,12 @@ DallasSensor::DallasSensor() : TelemetrySensor{} {} int32_t DallasSensor::runOnce() { - oneWire = new OneWire(moduleConfig.payloadVariant.telemetry.environment_sensor_pin); + oneWire = new OneWire(moduleConfig.telemetry.environment_sensor_pin); ds18b20 = new DS18B20(oneWire); ds18b20->begin(); ds18b20->setResolution(12); ds18b20->requestTemperatures(); - DEBUG_MSG("Telemetry: Opened DS18B20 on pin: %d\n", moduleConfig.payloadVariant.telemetry.environment_sensor_pin); + DEBUG_MSG("Telemetry: Opened DS18B20 on pin: %d\n", moduleConfig.telemetry.environment_sensor_pin); return (DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); } diff --git a/src/modules/esp32/RangeTestModule.cpp b/src/modules/esp32/RangeTestModule.cpp index f35da4b2f..71b1bbb53 100644 --- a/src/modules/esp32/RangeTestModule.cpp +++ b/src/modules/esp32/RangeTestModule.cpp @@ -36,23 +36,23 @@ int32_t RangeTestModule::runOnce() without having to configure it from the PythonAPI or WebUI. */ - // moduleConfig.payloadVariant.range_test.enabled = 1; - // moduleConfig.payloadVariant.range_test.sender = 45; - // moduleConfig.payloadVariant.range_test.save = 1; + // moduleConfig.range_test.enabled = 1; + // moduleConfig.range_test.sender = 45; + // moduleConfig.range_test.save = 1; // Fixed position is useful when testing indoors. // radioConfig.preferences.fixed_position = 1; - uint32_t senderHeartbeat = moduleConfig.payloadVariant.range_test.sender * 1000; + uint32_t senderHeartbeat = moduleConfig.range_test.sender * 1000; - if (moduleConfig.payloadVariant.range_test.enabled) { + if (moduleConfig.range_test.enabled) { if (firstTime) { rangeTestModuleRadio = new RangeTestModuleRadio(); firstTime = 0; - if (moduleConfig.payloadVariant.range_test.sender) { + if (moduleConfig.range_test.sender) { DEBUG_MSG("Initializing Range Test Module -- Sender\n"); return (5000); // Sending first message 5 seconds after initilization. } else { @@ -62,7 +62,7 @@ int32_t RangeTestModule::runOnce() } else { - if (moduleConfig.payloadVariant.range_test.sender) { + if (moduleConfig.range_test.sender) { // If sender DEBUG_MSG("Range Test Module - Sending heartbeat every %d ms\n", (senderHeartbeat)); @@ -131,7 +131,7 @@ ProcessMessage RangeTestModuleRadio::handleReceived(const MeshPacket &mp) { #ifndef NO_ESP32 - if (moduleConfig.payloadVariant.range_test.enabled) { + if (moduleConfig.range_test.enabled) { /* auto &p = mp.decoded; @@ -141,7 +141,7 @@ ProcessMessage RangeTestModuleRadio::handleReceived(const MeshPacket &mp) if (getFrom(&mp) != nodeDB.getNodeNum()) { - if (moduleConfig.payloadVariant.range_test.save) { + if (moduleConfig.range_test.save) { appendFile(mp); } diff --git a/src/modules/esp32/SerialModule.cpp b/src/modules/esp32/SerialModule.cpp index 35f6fe311..f0bf1666c 100644 --- a/src/modules/esp32/SerialModule.cpp +++ b/src/modules/esp32/SerialModule.cpp @@ -76,13 +76,13 @@ int32_t SerialModule::runOnce() without having to configure it from the PythonAPI or WebUI. */ - // moduleConfig.payloadVariant.serial.enabled = 1; - // moduleConfig.payloadVariant.serial.rxd = 35; - // moduleConfig.payloadVariant.serial.txd = 15; - // moduleConfig.payloadVariant.serial.timeout = 1000; - // moduleConfig.payloadVariant.serial.echo = 1; + // moduleConfig.serial.enabled = 1; + // moduleConfig.serial.rxd = 35; + // moduleConfig.serial.txd = 15; + // moduleConfig.serial.timeout = 1000; + // moduleConfig.serial.echo = 1; - if (moduleConfig.payloadVariant.serial.enabled) { + if (moduleConfig.serial.enabled) { if (firstTime) { @@ -91,65 +91,65 @@ int32_t SerialModule::runOnce() uint32_t baud = 0; - if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_Default) { + if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_Default) { baud = 38400; - } else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_110) { + } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_110) { baud = 110; - } else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_300) { + } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_300) { baud = 300; - } else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_600) { + } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_600) { baud = 600; - } else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_1200) { + } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_1200) { baud = 1200; - } else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_2400) { + } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_2400) { baud = 2400; - } else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_4800) { + } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_4800) { baud = 4800; - } else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_9600) { + } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_9600) { baud = 9600; - } else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_19200) { + } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_19200) { baud = 19200; - } else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_38400) { + } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_38400) { baud = 38400; - } else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_57600) { + } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_57600) { baud = 57600; - } else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_115200) { + } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_115200) { baud = 115200; - } else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_230400) { + } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_230400) { baud = 230400; - } else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_460800) { + } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_460800) { baud = 460800; - } else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_576000) { + } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_576000) { baud = 576000; - } else if (moduleConfig.payloadVariant.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_921600) { + } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_921600) { baud = 921600; } - if (moduleConfig.payloadVariant.serial.rxd && moduleConfig.payloadVariant.serial.txd) { - Serial2.begin(baud, SERIAL_8N1, moduleConfig.payloadVariant.serial.rxd, moduleConfig.payloadVariant.serial.txd); + if (moduleConfig.serial.rxd && moduleConfig.serial.txd) { + Serial2.begin(baud, SERIAL_8N1, moduleConfig.serial.rxd, moduleConfig.serial.txd); } else { Serial2.begin(baud, SERIAL_8N1, RXD2, TXD2); } - if (moduleConfig.payloadVariant.serial.timeout) { + if (moduleConfig.serial.timeout) { Serial2.setTimeout( - moduleConfig.payloadVariant.serial.timeout); // Number of MS to wait to set the timeout for the string. + moduleConfig.serial.timeout); // Number of MS to wait to set the timeout for the string. } else { Serial2.setTimeout(TIMEOUT); // Number of MS to wait to set the timeout for the string. @@ -211,7 +211,7 @@ ProcessMessage SerialModuleRadio::handleReceived(const MeshPacket &mp) { #ifndef NO_ESP32 - if (moduleConfig.payloadVariant.serial.enabled) { + if (moduleConfig.serial.enabled) { auto &p = mp.decoded; // DEBUG_MSG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n", @@ -220,10 +220,10 @@ ProcessMessage SerialModuleRadio::handleReceived(const MeshPacket &mp) if (getFrom(&mp) == nodeDB.getNodeNum()) { /* - * If moduleConfig.payloadVariant.serial.echo is true, then echo the packets that are sent out + * If moduleConfig.serial.echo is true, then echo the packets that are sent out * back to the TX of the serial interface. */ - if (moduleConfig.payloadVariant.serial.echo) { + if (moduleConfig.serial.echo) { // For some reason, we get the packet back twice when we send out of the radio. // TODO: need to find out why. @@ -237,13 +237,13 @@ ProcessMessage SerialModuleRadio::handleReceived(const MeshPacket &mp) } else { - if (moduleConfig.payloadVariant.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_MODE_Default || - moduleConfig.payloadVariant.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_MODE_SIMPLE) { + if (moduleConfig.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_MODE_Default || + moduleConfig.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_MODE_SIMPLE) { // DEBUG_MSG("* * Message came from the mesh\n"); // Serial2.println("* * Message came from the mesh"); Serial2.printf("%s", p.payload.bytes); - } else if (moduleConfig.payloadVariant.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_MODE_PROTO) { + } else if (moduleConfig.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_MODE_PROTO) { } } diff --git a/src/modules/esp32/StoreForwardModule.cpp b/src/modules/esp32/StoreForwardModule.cpp index ff8aeeb02..6ba14346e 100644 --- a/src/modules/esp32/StoreForwardModule.cpp +++ b/src/modules/esp32/StoreForwardModule.cpp @@ -19,7 +19,7 @@ int32_t StoreForwardModule::runOnce() #ifndef NO_ESP32 - if (moduleConfig.payloadVariant.store_forward.enabled) { + if (moduleConfig.store_forward.enabled) { if (config.device.role == Config_DeviceConfig_Role_Router) { @@ -242,7 +242,7 @@ void StoreForwardModule::sendMessage(NodeNum dest, char *str) ProcessMessage StoreForwardModule::handleReceived(const MeshPacket &mp) { #ifndef NO_ESP32 - if (moduleConfig.payloadVariant.store_forward.enabled) { + if (moduleConfig.store_forward.enabled) { DEBUG_MSG("--- S&F Received something\n"); @@ -295,7 +295,7 @@ ProcessMessage StoreForwardModule::handleReceived(const MeshPacket &mp) ProcessMessage StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndForward *p) { - if (!moduleConfig.payloadVariant.store_forward.enabled) { + if (!moduleConfig.store_forward.enabled) { // If this module is not enabled in any capacity, don't handle the packet, and allow other modules to consume return ProcessMessage::CONTINUE; } @@ -391,11 +391,11 @@ StoreForwardModule::StoreForwardModule() without having to configure it from the PythonAPI or WebUI. */ - moduleConfig.payloadVariant.store_forward.enabled = 1; + moduleConfig.store_forward.enabled = 1; config.power.is_always_powered = 1; } - if (moduleConfig.payloadVariant.store_forward.enabled) { + if (moduleConfig.store_forward.enabled) { // Router if (config.device.role == Config_DeviceConfig_Role_Router) { @@ -406,20 +406,20 @@ StoreForwardModule::StoreForwardModule() // Do the startup here // Maximum number of records to return. - if (moduleConfig.payloadVariant.store_forward.history_return_max) - this->historyReturnMax = moduleConfig.payloadVariant.store_forward.history_return_max; + if (moduleConfig.store_forward.history_return_max) + this->historyReturnMax = moduleConfig.store_forward.history_return_max; // Maximum time window for records to return (in minutes) - if (moduleConfig.payloadVariant.store_forward.history_return_window) - this->historyReturnWindow = moduleConfig.payloadVariant.store_forward.history_return_window; + if (moduleConfig.store_forward.history_return_window) + this->historyReturnWindow = moduleConfig.store_forward.history_return_window; // Maximum number of records to store in memory - if (moduleConfig.payloadVariant.store_forward.records) - this->records = moduleConfig.payloadVariant.store_forward.records; + if (moduleConfig.store_forward.records) + this->records = moduleConfig.store_forward.records; // Maximum number of records to store in memory - if (moduleConfig.payloadVariant.store_forward.heartbeat) - this->heartbeat = moduleConfig.payloadVariant.store_forward.heartbeat; + if (moduleConfig.store_forward.heartbeat) + this->heartbeat = moduleConfig.store_forward.heartbeat; // Popupate PSRAM with our data structures. this->populatePSRAM(); diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index c0f8792c8..4c50ff741 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -111,18 +111,18 @@ void MQTT::reconnect() const char *mqttUsername = "meshdev"; const char *mqttPassword = "large4cats"; - if (*moduleConfig.payloadVariant.mqtt.address) { - serverAddr = moduleConfig.payloadVariant.mqtt.address; // Override the default + if (*moduleConfig.mqtt.address) { + serverAddr = moduleConfig.mqtt.address; // Override the default mqttUsername = - moduleConfig.payloadVariant.mqtt.username; // do not use the hardcoded credentials for a custom mqtt server - mqttPassword = moduleConfig.payloadVariant.mqtt.password; + moduleConfig.mqtt.username; // do not use the hardcoded credentials for a custom mqtt server + mqttPassword = moduleConfig.mqtt.password; } else { // we are using the default server. Use the hardcoded credentials by default, but allow overriding - if (*moduleConfig.payloadVariant.mqtt.username && moduleConfig.payloadVariant.mqtt.username[0] != '\0') { - mqttUsername = moduleConfig.payloadVariant.mqtt.username; + if (*moduleConfig.mqtt.username && moduleConfig.mqtt.username[0] != '\0') { + mqttUsername = moduleConfig.mqtt.username; } - if (*moduleConfig.payloadVariant.mqtt.password && moduleConfig.payloadVariant.mqtt.password[0] != '\0') { - mqttPassword = moduleConfig.payloadVariant.mqtt.password; + if (*moduleConfig.mqtt.password && moduleConfig.mqtt.password[0] != '\0') { + mqttPassword = moduleConfig.mqtt.password; } } @@ -175,7 +175,7 @@ bool MQTT::wantsLink() const { bool hasChannel = false; - if (moduleConfig.payloadVariant.mqtt.disabled) { + if (moduleConfig.mqtt.disabled) { // DEBUG_MSG("MQTT disabled...\n"); } else { // No need for link if no channel needed it