firmware/src/modules/ExternalNotificationModule.h

63 lines
1.8 KiB
C
Raw Normal View History

#pragma once
#include "SinglePortModule.h"
#include "concurrency/OSThread.h"
#include "configuration.h"
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
#include <NonBlockingRtttl.h>
2023-01-04 13:45:28 +00:00
#else
// Noop class for portduino.
2023-01-21 13:34:29 +00:00
class rtttl
2023-01-04 13:45:28 +00:00
{
public:
explicit rtttl() {}
static bool isPlaying() { return false; }
static void play() {}
2023-01-21 13:34:29 +00:00
static void begin(byte a, const char *b){};
2023-01-04 13:45:28 +00:00
static void stop() {}
static bool done() { return true; }
};
2022-12-28 14:41:58 +00:00
#endif
#include <Arduino.h>
#include <functional>
2021-03-13 05:32:23 +00:00
/*
2022-02-27 09:49:24 +00:00
* Radio interface for ExternalNotificationModule
2021-03-13 05:32:23 +00:00
*
*/
class ExternalNotificationModule : public SinglePortModule, private concurrency::OSThread
{
2023-01-21 13:34:29 +00:00
uint32_t output = 0;
public:
2022-02-27 09:49:24 +00:00
ExternalNotificationModule();
uint32_t nagCycleCutoff = UINT32_MAX;
2021-01-28 04:06:39 +00:00
void setExternalOn(uint8_t index = 0);
void setExternalOff(uint8_t index = 0);
bool getExternal(uint8_t index = 0);
void stopNow();
void handleGetRingtone(const meshtastic_MeshPacket &req, meshtastic_AdminMessage *response);
void handleSetRingtone(const char *from_msg);
protected:
/** Called to handle a particular incoming message
2023-01-21 13:34:29 +00:00
@return ProcessMessage::STOP if you've guaranteed you've handled this message and no other handlers should be considered for
it
*/
virtual ProcessMessage handleReceived(const meshtastic_MeshPacket &mp) override;
2022-01-24 17:24:40 +00:00
virtual int32_t runOnce() override;
2023-01-04 13:45:28 +00:00
bool isNagging = false;
2023-01-21 17:39:58 +00:00
virtual AdminMessageHandleResult handleAdminMessageForModule(const meshtastic_MeshPacket &mp,
meshtastic_AdminMessage *request,
meshtastic_AdminMessage *response) override;
2021-03-13 05:32:23 +00:00
};
extern ExternalNotificationModule *externalNotificationModule;