Merge pull request #2170 from meshtastic/device-metadata-enhanced

Add role and position flags to metadata
This commit is contained in:
Ben Meadors 2023-01-18 15:16:40 -06:00 committed by GitHub
commit 48609b5bdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -113,7 +113,7 @@ bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
if (BleOta::getOtaAppVersion().isEmpty()) {
LOG_INFO("No OTA firmware available, scheduling regular reboot in %d seconds\n", s);
screen->startRebootScreen();
}else{
} else {
screen->startFirmwareUpdateScreen();
BleOta::switchToOtaApp();
LOG_INFO("Rebooting to OTA in %d seconds\n", s);
@ -141,7 +141,8 @@ bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
nodeDB.factoryReset();
reboot(DEFAULT_REBOOT_SECONDS);
break;
} case AdminMessage_nodedb_reset_tag: {
}
case AdminMessage_nodedb_reset_tag: {
LOG_INFO("Initiating node-db reset\n");
nodeDB.resetNodes();
reboot(DEFAULT_REBOOT_SECONDS);
@ -233,8 +234,7 @@ void AdminModule::handleSetConfig(const Config &c)
config.has_device = true;
config.device = c.payload_variant.device;
// If we're setting router role for the first time, install its intervals
if (!isRouter &&
c.payload_variant.device.role == Config_DeviceConfig_Role_ROUTER) {
if (!isRouter && c.payload_variant.device.role == Config_DeviceConfig_Role_ROUTER) {
nodeDB.initConfigIntervals();
nodeDB.initModuleConfigIntervals();
}
@ -265,8 +265,7 @@ void AdminModule::handleSetConfig(const Config &c)
LOG_INFO("Setting config: LoRa\n");
config.has_lora = true;
config.lora = c.payload_variant.lora;
if (isRegionUnset &&
config.lora.region > Config_LoRaConfig_RegionCode_UNSET) {
if (isRegionUnset && config.lora.region > Config_LoRaConfig_RegionCode_UNSET) {
config.lora.tx_enabled = true;
}
break;
@ -381,7 +380,8 @@ void AdminModule::handleGetConfig(const MeshPacket &req, const uint32_t configTy
LOG_INFO("Getting config: Network\n");
res.get_config_response.which_payload_variant = Config_network_tag;
res.get_config_response.payload_variant.network = config.network;
writeSecret(res.get_config_response.payload_variant.network.wifi_psk, sizeof(res.get_config_response.payload_variant.network.wifi_psk), config.network.wifi_psk);
writeSecret(res.get_config_response.payload_variant.network.wifi_psk,
sizeof(res.get_config_response.payload_variant.network.wifi_psk), config.network.wifi_psk);
break;
case AdminMessage_ConfigType_DISPLAY_CONFIG:
LOG_INFO("Getting config: Display\n");
@ -430,8 +430,7 @@ void AdminModule::handleGetModuleConfig(const MeshPacket &req, const uint32_t co
case AdminMessage_ModuleConfigType_EXTNOTIF_CONFIG:
LOG_INFO("Getting module config: External Notification\n");
res.get_module_config_response.which_payload_variant = ModuleConfig_external_notification_tag;
res.get_module_config_response.payload_variant.external_notification =
moduleConfig.external_notification;
res.get_module_config_response.payload_variant.external_notification = moduleConfig.external_notification;
break;
case AdminMessage_ModuleConfigType_STOREFORWARD_CONFIG:
LOG_INFO("Getting module config: Store & Forward\n");
@ -477,7 +476,8 @@ void AdminModule::handleGetModuleConfig(const MeshPacket &req, const uint32_t co
}
}
void AdminModule::handleGetDeviceMetadata(const MeshPacket &req) {
void AdminModule::handleGetDeviceMetadata(const MeshPacket &req)
{
AdminMessage r = AdminMessage_init_default;
DeviceMetadata deviceMetadata;
@ -487,6 +487,8 @@ void AdminModule::handleGetDeviceMetadata(const MeshPacket &req) {
deviceMetadata.hasBluetooth = HAS_BLUETOOTH;
deviceMetadata.hasWifi = HAS_WIFI;
deviceMetadata.hasEthernet = HAS_ETHERNET;
deviceMetadata.role = config.device.role;
deviceMetadata.position_flags = config.position.position_flags;
r.get_device_metadata_response = deviceMetadata;
r.which_payload_variant = AdminMessage_get_device_metadata_response_tag;
@ -519,8 +521,7 @@ void AdminModule::saveChanges(int saveWhat, bool shouldReboot)
} else {
LOG_INFO("Delaying save of changes to disk until the open transaction is committed\n");
}
if (shouldReboot)
{
if (shouldReboot) {
reboot(DEFAULT_REBOOT_SECONDS);
}
}