mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-13 16:11:24 +00:00
![Jonathan Bennett](/assets/img/avatar_default.png)
* Make SPI frequency configurable on Native * Make the tophone queue size configurable for Portduino * The modified SPISettings must be configured in setup(), after config.yaml is processed * make MeshService a pointer, so we can configure MAX_RX_TOPHONE at run time * Got a little over excited with refactoring * Silence a warning
39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
#pragma once
|
|
#include "MeshModule.h"
|
|
#include "Router.h"
|
|
|
|
/**
|
|
* Most modules are only interested in sending/receiving one particular portnum. This baseclass simplifies that common
|
|
* case.
|
|
*/
|
|
class SinglePortModule : public MeshModule
|
|
{
|
|
protected:
|
|
meshtastic_PortNum ourPortNum;
|
|
|
|
public:
|
|
/** Constructor
|
|
* name is for debugging output
|
|
*/
|
|
SinglePortModule(const char *_name, meshtastic_PortNum _ourPortNum) : MeshModule(_name), ourPortNum(_ourPortNum) {}
|
|
|
|
protected:
|
|
/**
|
|
* @return true if you want to receive the specified portnum
|
|
*/
|
|
virtual bool wantPacket(const meshtastic_MeshPacket *p) override { return p->decoded.portnum == ourPortNum; }
|
|
|
|
/**
|
|
* Return a mesh packet which has been preinited as a data packet with a particular port number.
|
|
* You can then send this packet (after customizing any of the payload fields you might need) with
|
|
* service->sendToMesh()
|
|
*/
|
|
meshtastic_MeshPacket *allocDataPacket()
|
|
{
|
|
// Update our local node info with our position (even if we don't decide to update anyone else)
|
|
meshtastic_MeshPacket *p = router->allocForSending();
|
|
p->decoded.portnum = ourPortNum;
|
|
|
|
return p;
|
|
}
|
|
}; |