mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-16 18:12:07 +00:00
Fixed it
This commit is contained in:
parent
1fa2ca6a14
commit
0414ca2dc0
@ -1 +1 @@
|
|||||||
Subproject commit 4ef7e46a8b83d4d2147f027c7aaa7d1b481f8688
|
Subproject commit 516074f2e49743c234430abb2ea43ea3f66b0acb
|
@ -22,6 +22,17 @@ typedef struct _meshtastic_NetworkConnectionStatus {
|
|||||||
bool is_syslog_connected;
|
bool is_syslog_connected;
|
||||||
} meshtastic_NetworkConnectionStatus;
|
} meshtastic_NetworkConnectionStatus;
|
||||||
|
|
||||||
|
/* WiFi connection status */
|
||||||
|
typedef struct _meshtastic_WifiConnectionStatus {
|
||||||
|
/* Connection status */
|
||||||
|
bool has_status;
|
||||||
|
meshtastic_NetworkConnectionStatus status;
|
||||||
|
/* WiFi access point ssid */
|
||||||
|
char ssid[33];
|
||||||
|
/* Rssi of wireless connection */
|
||||||
|
int32_t rssi;
|
||||||
|
} meshtastic_WifiConnectionStatus;
|
||||||
|
|
||||||
/* Ethernet connection status */
|
/* Ethernet connection status */
|
||||||
typedef struct _meshtastic_EthernetConnectionStatus {
|
typedef struct _meshtastic_EthernetConnectionStatus {
|
||||||
/* Connection status */
|
/* Connection status */
|
||||||
@ -29,17 +40,6 @@ typedef struct _meshtastic_EthernetConnectionStatus {
|
|||||||
meshtastic_NetworkConnectionStatus status;
|
meshtastic_NetworkConnectionStatus status;
|
||||||
} meshtastic_EthernetConnectionStatus;
|
} meshtastic_EthernetConnectionStatus;
|
||||||
|
|
||||||
/* WiFi connection status */
|
|
||||||
typedef struct _meshtastic_WifiConnectionStatus {
|
|
||||||
/* Connection status */
|
|
||||||
bool has_status;
|
|
||||||
meshtastic_EthernetConnectionStatus status;
|
|
||||||
/* WiFi access point ssid */
|
|
||||||
char ssid[33];
|
|
||||||
/* Rssi of wireless connection */
|
|
||||||
int32_t rssi;
|
|
||||||
} meshtastic_WifiConnectionStatus;
|
|
||||||
|
|
||||||
/* Bluetooth connection status */
|
/* Bluetooth connection status */
|
||||||
typedef struct _meshtastic_BluetoothConnectionStatus {
|
typedef struct _meshtastic_BluetoothConnectionStatus {
|
||||||
/* The pairing pin for bluetooth */
|
/* The pairing pin for bluetooth */
|
||||||
@ -80,13 +80,13 @@ extern "C" {
|
|||||||
|
|
||||||
/* Initializer values for message structs */
|
/* Initializer values for message structs */
|
||||||
#define meshtastic_DeviceConnectionStatus_init_default {false, meshtastic_WifiConnectionStatus_init_default, false, meshtastic_EthernetConnectionStatus_init_default, false, meshtastic_BluetoothConnectionStatus_init_default, false, meshtastic_SerialConnectionStatus_init_default}
|
#define meshtastic_DeviceConnectionStatus_init_default {false, meshtastic_WifiConnectionStatus_init_default, false, meshtastic_EthernetConnectionStatus_init_default, false, meshtastic_BluetoothConnectionStatus_init_default, false, meshtastic_SerialConnectionStatus_init_default}
|
||||||
#define meshtastic_WifiConnectionStatus_init_default {false, meshtastic_EthernetConnectionStatus_init_default, "", 0}
|
#define meshtastic_WifiConnectionStatus_init_default {false, meshtastic_NetworkConnectionStatus_init_default, "", 0}
|
||||||
#define meshtastic_EthernetConnectionStatus_init_default {false, meshtastic_NetworkConnectionStatus_init_default}
|
#define meshtastic_EthernetConnectionStatus_init_default {false, meshtastic_NetworkConnectionStatus_init_default}
|
||||||
#define meshtastic_NetworkConnectionStatus_init_default {0, 0, 0, 0}
|
#define meshtastic_NetworkConnectionStatus_init_default {0, 0, 0, 0}
|
||||||
#define meshtastic_BluetoothConnectionStatus_init_default {0, 0, 0}
|
#define meshtastic_BluetoothConnectionStatus_init_default {0, 0, 0}
|
||||||
#define meshtastic_SerialConnectionStatus_init_default {0, 0}
|
#define meshtastic_SerialConnectionStatus_init_default {0, 0}
|
||||||
#define meshtastic_DeviceConnectionStatus_init_zero {false, meshtastic_WifiConnectionStatus_init_zero, false, meshtastic_EthernetConnectionStatus_init_zero, false, meshtastic_BluetoothConnectionStatus_init_zero, false, meshtastic_SerialConnectionStatus_init_zero}
|
#define meshtastic_DeviceConnectionStatus_init_zero {false, meshtastic_WifiConnectionStatus_init_zero, false, meshtastic_EthernetConnectionStatus_init_zero, false, meshtastic_BluetoothConnectionStatus_init_zero, false, meshtastic_SerialConnectionStatus_init_zero}
|
||||||
#define meshtastic_WifiConnectionStatus_init_zero {false, meshtastic_EthernetConnectionStatus_init_zero, "", 0}
|
#define meshtastic_WifiConnectionStatus_init_zero {false, meshtastic_NetworkConnectionStatus_init_zero, "", 0}
|
||||||
#define meshtastic_EthernetConnectionStatus_init_zero {false, meshtastic_NetworkConnectionStatus_init_zero}
|
#define meshtastic_EthernetConnectionStatus_init_zero {false, meshtastic_NetworkConnectionStatus_init_zero}
|
||||||
#define meshtastic_NetworkConnectionStatus_init_zero {0, 0, 0, 0}
|
#define meshtastic_NetworkConnectionStatus_init_zero {0, 0, 0, 0}
|
||||||
#define meshtastic_BluetoothConnectionStatus_init_zero {0, 0, 0}
|
#define meshtastic_BluetoothConnectionStatus_init_zero {0, 0, 0}
|
||||||
@ -97,10 +97,10 @@ extern "C" {
|
|||||||
#define meshtastic_NetworkConnectionStatus_is_connected_tag 2
|
#define meshtastic_NetworkConnectionStatus_is_connected_tag 2
|
||||||
#define meshtastic_NetworkConnectionStatus_is_mqtt_connected_tag 3
|
#define meshtastic_NetworkConnectionStatus_is_mqtt_connected_tag 3
|
||||||
#define meshtastic_NetworkConnectionStatus_is_syslog_connected_tag 4
|
#define meshtastic_NetworkConnectionStatus_is_syslog_connected_tag 4
|
||||||
#define meshtastic_EthernetConnectionStatus_status_tag 1
|
|
||||||
#define meshtastic_WifiConnectionStatus_status_tag 1
|
#define meshtastic_WifiConnectionStatus_status_tag 1
|
||||||
#define meshtastic_WifiConnectionStatus_ssid_tag 2
|
#define meshtastic_WifiConnectionStatus_ssid_tag 2
|
||||||
#define meshtastic_WifiConnectionStatus_rssi_tag 3
|
#define meshtastic_WifiConnectionStatus_rssi_tag 3
|
||||||
|
#define meshtastic_EthernetConnectionStatus_status_tag 1
|
||||||
#define meshtastic_BluetoothConnectionStatus_pin_tag 1
|
#define meshtastic_BluetoothConnectionStatus_pin_tag 1
|
||||||
#define meshtastic_BluetoothConnectionStatus_rssi_tag 2
|
#define meshtastic_BluetoothConnectionStatus_rssi_tag 2
|
||||||
#define meshtastic_BluetoothConnectionStatus_is_connected_tag 3
|
#define meshtastic_BluetoothConnectionStatus_is_connected_tag 3
|
||||||
@ -130,7 +130,7 @@ X(a, STATIC, SINGULAR, STRING, ssid, 2) \
|
|||||||
X(a, STATIC, SINGULAR, INT32, rssi, 3)
|
X(a, STATIC, SINGULAR, INT32, rssi, 3)
|
||||||
#define meshtastic_WifiConnectionStatus_CALLBACK NULL
|
#define meshtastic_WifiConnectionStatus_CALLBACK NULL
|
||||||
#define meshtastic_WifiConnectionStatus_DEFAULT NULL
|
#define meshtastic_WifiConnectionStatus_DEFAULT NULL
|
||||||
#define meshtastic_WifiConnectionStatus_status_MSGTYPE meshtastic_EthernetConnectionStatus
|
#define meshtastic_WifiConnectionStatus_status_MSGTYPE meshtastic_NetworkConnectionStatus
|
||||||
|
|
||||||
#define meshtastic_EthernetConnectionStatus_FIELDLIST(X, a) \
|
#define meshtastic_EthernetConnectionStatus_FIELDLIST(X, a) \
|
||||||
X(a, STATIC, OPTIONAL, MESSAGE, status, 1)
|
X(a, STATIC, OPTIONAL, MESSAGE, status, 1)
|
||||||
@ -176,11 +176,11 @@ extern const pb_msgdesc_t meshtastic_SerialConnectionStatus_msg;
|
|||||||
|
|
||||||
/* Maximum encoded size of messages (where known) */
|
/* Maximum encoded size of messages (where known) */
|
||||||
#define meshtastic_BluetoothConnectionStatus_size 19
|
#define meshtastic_BluetoothConnectionStatus_size 19
|
||||||
#define meshtastic_DeviceConnectionStatus_size 108
|
#define meshtastic_DeviceConnectionStatus_size 106
|
||||||
#define meshtastic_EthernetConnectionStatus_size 13
|
#define meshtastic_EthernetConnectionStatus_size 13
|
||||||
#define meshtastic_NetworkConnectionStatus_size 11
|
#define meshtastic_NetworkConnectionStatus_size 11
|
||||||
#define meshtastic_SerialConnectionStatus_size 8
|
#define meshtastic_SerialConnectionStatus_size 8
|
||||||
#define meshtastic_WifiConnectionStatus_size 60
|
#define meshtastic_WifiConnectionStatus_size 58
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
@ -33,7 +33,8 @@ static const char *secretReserved = "sekrit";
|
|||||||
/// If buf is the reserved secret word, replace the buffer with currentVal
|
/// If buf is the reserved secret word, replace the buffer with currentVal
|
||||||
static void writeSecret(char *buf, size_t bufsz, const char *currentVal)
|
static void writeSecret(char *buf, size_t bufsz, const char *currentVal)
|
||||||
{
|
{
|
||||||
if (strcmp(buf, secretReserved) == 0) {
|
if (strcmp(buf, secretReserved) == 0)
|
||||||
|
{
|
||||||
strncpy(buf, currentVal, bufsz);
|
strncpy(buf, currentVal, bufsz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -51,7 +52,8 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
|
|||||||
bool handled = false;
|
bool handled = false;
|
||||||
assert(r);
|
assert(r);
|
||||||
|
|
||||||
switch (r->which_payload_variant) {
|
switch (r->which_payload_variant)
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getters
|
* Getters
|
||||||
@ -71,7 +73,8 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
|
|||||||
handleGetModuleConfig(mp, r->get_module_config_request);
|
handleGetModuleConfig(mp, r->get_module_config_request);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case meshtastic_AdminMessage_get_channel_request_tag: {
|
case meshtastic_AdminMessage_get_channel_request_tag:
|
||||||
|
{
|
||||||
uint32_t i = r->get_channel_request - 1;
|
uint32_t i = r->get_channel_request - 1;
|
||||||
LOG_INFO("Client is getting channel %u\n", i);
|
LOG_INFO("Client is getting channel %u\n", i);
|
||||||
if (i >= MAX_NUM_CHANNELS)
|
if (i >= MAX_NUM_CHANNELS)
|
||||||
@ -110,17 +113,22 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
|
|||||||
/**
|
/**
|
||||||
* Other
|
* Other
|
||||||
*/
|
*/
|
||||||
case meshtastic_AdminMessage_reboot_seconds_tag: {
|
case meshtastic_AdminMessage_reboot_seconds_tag:
|
||||||
|
{
|
||||||
reboot(r->reboot_seconds);
|
reboot(r->reboot_seconds);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case meshtastic_AdminMessage_reboot_ota_seconds_tag: {
|
case meshtastic_AdminMessage_reboot_ota_seconds_tag:
|
||||||
|
{
|
||||||
int32_t s = r->reboot_ota_seconds;
|
int32_t s = r->reboot_ota_seconds;
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
if (BleOta::getOtaAppVersion().isEmpty()) {
|
if (BleOta::getOtaAppVersion().isEmpty())
|
||||||
|
{
|
||||||
LOG_INFO("No OTA firmware available, scheduling regular reboot in %d seconds\n", s);
|
LOG_INFO("No OTA firmware available, scheduling regular reboot in %d seconds\n", s);
|
||||||
screen->startRebootScreen();
|
screen->startRebootScreen();
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
screen->startFirmwareUpdateScreen();
|
screen->startFirmwareUpdateScreen();
|
||||||
BleOta::switchToOtaApp();
|
BleOta::switchToOtaApp();
|
||||||
LOG_INFO("Rebooting to OTA in %d seconds\n", s);
|
LOG_INFO("Rebooting to OTA in %d seconds\n", s);
|
||||||
@ -132,41 +140,48 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
|
|||||||
rebootAtMsec = (s < 0) ? 0 : (millis() + s * 1000);
|
rebootAtMsec = (s < 0) ? 0 : (millis() + s * 1000);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case meshtastic_AdminMessage_shutdown_seconds_tag: {
|
case meshtastic_AdminMessage_shutdown_seconds_tag:
|
||||||
|
{
|
||||||
int32_t s = r->shutdown_seconds;
|
int32_t s = r->shutdown_seconds;
|
||||||
LOG_INFO("Shutdown in %d seconds\n", s);
|
LOG_INFO("Shutdown in %d seconds\n", s);
|
||||||
shutdownAtMsec = (s < 0) ? 0 : (millis() + s * 1000);
|
shutdownAtMsec = (s < 0) ? 0 : (millis() + s * 1000);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case meshtastic_AdminMessage_get_device_metadata_request_tag: {
|
case meshtastic_AdminMessage_get_device_metadata_request_tag:
|
||||||
|
{
|
||||||
LOG_INFO("Client is getting device metadata\n");
|
LOG_INFO("Client is getting device metadata\n");
|
||||||
handleGetDeviceMetadata(mp);
|
handleGetDeviceMetadata(mp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case meshtastic_AdminMessage_factory_reset_tag: {
|
case meshtastic_AdminMessage_factory_reset_tag:
|
||||||
|
{
|
||||||
LOG_INFO("Initiating factory reset\n");
|
LOG_INFO("Initiating factory reset\n");
|
||||||
nodeDB.factoryReset();
|
nodeDB.factoryReset();
|
||||||
reboot(DEFAULT_REBOOT_SECONDS);
|
reboot(DEFAULT_REBOOT_SECONDS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case meshtastic_AdminMessage_nodedb_reset_tag: {
|
case meshtastic_AdminMessage_nodedb_reset_tag:
|
||||||
|
{
|
||||||
LOG_INFO("Initiating node-db reset\n");
|
LOG_INFO("Initiating node-db reset\n");
|
||||||
nodeDB.resetNodes();
|
nodeDB.resetNodes();
|
||||||
reboot(DEFAULT_REBOOT_SECONDS);
|
reboot(DEFAULT_REBOOT_SECONDS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case meshtastic_AdminMessage_begin_edit_settings_tag: {
|
case meshtastic_AdminMessage_begin_edit_settings_tag:
|
||||||
|
{
|
||||||
LOG_INFO("Beginning transaction for editing settings\n");
|
LOG_INFO("Beginning transaction for editing settings\n");
|
||||||
hasOpenEditTransaction = true;
|
hasOpenEditTransaction = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case meshtastic_AdminMessage_commit_edit_settings_tag: {
|
case meshtastic_AdminMessage_commit_edit_settings_tag:
|
||||||
|
{
|
||||||
LOG_INFO("Committing transaction for edited settings\n");
|
LOG_INFO("Committing transaction for edited settings\n");
|
||||||
hasOpenEditTransaction = false;
|
hasOpenEditTransaction = false;
|
||||||
saveChanges(SEGMENT_CONFIG | SEGMENT_MODULECONFIG | SEGMENT_DEVICESTATE | SEGMENT_CHANNELS);
|
saveChanges(SEGMENT_CONFIG | SEGMENT_MODULECONFIG | SEGMENT_DEVICESTATE | SEGMENT_CHANNELS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case meshtastic_AdminMessage_get_device_connection_status_request_tag: {
|
case meshtastic_AdminMessage_get_device_connection_status_request_tag:
|
||||||
|
{
|
||||||
LOG_INFO("Client is getting device connection status\n");
|
LOG_INFO("Client is getting device connection status\n");
|
||||||
handleGetDeviceConnectionStatus(mp);
|
handleGetDeviceConnectionStatus(mp);
|
||||||
break;
|
break;
|
||||||
@ -182,11 +197,16 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
|
|||||||
meshtastic_AdminMessage res = meshtastic_AdminMessage_init_default;
|
meshtastic_AdminMessage res = meshtastic_AdminMessage_init_default;
|
||||||
AdminMessageHandleResult handleResult = MeshModule::handleAdminMessageForAllPlugins(mp, r, &res);
|
AdminMessageHandleResult handleResult = MeshModule::handleAdminMessageForAllPlugins(mp, r, &res);
|
||||||
|
|
||||||
if (handleResult == AdminMessageHandleResult::HANDLED_WITH_RESPONSE) {
|
if (handleResult == AdminMessageHandleResult::HANDLED_WITH_RESPONSE)
|
||||||
|
{
|
||||||
myReply = allocDataProtobuf(res);
|
myReply = allocDataProtobuf(res);
|
||||||
} else if (mp.decoded.want_response) {
|
}
|
||||||
|
else if (mp.decoded.want_response)
|
||||||
|
{
|
||||||
LOG_DEBUG("We did not responded to a request that wanted a respond. req.variant=%d\n", r->which_payload_variant);
|
LOG_DEBUG("We did not responded to a request that wanted a respond. req.variant=%d\n", r->which_payload_variant);
|
||||||
} else if (handleResult != AdminMessageHandleResult::HANDLED) {
|
}
|
||||||
|
else if (handleResult != AdminMessageHandleResult::HANDLED)
|
||||||
|
{
|
||||||
// Probably a message sent by us or sent to our local node. FIXME, we should avoid scanning these messages
|
// Probably a message sent by us or sent to our local node. FIXME, we should avoid scanning these messages
|
||||||
LOG_INFO("Ignoring nonrelevant admin %d\n", r->which_payload_variant);
|
LOG_INFO("Ignoring nonrelevant admin %d\n", r->which_payload_variant);
|
||||||
}
|
}
|
||||||
@ -194,7 +214,8 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If asked for a response and it is not yet set, generate an 'ACK' response
|
// If asked for a response and it is not yet set, generate an 'ACK' response
|
||||||
if (mp.decoded.want_response && !myReply) {
|
if (mp.decoded.want_response && !myReply)
|
||||||
|
{
|
||||||
myReply = allocErrorResponse(meshtastic_Routing_Error_NONE, &mp);
|
myReply = allocErrorResponse(meshtastic_Routing_Error_NONE, &mp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,26 +231,31 @@ void AdminModule::handleSetOwner(const meshtastic_User &o)
|
|||||||
int changed = 0;
|
int changed = 0;
|
||||||
bool licensed_changed = false;
|
bool licensed_changed = false;
|
||||||
|
|
||||||
if (*o.long_name) {
|
if (*o.long_name)
|
||||||
|
{
|
||||||
changed |= strcmp(owner.long_name, o.long_name);
|
changed |= strcmp(owner.long_name, o.long_name);
|
||||||
strncpy(owner.long_name, o.long_name, sizeof(owner.long_name));
|
strncpy(owner.long_name, o.long_name, sizeof(owner.long_name));
|
||||||
}
|
}
|
||||||
if (*o.short_name) {
|
if (*o.short_name)
|
||||||
|
{
|
||||||
changed |= strcmp(owner.short_name, o.short_name);
|
changed |= strcmp(owner.short_name, o.short_name);
|
||||||
strncpy(owner.short_name, o.short_name, sizeof(owner.short_name));
|
strncpy(owner.short_name, o.short_name, sizeof(owner.short_name));
|
||||||
}
|
}
|
||||||
if (*o.id) {
|
if (*o.id)
|
||||||
|
{
|
||||||
changed |= strcmp(owner.id, o.id);
|
changed |= strcmp(owner.id, o.id);
|
||||||
strncpy(owner.id, o.id, sizeof(owner.id));
|
strncpy(owner.id, o.id, sizeof(owner.id));
|
||||||
}
|
}
|
||||||
if (owner.is_licensed != o.is_licensed) {
|
if (owner.is_licensed != o.is_licensed)
|
||||||
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
licensed_changed = true;
|
licensed_changed = true;
|
||||||
owner.is_licensed = o.is_licensed;
|
owner.is_licensed = o.is_licensed;
|
||||||
config.lora.override_duty_cycle = owner.is_licensed; // override duty cycle for licensed operators
|
config.lora.override_duty_cycle = owner.is_licensed; // override duty cycle for licensed operators
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) { // If nothing really changed, don't broadcast on the network or write to flash
|
if (changed)
|
||||||
|
{ // If nothing really changed, don't broadcast on the network or write to flash
|
||||||
service.reloadOwner(!hasOpenEditTransaction);
|
service.reloadOwner(!hasOpenEditTransaction);
|
||||||
licensed_changed ? saveChanges(SEGMENT_CONFIG | SEGMENT_DEVICESTATE) : saveChanges(SEGMENT_DEVICESTATE);
|
licensed_changed ? saveChanges(SEGMENT_CONFIG | SEGMENT_DEVICESTATE) : saveChanges(SEGMENT_DEVICESTATE);
|
||||||
}
|
}
|
||||||
@ -240,7 +266,8 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
|
|||||||
auto existingRole = config.device.role;
|
auto existingRole = config.device.role;
|
||||||
bool isRegionUnset = (config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_UNSET);
|
bool isRegionUnset = (config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_UNSET);
|
||||||
|
|
||||||
switch (c.which_payload_variant) {
|
switch (c.which_payload_variant)
|
||||||
|
{
|
||||||
case meshtastic_Config_device_tag:
|
case meshtastic_Config_device_tag:
|
||||||
LOG_INFO("Setting config: Device\n");
|
LOG_INFO("Setting config: Device\n");
|
||||||
config.has_device = true;
|
config.has_device = true;
|
||||||
@ -275,7 +302,8 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
|
|||||||
LOG_INFO("Setting config: LoRa\n");
|
LOG_INFO("Setting config: LoRa\n");
|
||||||
config.has_lora = true;
|
config.has_lora = true;
|
||||||
config.lora = c.payload_variant.lora;
|
config.lora = c.payload_variant.lora;
|
||||||
if (isRegionUnset && config.lora.region > meshtastic_Config_LoRaConfig_RegionCode_UNSET) {
|
if (isRegionUnset && config.lora.region > meshtastic_Config_LoRaConfig_RegionCode_UNSET)
|
||||||
|
{
|
||||||
config.lora.tx_enabled = true;
|
config.lora.tx_enabled = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -291,7 +319,8 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
|
|||||||
|
|
||||||
void AdminModule::handleSetModuleConfig(const meshtastic_ModuleConfig &c)
|
void AdminModule::handleSetModuleConfig(const meshtastic_ModuleConfig &c)
|
||||||
{
|
{
|
||||||
switch (c.which_payload_variant) {
|
switch (c.which_payload_variant)
|
||||||
|
{
|
||||||
case meshtastic_ModuleConfig_mqtt_tag:
|
case meshtastic_ModuleConfig_mqtt_tag:
|
||||||
LOG_INFO("Setting module config: MQTT\n");
|
LOG_INFO("Setting module config: MQTT\n");
|
||||||
moduleConfig.has_mqtt = true;
|
moduleConfig.has_mqtt = true;
|
||||||
@ -355,7 +384,8 @@ void AdminModule::handleSetChannel(const meshtastic_Channel &cc)
|
|||||||
|
|
||||||
void AdminModule::handleGetOwner(const meshtastic_MeshPacket &req)
|
void AdminModule::handleGetOwner(const meshtastic_MeshPacket &req)
|
||||||
{
|
{
|
||||||
if (req.decoded.want_response) {
|
if (req.decoded.want_response)
|
||||||
|
{
|
||||||
// We create the reply here
|
// We create the reply here
|
||||||
meshtastic_AdminMessage res = meshtastic_AdminMessage_init_default;
|
meshtastic_AdminMessage res = meshtastic_AdminMessage_init_default;
|
||||||
res.get_owner_response = owner;
|
res.get_owner_response = owner;
|
||||||
@ -369,8 +399,10 @@ void AdminModule::handleGetConfig(const meshtastic_MeshPacket &req, const uint32
|
|||||||
{
|
{
|
||||||
meshtastic_AdminMessage res = meshtastic_AdminMessage_init_default;
|
meshtastic_AdminMessage res = meshtastic_AdminMessage_init_default;
|
||||||
|
|
||||||
if (req.decoded.want_response) {
|
if (req.decoded.want_response)
|
||||||
switch (configType) {
|
{
|
||||||
|
switch (configType)
|
||||||
|
{
|
||||||
case meshtastic_AdminMessage_ConfigType_DEVICE_CONFIG:
|
case meshtastic_AdminMessage_ConfigType_DEVICE_CONFIG:
|
||||||
LOG_INFO("Getting config: Device\n");
|
LOG_INFO("Getting config: Device\n");
|
||||||
res.get_config_response.which_payload_variant = meshtastic_Config_device_tag;
|
res.get_config_response.which_payload_variant = meshtastic_Config_device_tag;
|
||||||
@ -425,8 +457,10 @@ void AdminModule::handleGetModuleConfig(const meshtastic_MeshPacket &req, const
|
|||||||
{
|
{
|
||||||
meshtastic_AdminMessage res = meshtastic_AdminMessage_init_default;
|
meshtastic_AdminMessage res = meshtastic_AdminMessage_init_default;
|
||||||
|
|
||||||
if (req.decoded.want_response) {
|
if (req.decoded.want_response)
|
||||||
switch (configType) {
|
{
|
||||||
|
switch (configType)
|
||||||
|
{
|
||||||
case meshtastic_AdminMessage_ModuleConfigType_MQTT_CONFIG:
|
case meshtastic_AdminMessage_ModuleConfigType_MQTT_CONFIG:
|
||||||
LOG_INFO("Getting module config: MQTT\n");
|
LOG_INFO("Getting module config: MQTT\n");
|
||||||
res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_mqtt_tag;
|
res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_mqtt_tag;
|
||||||
@ -514,29 +548,36 @@ void AdminModule::handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &r
|
|||||||
|
|
||||||
#if HAS_WIFI
|
#if HAS_WIFI
|
||||||
conn.has_wifi = true;
|
conn.has_wifi = true;
|
||||||
conn.wifi.status.status.is_connected = WiFi.status() != WL_CONNECTED;
|
conn.wifi.has_status = true;
|
||||||
|
conn.wifi.status.is_connected = WiFi.status() != WL_CONNECTED;
|
||||||
strncpy(conn.wifi.ssid, config.network.wifi_ssid, 33);
|
strncpy(conn.wifi.ssid, config.network.wifi_ssid, 33);
|
||||||
if (conn.wifi.status.status.is_connected) {
|
if (conn.wifi.status.is_connected)
|
||||||
|
{
|
||||||
conn.wifi.rssi = WiFi.RSSI();
|
conn.wifi.rssi = WiFi.RSSI();
|
||||||
conn.wifi.status.status.ip_address = WiFi.localIP();
|
conn.wifi.status.ip_address = WiFi.localIP();
|
||||||
conn.wifi.status.status.is_mqtt_connected = mqtt && mqtt->connected();
|
conn.wifi.status.is_mqtt_connected = mqtt && mqtt->connected();
|
||||||
conn.wifi.status.status.is_syslog_connected = false; // FIXME wire this up
|
conn.wifi.status.is_syslog_connected = false; // FIXME wire this up
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAS_ETHERNET
|
#if HAS_ETHERNET
|
||||||
conn.has_ethernet = true;
|
conn.has_ethernet = true;
|
||||||
if (Ethernet.linkStatus() == LinkON) {
|
conn.ethernet.has_status = true;
|
||||||
|
if (Ethernet.linkStatus() == LinkON)
|
||||||
|
{
|
||||||
conn.ethernet.status.is_connected = true;
|
conn.ethernet.status.is_connected = true;
|
||||||
conn.ethernet.status.ip_address = Ethernet.localIP();
|
conn.ethernet.status.ip_address = Ethernet.localIP();
|
||||||
conn.ethernet.status.is_mqtt_connected = mqtt && mqtt->connected();
|
conn.ethernet.status.is_mqtt_connected = mqtt && mqtt->connected();
|
||||||
conn.ethernet.status.is_syslog_connected = false; // FIXME wire this up
|
conn.ethernet.status.is_syslog_connected = false; // FIXME wire this up
|
||||||
}
|
}
|
||||||
conn.ethernet.status.is_connected = false;
|
else
|
||||||
|
{
|
||||||
|
conn.ethernet.status.is_connected = false;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAS_BLUETOOTH
|
#if HAS_BLUETOOTH
|
||||||
conn.has_bluetooth = HAS_BLUETOOTH;
|
conn.has_bluetooth = true;
|
||||||
conn.bluetooth.pin = config.bluetooth.fixed_pin;
|
conn.bluetooth.pin = config.bluetooth.fixed_pin;
|
||||||
#endif
|
#endif
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
@ -556,7 +597,8 @@ void AdminModule::handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &r
|
|||||||
|
|
||||||
void AdminModule::handleGetChannel(const meshtastic_MeshPacket &req, uint32_t channelIndex)
|
void AdminModule::handleGetChannel(const meshtastic_MeshPacket &req, uint32_t channelIndex)
|
||||||
{
|
{
|
||||||
if (req.decoded.want_response) {
|
if (req.decoded.want_response)
|
||||||
|
{
|
||||||
// We create the reply here
|
// We create the reply here
|
||||||
meshtastic_AdminMessage r = meshtastic_AdminMessage_init_default;
|
meshtastic_AdminMessage r = meshtastic_AdminMessage_init_default;
|
||||||
r.get_channel_response = channels.getByIndex(channelIndex);
|
r.get_channel_response = channels.getByIndex(channelIndex);
|
||||||
@ -574,13 +616,17 @@ void AdminModule::reboot(int32_t seconds)
|
|||||||
|
|
||||||
void AdminModule::saveChanges(int saveWhat, bool shouldReboot)
|
void AdminModule::saveChanges(int saveWhat, bool shouldReboot)
|
||||||
{
|
{
|
||||||
if (!hasOpenEditTransaction) {
|
if (!hasOpenEditTransaction)
|
||||||
|
{
|
||||||
LOG_INFO("Saving changes to disk\n");
|
LOG_INFO("Saving changes to disk\n");
|
||||||
service.reloadConfig(saveWhat); // Calls saveToDisk among other things
|
service.reloadConfig(saveWhat); // Calls saveToDisk among other things
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
LOG_INFO("Delaying save of changes to disk until the open transaction is committed\n");
|
LOG_INFO("Delaying save of changes to disk until the open transaction is committed\n");
|
||||||
}
|
}
|
||||||
if (shouldReboot) {
|
if (shouldReboot)
|
||||||
|
{
|
||||||
reboot(DEFAULT_REBOOT_SECONDS);
|
reboot(DEFAULT_REBOOT_SECONDS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user