mirror of
https://github.com/meshtastic/python.git
synced 2026-03-03 14:26:43 -05:00
regen doc with overriding the pdoc _is_public()
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
|
||||
<meta name="generator" content="pdoc 0.10.0" />
|
||||
<meta name="generator" content="pdoc 0.10.1.dev1+g4aa70de.d20211229" />
|
||||
<title>meshtastic.mesh_interface API documentation</title>
|
||||
<meta name="description" content="Mesh Interface class" />
|
||||
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
|
||||
@@ -1395,6 +1395,555 @@ link - just be a dumb serial client.</p></div>
|
||||
</ul>
|
||||
<h3>Methods</h3>
|
||||
<dl>
|
||||
<dt id="meshtastic.mesh_interface.MeshInterface._addResponseHandler"><code class="name flex">
|
||||
<span>def <span class="ident">_addResponseHandler</span></span>(<span>self, requestId, callback)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def _addResponseHandler(self, requestId, callback):
|
||||
self.responseHandlers[requestId] = ResponseHandler(callback)</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="meshtastic.mesh_interface.MeshInterface._connected"><code class="name flex">
|
||||
<span>def <span class="ident">_connected</span></span>(<span>self)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Called by this class to tell clients we are now fully connected to a node</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def _connected(self):
|
||||
"""Called by this class to tell clients we are now fully connected to a node
|
||||
"""
|
||||
# (because I'm lazy) _connected might be called when remote Node
|
||||
# objects complete their config reads, don't generate redundant isConnected
|
||||
# for the local interface
|
||||
if not self.isConnected.is_set():
|
||||
self.isConnected.set()
|
||||
self._startHeartbeat()
|
||||
publishingThread.queueWork(lambda: pub.sendMessage(
|
||||
"meshtastic.connection.established", interface=self))</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="meshtastic.mesh_interface.MeshInterface._disconnected"><code class="name flex">
|
||||
<span>def <span class="ident">_disconnected</span></span>(<span>self)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Called by subclasses to tell clients this interface has disconnected</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def _disconnected(self):
|
||||
"""Called by subclasses to tell clients this interface has disconnected"""
|
||||
self.isConnected.clear()
|
||||
publishingThread.queueWork(lambda: pub.sendMessage(
|
||||
"meshtastic.connection.lost", interface=self))</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="meshtastic.mesh_interface.MeshInterface._fixupPosition"><code class="name flex">
|
||||
<span>def <span class="ident">_fixupPosition</span></span>(<span>self, position)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Convert integer lat/lon into floats</p>
|
||||
<h2 id="arguments">Arguments</h2>
|
||||
<p>position {Position dictionary} – object ot fix up</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def _fixupPosition(self, position):
|
||||
"""Convert integer lat/lon into floats
|
||||
|
||||
Arguments:
|
||||
position {Position dictionary} -- object ot fix up
|
||||
"""
|
||||
if "latitudeI" in position:
|
||||
position["latitude"] = position["latitudeI"] * 1e-7
|
||||
if "longitudeI" in position:
|
||||
position["longitude"] = position["longitudeI"] * 1e-7</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="meshtastic.mesh_interface.MeshInterface._generatePacketId"><code class="name flex">
|
||||
<span>def <span class="ident">_generatePacketId</span></span>(<span>self)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Get a new unique packet ID</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def _generatePacketId(self):
|
||||
"""Get a new unique packet ID"""
|
||||
if self.currentPacketId is None:
|
||||
raise Exception("Not connected yet, can not generate packet")
|
||||
else:
|
||||
self.currentPacketId = (self.currentPacketId + 1) & 0xffffffff
|
||||
return self.currentPacketId</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="meshtastic.mesh_interface.MeshInterface._getOrCreateByNum"><code class="name flex">
|
||||
<span>def <span class="ident">_getOrCreateByNum</span></span>(<span>self, nodeNum)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Given a nodenum find the NodeInfo in the DB (or create if necessary)</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">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": nodeNum} # Create a minimial node db entry
|
||||
self.nodesByNum[nodeNum] = n
|
||||
return n</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="meshtastic.mesh_interface.MeshInterface._handleConfigComplete"><code class="name flex">
|
||||
<span>def <span class="ident">_handleConfigComplete</span></span>(<span>self)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Done with initial config messages, now send regular MeshPackets
|
||||
to ask for settings and channels</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def _handleConfigComplete(self):
|
||||
"""
|
||||
Done with initial config messages, now send regular MeshPackets
|
||||
to ask for settings and channels
|
||||
"""
|
||||
self.localNode.requestConfig()</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="meshtastic.mesh_interface.MeshInterface._handleFromRadio"><code class="name flex">
|
||||
<span>def <span class="ident">_handleFromRadio</span></span>(<span>self, fromRadioBytes)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Handle a packet that arrived from the radio(update model and publish events)</p>
|
||||
<p>Called by subclasses.</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def _handleFromRadio(self, fromRadioBytes):
|
||||
"""
|
||||
Handle a packet that arrived from the radio(update model and publish events)
|
||||
|
||||
Called by subclasses."""
|
||||
fromRadio = mesh_pb2.FromRadio()
|
||||
fromRadio.ParseFromString(fromRadioBytes)
|
||||
logging.debug(f"in mesh_interface.py _handleFromRadio() fromRadioBytes: {fromRadioBytes}")
|
||||
asDict = google.protobuf.json_format.MessageToDict(fromRadio)
|
||||
logging.debug(f"Received from radio: {fromRadio}")
|
||||
if fromRadio.HasField("my_info"):
|
||||
self.myInfo = fromRadio.my_info
|
||||
self.localNode.nodeNum = self.myInfo.my_node_num
|
||||
logging.debug(f"Received myinfo: {stripnl(fromRadio.my_info)}")
|
||||
|
||||
failmsg = None
|
||||
# Check for app too old
|
||||
if self.myInfo.min_app_version > OUR_APP_VERSION:
|
||||
failmsg = "This device needs a newer python client, run 'pip install --upgrade meshtastic'."\
|
||||
"For more information see https://tinyurl.com/5bjsxu32"
|
||||
|
||||
# check for firmware too old
|
||||
if self.myInfo.max_channels == 0:
|
||||
failmsg = "This version of meshtastic-python requires device firmware version 1.2 or later. "\
|
||||
"For more information see https://tinyurl.com/5bjsxu32"
|
||||
|
||||
if failmsg:
|
||||
self.failure = Exception(failmsg)
|
||||
self.isConnected.set() # let waitConnected return this exception
|
||||
self.close()
|
||||
|
||||
elif fromRadio.HasField("node_info"):
|
||||
node = asDict["nodeInfo"]
|
||||
try:
|
||||
self._fixupPosition(node["position"])
|
||||
except:
|
||||
logging.debug("Node without position")
|
||||
|
||||
logging.debug(f"Received nodeinfo: {node}")
|
||||
|
||||
self.nodesByNum[node["num"]] = node
|
||||
if "user" in node: # Some nodes might not have user/ids assigned yet
|
||||
if "id" in node["user"]:
|
||||
self.nodes[node["user"]["id"]] = node
|
||||
publishingThread.queueWork(lambda: pub.sendMessage("meshtastic.node.updated",
|
||||
node=node, interface=self))
|
||||
elif fromRadio.config_complete_id == self.configId:
|
||||
# we ignore the config_complete_id, it is unneeded for our
|
||||
# stream API fromRadio.config_complete_id
|
||||
logging.debug(f"Config complete ID {self.configId}")
|
||||
self._handleConfigComplete()
|
||||
elif fromRadio.HasField("packet"):
|
||||
self._handlePacketFromRadio(fromRadio.packet)
|
||||
elif fromRadio.rebooted:
|
||||
# Tell clients the device went away. Careful not to call the overridden
|
||||
# subclass version that closes the serial port
|
||||
MeshInterface._disconnected(self)
|
||||
|
||||
self._startConfig() # redownload the node db etc...
|
||||
else:
|
||||
logging.debug("Unexpected FromRadio payload")</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="meshtastic.mesh_interface.MeshInterface._handlePacketFromRadio"><code class="name flex">
|
||||
<span>def <span class="ident">_handlePacketFromRadio</span></span>(<span>self, meshPacket, hack=False)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Handle a MeshPacket that just arrived from the radio</p>
|
||||
<p>hack - well, since we used 'from', which is a python keyword,
|
||||
as an attribute to MeshPacket in protobufs,
|
||||
there really is no way to do something like this:
|
||||
meshPacket = mesh_pb2.MeshPacket()
|
||||
meshPacket.from = 123
|
||||
If hack is True, we can unit test this code.</p>
|
||||
<p>Will publish one of the following events:
|
||||
- meshtastic.receive.text(packet = MeshPacket dictionary)
|
||||
- meshtastic.receive.position(packet = MeshPacket dictionary)
|
||||
- meshtastic.receive.user(packet = MeshPacket dictionary)
|
||||
- meshtastic.receive.data(packet = MeshPacket dictionary)</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def _handlePacketFromRadio(self, meshPacket, hack=False):
|
||||
"""Handle a MeshPacket that just arrived from the radio
|
||||
|
||||
hack - well, since we used 'from', which is a python keyword,
|
||||
as an attribute to MeshPacket in protobufs,
|
||||
there really is no way to do something like this:
|
||||
meshPacket = mesh_pb2.MeshPacket()
|
||||
meshPacket.from = 123
|
||||
If hack is True, we can unit test this code.
|
||||
|
||||
Will publish one of the following events:
|
||||
- meshtastic.receive.text(packet = MeshPacket dictionary)
|
||||
- meshtastic.receive.position(packet = MeshPacket dictionary)
|
||||
- meshtastic.receive.user(packet = MeshPacket dictionary)
|
||||
- meshtastic.receive.data(packet = MeshPacket dictionary)
|
||||
"""
|
||||
asDict = google.protobuf.json_format.MessageToDict(meshPacket)
|
||||
|
||||
# We normally decompose the payload into a dictionary so that the client
|
||||
# doesn't need to understand protobufs. But advanced clients might
|
||||
# want the raw protobuf, so we provide it in "raw"
|
||||
asDict["raw"] = meshPacket
|
||||
|
||||
# from might be missing if the nodenum was zero.
|
||||
if not hack and "from" not in asDict:
|
||||
asDict["from"] = 0
|
||||
logging.error(f"Device returned a packet we sent, ignoring: {stripnl(asDict)}")
|
||||
print(f"Error: Device returned a packet we sent, ignoring: {stripnl(asDict)}")
|
||||
return
|
||||
if "to" not in asDict:
|
||||
asDict["to"] = 0
|
||||
|
||||
# /add fromId and toId fields based on the node ID
|
||||
try:
|
||||
asDict["fromId"] = self._nodeNumToId(asDict["from"])
|
||||
except Exception as ex:
|
||||
logging.warning(f"Not populating fromId {ex}")
|
||||
try:
|
||||
asDict["toId"] = self._nodeNumToId(asDict["to"])
|
||||
except Exception as ex:
|
||||
logging.warning(f"Not populating toId {ex}")
|
||||
|
||||
# We could provide our objects as DotMaps - which work with . notation or as dictionaries
|
||||
# asObj = DotMap(asDict)
|
||||
topic = "meshtastic.receive" # Generic unknown packet type
|
||||
|
||||
decoded = asDict["decoded"]
|
||||
# The default MessageToDict converts byte arrays into base64 strings.
|
||||
# We don't want that - it messes up data payload. So slam in the correct
|
||||
# byte array.
|
||||
decoded["payload"] = meshPacket.decoded.payload
|
||||
|
||||
# UNKNOWN_APP is the default protobuf portnum value, and therefore if not
|
||||
# set it will not be populated at all to make API usage easier, set
|
||||
# it to prevent confusion
|
||||
if "portnum" not in decoded:
|
||||
new_portnum = portnums_pb2.PortNum.Name(portnums_pb2.PortNum.UNKNOWN_APP)
|
||||
decoded["portnum"] = new_portnum
|
||||
logging.warning(f"portnum was not in decoded. Setting to:{new_portnum}")
|
||||
|
||||
portnum = decoded["portnum"]
|
||||
|
||||
topic = f"meshtastic.receive.data.{portnum}"
|
||||
|
||||
# decode position protobufs and update nodedb, provide decoded version
|
||||
# as "position" in the published msg move the following into a 'decoders'
|
||||
# API that clients could register?
|
||||
portNumInt = meshPacket.decoded.portnum # we want portnum as an int
|
||||
handler = protocols.get(portNumInt)
|
||||
# The decoded protobuf as a dictionary (if we understand this message)
|
||||
p = None
|
||||
if handler is not None:
|
||||
topic = f"meshtastic.receive.{handler.name}"
|
||||
|
||||
# Convert to protobuf if possible
|
||||
if handler.protobufFactory is not None:
|
||||
pb = handler.protobufFactory()
|
||||
pb.ParseFromString(meshPacket.decoded.payload)
|
||||
p = google.protobuf.json_format.MessageToDict(pb)
|
||||
asDict["decoded"][handler.name] = p
|
||||
# Also provide the protobuf raw
|
||||
asDict["decoded"][handler.name]["raw"] = pb
|
||||
|
||||
# Call specialized onReceive if necessary
|
||||
if handler.onReceive is not None:
|
||||
handler.onReceive(self, asDict)
|
||||
|
||||
# Is this message in response to a request, if so, look for a handler
|
||||
requestId = decoded.get("requestId")
|
||||
if requestId is not None:
|
||||
# We ignore ACK packets, but send NAKs and data responses to the handlers
|
||||
routing = decoded.get("routing")
|
||||
isAck = routing is not None and ("errorReason" not in routing)
|
||||
if not isAck:
|
||||
# we keep the responseHandler in dict until we get a non ack
|
||||
handler = self.responseHandlers.pop(requestId, None)
|
||||
if handler is not None:
|
||||
handler.callback(asDict)
|
||||
|
||||
logging.debug(f"Publishing {topic}: packet={stripnl(asDict)} ")
|
||||
publishingThread.queueWork(lambda: pub.sendMessage(
|
||||
topic, packet=asDict, interface=self))</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="meshtastic.mesh_interface.MeshInterface._nodeNumToId"><code class="name flex">
|
||||
<span>def <span class="ident">_nodeNumToId</span></span>(<span>self, num)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Map a node node number to a node ID</p>
|
||||
<h2 id="arguments">Arguments</h2>
|
||||
<p>num {int} – Node number</p>
|
||||
<h2 id="returns">Returns</h2>
|
||||
<p>string – Node ID</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def _nodeNumToId(self, num):
|
||||
"""Map a node node number to a node ID
|
||||
|
||||
Arguments:
|
||||
num {int} -- Node number
|
||||
|
||||
Returns:
|
||||
string -- Node ID
|
||||
"""
|
||||
if num == BROADCAST_NUM:
|
||||
return BROADCAST_ADDR
|
||||
|
||||
try:
|
||||
return self.nodesByNum[num]["user"]["id"]
|
||||
except:
|
||||
logging.debug(f"Node {num} not found for fromId")
|
||||
return None</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="meshtastic.mesh_interface.MeshInterface._sendDisconnect"><code class="name flex">
|
||||
<span>def <span class="ident">_sendDisconnect</span></span>(<span>self)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Tell device we are done using it</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def _sendDisconnect(self):
|
||||
"""Tell device we are done using it"""
|
||||
m = mesh_pb2.ToRadio()
|
||||
m.disconnect = True
|
||||
self._sendToRadio(m)</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="meshtastic.mesh_interface.MeshInterface._sendPacket"><code class="name flex">
|
||||
<span>def <span class="ident">_sendPacket</span></span>(<span>self, meshPacket, destinationId='^all', wantAck=False, hopLimit=None)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Send a MeshPacket to the specified node (or if unspecified, broadcast).
|
||||
You probably don't want this - use sendData instead.</p>
|
||||
<p>Returns the sent packet. The id field will be populated in this packet and
|
||||
can be used to track future message acks/naks.</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def _sendPacket(self, meshPacket,
|
||||
destinationId=BROADCAST_ADDR,
|
||||
wantAck=False, hopLimit=None):
|
||||
"""Send a MeshPacket to the specified node (or if unspecified, broadcast).
|
||||
You probably don't want this - use sendData instead.
|
||||
|
||||
Returns the sent packet. The id field will be populated in this packet and
|
||||
can be used to track future message acks/naks.
|
||||
"""
|
||||
if hopLimit is None:
|
||||
hopLimit = self.defaultHopLimit
|
||||
|
||||
# We allow users to talk to the local node before we've completed the full connection flow...
|
||||
if(self.myInfo is not None and destinationId != self.myInfo.my_node_num):
|
||||
self._waitConnected()
|
||||
|
||||
toRadio = mesh_pb2.ToRadio()
|
||||
|
||||
nodeNum = 0
|
||||
if destinationId is None:
|
||||
our_exit("Warning: destinationId must not be None")
|
||||
elif isinstance(destinationId, int):
|
||||
nodeNum = destinationId
|
||||
elif destinationId == BROADCAST_ADDR:
|
||||
nodeNum = BROADCAST_NUM
|
||||
elif destinationId == LOCAL_ADDR:
|
||||
if self.myInfo:
|
||||
nodeNum = self.myInfo.my_node_num
|
||||
else:
|
||||
our_exit("Warning: No myInfo found.")
|
||||
# A simple hex style nodeid - we can parse this without needing the DB
|
||||
elif destinationId.startswith("!"):
|
||||
nodeNum = int(destinationId[1:], 16)
|
||||
else:
|
||||
if self.nodes:
|
||||
node = self.nodes.get(destinationId)
|
||||
if not node:
|
||||
our_exit(f"Warning: NodeId {destinationId} not found in DB")
|
||||
nodeNum = node['num']
|
||||
else:
|
||||
logging.warning("Warning: There were no self.nodes.")
|
||||
|
||||
meshPacket.to = nodeNum
|
||||
meshPacket.want_ack = wantAck
|
||||
meshPacket.hop_limit = hopLimit
|
||||
|
||||
# if the user hasn't set an ID for this packet (likely and recommended),
|
||||
# we should pick a new unique ID so the message can be tracked.
|
||||
if meshPacket.id == 0:
|
||||
meshPacket.id = self._generatePacketId()
|
||||
|
||||
toRadio.packet.CopyFrom(meshPacket)
|
||||
if self.noProto:
|
||||
logging.warning(f"Not sending packet because protocol use is disabled by noProto")
|
||||
else:
|
||||
logging.debug(f"Sending packet: {stripnl(meshPacket)}")
|
||||
self._sendToRadio(toRadio)
|
||||
return meshPacket</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="meshtastic.mesh_interface.MeshInterface._sendToRadio"><code class="name flex">
|
||||
<span>def <span class="ident">_sendToRadio</span></span>(<span>self, toRadio)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Send a ToRadio protobuf to the device</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def _sendToRadio(self, toRadio):
|
||||
"""Send a ToRadio protobuf to the device"""
|
||||
if self.noProto:
|
||||
logging.warning(f"Not sending packet because protocol use is disabled by noProto")
|
||||
else:
|
||||
#logging.debug(f"Sending toRadio: {stripnl(toRadio)}")
|
||||
self._sendToRadioImpl(toRadio)</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="meshtastic.mesh_interface.MeshInterface._sendToRadioImpl"><code class="name flex">
|
||||
<span>def <span class="ident">_sendToRadioImpl</span></span>(<span>self, toRadio)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Send a ToRadio protobuf to the device</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def _sendToRadioImpl(self, toRadio):
|
||||
"""Send a ToRadio protobuf to the device"""
|
||||
logging.error(f"Subclass must provide toradio: {toRadio}")</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="meshtastic.mesh_interface.MeshInterface._startConfig"><code class="name flex">
|
||||
<span>def <span class="ident">_startConfig</span></span>(<span>self)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Start device packets flowing</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def _startConfig(self):
|
||||
"""Start device packets flowing"""
|
||||
self.myInfo = None
|
||||
self.nodes = {} # nodes keyed by ID
|
||||
self.nodesByNum = {} # nodes keyed by nodenum
|
||||
|
||||
startConfig = mesh_pb2.ToRadio()
|
||||
self.configId = random.randint(0, 0xffffffff)
|
||||
startConfig.want_config_id = self.configId
|
||||
self._sendToRadio(startConfig)</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="meshtastic.mesh_interface.MeshInterface._startHeartbeat"><code class="name flex">
|
||||
<span>def <span class="ident">_startHeartbeat</span></span>(<span>self)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>We need to send a heartbeat message to the device every X seconds</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def _startHeartbeat(self):
|
||||
"""We need to send a heartbeat message to the device every X seconds"""
|
||||
def callback():
|
||||
self.heartbeatTimer = None
|
||||
prefs = self.localNode.radioConfig.preferences
|
||||
i = prefs.phone_timeout_secs / 2
|
||||
logging.debug(f"Sending heartbeat, interval {i}")
|
||||
if i != 0:
|
||||
self.heartbeatTimer = threading.Timer(i, callback)
|
||||
self.heartbeatTimer.start()
|
||||
p = mesh_pb2.ToRadio()
|
||||
self._sendToRadio(p)
|
||||
|
||||
callback() # run our periodic callback now, it will make another timer if necessary</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="meshtastic.mesh_interface.MeshInterface._waitConnected"><code class="name flex">
|
||||
<span>def <span class="ident">_waitConnected</span></span>(<span>self)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Block until the initial node db download is complete, or timeout
|
||||
and raise an exception</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def _waitConnected(self):
|
||||
"""Block until the initial node db download is complete, or timeout
|
||||
and raise an exception"""
|
||||
if not self.noProto:
|
||||
if not self.isConnected.wait(15.0): # timeout after x seconds
|
||||
raise Exception("Timed out waiting for connection completion")
|
||||
|
||||
# If we failed while connecting, raise the connection to the client
|
||||
if self.failure:
|
||||
raise self.failure</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="meshtastic.mesh_interface.MeshInterface.close"><code class="name flex">
|
||||
<span>def <span class="ident">close</span></span>(<span>self)</span>
|
||||
</code></dt>
|
||||
@@ -1824,7 +2373,24 @@ and can be used to track future message acks/naks.</p></div>
|
||||
<ul>
|
||||
<li>
|
||||
<h4><code><a title="meshtastic.mesh_interface.MeshInterface" href="#meshtastic.mesh_interface.MeshInterface">MeshInterface</a></code></h4>
|
||||
<ul class="two-column">
|
||||
<ul class="">
|
||||
<li><code><a title="meshtastic.mesh_interface.MeshInterface._addResponseHandler" href="#meshtastic.mesh_interface.MeshInterface._addResponseHandler">_addResponseHandler</a></code></li>
|
||||
<li><code><a title="meshtastic.mesh_interface.MeshInterface._connected" href="#meshtastic.mesh_interface.MeshInterface._connected">_connected</a></code></li>
|
||||
<li><code><a title="meshtastic.mesh_interface.MeshInterface._disconnected" href="#meshtastic.mesh_interface.MeshInterface._disconnected">_disconnected</a></code></li>
|
||||
<li><code><a title="meshtastic.mesh_interface.MeshInterface._fixupPosition" href="#meshtastic.mesh_interface.MeshInterface._fixupPosition">_fixupPosition</a></code></li>
|
||||
<li><code><a title="meshtastic.mesh_interface.MeshInterface._generatePacketId" href="#meshtastic.mesh_interface.MeshInterface._generatePacketId">_generatePacketId</a></code></li>
|
||||
<li><code><a title="meshtastic.mesh_interface.MeshInterface._getOrCreateByNum" href="#meshtastic.mesh_interface.MeshInterface._getOrCreateByNum">_getOrCreateByNum</a></code></li>
|
||||
<li><code><a title="meshtastic.mesh_interface.MeshInterface._handleConfigComplete" href="#meshtastic.mesh_interface.MeshInterface._handleConfigComplete">_handleConfigComplete</a></code></li>
|
||||
<li><code><a title="meshtastic.mesh_interface.MeshInterface._handleFromRadio" href="#meshtastic.mesh_interface.MeshInterface._handleFromRadio">_handleFromRadio</a></code></li>
|
||||
<li><code><a title="meshtastic.mesh_interface.MeshInterface._handlePacketFromRadio" href="#meshtastic.mesh_interface.MeshInterface._handlePacketFromRadio">_handlePacketFromRadio</a></code></li>
|
||||
<li><code><a title="meshtastic.mesh_interface.MeshInterface._nodeNumToId" href="#meshtastic.mesh_interface.MeshInterface._nodeNumToId">_nodeNumToId</a></code></li>
|
||||
<li><code><a title="meshtastic.mesh_interface.MeshInterface._sendDisconnect" href="#meshtastic.mesh_interface.MeshInterface._sendDisconnect">_sendDisconnect</a></code></li>
|
||||
<li><code><a title="meshtastic.mesh_interface.MeshInterface._sendPacket" href="#meshtastic.mesh_interface.MeshInterface._sendPacket">_sendPacket</a></code></li>
|
||||
<li><code><a title="meshtastic.mesh_interface.MeshInterface._sendToRadio" href="#meshtastic.mesh_interface.MeshInterface._sendToRadio">_sendToRadio</a></code></li>
|
||||
<li><code><a title="meshtastic.mesh_interface.MeshInterface._sendToRadioImpl" href="#meshtastic.mesh_interface.MeshInterface._sendToRadioImpl">_sendToRadioImpl</a></code></li>
|
||||
<li><code><a title="meshtastic.mesh_interface.MeshInterface._startConfig" href="#meshtastic.mesh_interface.MeshInterface._startConfig">_startConfig</a></code></li>
|
||||
<li><code><a title="meshtastic.mesh_interface.MeshInterface._startHeartbeat" href="#meshtastic.mesh_interface.MeshInterface._startHeartbeat">_startHeartbeat</a></code></li>
|
||||
<li><code><a title="meshtastic.mesh_interface.MeshInterface._waitConnected" href="#meshtastic.mesh_interface.MeshInterface._waitConnected">_waitConnected</a></code></li>
|
||||
<li><code><a title="meshtastic.mesh_interface.MeshInterface.close" href="#meshtastic.mesh_interface.MeshInterface.close">close</a></code></li>
|
||||
<li><code><a title="meshtastic.mesh_interface.MeshInterface.getLongName" href="#meshtastic.mesh_interface.MeshInterface.getLongName">getLongName</a></code></li>
|
||||
<li><code><a title="meshtastic.mesh_interface.MeshInterface.getMyNodeInfo" href="#meshtastic.mesh_interface.MeshInterface.getMyNodeInfo">getMyNodeInfo</a></code></li>
|
||||
@@ -1845,7 +2411,7 @@ and can be used to track future message acks/naks.</p></div>
|
||||
</nav>
|
||||
</main>
|
||||
<footer id="footer">
|
||||
<p>Generated by <a href="https://pdoc3.github.io/pdoc" title="pdoc: Python API documentation generator"><cite>pdoc</cite> 0.10.0</a>.</p>
|
||||
<p>Generated by <a href="https://pdoc3.github.io/pdoc" title="pdoc: Python API documentation generator"><cite>pdoc</cite> 0.10.1.dev1+g4aa70de.d20211229</a>.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user