2021-02-21 14:03:44 +08:00
|
|
|
#pragma once
|
2022-03-09 19:01:43 +11:00
|
|
|
#include "ProtobufModule.h"
|
2021-02-21 14:03:44 +08:00
|
|
|
|
|
|
|
|
/**
|
2022-02-27 02:21:02 -08:00
|
|
|
* Routing module for router control messages
|
2021-02-21 14:03:44 +08:00
|
|
|
*/
|
2022-03-09 19:01:43 +11:00
|
|
|
class AdminModule : public ProtobufModule<AdminMessage>
|
2021-02-21 14:03:44 +08:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/** Constructor
|
|
|
|
|
* name is for debugging output
|
|
|
|
|
*/
|
2022-02-27 02:21:02 -08:00
|
|
|
AdminModule();
|
2021-02-21 14:03:44 +08:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
*/
|
2022-01-24 17:24:40 +00:00
|
|
|
virtual bool handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *p) override;
|
2021-02-21 14:03:44 +08:00
|
|
|
|
|
|
|
|
private:
|
2022-11-20 19:50:45 -06:00
|
|
|
bool hasOpenEditTransaction = false;
|
|
|
|
|
|
|
|
|
|
void saveChanges(int saveWhat, bool shouldReboot = true);
|
2022-05-02 22:00:24 +10:00
|
|
|
/**
|
|
|
|
|
* Getters
|
|
|
|
|
*/
|
|
|
|
|
void handleGetOwner(const MeshPacket &req);
|
2022-05-03 22:16:50 +10:00
|
|
|
void handleGetConfig(const MeshPacket &req, uint32_t configType);
|
|
|
|
|
void handleGetModuleConfig(const MeshPacket &req, uint32_t configType);
|
2022-05-02 22:00:24 +10:00
|
|
|
void handleGetChannel(const MeshPacket &req, uint32_t channelIndex);
|
2022-08-08 07:19:04 -05:00
|
|
|
void handleGetDeviceMetadata(const MeshPacket &req);
|
2022-05-02 22:00:24 +10:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Setters
|
|
|
|
|
*/
|
2021-02-21 14:03:44 +08:00
|
|
|
void handleSetOwner(const User &o);
|
2022-05-02 22:00:24 +10:00
|
|
|
void handleSetChannel(const Channel &cc);
|
2022-05-02 10:24:28 +10:00
|
|
|
void handleSetConfig(const Config &c);
|
2022-05-02 22:00:24 +10:00
|
|
|
void handleSetModuleConfig(const ModuleConfig &c);
|
|
|
|
|
void handleSetChannel();
|
2022-10-19 19:19:04 -05:00
|
|
|
void reboot(int32_t seconds);
|
2021-02-21 14:03:44 +08:00
|
|
|
};
|
|
|
|
|
|
2022-02-27 02:21:02 -08:00
|
|
|
extern AdminModule *adminModule;
|