Get last message using Meshtastic Python API? (feature request)

In a simple non-developer world, the Meshtastic python utility is great for simple integration to other IOT environments, but it would be even better if there was a command to allow us to retrieve the last known message (or messages).

This would allow a 3rd party app to easily be able to retrieve, respond to and reply to any messages, which is particularly useful where we are building IOT connected base stations.


Hmm. I think this might already be there. If before your app creates a SerialInterface instance, you subscribe for notification on new messages (via pub.subscribe(onReceive, “meshtastic.receive”)) you’ll be informed of any new received messages or any messages that arrived at the device before your app connected (up to a limit based on the amount of RAM on the device).

Does that help?

1 Like

Not quite. I was referring to the Meshtastic python command line utility, for us non-developers.


If you run

meshtastic --seriallog stdout --debug

There is other output as well, but the messages will show up.

1 Like

I don’t think this is what @Avron is talking about. I guess what they have in mind (and which is what I need, too) is the following.

  • A node is running on battery power, not connected to a computer, and unattended for some time (hours, days).

  • During this time, the node receives messages.

  • After that time, an “administrator” arrives, connects via USB, and wants to dump all messages received during the period of unattended operation.

Python’s onReceive API needs the computer to be physically connected to the node all the time as does seriallog.

The range test plug-in may fit the bill here. Configure it to save the messages and received messages will be saved to a csv.

Can’t exactly get the data over usb, but it’s a start.

1 Like

What if someone made an “inbox” plugin specifically for storing last n messages with a simple command for retrieval?

1 Like

Maybe :slight_smile: I think the plugin system should be able to support that kind of effort today.

This is close, but not quite.

Ideally I’d like to be able to use the meshtastic command line to show me the last received message in a similar way it allows me to sendtext. for example, something like: meshtastic --gettext
to return the last message in the form of a json, showing sender, time sent and message.

That way it is easy to integrate with less open IOT systems where we can use meshtastic to pass data and react to data, just by using this command line tool.

To further clarify, I am a casual developer and still have no idea how to add “plug-ins” and every time someone mentions just using them, I shudder, so am staying well away from tweaking my own versions of meshtastic.

Instead I’m looking at the command line utility as a great tool for allowing connected devices to use meshtastic as a network to pass IOT data and react to inbound messages.

So, for me being able to use the meshtastic command line utility to sendtext works a treat, but I can’t look for and act on inbound messages and their content…

Understood. For a casual developer, I’d encourage you to try python and our python api (and we’ll help when you have questions). I’d bet it is even easier than parsing any text output from the command line tool.


the 10ish line example here includes reading messages from the device:

1 Like

Still very deep end for me, but I’ll get there.

In the meantime, I noticed there is a DeviceState field called rx_text_message that keeps the last received message. Is there a way we can let the Meshtastic CLI have a function to return that stored value?

1 Like