mirror of
https://github.com/meshtastic/firmware.git
synced 2026-05-29 19:24:46 -04:00
* Enhance LoRa configuration with modem presets and validation logic * Rename bootstrapLoRaConfigFromPreset tests to validateModemConfig for clarity and consistency * additional tidy-ups to the validateModemConfig - still fundamentally broken at this point * Enhance region validation by adding numPresets to RegionInfo and implementing validateRegionConfig in RadioInterface * Add validation for modem configuration in applyModemConfig * Fix region unset handling and improve modem config validation in handleSetConfig * Refactor LoRa configuration validation methods and introduce clamping method for invalid settings * Update handleSetConfig to use fromOthers parameter to either correct or reject invalid settings * Fix some of the copilot review comments for LoRa configuration validation and clamping methods; add tests for region and preset handling * Redid the slot default checking and calculation. Should resolve the outstanding comments. * Add bandwidth calculation for LoRa modem preset fallback in clampConfigLora * Remove unused preset name variable in validateConfigLora and fix default frequency slot check in applyModemConfig * update tests for region handling * Got the synthetic colleague to add mock service for testing * Flash savings... hopefully * Refactor modem preset handling to use sentinel values and improve default preset retrieval * Refactor region handling to use profile structures for modem presets and channel calculations * added comments for clarity on parameters * Add shadow table tests and validateConfigLora enhancements for region presets * Add isFromUs tests for preset validation in AdminModule * Respond to copilot github review * address copilot comments * address null poointers * fix build errors * Fix the fix, undo the silly suggestions from synthetic reviewer. * we all float here * Fix include path for AdminModule in test_main.cpp * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * More suggestion fixes * admin module merge conflicts * admin module fixes from merge hell * fix: initialize default frequency slot and custom channel name; update LNA mode handling * save some bytes... * fix: simplify error logging for bandwidth checks in LoRa configuration * Update src/mesh/MeshRadio.h Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
89 lines
3.0 KiB
C++
89 lines
3.0 KiB
C++
#pragma once
|
|
#ifdef ESP_PLATFORM
|
|
#include <esp_ota_ops.h>
|
|
#endif
|
|
#include "ProtobufModule.h"
|
|
#include <sys/types.h>
|
|
#if HAS_WIFI
|
|
#include "mesh/wifi/WiFiAPClient.h"
|
|
#endif
|
|
|
|
/**
|
|
* Datatype passed to Observers by AdminModule, to allow external handling of admin messages
|
|
*/
|
|
struct AdminModule_ObserverData {
|
|
const meshtastic_AdminMessage *request;
|
|
meshtastic_AdminMessage *response;
|
|
AdminMessageHandleResult *result;
|
|
};
|
|
|
|
/**
|
|
* Admin module for admin messages
|
|
*/
|
|
class AdminModule : public ProtobufModule<meshtastic_AdminMessage>, public Observable<AdminModule_ObserverData *>
|
|
{
|
|
public:
|
|
/** Constructor
|
|
* name is for debugging output
|
|
*/
|
|
AdminModule();
|
|
|
|
protected:
|
|
/** Called to handle a particular incoming message
|
|
|
|
@return true if you've guaranteed you've handled this message and no other handlers should be considered for it
|
|
*/
|
|
virtual bool handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_AdminMessage *p) override;
|
|
|
|
private:
|
|
bool hasOpenEditTransaction = false;
|
|
|
|
uint8_t session_passkey[8] = {0};
|
|
uint session_time = 0;
|
|
|
|
void saveChanges(int saveWhat, bool shouldReboot = true);
|
|
|
|
/**
|
|
* Getters
|
|
*/
|
|
void handleGetModuleConfigResponse(const meshtastic_MeshPacket &req, meshtastic_AdminMessage *p);
|
|
void handleGetOwner(const meshtastic_MeshPacket &req);
|
|
void handleGetConfig(const meshtastic_MeshPacket &req, uint32_t configType);
|
|
void handleGetModuleConfig(const meshtastic_MeshPacket &req, uint32_t configType);
|
|
void handleGetChannel(const meshtastic_MeshPacket &req, uint32_t channelIndex);
|
|
void handleGetDeviceMetadata(const meshtastic_MeshPacket &req);
|
|
void handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &req);
|
|
void handleGetNodeRemoteHardwarePins(const meshtastic_MeshPacket &req);
|
|
void handleGetDeviceUIConfig(const meshtastic_MeshPacket &req);
|
|
/**
|
|
* Setters
|
|
*/
|
|
void handleSetOwner(const meshtastic_User &o);
|
|
void handleSetChannel(const meshtastic_Channel &cc);
|
|
|
|
protected:
|
|
void handleSetConfig(const meshtastic_Config &c, bool fromOthers);
|
|
|
|
private:
|
|
bool handleSetModuleConfig(const meshtastic_ModuleConfig &c);
|
|
void handleSetChannel();
|
|
void handleSetHamMode(const meshtastic_HamParameters &req);
|
|
void handleStoreDeviceUIConfig(const meshtastic_DeviceUIConfig &uicfg);
|
|
void handleSendInputEvent(const meshtastic_AdminMessage_InputEvent &inputEvent);
|
|
void reboot(int32_t seconds);
|
|
|
|
void setPassKey(meshtastic_AdminMessage *res);
|
|
bool checkPassKey(meshtastic_AdminMessage *res);
|
|
|
|
bool messageIsResponse(const meshtastic_AdminMessage *r);
|
|
bool messageIsRequest(const meshtastic_AdminMessage *r);
|
|
void sendWarning(const char *format, ...) __attribute__((format(printf, 2, 3)));
|
|
void sendWarningAndLog(const char *format, ...) __attribute__((format(printf, 2, 3)));
|
|
};
|
|
|
|
static constexpr const char *licensedModeMessage =
|
|
"Licensed mode activated, removing admin channel and encryption from all channels";
|
|
|
|
extern AdminModule *adminModule;
|
|
|
|
void disableBluetooth(); |