Files
firmware/src/modules/AdminModule.h

62 lines
2.1 KiB
C
Raw Normal View History

2021-02-21 14:03:44 +08:00
#pragma once
#include "ProtobufModule.h"
#if HAS_WIFI
#include "mesh/wifi/WiFiAPClient.h"
2023-02-02 14:05:58 -06:00
#endif
2021-02-21 14:03:44 +08:00
/**
2022-11-25 20:32:43 +01:00
* Admin module for admin messages
2021-02-21 14:03:44 +08:00
*/
Show specific frame when updating screen (#4264) * Updated setFrames in Screen.cpp Added code to attempt to revert back to the same frame that user was on prior to setFrame reload. * Space added Screen.cpp * Update Screen.cpp Make screen to revert to Frame 0 if the originally displayed frame is no longer there. * Update Screen.cpp Inserted boolean holdPosition into setFrames to indicate the requirement to stay on the same frame ( if =true) or else it will switch to new frame . Only Screen::handleStatusUpdate calls with setFrame(true). ( For Node Updates) All other types of updates call as before setFrame(), so it will change focus as needed. * Hold position, even if number of frames increases * Hold position, if handling an outgoing text message * Update Screen.cpp * Reverted chnages related to devicestate.has_rx_text_message * Reset to master * CannedMessages only handles routing packets when waiting for ACK Previously, this was calling Screen::setFrames at unexpected times * Gather position info about screen frames while regenerating * Make admin module observable Notify only when relevant. Currently: only to handle remove_nodenum. * Optionally specify which frame to focus when setFrames runs * UIFrameEvent uses enum instead of multiple booleans * Allow modules to request their own frame to be focussed This is done internally by calling MeshModule::requestFocus() Easier this way, insteady of passing the info in the UIFrameEvent: * Modules don't always know whether they should be focussed until after the UIFrameEvent has been raised, in dramFrame * Don't have to pass reference to module instance as parameter though several methods * E-Ink screensaver uses FOCUS_PRESERVE Previously, it had its own basic implementation of this. * Spelling: regional variant * trunk * Fix HAS_SCREEN guarding * More HAS_SCREEN guarding --------- Co-authored-by: BIST <77391720+slash-bit@users.noreply.github.com> Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: slash-bit <v-b2@live.com>
2024-07-12 11:51:26 +12:00
class AdminModule : public ProtobufModule<meshtastic_AdminMessage>, public Observable<const meshtastic_AdminMessage *>
2021-02-21 14:03:44 +08:00
{
2023-02-03 08:50:10 -06:00
public:
/** Constructor
* name is for debugging output
*/
AdminModule();
2021-02-21 14:03:44 +08:00
2023-02-03 08:50:10 -06:00
protected:
/** Called to handle a particular incoming message
2021-02-21 14:03:44 +08:00
2023-02-03 08:50:10 -06:00
@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;
2021-02-21 14:03:44 +08:00
2023-02-03 08:50:10 -06:00
private:
bool hasOpenEditTransaction = false;
uint8_t session_passkey[8] = {0};
uint session_time = 0;
2023-02-03 08:50:10 -06:00
void saveChanges(int saveWhat, bool shouldReboot = true);
2023-02-03 08:50:10 -06:00
/**
* Getters
*/
void handleGetModuleConfigResponse(const meshtastic_MeshPacket &req, meshtastic_AdminMessage *p);
2023-02-03 08:50:10 -06:00
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);
2023-02-03 08:50:10 -06:00
/**
* Setters
*/
void handleSetOwner(const meshtastic_User &o);
void handleSetChannel(const meshtastic_Channel &cc);
void handleSetConfig(const meshtastic_Config &c);
void handleSetModuleConfig(const meshtastic_ModuleConfig &c);
void handleSetChannel();
2023-02-04 15:11:36 -06:00
void handleSetHamMode(const meshtastic_HamParameters &req);
2023-02-03 08:50:10 -06:00
void reboot(int32_t seconds);
void setPassKey(meshtastic_AdminMessage *res);
bool checkPassKey(meshtastic_AdminMessage *res);
bool messageIsResponse(meshtastic_AdminMessage *r);
bool messageIsRequest(meshtastic_AdminMessage *r);
2021-02-21 14:03:44 +08:00
};
extern AdminModule *adminModule;