doc updates

This commit is contained in:
geeksville
2020-05-22 11:04:31 -07:00
parent 94175874f0
commit bf085ab1d4
3 changed files with 49 additions and 33 deletions

View File

@@ -158,7 +158,7 @@ class MeshInterface:
self.isConnected = False
self._startConfig()
def sendText(self, text, destinationId=BROADCAST_ADDR, wantAck=False):
def sendText(self, text, destinationId=BROADCAST_ADDR, wantAck=False, wantResponse=False):
"""Send a utf8 string to some other node, if the node has a display it will also be shown on the device.
Arguments:
@@ -168,13 +168,14 @@ class MeshInterface:
destinationId {nodeId or nodeNum} -- where to send this message (default: {BROADCAST_ADDR})
"""
self.sendData(text.encode("utf-8"), destinationId,
dataType=mesh_pb2.Data.CLEAR_TEXT, wantAck=wantAck)
dataType=mesh_pb2.Data.CLEAR_TEXT, wantAck=wantAck, wantResponse=wantResponse)
def sendData(self, byteData, destinationId=BROADCAST_ADDR, dataType=mesh_pb2.Data.OPAQUE, wantAck=False):
def sendData(self, byteData, destinationId=BROADCAST_ADDR, dataType=mesh_pb2.Data.OPAQUE, wantAck=False, wantResponse=False):
"""Send a data packet to some other node"""
meshPacket = mesh_pb2.MeshPacket()
meshPacket.decoded.data.payload = byteData
meshPacket.decoded.data.typ = dataType
meshPacket.decoded.want_response = wantResponse
self.sendPacket(meshPacket, destinationId, wantAck=wantAck)
def sendPacket(self, meshPacket, destinationId=BROADCAST_ADDR, wantAck=False):
@@ -245,7 +246,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:
@@ -616,7 +620,7 @@ debugOut</p>
self.isConnected = False
self._startConfig()
def sendText(self, text, destinationId=BROADCAST_ADDR, wantAck=False):
def sendText(self, text, destinationId=BROADCAST_ADDR, wantAck=False, wantResponse=False):
&#34;&#34;&#34;Send a utf8 string to some other node, if the node has a display it will also be shown on the device.
Arguments:
@@ -626,13 +630,14 @@ debugOut</p>
destinationId {nodeId or nodeNum} -- where to send this message (default: {BROADCAST_ADDR})
&#34;&#34;&#34;
self.sendData(text.encode(&#34;utf-8&#34;), destinationId,
dataType=mesh_pb2.Data.CLEAR_TEXT, wantAck=wantAck)
dataType=mesh_pb2.Data.CLEAR_TEXT, wantAck=wantAck, wantResponse=wantResponse)
def sendData(self, byteData, destinationId=BROADCAST_ADDR, dataType=mesh_pb2.Data.OPAQUE, wantAck=False):
def sendData(self, byteData, destinationId=BROADCAST_ADDR, dataType=mesh_pb2.Data.OPAQUE, wantAck=False, wantResponse=False):
&#34;&#34;&#34;Send a data packet to some other node&#34;&#34;&#34;
meshPacket = mesh_pb2.MeshPacket()
meshPacket.decoded.data.payload = byteData
meshPacket.decoded.data.typ = dataType
meshPacket.decoded.want_response = wantResponse
self.sendPacket(meshPacket, destinationId, wantAck=wantAck)
def sendPacket(self, meshPacket, destinationId=BROADCAST_ADDR, wantAck=False):
@@ -703,7 +708,10 @@ debugOut</p>
self.radioConfig = fromRadio.radio
elif fromRadio.HasField(&#34;node_info&#34;):
node = asDict[&#34;nodeInfo&#34;]
self._fixupPosition(node[&#34;position&#34;])
try:
self._fixupPosition(node[&#34;position&#34;])
except:
logging.debug(&#34;Node without position&#34;)
self._nodesByNum[node[&#34;num&#34;]] = node
self.nodes[node[&#34;user&#34;][&#34;id&#34;]] = node
elif fromRadio.config_complete_id == MY_CONFIG_ID:
@@ -793,7 +801,7 @@ debugOut</p>
<h3>Methods</h3>
<dl>
<dt id="meshtastic.MeshInterface.sendData"><code class="name flex">
<span>def <span class="ident">sendData</span></span>(<span>self, byteData, destinationId='all', dataType=0, wantAck=False)</span>
<span>def <span class="ident">sendData</span></span>(<span>self, byteData, destinationId='all', dataType=0, wantAck=False, wantResponse=False)</span>
</code></dt>
<dd>
<div class="desc"><p>Send a data packet to some other node</p></div>
@@ -801,11 +809,12 @@ debugOut</p>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def sendData(self, byteData, destinationId=BROADCAST_ADDR, dataType=mesh_pb2.Data.OPAQUE, wantAck=False):
<pre><code class="python">def sendData(self, byteData, destinationId=BROADCAST_ADDR, dataType=mesh_pb2.Data.OPAQUE, wantAck=False, wantResponse=False):
&#34;&#34;&#34;Send a data packet to some other node&#34;&#34;&#34;
meshPacket = mesh_pb2.MeshPacket()
meshPacket.decoded.data.payload = byteData
meshPacket.decoded.data.typ = dataType
meshPacket.decoded.want_response = wantResponse
self.sendPacket(meshPacket, destinationId, wantAck=wantAck)</code></pre>
</details>
</dd>
@@ -839,7 +848,7 @@ You probably don't want this - use sendData instead.</p></div>
</details>
</dd>
<dt id="meshtastic.MeshInterface.sendText"><code class="name flex">
<span>def <span class="ident">sendText</span></span>(<span>self, text, destinationId='all', wantAck=False)</span>
<span>def <span class="ident">sendText</span></span>(<span>self, text, destinationId='all', wantAck=False, wantResponse=False)</span>
</code></dt>
<dd>
<div class="desc"><p>Send a utf8 string to some other node, if the node has a display it will also be shown on the device.</p>
@@ -851,7 +860,7 @@ destinationId {nodeId or nodeNum} &ndash; where to send this message (default: {
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def sendText(self, text, destinationId=BROADCAST_ADDR, wantAck=False):
<pre><code class="python">def sendText(self, text, destinationId=BROADCAST_ADDR, wantAck=False, wantResponse=False):
&#34;&#34;&#34;Send a utf8 string to some other node, if the node has a display it will also be shown on the device.
Arguments:
@@ -861,7 +870,7 @@ destinationId {nodeId or nodeNum} &ndash; where to send this message (default: {
destinationId {nodeId or nodeNum} -- where to send this message (default: {BROADCAST_ADDR})
&#34;&#34;&#34;
self.sendData(text.encode(&#34;utf-8&#34;), destinationId,
dataType=mesh_pb2.Data.CLEAR_TEXT, wantAck=wantAck)</code></pre>
dataType=mesh_pb2.Data.CLEAR_TEXT, wantAck=wantAck, wantResponse=wantResponse)</code></pre>
</details>
</dd>
<dt id="meshtastic.MeshInterface.writeConfig"><code class="name flex">

View File

@@ -65,7 +65,7 @@ def subscribe():
pub.subscribe(onNode, &#34;meshtastic.node&#34;)
def testSend(fromInterface, toInterface):
def testSend(fromInterface, toInterface, isBroadcast=False):
&#34;&#34;&#34;
Sends one test packet between two nodes and then returns success or failure
@@ -79,25 +79,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&#34;Sending test packet from {fromNode} to {toNode}&#34;)
fromInterface.sendText(f&#34;Test {testNumber}&#34;, toNode, wantAck=True)
time.sleep(30)
time.sleep(45)
return (len(receivedPackets) &gt;= 1)
def testThread():
def testThread(numTests=50):
logging.info(&#34;Found devices, starting tests...&#34;)
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(
@@ -281,7 +283,7 @@ def testAll():
</details>
</dd>
<dt id="meshtastic.test.testSend"><code class="name flex">
<span>def <span class="ident">testSend</span></span>(<span>fromInterface, toInterface)</span>
<span>def <span class="ident">testSend</span></span>(<span>fromInterface, toInterface, isBroadcast=False)</span>
</code></dt>
<dd>
<div class="desc"><p>Sends one test packet between two nodes and then returns success or failure</p>
@@ -297,7 +299,7 @@ toInterface {[type]} &ndash; [description]</p>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def testSend(fromInterface, toInterface):
<pre><code class="python">def testSend(fromInterface, toInterface, isBroadcast=False):
&#34;&#34;&#34;
Sends one test packet between two nodes and then returns success or failure
@@ -311,19 +313,20 @@ toInterface {[type]} &ndash; [description]</p>
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&#34;Sending test packet from {fromNode} to {toNode}&#34;)
fromInterface.sendText(f&#34;Test {testNumber}&#34;, toNode, wantAck=True)
time.sleep(30)
time.sleep(45)
return (len(receivedPackets) &gt;= 1)</code></pre>
</details>
</dd>
<dt id="meshtastic.test.testThread"><code class="name flex">
<span>def <span class="ident">testThread</span></span>(<span>)</span>
<span>def <span class="ident">testThread</span></span>(<span>numTests=50)</span>
</code></dt>
<dd>
<div class="desc"></div>
@@ -331,14 +334,15 @@ toInterface {[type]} &ndash; [description]</p>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def testThread():
<pre><code class="python">def testThread(numTests=50):
logging.info(&#34;Found devices, starting tests...&#34;)
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(

View File

@@ -28,6 +28,9 @@
import serial
import serial.tools.list_ports
&#34;&#34;&#34;Some devices such as a seger jlink we never want to accidentally open&#34;&#34;&#34;
blacklistVids = dict.fromkeys([0x1366])
def findPorts():
&#34;&#34;&#34;Find all ports that might have meshtastic devices
@@ -36,7 +39,7 @@ def findPorts():
list -- a list of device paths
&#34;&#34;&#34;
l = list(map(lambda port: port.device,
filter(lambda port: port.vid != None,
filter(lambda port: port.vid != None and port.vid not in blacklistVids,
serial.tools.list_ports.comports())))
l.sort()
return l
@@ -77,7 +80,7 @@ class dotdict(dict):
list -- a list of device paths
&#34;&#34;&#34;
l = list(map(lambda port: port.device,
filter(lambda port: port.vid != None,
filter(lambda port: port.vid != None and port.vid not in blacklistVids,
serial.tools.list_ports.comports())))
l.sort()
return l</code></pre>