From 1d40495c0be0b168b710109914d335c59202c92f Mon Sep 17 00:00:00 2001
From: Nils Werner
Date: Fri, 2 Oct 2020 13:48:37 +0200
Subject: [PATCH] Implement meshtastic.receive.text topic
---
docs/meshtastic/index.html | 10 ++++++++--
meshtastic/__init__.py | 5 ++++-
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/docs/meshtastic/index.html b/docs/meshtastic/index.html
index a47db99..6862e57 100644
--- a/docs/meshtastic/index.html
+++ b/docs/meshtastic/index.html
@@ -41,9 +41,10 @@ topics:
- meshtastic.connection.established - published once we've successfully connected to the radio and downloaded the node DB
- meshtastic.connection.lost - published once we've lost our link to the radio
-- meshtastic.receive.position(packet) - delivers a received packet as a dictionary, if you only care about a particular
+
- meshtastic.receive.text(packet) - delivers a received packet as a dictionary, if you only care about a particular
type of packet, you should subscribe to the full topic name.
If you want to see all packets, simply subscribe to "meshtastic.receive".
+- meshtastic.receive.position(packet)
- meshtastic.receive.user(packet)
- meshtastic.receive.data(packet)
- meshtastic.node.updated(node = NodeInfo) - published when a node in the DB changes (appears, location changed, username changed, etc…)
@@ -103,8 +104,9 @@ topics:
- meshtastic.connection.established - published once we've successfully connected to the radio and downloaded the node DB
- meshtastic.connection.lost - published once we've lost our link to the radio
-- meshtastic.receive.position(packet) - delivers a received packet as a dictionary, if you only care about a particular
+- meshtastic.receive.text(packet) - delivers a received packet as a dictionary, if you only care about a particular
type of packet, you should subscribe to the full topic name. If you want to see all packets, simply subscribe to "meshtastic.receive".
+- meshtastic.receive.position(packet)
- meshtastic.receive.user(packet)
- meshtastic.receive.data(packet)
- meshtastic.node.updated(node = NodeInfo) - published when a node in the DB changes (appears, location changed, username changed, etc...)
@@ -411,6 +413,7 @@ class MeshInterface:
"""Handle a MeshPacket that just arrived from the radio
Will publish one of the following events:
+ - meshtastic.receive.text(packet = MeshPacket dictionary)
- meshtastic.receive.position(packet = MeshPacket dictionary)
- meshtastic.receive.user(packet = MeshPacket dictionary)
- meshtastic.receive.data(packet = MeshPacket dictionary)
@@ -450,6 +453,7 @@ class MeshInterface:
# For text messages, we go ahead and decode the text to ascii for our users
if asDict["decoded"]["data"]["typ"] == "CLEAR_TEXT":
+ topic = "meshtastic.receive.text"
asDict["decoded"]["data"]["text"] = meshPacket.decoded.data.payload.decode(
"utf-8")
@@ -1094,6 +1098,7 @@ debugOut
"""Handle a MeshPacket that just arrived from the radio
Will publish one of the following events:
+ - meshtastic.receive.text(packet = MeshPacket dictionary)
- meshtastic.receive.position(packet = MeshPacket dictionary)
- meshtastic.receive.user(packet = MeshPacket dictionary)
- meshtastic.receive.data(packet = MeshPacket dictionary)
@@ -1133,6 +1138,7 @@ debugOut
# For text messages, we go ahead and decode the text to ascii for our users
if asDict["decoded"]["data"]["typ"] == "CLEAR_TEXT":
+ topic = "meshtastic.receive.text"
asDict["decoded"]["data"]["text"] = meshPacket.decoded.data.payload.decode(
"utf-8")
diff --git a/meshtastic/__init__.py b/meshtastic/__init__.py
index c64cf16..1893d30 100644
--- a/meshtastic/__init__.py
+++ b/meshtastic/__init__.py
@@ -20,8 +20,9 @@ topics:
- meshtastic.connection.established - published once we've successfully connected to the radio and downloaded the node DB
- meshtastic.connection.lost - published once we've lost our link to the radio
-- meshtastic.receive.position(packet) - delivers a received packet as a dictionary, if you only care about a particular
+- meshtastic.receive.text(packet) - delivers a received packet as a dictionary, if you only care about a particular
type of packet, you should subscribe to the full topic name. If you want to see all packets, simply subscribe to "meshtastic.receive".
+- meshtastic.receive.position(packet)
- meshtastic.receive.user(packet)
- meshtastic.receive.data(packet)
- meshtastic.node.updated(node = NodeInfo) - published when a node in the DB changes (appears, location changed, username changed, etc...)
@@ -328,6 +329,7 @@ class MeshInterface:
"""Handle a MeshPacket that just arrived from the radio
Will publish one of the following events:
+ - meshtastic.receive.text(packet = MeshPacket dictionary)
- meshtastic.receive.position(packet = MeshPacket dictionary)
- meshtastic.receive.user(packet = MeshPacket dictionary)
- meshtastic.receive.data(packet = MeshPacket dictionary)
@@ -367,6 +369,7 @@ class MeshInterface:
# For text messages, we go ahead and decode the text to ascii for our users
if asDict["decoded"]["data"]["typ"] == "CLEAR_TEXT":
+ topic = "meshtastic.receive.text"
asDict["decoded"]["data"]["text"] = meshPacket.decoded.data.payload.decode(
"utf-8")