Python byte arrays can’t be directly stored in json. You’ll need to convert them to a somehow (either as utf8 if you know they are characters or usually base64)
The provided packet is a dictionary with a number of entries.
Received: {'from': 3294300496, 'to': 4294967295, 'decoded': {'data': {'portnum': 'TEXT_MESSAGE_APP', 'payload': b'hi'}}, 'id': 2707257921, 'rxSnr': 9.75, 'hopLimit': 1, 'fromId': '!240ac45b0950', 'toId': '^all'}
b'hi'
ERROR:root:Error while handling message from radio 'dict' object has no attribute 'decode'
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/meshtastic/__init__.py", line 676, in __reader
self._handleFromRadio(self._rxBuf[HEADER_LEN:])
File "/usr/local/lib/python3.8/dist-packages/meshtastic/__init__.py", line 384, in _handleFromRadio
self._handlePacketFromRadio(fromRadio.packet)
File "/usr/local/lib/python3.8/dist-packages/meshtastic/__init__.py", line 513, in _handlePacketFromRadio
pub.sendMessage(topic, packet=asDict, interface=self)
File "/usr/local/lib/python3.8/dist-packages/pubsub/core/publisher.py", line 216, in sendMessage
topicObj.publish(**msgData)
File "/usr/local/lib/python3.8/dist-packages/pubsub/core/topicobj.py", line 452, in publish
self.__sendMessage(msgData, topicObj, msgDataSubset)
File "/usr/local/lib/python3.8/dist-packages/pubsub/core/topicobj.py", line 482, in __sendMessage
listener(data, self, allData)
File "/usr/local/lib/python3.8/dist-packages/pubsub/core/listener.py", line 237, in __call__
cb(**kwargs)
File "distmeshthread.py", line 39, in onReceive
data = packet.decode('utf-8')
AttributeError: 'dict' object has no attribute 'decode'