mirror of
https://github.com/meshtastic/python.git
synced 2026-01-01 12:27:59 -05:00
0.7.5
This commit is contained in:
@@ -302,6 +302,19 @@ class MeshInterface:
|
||||
logging.error("Node not found for fromId")
|
||||
return None
|
||||
|
||||
def _getOrCreateByNum(self, nodeNum):
|
||||
"""Given a nodenum find the NodeInfo in the DB (or create if necessary)"""
|
||||
if nodeNum == BROADCAST_NUM:
|
||||
raise Exception("Can not create/find nodenum by the broadcast num")
|
||||
|
||||
if nodeNum in self._nodesByNum:
|
||||
return self._nodesByNum[nodeNum]
|
||||
else:
|
||||
n = { num: n } # Create a minimial node db entry
|
||||
self._nodesByNum[nodeNum] = n
|
||||
return n
|
||||
|
||||
|
||||
def _handlePacketFromRadio(self, meshPacket):
|
||||
"""Handle a MeshPacket that just arrived from the radio
|
||||
|
||||
@@ -324,13 +337,16 @@ class MeshInterface:
|
||||
p = asDict["decoded"]["position"]
|
||||
self._fixupPosition(p)
|
||||
# update node DB as needed
|
||||
self._nodesByNum[asDict["from"]]["position"] = p
|
||||
self._getOrCreateByNum(asDict["from"])["position"] = p
|
||||
|
||||
if meshPacket.decoded.HasField("user"):
|
||||
topic = "meshtastic.receive.user"
|
||||
u = asDict["decoded"]["user"]
|
||||
# update node DB as needed
|
||||
self._nodesByNum[asDict["from"]]["user"] = u
|
||||
n = self._getOrCreateByNum(asDict["from"])
|
||||
n["user"] = u
|
||||
# We now have a node ID, make sure it is uptodate in that table
|
||||
self.nodes[u["id"]] = u
|
||||
|
||||
if meshPacket.decoded.HasField("data"):
|
||||
topic = "meshtastic.receive.data"
|
||||
@@ -783,6 +799,19 @@ debugOut</p>
|
||||
logging.error("Node not found for fromId")
|
||||
return None
|
||||
|
||||
def _getOrCreateByNum(self, nodeNum):
|
||||
"""Given a nodenum find the NodeInfo in the DB (or create if necessary)"""
|
||||
if nodeNum == BROADCAST_NUM:
|
||||
raise Exception("Can not create/find nodenum by the broadcast num")
|
||||
|
||||
if nodeNum in self._nodesByNum:
|
||||
return self._nodesByNum[nodeNum]
|
||||
else:
|
||||
n = { num: n } # Create a minimial node db entry
|
||||
self._nodesByNum[nodeNum] = n
|
||||
return n
|
||||
|
||||
|
||||
def _handlePacketFromRadio(self, meshPacket):
|
||||
"""Handle a MeshPacket that just arrived from the radio
|
||||
|
||||
@@ -805,13 +834,16 @@ debugOut</p>
|
||||
p = asDict["decoded"]["position"]
|
||||
self._fixupPosition(p)
|
||||
# update node DB as needed
|
||||
self._nodesByNum[asDict["from"]]["position"] = p
|
||||
self._getOrCreateByNum(asDict["from"])["position"] = p
|
||||
|
||||
if meshPacket.decoded.HasField("user"):
|
||||
topic = "meshtastic.receive.user"
|
||||
u = asDict["decoded"]["user"]
|
||||
# update node DB as needed
|
||||
self._nodesByNum[asDict["from"]]["user"] = u
|
||||
n = self._getOrCreateByNum(asDict["from"])
|
||||
n["user"] = u
|
||||
# We now have a node ID, make sure it is uptodate in that table
|
||||
self.nodes[u["id"]] = u
|
||||
|
||||
if meshPacket.decoded.HasField("data"):
|
||||
topic = "meshtastic.receive.data"
|
||||
|
||||
2
setup.py
2
setup.py
@@ -10,7 +10,7 @@ with open("README.md", "r") as fh:
|
||||
# This call to setup() does all the work
|
||||
setup(
|
||||
name="meshtastic",
|
||||
version="0.7.3",
|
||||
version="0.7.5",
|
||||
description="Python API & client shell for talking to Meshtastic devices",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
|
||||
Reference in New Issue
Block a user