Merge branch 'master' into nomad-gemini

This commit is contained in:
Thomas Göttgens
2024-12-29 22:50:31 +01:00
committed by GitHub
224 changed files with 16932 additions and 1755 deletions
+38 -5
View File
@@ -18,7 +18,7 @@
#ifdef ARCH_PORTDUINO
#include "unistd.h"
#endif
#include "../userPrefs.h"
#include "Default.h"
#include "TypeConversions.h"
@@ -175,6 +175,12 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
LOG_INFO("Client set ham mode");
handleSetHamMode(r->set_ham_mode);
break;
case meshtastic_AdminMessage_get_ui_config_request_tag: {
LOG_INFO("Client is getting device-ui config");
handleGetDeviceUIConfig(mp);
handled = true;
break;
}
/**
* Other
@@ -234,6 +240,12 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
reboot(DEFAULT_REBOOT_SECONDS);
break;
}
case meshtastic_AdminMessage_store_ui_config_tag: {
LOG_INFO("Storing device-ui config");
handleStoreDeviceUIConfig(r->store_ui_config);
handled = true;
break;
}
case meshtastic_AdminMessage_begin_edit_settings_tag: {
LOG_INFO("Begin transaction for editing settings");
hasOpenEditTransaction = true;
@@ -358,7 +370,7 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
#ifdef ARCH_PORTDUINO
case meshtastic_AdminMessage_exit_simulator_tag:
LOG_INFO("Exiting simulator");
_exit(0);
exit(0);
break;
#endif
@@ -477,7 +489,7 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
IS_ONE_OF(config.device.role, meshtastic_Config_DeviceConfig_Role_ROUTER,
meshtastic_Config_DeviceConfig_Role_REPEATER)) {
config.device.rebroadcast_mode = meshtastic_Config_DeviceConfig_RebroadcastMode_ALL;
const char *warning = "Rebroadcast mode can't be set to NONE for a router or repeater\n";
const char *warning = "Rebroadcast mode can't be set to NONE for a router or repeater";
LOG_WARN(warning);
sendWarning(warning);
}
@@ -629,6 +641,9 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
requiresReboot = false;
break;
case meshtastic_Config_device_ui_tag:
// NOOP! This is handled by handleStoreDeviceUIConfig
break;
}
if (requiresReboot && !hasOpenEditTransaction) {
disableBluetooth();
@@ -791,6 +806,10 @@ void AdminModule::handleGetConfig(const meshtastic_MeshPacket &req, const uint32
LOG_INFO("Get config: Sessionkey");
res.get_config_response.which_payload_variant = meshtastic_Config_sessionkey_tag;
break;
case meshtastic_AdminMessage_ConfigType_DEVICEUI_CONFIG:
// NOOP! This is handled by handleGetDeviceUIConfig
res.get_config_response.which_payload_variant = meshtastic_Config_device_ui_tag;
break;
}
// NOTE: The phone app needs to know the ls_secs value so it can properly expect sleep behavior.
// So even if we internally use 0 to represent 'use default' we still need to send the value we are
@@ -1003,6 +1022,14 @@ void AdminModule::handleGetChannel(const meshtastic_MeshPacket &req, uint32_t ch
}
}
void AdminModule::handleGetDeviceUIConfig(const meshtastic_MeshPacket &req)
{
meshtastic_AdminMessage r = meshtastic_AdminMessage_init_default;
r.which_payload_variant = meshtastic_AdminMessage_get_ui_config_response_tag;
r.get_ui_config_response = uiconfig;
myReply = allocDataProtobuf(r);
}
void AdminModule::reboot(int32_t seconds)
{
LOG_INFO("Reboot in %d seconds", seconds);
@@ -1023,6 +1050,11 @@ void AdminModule::saveChanges(int saveWhat, bool shouldReboot)
}
}
void AdminModule::handleStoreDeviceUIConfig(const meshtastic_DeviceUIConfig &uicfg)
{
nodeDB->saveProto("/prefs/uiconfig.proto", meshtastic_DeviceUIConfig_size, &meshtastic_DeviceUIConfig_msg, &uicfg);
}
void AdminModule::handleSetHamMode(const meshtastic_HamParameters &p)
{
// Set call sign and override lora limitations for licensed use
@@ -1089,7 +1121,7 @@ bool AdminModule::messageIsResponse(const meshtastic_AdminMessage *r)
r->which_payload_variant == meshtastic_AdminMessage_get_ringtone_response_tag ||
r->which_payload_variant == meshtastic_AdminMessage_get_device_connection_status_response_tag ||
r->which_payload_variant == meshtastic_AdminMessage_get_node_remote_hardware_pins_response_tag ||
r->which_payload_variant == meshtastic_NodeRemoteHardwarePinsResponse_node_remote_hardware_pins_tag)
r->which_payload_variant == meshtastic_AdminMessage_get_ui_config_response_tag)
return true;
else
return false;
@@ -1105,7 +1137,8 @@ bool AdminModule::messageIsRequest(const meshtastic_AdminMessage *r)
r->which_payload_variant == meshtastic_AdminMessage_get_device_metadata_request_tag ||
r->which_payload_variant == meshtastic_AdminMessage_get_ringtone_request_tag ||
r->which_payload_variant == meshtastic_AdminMessage_get_device_connection_status_request_tag ||
r->which_payload_variant == meshtastic_AdminMessage_get_node_remote_hardware_pins_request_tag)
r->which_payload_variant == meshtastic_AdminMessage_get_node_remote_hardware_pins_request_tag ||
r->which_payload_variant == meshtastic_AdminMessage_get_ui_config_request_tag)
return true;
else
return false;