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