From 45e6e86ff9e23df0efcce09bebf3f68c34279be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 29 Dec 2022 21:35:32 +0100 Subject: [PATCH] - add RemoteHardware (and the missing S&F config) in - make the config boundaries automatic --- src/mesh/PhoneAPI.cpp | 16 ++++++++++++---- src/modules/AdminModule.cpp | 12 +++++++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index b50f93bf0..ac134f352 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -171,7 +171,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) // Advance when we have sent all of our Channels if (config_state >= MAX_NUM_CHANNELS) { state = STATE_SEND_CONFIG; - config_state = Config_device_tag; + config_state = _AdminMessage_ConfigType_MIN + 1; } break; @@ -215,9 +215,9 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) config_state++; // Advance when we have sent all of our config objects - if (config_state > Config_bluetooth_tag) { + if (config_state > (_AdminMessage_ConfigType_MAX + 1)) { state = STATE_SEND_MODULECONFIG; - config_state = ModuleConfig_mqtt_tag; + config_state = _AdminMessage_ModuleConfigType_MIN + 1; } break; @@ -237,6 +237,10 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) fromRadioScratch.moduleConfig.which_payload_variant = ModuleConfig_external_notification_tag; fromRadioScratch.moduleConfig.payload_variant.external_notification = moduleConfig.external_notification; break; + case ModuleConfig_store_forward_tag: + fromRadioScratch.moduleConfig.which_payload_variant = ModuleConfig_store_forward_tag; + fromRadioScratch.moduleConfig.payload_variant.store_forward = moduleConfig.store_forward; + break; case ModuleConfig_range_test_tag: fromRadioScratch.moduleConfig.which_payload_variant = ModuleConfig_range_test_tag; fromRadioScratch.moduleConfig.payload_variant.range_test = moduleConfig.range_test; @@ -253,11 +257,15 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) fromRadioScratch.moduleConfig.which_payload_variant = ModuleConfig_audio_tag; fromRadioScratch.moduleConfig.payload_variant.audio = moduleConfig.audio; break; + case ModuleConfig_remote_hardware_tag: + fromRadioScratch.moduleConfig.which_payload_variant = ModuleConfig_remote_hardware_tag; + fromRadioScratch.moduleConfig.payload_variant.remote_hardware = moduleConfig.remote_hardware; + break; } config_state++; // Advance when we have sent all of our ModuleConfig objects - if (config_state > ModuleConfig_audio_tag) { + if (config_state > (_AdminMessage_ModuleConfigType_MAX + 1)) { state = STATE_SEND_COMPLETE_ID; config_state = 0; } diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 2ed050f66..023cf7396 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -323,8 +323,13 @@ void AdminModule::handleSetModuleConfig(const ModuleConfig &c) moduleConfig.has_audio = true; moduleConfig.audio = c.payload_variant.audio; break; + case ModuleConfig_remote_hardware_tag: + DEBUG_MSG("Setting module config: Remote Hardware\n"); + moduleConfig.has_remote_hardware = true; + moduleConfig.remote_hardware = c.payload_variant.remote_hardware; + break; } - + saveChanges(SEGMENT_MODULECONFIG); } @@ -453,6 +458,11 @@ void AdminModule::handleGetModuleConfig(const MeshPacket &req, const uint32_t co res.get_module_config_response.which_payload_variant = ModuleConfig_audio_tag; res.get_module_config_response.payload_variant.audio = moduleConfig.audio; break; + case AdminMessage_ModuleConfigType_REMOTEHARDWARE_CONFIG: + DEBUG_MSG("Getting module config: Remote Hardware\n"); + res.get_module_config_response.which_payload_variant = ModuleConfig_remote_hardware_tag; + res.get_module_config_response.payload_variant.remote_hardware = moduleConfig.remote_hardware; + break; } // NOTE: The phone app needs to know the ls_secsvalue so it can properly expect sleep behavior.