2024-11-03 08:24:04 -05:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
2021-02-21 14:03:44 +08:00
|
|
|
#pragma once
|
2022-03-09 19:01:43 +11:00
|
|
|
#include "ProtobufModule.h"
|
2024-07-03 15:39:09 -07:00
|
|
|
#if HAS_WIFI
|
2023-12-02 21:47:52 +01:00
|
|
|
#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
|
|
|
*/
|
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;
|
2022-11-20 19:50:45 -06:00
|
|
|
|
2024-08-17 08:41:12 -05:00
|
|
|
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-05-22 07:00:20 -05:00
|
|
|
|
2023-02-03 08:50:10 -06:00
|
|
|
/**
|
|
|
|
|
* Getters
|
|
|
|
|
*/
|
2023-05-22 07:00:20 -05:00
|
|
|
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);
|
2023-05-22 07:00:20 -05:00
|
|
|
void handleGetNodeRemoteHardwarePins(const meshtastic_MeshPacket &req);
|
2024-12-27 10:46:21 +11:00
|
|
|
void handleGetDeviceUIConfig(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);
|
2025-02-16 05:15:30 -08:00
|
|
|
bool handleSetModuleConfig(const meshtastic_ModuleConfig &c);
|
2023-02-03 08:50:10 -06:00
|
|
|
void handleSetChannel();
|
2023-02-04 15:11:36 -06:00
|
|
|
void handleSetHamMode(const meshtastic_HamParameters &req);
|
2024-12-27 10:46:21 +11:00
|
|
|
void handleStoreDeviceUIConfig(const meshtastic_DeviceUIConfig &uicfg);
|
2023-02-03 08:50:10 -06:00
|
|
|
void reboot(int32_t seconds);
|
2024-08-17 08:41:12 -05:00
|
|
|
|
|
|
|
|
void setPassKey(meshtastic_AdminMessage *res);
|
|
|
|
|
bool checkPassKey(meshtastic_AdminMessage *res);
|
|
|
|
|
|
2024-09-26 02:09:06 +02:00
|
|
|
bool messageIsResponse(const meshtastic_AdminMessage *r);
|
|
|
|
|
bool messageIsRequest(const meshtastic_AdminMessage *r);
|
2024-10-12 06:17:44 -05:00
|
|
|
void sendWarning(const char *message);
|
2021-02-21 14:03:44 +08:00
|
|
|
};
|
|
|
|
|
|
2024-09-11 08:42:26 -05:00
|
|
|
extern AdminModule *adminModule;
|
|
|
|
|
|
|
|
|
|
void disableBluetooth();
|