Offline MQTT message queueing

Hi, I’m happy to provide the current working code. But we have a customer who’s pushing MQTT messages from BASIC. They want to store messages that don’t get sent in the event the ewon loses connection to the broker.

Is there any guidance on writing files to an SDcard that can be read and then published once the script detects it’s connected again?

I am also open to the idea of reading historical tags to publish those. If possible it may be more prudent considering how the current code is set up. I am happy to share the code but wanted to see if there was any general guidance.

To Recap: I need to, in the even the device loses connection to the broker, push a MQTT message to the SD card, then read and post it to the broker on connection recovery.

Thanks

There is already a thread about this topic on the eWON Developer forum.

https://techforum.ewon.biz/thread-1048.html

There is also a BASIC script that you can use. You must have 14.0s2 or higher firmware.

Thank you Kyle, this looks like exactly what I needed, I will test it out.

Additionally do you know if there is a method similar to NBTAGS bit only called tags that are in the A group?

Thanks,

Brian

Hey Brian,

There is no built in function for that, but you can load the tag list and use an IF statement to see if it’s in a group.

It would look something like this:

n% = GETSYS PRG,"NBTAGS"
//Browse all Tags
For i%=0 To n%-1
   SETSYS TAG, "LOAD", -i%
   Group% = VAL GETSYS TAG, "IVGroupA"
   IF Group% = 1 THEN //it belongs to Group A
          //whatever you're trying to do
   ENDIF
Next i%

Kyle

1 Like