wire in part 1 of serial mode... select if you want textmsg or own portnum via config.

This commit is contained in:
Thomas Göttgens
2022-10-05 11:39:50 +02:00
parent e5605cc6fe
commit 4d2cb45f9f
2 changed files with 32 additions and 16 deletions

View File

@@ -4,6 +4,8 @@
#include "concurrency/OSThread.h"
#include "configuration.h"
#include <Arduino.h>
#include "MeshModule.h"
#include "Router.h"
#include <functional>
class SerialModule : private concurrency::OSThread
@@ -23,16 +25,11 @@ extern SerialModule *serialModule;
* Radio interface for SerialModule
*
*/
class SerialModuleRadio : public SinglePortModule
class SerialModuleRadio : public MeshModule
{
uint32_t lastRxID = 0;
public:
/*
TODO: Switch this to PortNum_SERIAL_APP once the change is able to be merged back here
from the main code.
*/
SerialModuleRadio();
/**
@@ -48,6 +45,20 @@ class SerialModuleRadio : public SinglePortModule
@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 MeshPacket &mp) override;
PortNum ourPortNum;
virtual bool wantPacket(const MeshPacket *p) override { return p->decoded.portnum == ourPortNum; }
MeshPacket *allocDataPacket()
{
// Update our local node info with our position (even if we don't decide to update anyone else)
MeshPacket *p = router->allocForSending();
p->decoded.portnum = ourPortNum;
return p;
}
};
extern SerialModuleRadio *serialModuleRadio;