Implement rebroadcast mode NONE (#5040)

* Implement rebroadcast mode none

* Correct debug message
This commit is contained in:
Ben Meadors
2024-10-12 06:17:44 -05:00
committed by GitHub
parent 37448205b5
commit fb9f361052
4 changed files with 28 additions and 2 deletions

View File

@@ -451,6 +451,14 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
requiresReboot = false;
}
config.device = c.payload_variant.device;
if (config.device.rebroadcast_mode == meshtastic_Config_DeviceConfig_RebroadcastMode_NONE &&
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";
LOG_WARN(warning);
sendWarning(warning);
}
// If we're setting router role for the first time, install its intervals
if (existingRole != c.payload_variant.device.role)
nodeDB->installRoleDefaults(c.payload_variant.device.role);
@@ -1064,6 +1072,15 @@ bool AdminModule::messageIsRequest(const meshtastic_AdminMessage *r)
return false;
}
void AdminModule::sendWarning(const char *message)
{
meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed();
cn->level = meshtastic_LogRecord_Level_WARNING;
cn->time = getValidTime(RTCQualityFromNet);
strncpy(cn->message, message, sizeof(cn->message));
service->sendClientNotification(cn);
}
void disableBluetooth()
{
#if HAS_BLUETOOTH

View File

@@ -57,6 +57,7 @@ class AdminModule : public ProtobufModule<meshtastic_AdminMessage>, public Obser
bool messageIsResponse(const meshtastic_AdminMessage *r);
bool messageIsRequest(const meshtastic_AdminMessage *r);
void sendWarning(const char *message);
};
extern AdminModule *adminModule;