WIP on GPIO example

This commit is contained in:
Kevin Hester
2020-12-07 10:18:11 +08:00
parent 8f5a1f19d3
commit 90060e84c0
12 changed files with 140 additions and 60 deletions
+16
View File
@@ -1,5 +1,6 @@
#pragma once
#include "MeshPlugin.h"
#include "Router.h"
/**
* Most plugins are only interested in sending/receving one particular portnum. This baseclass simplifies that common
@@ -21,4 +22,19 @@ class SinglePortPlugin : public MeshPlugin
* @return true if you want to receive the specified portnum
*/
virtual bool wantPortnum(PortNum p) { return p == 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()
*/
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.which_payload = SubPacket_data_tag;
p->decoded.data.portnum = ourPortNum;
return p;
}
};