cope with nodes that don't have positions

This commit is contained in:
geeksville
2020-05-21 21:15:19 -07:00
parent d76761c8f0
commit f73dea44b6
2 changed files with 14 additions and 9 deletions

View File

@@ -174,7 +174,10 @@ class MeshInterface:
self.radioConfig = fromRadio.radio
elif fromRadio.HasField("node_info"):
node = asDict["nodeInfo"]
self._fixupPosition(node["position"])
try:
self._fixupPosition(node["position"])
except:
logging.debug("Node without position")
self._nodesByNum[node["num"]] = node
self.nodes[node["user"]["id"]] = node
elif fromRadio.config_complete_id == MY_CONFIG_ID:

View File

@@ -39,7 +39,7 @@ def subscribe():
pub.subscribe(onNode, "meshtastic.node")
def testSend(fromInterface, toInterface):
def testSend(fromInterface, toInterface, isBroadcast=False):
"""
Sends one test packet between two nodes and then returns success or failure
@@ -53,25 +53,27 @@ def testSend(fromInterface, toInterface):
global receivedPackets
receivedPackets = []
fromNode = fromInterface.myInfo.my_node_num
toNode = toInterface.myInfo.my_node_num
# FIXME, hack to test broadcast
# toNode = 255
if isBroadcast:
toNode = 255
else:
toNode = toInterface.myInfo.my_node_num
logging.info(f"Sending test packet from {fromNode} to {toNode}")
fromInterface.sendText(f"Test {testNumber}", toNode, wantAck=True)
time.sleep(30)
time.sleep(45)
return (len(receivedPackets) >= 1)
def testThread():
def testThread(numTests=50):
logging.info("Found devices, starting tests...")
numFail = 0
numSuccess = 0
while True:
for i in range(numTests):
global testNumber
testNumber = testNumber + 1
success = testSend(interfaces[0], interfaces[1])
isBroadcast = True
success = testSend(interfaces[0], interfaces[1], isBroadcast)
if not success:
numFail = numFail + 1
logging.error(