I’m trying to connect my raspberry pi with a meshtastic device,
actually i can send text message with the command “meshtastic --sendtext Hello_world” it work perfectly!
But i do not figure out how to receive message or how to read message that have been received by my device.
Unfortunately there aren’t a lot of examples out there; I’m not sure why the Python API is designed in this way. But perhaps the following may help.
You’ll want to do something like this:
# This callback will be called for every packet received from the radio
def callback(packet):
# You will need to adapt this code
print(repr(packet));
if (packet.decoded.portnum == 1): # Filter for text messaging app only.
print(f'received txt message - {packet.decoded.payload.decode("utf-8")}');
# Change the next two lines if you're connecting over TCP/IP:
# from meshtastic.tcp_interface import TCPInterface
# local = TCPInterface(hostname="meshtastic.local")
from meshtastic.serial_interface import SerialInterface;
local = SerialInterface();
local.sendText(text="hello", onResponse=callback);