2021-01-14 04:22:59 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "SinglePortPlugin.h"
|
|
|
|
#include "concurrency/OSThread.h"
|
|
|
|
#include "configuration.h"
|
|
|
|
#include <Arduino.h>
|
|
|
|
#include <functional>
|
|
|
|
|
2022-02-27 10:21:02 +00:00
|
|
|
class SerialModule : private concurrency::OSThread
|
2021-01-14 04:22:59 +00:00
|
|
|
{
|
|
|
|
bool firstTime = 1;
|
|
|
|
|
|
|
|
public:
|
2022-02-27 10:21:02 +00:00
|
|
|
SerialModule();
|
2021-01-14 04:22:59 +00:00
|
|
|
|
|
|
|
protected:
|
2022-01-24 17:24:40 +00:00
|
|
|
virtual int32_t runOnce() override;
|
2021-01-14 04:22:59 +00:00
|
|
|
};
|
|
|
|
|
2022-02-27 10:21:02 +00:00
|
|
|
extern SerialModule *serialModule;
|
2021-01-14 04:22:59 +00:00
|
|
|
|
|
|
|
/*
|
2022-02-27 10:21:02 +00:00
|
|
|
* Radio interface for SerialModule
|
2021-01-14 04:22:59 +00:00
|
|
|
*
|
|
|
|
*/
|
2022-02-27 10:21:02 +00:00
|
|
|
class SerialModuleRadio : public SinglePortPlugin
|
2021-01-14 04:22:59 +00:00
|
|
|
{
|
2022-01-24 07:00:14 +00:00
|
|
|
uint32_t lastRxID = 0;
|
2021-01-14 04:22:59 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
/*
|
|
|
|
TODO: Switch this to PortNum_SERIAL_APP once the change is able to be merged back here
|
|
|
|
from the main code.
|
|
|
|
*/
|
|
|
|
|
2022-02-27 10:21:02 +00:00
|
|
|
SerialModuleRadio();
|
2021-01-14 04:22:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Send our payload into the mesh
|
|
|
|
*/
|
|
|
|
void sendPayload(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false);
|
|
|
|
|
|
|
|
protected:
|
2022-01-24 17:24:40 +00:00
|
|
|
virtual MeshPacket *allocReply() override;
|
2021-01-14 04:22:59 +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-14 04:22:59 +00:00
|
|
|
*/
|
2022-01-24 17:24:40 +00:00
|
|
|
virtual ProcessMessage handleReceived(const MeshPacket &mp) override;
|
2021-01-14 04:22:59 +00:00
|
|
|
};
|
|
|
|
|
2022-02-27 10:21:02 +00:00
|
|
|
extern SerialModuleRadio *serialModuleRadio;
|