mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-02 18:59:56 +00:00
Allow plugins to write to the parsed protobuf (minimizes copies in some cases)
This commit is contained in:
parent
676a6f3bea
commit
d40b66beac
@ -28,7 +28,7 @@ template <class T> class ProtobufPlugin : protected SinglePortPlugin
|
||||
* In general decoded will always be !NULL. But in some special applications (where you have handling packets
|
||||
* for multiple port numbers, decoding will ONLY be attempted for packets where the portnum matches our expected ourPortNum.
|
||||
*/
|
||||
virtual bool handleReceivedProtobuf(const MeshPacket &mp, const T *decoded) = 0;
|
||||
virtual bool handleReceivedProtobuf(const MeshPacket &mp, T *decoded) = 0;
|
||||
|
||||
/**
|
||||
* Return a mesh packet which has been preinited with a particular protobuf data payload and port number.
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
NodeInfoPlugin *nodeInfoPlugin;
|
||||
|
||||
bool NodeInfoPlugin::handleReceivedProtobuf(const MeshPacket &mp, const User *pptr)
|
||||
bool NodeInfoPlugin::handleReceivedProtobuf(const MeshPacket &mp, User *pptr)
|
||||
{
|
||||
auto p = *pptr;
|
||||
|
||||
|
@ -26,7 +26,7 @@ class NodeInfoPlugin : public ProtobufPlugin<User>, private concurrency::OSThrea
|
||||
|
||||
@return true if you've guaranteed you've handled this message and no other handlers should be considered for it
|
||||
*/
|
||||
virtual bool handleReceivedProtobuf(const MeshPacket &mp, const User *p);
|
||||
virtual bool handleReceivedProtobuf(const MeshPacket &mp, User *p);
|
||||
|
||||
/** Messages can be received that have the want_response bit set. If set, this callback will be invoked
|
||||
* so that subclasses can (optionally) send a response back to the original sender. */
|
||||
|
@ -14,7 +14,7 @@ PositionPlugin::PositionPlugin()
|
||||
setIntervalFromNow(60 * 1000); // Send our initial position 60 seconds after we start (to give GPS time to setup)
|
||||
}
|
||||
|
||||
bool PositionPlugin::handleReceivedProtobuf(const MeshPacket &mp, const Position *pptr)
|
||||
bool PositionPlugin::handleReceivedProtobuf(const MeshPacket &mp, Position *pptr)
|
||||
{
|
||||
auto p = *pptr;
|
||||
|
||||
|
@ -33,7 +33,7 @@ class PositionPlugin : public ProtobufPlugin<Position>, private concurrency::OST
|
||||
|
||||
@return true if you've guaranteed you've handled this message and no other handlers should be considered for it
|
||||
*/
|
||||
virtual bool handleReceivedProtobuf(const MeshPacket &mp, const Position *p);
|
||||
virtual bool handleReceivedProtobuf(const MeshPacket &mp, Position *p);
|
||||
|
||||
/** Messages can be received that have the want_response bit set. If set, this callback will be invoked
|
||||
* so that subclasses can (optionally) send a response back to the original sender. */
|
||||
|
@ -48,7 +48,7 @@ RemoteHardwarePlugin::RemoteHardwarePlugin()
|
||||
{
|
||||
}
|
||||
|
||||
bool RemoteHardwarePlugin::handleReceivedProtobuf(const MeshPacket &req, const HardwareMessage *pptr)
|
||||
bool RemoteHardwarePlugin::handleReceivedProtobuf(const MeshPacket &req, HardwareMessage *pptr)
|
||||
{
|
||||
auto p = *pptr;
|
||||
DEBUG_MSG("Received RemoteHardware typ=%d\n", p.typ);
|
||||
|
@ -27,7 +27,7 @@ class RemoteHardwarePlugin : public ProtobufPlugin<HardwareMessage>, private con
|
||||
|
||||
@return true if you've guaranteed you've handled this message and no other handlers should be considered for it
|
||||
*/
|
||||
virtual bool handleReceivedProtobuf(const MeshPacket &mp, const HardwareMessage *p);
|
||||
virtual bool handleReceivedProtobuf(const MeshPacket &mp, HardwareMessage *p);
|
||||
|
||||
/**
|
||||
* Periodically read the gpios we have been asked to WATCH, if they have changed,
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
RoutingPlugin *routingPlugin;
|
||||
|
||||
bool RoutingPlugin::handleReceivedProtobuf(const MeshPacket &mp, const Routing *r)
|
||||
bool RoutingPlugin::handleReceivedProtobuf(const MeshPacket &mp, Routing *r)
|
||||
{
|
||||
printPacket("Routing sniffing", &mp);
|
||||
router->sniffReceived(&mp, r);
|
||||
|
@ -22,7 +22,7 @@ class RoutingPlugin : public ProtobufPlugin<Routing>
|
||||
|
||||
@return true if you've guaranteed you've handled this message and no other handlers should be considered for it
|
||||
*/
|
||||
virtual bool handleReceivedProtobuf(const MeshPacket &mp, const Routing *p);
|
||||
virtual bool handleReceivedProtobuf(const MeshPacket &mp, Routing *p);
|
||||
|
||||
/** Messages can be received that have the want_response bit set. If set, this callback will be invoked
|
||||
* so that subclasses can (optionally) send a response back to the original sender. */
|
||||
|
@ -204,7 +204,7 @@ void EnvironmentalMeasurementPlugin::drawFrame(OLEDDisplay *display, OLEDDisplay
|
||||
|
||||
}
|
||||
|
||||
bool EnvironmentalMeasurementPlugin::handleReceivedProtobuf(const MeshPacket &mp, const EnvironmentalMeasurement *p)
|
||||
bool EnvironmentalMeasurementPlugin::handleReceivedProtobuf(const MeshPacket &mp, EnvironmentalMeasurement *p)
|
||||
{
|
||||
if (!(radioConfig.preferences.environmental_measurement_plugin_measurement_enabled || radioConfig.preferences.environmental_measurement_plugin_screen_enabled)){
|
||||
// If this plugin is not enabled in any capacity, don't handle the packet, and allow other plugins to consume
|
||||
|
@ -18,7 +18,7 @@ class EnvironmentalMeasurementPlugin : private concurrency::OSThread, public Pro
|
||||
/** Called to handle a particular incoming message
|
||||
@return true if you've guaranteed you've handled this message and no other handlers should be considered for it
|
||||
*/
|
||||
virtual bool handleReceivedProtobuf(const MeshPacket &mp, const EnvironmentalMeasurement *p);
|
||||
virtual bool handleReceivedProtobuf(const MeshPacket &mp, EnvironmentalMeasurement *p);
|
||||
virtual int32_t runOnce();
|
||||
/**
|
||||
* Send our EnvironmentalMeasurement into the mesh
|
||||
|
Loading…
Reference in New Issue
Block a user