I would like to have a Raspberry Pi Pico send serial messages to the radio. I do not think the pico has enough storage or serial compatibility out of the box to implement the meshtastic library directly.
My goal is to put a series of buttons on a pico and interface it usb/usb to the node where I push a button on the pico, it sends a message to the radio. I know that the canned message module exists and does this already, though there are a few reasons I’m trying this, not the least of which because it’s a challenge but mostly given the environment where this will be used (incredibly high light with the need for incredibly simple input to reduce errors in a really distracting environment).
Right now I’m building it locally, trying to brute force the equivalent of interface.sendText(“asdfoo”) from a python script.
serialPort = serial.Serial(port = "/dev/cu.wchusbserial51850266181", baudrate=921600,
bytesize=8, timeout=2, stopbits=serial.STOPBITS_ONE)
def getPacket(text):
x = {'to': 0xffffffff,'want_ack': False,'hop_limit': 3,'channel':0,'payload': text,'portnum': 'TEXT_MESSAGE_APP','want_response': False,'id': 46834053}
return x
def sendText(text):
print(text)
meshPacket = getPacket(text)
#json_object = json.dumps(meshPacket, indent = 0)
print(bytes(str(meshPacket),'utf-8'))
serialPort.write(str(meshPacket).encode('utf-8'))
sendText("asdfoo")
>>> output
asdfoo
b"{'to': 4294967295, 'want_ack': False, 'hop_limit': 3, 'channel': 0, 'payload': 'asdfoo', 'portnum':
'TEXT_MESSAGE_APP', 'want_response': False, 'id': 46834053}"
I am pretty sure that 1) I don’t have the exact message format and 2) the encoding might be off. I took the example from the mesh_interface.py as best I could. Any thoughts on this?