1.2.0 release to pypi

This commit is contained in:
Kevin Hester
2021-03-03 11:21:37 +08:00
parent 3b8136d769
commit 171c79b414
11 changed files with 2848 additions and 1803 deletions

View File

@@ -47,6 +47,7 @@ testNumber = 0
sendingInterface = None
def onReceive(packet, interface):
"""Callback invoked when a packet arrives"""
if sendingInterface == interface:
@@ -55,10 +56,11 @@ def onReceive(packet, interface):
print(f"From {interface.stream.port}: {packet}")
p = DotMap(packet)
if p.decoded.data.portnum == "TEXT_MESSAGE_APP":
if p.decoded.portnum == "TEXT_MESSAGE_APP":
# We only care a about clear text packets
receivedPackets.append(p)
def onNode(node):
"""Callback invoked when the node DB changes"""
print(f"Node changed: {node}")
@@ -91,7 +93,7 @@ def testSend(fromInterface, toInterface, isBroadcast=False, asBinary=False):
toNode = toInterface.myInfo.my_node_num
logging.info(f"Sending test packet from {fromNode} to {toNode}")
wantAck = False # Don't want any sort of reliaible sending
wantAck = False # Don't want any sort of reliaible sending
global sendingInterface
sendingInterface = fromInterface
if not asBinary:
@@ -99,11 +101,11 @@ def testSend(fromInterface, toInterface, isBroadcast=False, asBinary=False):
else:
fromInterface.sendData((f"Binary {testNumber}").encode(
"utf-8"), toNode, wantAck=wantAck)
for sec in range(45): # max of 45 secs before we timeout
for sec in range(45): # max of 45 secs before we timeout
time.sleep(1)
if (len(receivedPackets) >= 1):
return True
return False # Failed to send
return False # Failed to send
def testThread(numTests=50):
@@ -116,14 +118,15 @@ def testThread(numTests=50):
isBroadcast = True
# asBinary=(i % 2 == 0)
success = testSend(
interfaces[0], interfaces[1], isBroadcast, asBinary = False)
interfaces[0], interfaces[1], isBroadcast, asBinary=False)
if not success:
numFail = numFail + 1
logging.error(
f"Test failed, expected packet not received ({numFail} failures so far)")
else:
numSuccess = numSuccess + 1
logging.info(f"Test succeeded ({numSuccess} successes ({numFail} failures) so far)")
logging.info(
f"Test succeeded ({numSuccess} successes ({numFail} failures) so far)")
if numFail >= 3:
for i in interfaces:
@@ -137,11 +140,13 @@ def onConnection(topic=pub.AUTO_TOPIC):
"""Callback invoked when we connect/disconnect from a radio"""
print(f"Connection changed: {topic.getName()}")
def openDebugLog(portName):
debugname = "log" + portName.replace("/", "_")
logging.info(f"Writing serial debugging to {debugname}")
return open(debugname, 'w+', buffering=1)
def testAll():
"""
Run a series of tests using devices we can find.
@@ -163,8 +168,7 @@ def testAll():
testThread()
for i in interfaces:
i.close()
</code></pre>
i.close()</code></pre>
</details>
</section>
<section>
@@ -226,7 +230,7 @@ def testAll():
print(f&#34;From {interface.stream.port}: {packet}&#34;)
p = DotMap(packet)
if p.decoded.data.portnum == &#34;TEXT_MESSAGE_APP&#34;:
if p.decoded.portnum == &#34;TEXT_MESSAGE_APP&#34;:
# We only care a about clear text packets
receivedPackets.append(p)</code></pre>
</details>
@@ -334,7 +338,7 @@ toInterface {[type]} &ndash; [description]</p>
toNode = toInterface.myInfo.my_node_num
logging.info(f&#34;Sending test packet from {fromNode} to {toNode}&#34;)
wantAck = False # Don&#39;t want any sort of reliaible sending
wantAck = False # Don&#39;t want any sort of reliaible sending
global sendingInterface
sendingInterface = fromInterface
if not asBinary:
@@ -342,11 +346,11 @@ toInterface {[type]} &ndash; [description]</p>
else:
fromInterface.sendData((f&#34;Binary {testNumber}&#34;).encode(
&#34;utf-8&#34;), toNode, wantAck=wantAck)
for sec in range(45): # max of 45 secs before we timeout
for sec in range(45): # max of 45 secs before we timeout
time.sleep(1)
if (len(receivedPackets) &gt;= 1):
return True
return False # Failed to send</code></pre>
return False # Failed to send</code></pre>
</details>
</dd>
<dt id="meshtastic.test.testThread"><code class="name flex">
@@ -368,14 +372,15 @@ toInterface {[type]} &ndash; [description]</p>
isBroadcast = True
# asBinary=(i % 2 == 0)
success = testSend(
interfaces[0], interfaces[1], isBroadcast, asBinary = False)
interfaces[0], interfaces[1], isBroadcast, asBinary=False)
if not success:
numFail = numFail + 1
logging.error(
f&#34;Test failed, expected packet not received ({numFail} failures so far)&#34;)
else:
numSuccess = numSuccess + 1
logging.info(f&#34;Test succeeded ({numSuccess} successes ({numFail} failures) so far)&#34;)
logging.info(
f&#34;Test succeeded ({numSuccess} successes ({numFail} failures) so far)&#34;)
if numFail &gt;= 3:
for i in interfaces: