diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 8d69289f0..3c4cef829 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -106,6 +106,10 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta else handleSetChannel(r->set_channel); break; + case meshtastic_AdminMessage_set_ham_mode_tag: + LOG_INFO("Client is setting ham mode\n"); + handleSetHamMode(r->set_ham_mode); + break; /** * Other @@ -598,6 +602,18 @@ void AdminModule::saveChanges(int saveWhat, bool shouldReboot) } } +void AdminModule::handleSetHamMode(const meshtastic_HamParameters &p) +{ + strncpy(owner.long_name, p.call_sign, sizeof(owner.long_name)); + owner.is_licensed = true; + config.lora.override_duty_cycle = true; + config.lora.tx_power = p.tx_power; + config.lora.override_frequency = p.frequency; + + service.reloadOwner(false); + service.reloadConfig(SEGMENT_CONFIG | SEGMENT_DEVICESTATE); +} + AdminModule::AdminModule() : ProtobufModule("Admin", meshtastic_PortNum_ADMIN_APP, &meshtastic_AdminMessage_msg) { // restrict to the admin channel for rx diff --git a/src/modules/AdminModule.h b/src/modules/AdminModule.h index 76f6f8033..7170e61d6 100644 --- a/src/modules/AdminModule.h +++ b/src/modules/AdminModule.h @@ -43,6 +43,7 @@ class AdminModule : public ProtobufModule void handleSetConfig(const meshtastic_Config &c); void handleSetModuleConfig(const meshtastic_ModuleConfig &c); void handleSetChannel(); + void handleSetHamMode(const meshtastic_HamParameters &req); void reboot(int32_t seconds); };