mirror of
https://github.com/meshtastic/python.git
synced 2026-04-20 14:58:54 -04:00
1.2.16
This commit is contained in:
@@ -51,7 +51,7 @@ sendingInterface = None
|
||||
def onReceive(packet, interface):
|
||||
"""Callback invoked when a packet arrives"""
|
||||
if sendingInterface == interface:
|
||||
pass
|
||||
pass
|
||||
# print("Ignoring sending interface")
|
||||
else:
|
||||
# print(f"From {interface.stream.port}: {packet}")
|
||||
@@ -93,7 +93,8 @@ def testSend(fromInterface, toInterface, isBroadcast=False, asBinary=False, want
|
||||
else:
|
||||
toNode = toInterface.myInfo.my_node_num
|
||||
|
||||
logging.debug(f"Sending test wantAck={wantAck} packet from {fromNode} to {toNode}")
|
||||
logging.debug(
|
||||
f"Sending test wantAck={wantAck} packet from {fromNode} to {toNode}")
|
||||
global sendingInterface
|
||||
sendingInterface = fromInterface
|
||||
if not asBinary:
|
||||
@@ -128,7 +129,7 @@ def runTests(numTests=50, wantAck=False, maxFailures=0):
|
||||
logging.info(
|
||||
f"Test succeeded {numSuccess} successes {numFail} failures so far")
|
||||
|
||||
#if numFail >= 3:
|
||||
# if numFail >= 3:
|
||||
# for i in interfaces:
|
||||
# i.close()
|
||||
# return
|
||||
@@ -140,10 +141,12 @@ def runTests(numTests=50, wantAck=False, maxFailures=0):
|
||||
|
||||
return numFail
|
||||
|
||||
|
||||
def testThread(numTests=50):
|
||||
logging.info("Found devices, starting tests...")
|
||||
runTests(numTests, wantAck=True)
|
||||
runTests(numTests, wantAck=False, maxFailures=5) # Allow a few dropped packets
|
||||
# Allow a few dropped packets
|
||||
runTests(numTests, wantAck=False, maxFailures=5)
|
||||
|
||||
|
||||
def onConnection(topic=pub.AUTO_TOPIC):
|
||||
@@ -180,6 +183,7 @@ def testAll():
|
||||
for i in interfaces:
|
||||
i.close()
|
||||
|
||||
|
||||
def testSimulator():
|
||||
"""
|
||||
Assume that someone has launched meshtastic-native as a simulated node.
|
||||
@@ -254,7 +258,7 @@ def testSimulator():
|
||||
<pre><code class="python">def onReceive(packet, interface):
|
||||
"""Callback invoked when a packet arrives"""
|
||||
if sendingInterface == interface:
|
||||
pass
|
||||
pass
|
||||
# print("Ignoring sending interface")
|
||||
else:
|
||||
# print(f"From {interface.stream.port}: {packet}")
|
||||
@@ -309,7 +313,7 @@ def testSimulator():
|
||||
logging.info(
|
||||
f"Test succeeded {numSuccess} successes {numFail} failures so far")
|
||||
|
||||
#if numFail >= 3:
|
||||
# if numFail >= 3:
|
||||
# for i in interfaces:
|
||||
# i.close()
|
||||
# return
|
||||
@@ -409,7 +413,8 @@ toInterface {[type]} – [description]</p>
|
||||
else:
|
||||
toNode = toInterface.myInfo.my_node_num
|
||||
|
||||
logging.debug(f"Sending test wantAck={wantAck} packet from {fromNode} to {toNode}")
|
||||
logging.debug(
|
||||
f"Sending test wantAck={wantAck} packet from {fromNode} to {toNode}")
|
||||
global sendingInterface
|
||||
sendingInterface = fromInterface
|
||||
if not asBinary:
|
||||
@@ -469,7 +474,8 @@ python3 -c 'from meshtastic.test import testSimulator; testSimulator()'</p></div
|
||||
<pre><code class="python">def testThread(numTests=50):
|
||||
logging.info("Found devices, starting tests...")
|
||||
runTests(numTests, wantAck=True)
|
||||
runTests(numTests, wantAck=False, maxFailures=5) # Allow a few dropped packets</code></pre>
|
||||
# Allow a few dropped packets
|
||||
runTests(numTests, wantAck=False, maxFailures=5)</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
Reference in New Issue
Block a user