3535- `meshtastic.receive.data.portnum(packet)` (where portnum is an integer or well known PortNum enum)
3636- `meshtastic.node.updated(node = NodeInfo)` - published when a node in the DB changes (appears, location changed, username changed, etc...)
3737- `meshtastic.log.line(line)` - a raw unparsed log line from the radio
38+ - `meshtastic.clientNotification(notification, interface) - a ClientNotification sent from the radio
3839
3940We receive position, user, or data packets from the mesh. You probably only care about `meshtastic.receive.data`. The first argument for
4041that publish will be the packet. Text or binary data packets (from `sendData` or `sendText`) will both arrive this way. If you print packet
@@ -128,6 +129,7 @@ def onConnection(interface, topic=pub.AUTO_TOPIC): # called when we (re)connect
128129
129130publishingThread = DeferredExecution ("publishing" )
130131
132+ logger = logging .getLogger (__name__ )
131133
132134class ResponseHandler (NamedTuple ):
133135 """A pending response callback, waiting for a response to one of our messages"""
@@ -159,31 +161,31 @@ def _onTextReceive(iface, asDict):
159161 #
160162 # Usually btw this problem is caused by apps sending binary data but setting the payload type to
161163 # text.
162- logging .debug (f"in _onTextReceive() asDict:{ asDict } " )
164+ logger .debug (f"in _onTextReceive() asDict:{ asDict } " )
163165 try :
164166 asBytes = asDict ["decoded" ]["payload" ]
165167 asDict ["decoded" ]["text" ] = asBytes .decode ("utf-8" )
166168 except Exception as ex :
167- logging .error (f"Malformatted utf8 in text message: { ex } " )
169+ logger .error (f"Malformatted utf8 in text message: { ex } " )
168170 _receiveInfoUpdate (iface , asDict )
169171
170172
171173def _onPositionReceive (iface , asDict ):
172174 """Special auto parsing for received messages"""
173- logging .debug (f"in _onPositionReceive() asDict:{ asDict } " )
175+ logger .debug (f"in _onPositionReceive() asDict:{ asDict } " )
174176 if "decoded" in asDict :
175177 if "position" in asDict ["decoded" ] and "from" in asDict :
176178 p = asDict ["decoded" ]["position" ]
177- logging .debug (f"p:{ p } " )
179+ logger .debug (f"p:{ p } " )
178180 p = iface ._fixupPosition (p )
179- logging .debug (f"after fixup p:{ p } " )
181+ logger .debug (f"after fixup p:{ p } " )
180182 # update node DB as needed
181183 iface ._getOrCreateByNum (asDict ["from" ])["position" ] = p
182184
183185
184186def _onNodeInfoReceive (iface , asDict ):
185187 """Special auto parsing for received messages"""
186- logging .debug (f"in _onNodeInfoReceive() asDict:{ asDict } " )
188+ logger .debug (f"in _onNodeInfoReceive() asDict:{ asDict } " )
187189 if "decoded" in asDict :
188190 if "user" in asDict ["decoded" ] and "from" in asDict :
189191 p = asDict ["decoded" ]["user" ]
@@ -197,7 +199,7 @@ def _onNodeInfoReceive(iface, asDict):
197199
198200def _onTelemetryReceive (iface , asDict ):
199201 """Automatically update device metrics on received packets"""
200- logging .debug (f"in _onTelemetryReceive() asDict:{ asDict } " )
202+ logger .debug (f"in _onTelemetryReceive() asDict:{ asDict } " )
201203 if "from" not in asDict :
202204 return
203205
@@ -221,7 +223,7 @@ def _onTelemetryReceive(iface, asDict):
221223 updateObj = telemetry .get (toUpdate )
222224 newMetrics = node .get (toUpdate , {})
223225 newMetrics .update (updateObj )
224- logging .debug (f"updating { toUpdate } metrics for { asDict ['from' ]} to { newMetrics } " )
226+ logger .debug (f"updating { toUpdate } metrics for { asDict ['from' ]} to { newMetrics } " )
225227 node [toUpdate ] = newMetrics
226228
227229def _receiveInfoUpdate (iface , asDict ):
@@ -233,7 +235,7 @@ def _receiveInfoUpdate(iface, asDict):
233235
234236def _onAdminReceive (iface , asDict ):
235237 """Special auto parsing for received messages"""
236- logging .debug (f"in _onAdminReceive() asDict:{ asDict } " )
238+ logger .debug (f"in _onAdminReceive() asDict:{ asDict } " )
237239 if "decoded" in asDict and "from" in asDict and "admin" in asDict ["decoded" ]:
238240 adminMessage = asDict ["decoded" ]["admin" ]["raw" ]
239241 iface ._getOrCreateByNum (asDict ["from" ])["adminSessionPassKey" ] = adminMessage .session_passkey
0 commit comments