mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-02 11:55:56 +00:00

Some checks are pending
CI / setup (check) (push) Waiting to run
CI / setup (esp32) (push) Waiting to run
CI / setup (esp32c3) (push) Waiting to run
CI / setup (esp32c6) (push) Waiting to run
CI / setup (esp32s3) (push) Waiting to run
CI / setup (nrf52840) (push) Waiting to run
CI / setup (rp2040) (push) Waiting to run
CI / setup (stm32) (push) Waiting to run
CI / check (push) Blocked by required conditions
CI / build-esp32 (push) Blocked by required conditions
CI / build-esp32-s3 (push) Blocked by required conditions
CI / build-esp32-c3 (push) Blocked by required conditions
CI / build-esp32-c6 (push) Blocked by required conditions
CI / build-nrf52 (push) Blocked by required conditions
CI / build-rpi2040 (push) Blocked by required conditions
CI / build-stm32 (push) Blocked by required conditions
CI / build-debian-src (push) Waiting to run
CI / package-pio-deps-native-tft (push) Waiting to run
CI / test-native (push) Waiting to run
CI / docker-deb-amd64 (push) Waiting to run
CI / docker-deb-amd64-tft (push) Waiting to run
CI / docker-alp-amd64 (push) Waiting to run
CI / docker-alp-amd64-tft (push) Waiting to run
CI / docker-deb-arm64 (push) Waiting to run
CI / docker-deb-armv7 (push) Waiting to run
CI / gather-artifacts (esp32) (push) Blocked by required conditions
CI / gather-artifacts (esp32c3) (push) Blocked by required conditions
CI / gather-artifacts (esp32c6) (push) Blocked by required conditions
CI / gather-artifacts (esp32s3) (push) Blocked by required conditions
CI / gather-artifacts (nrf52840) (push) Blocked by required conditions
CI / gather-artifacts (rp2040) (push) Blocked by required conditions
CI / gather-artifacts (stm32) (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
CI / release-firmware (esp32) (push) Blocked by required conditions
CI / release-firmware (esp32c3) (push) Blocked by required conditions
CI / release-firmware (esp32c6) (push) Blocked by required conditions
CI / release-firmware (esp32s3) (push) Blocked by required conditions
CI / release-firmware (nrf52840) (push) Blocked by required conditions
CI / release-firmware (rp2040) (push) Blocked by required conditions
CI / release-firmware (stm32) (push) Blocked by required conditions
CI / publish-firmware (push) Blocked by required conditions
* Allow observers to respond to AdminMessage requests Ground work for CannedMessage getters and setters * Enable CannedMessage config in apps for InkHUD devices * Migrate the InkHUD::Events AdminModule observer Use the new AdminModule_ObserverData struct * Bare-bones NicheGraphics util to access canned messages Handles loading and parsing. Handle admin messages for setting and getting. * Send canned messages via on-screen menu * Change ThreadedMessageApplet from Observer to Module API Allows us to intercept locally generated packets ('loopbackOK = true'), to handle outgoing canned messages. * Fix: crash getting empty canned message string via Client API * Move file into Utils subdir * Move an include statement from .cpp to .h * Limit strncpy size of dest, not source Wasn't critical in ths specific case, but definitely a mistake.
82 lines
2.8 KiB
C++
82 lines
2.8 KiB
C++
#include <sys/types.h>
|
|
|
|
#pragma once
|
|
#include "ProtobufModule.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);
|
|
void handleSetConfig(const meshtastic_Config &c);
|
|
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 *message);
|
|
};
|
|
|
|
static constexpr const char *licensedModeMessage =
|
|
"Licensed mode activated, removing admin channel and encryption from all channels";
|
|
|
|
extern AdminModule *adminModule;
|
|
|
|
void disableBluetooth(); |