MySensors icon indicating copy to clipboard operation
MySensors copied to clipboard

Intercepting network messages in a gateway

Open SinishaDjukic opened this issue 5 years ago • 3 comments

During development it useful to have a way to monitor sensor messages on a gateway. For example, I would like to monitor the low power sensor battery levels over a period of days and weeks to ensure that low power has really been achieved.

For sure, this can be done with some of the existing controller UIs, but this also has certain disadvantages. E.g. you need to have a controller machine up and running for the whole time, or set up a dedicated RPi just for the purpose of experimentation and development.

Instead I'm using M5Stack and displaying the latest message (sender, type, value) and the latest known sensor state (battery, temperature, etc.). This is very convenient and mobile (built-in battery), and easy to modify and extend.

In order to do so I've modified gatewayTransportSend in MyGatewayTransportSerial.cpp and added a hook there. But is there a better way?

SinishaDjukic avatar May 14 '20 04:05 SinishaDjukic

Can't you use the official API (the same that all controllers use)? https://www.mysensors.org/download/serial_api_20

An alternative might be to implement the receive function.

mfalkvidd avatar May 14 '20 12:05 mfalkvidd

Using the serial gateway implementation on the one side and implementing a serial controller on the other - all on the same device - seems a bit of an overkill...

The current MY_GATEWAY_XXX defines instantiate specific gateway implementations (serial, MQTT, etc.), but would it work if do not use any of the default implementations? Like this:

  1. define these instead: #define MY_GATEWAY_FEATURE #define MY_IS_GATEWAY (true) #define MY_NODE_TYPE "GW"
  2. implement the functions from MyGatewayTransport.h

Anything missing?

SinishaDjukic avatar May 14 '20 12:05 SinishaDjukic

Hi @SinishaDjukic,

Not sure how you progress on this, and maybe my suggestion will be more "heavy weight" than you would like, but personally I use MQTT as something in between a full controller installation and just the gateway. Yes it will require some SBC on your network, however for most of us hacking on these sort of things that is not a problem (I know that I personally have several such machines running already anyway). mosquitto broker is only an apt install away in Debian, and then with tools like mqttwarn you can log this stuff directly into databases (or text files, if you prefer) right at the MQTT level, with no controller required. This is what I plan on doing, and am about halfway along in implementing it.

TRSx80 avatar Jun 29 '20 16:06 TRSx80