mirror of
https://github.com/meshtastic/python.git
synced 2026-01-02 04:47:54 -05:00
1.1.31 bury taptun2 deeper so that windows can't accidentally touch it
This commit is contained in:
@@ -34,6 +34,7 @@ the device.</li>
|
||||
Includes always up-to-date location and username information for each
|
||||
node in the mesh.
|
||||
This is a read-only datastructure.</li>
|
||||
<li>nodesByNum - like "nodes" but keyed by nodeNum instead of nodeId</li>
|
||||
<li>myInfo - Contains read-only information about the local radio device (software version, hardware version, etc)</li>
|
||||
</ul>
|
||||
<h1 id="published-pubsub-topics">Published PubSub topics</h1>
|
||||
@@ -97,6 +98,7 @@ properties of SerialInterface:
|
||||
the device.
|
||||
- nodes - The database of received nodes. Includes always up-to-date location and username information for each
|
||||
node in the mesh. This is a read-only datastructure.
|
||||
- nodesByNum - like "nodes" but keyed by nodeNum instead of nodeId
|
||||
- myInfo - Contains read-only information about the local radio device (software version, hardware version, etc)
|
||||
|
||||
# Published PubSub topics
|
||||
@@ -322,14 +324,15 @@ class MeshInterface:
|
||||
self._sendToRadio(t)
|
||||
logging.debug("Wrote config")
|
||||
|
||||
def getMyUser(self):
|
||||
def getMyNodeInfo(self):
|
||||
if self.myInfo is None:
|
||||
return None
|
||||
myId = self.myInfo.my_node_num
|
||||
for _, nodeDict in self.nodes.items():
|
||||
if 'num' in nodeDict and nodeDict['num'] == myId:
|
||||
if 'user' in nodeDict:
|
||||
return nodeDict['user']
|
||||
return self.nodesByNum.get(self.myInfo.my_node_num)
|
||||
|
||||
def getMyUser(self):
|
||||
nodeInfo = self.getMyNodeInfo()
|
||||
if nodeInfo is not None:
|
||||
return nodeInfo.get('user')
|
||||
return None
|
||||
|
||||
def getLongName(self):
|
||||
@@ -421,7 +424,7 @@ class MeshInterface:
|
||||
"""Start device packets flowing"""
|
||||
self.myInfo = None
|
||||
self.nodes = {} # nodes keyed by ID
|
||||
self._nodesByNum = {} # nodes keyed by nodenum
|
||||
self.nodesByNum = {} # nodes keyed by nodenum
|
||||
self.radioConfig = None
|
||||
self.currentPacketId = None
|
||||
|
||||
@@ -465,7 +468,7 @@ class MeshInterface:
|
||||
self._fixupPosition(node["position"])
|
||||
except:
|
||||
logging.debug("Node without position")
|
||||
self._nodesByNum[node["num"]] = node
|
||||
self.nodesByNum[node["num"]] = node
|
||||
if "user" in node: # Some nodes might not have user/ids assigned yet
|
||||
self.nodes[node["user"]["id"]] = node
|
||||
pub.sendMessage("meshtastic.node.updated", node=node, interface=self)
|
||||
@@ -506,7 +509,7 @@ class MeshInterface:
|
||||
return BROADCAST_ADDR
|
||||
|
||||
try:
|
||||
return self._nodesByNum[num]["user"]["id"]
|
||||
return self.nodesByNum[num]["user"]["id"]
|
||||
except:
|
||||
logging.warn("Node not found for fromId")
|
||||
return None
|
||||
@@ -516,11 +519,11 @@ class MeshInterface:
|
||||
if nodeNum == BROADCAST_NUM:
|
||||
raise Exception("Can not create/find nodenum by the broadcast num")
|
||||
|
||||
if nodeNum in self._nodesByNum:
|
||||
return self._nodesByNum[nodeNum]
|
||||
if nodeNum in self.nodesByNum:
|
||||
return self.nodesByNum[nodeNum]
|
||||
else:
|
||||
n = {"num": nodeNum} # Create a minimial node db entry
|
||||
self._nodesByNum[nodeNum] = n
|
||||
self.nodesByNum[nodeNum] = n
|
||||
return n
|
||||
|
||||
def _handlePacketFromRadio(self, meshPacket):
|
||||
@@ -1175,14 +1178,15 @@ noProto – If True, don't try to run our protocol on the link - just be a d
|
||||
self._sendToRadio(t)
|
||||
logging.debug("Wrote config")
|
||||
|
||||
def getMyUser(self):
|
||||
def getMyNodeInfo(self):
|
||||
if self.myInfo is None:
|
||||
return None
|
||||
myId = self.myInfo.my_node_num
|
||||
for _, nodeDict in self.nodes.items():
|
||||
if 'num' in nodeDict and nodeDict['num'] == myId:
|
||||
if 'user' in nodeDict:
|
||||
return nodeDict['user']
|
||||
return self.nodesByNum.get(self.myInfo.my_node_num)
|
||||
|
||||
def getMyUser(self):
|
||||
nodeInfo = self.getMyNodeInfo()
|
||||
if nodeInfo is not None:
|
||||
return nodeInfo.get('user')
|
||||
return None
|
||||
|
||||
def getLongName(self):
|
||||
@@ -1274,7 +1278,7 @@ noProto – If True, don't try to run our protocol on the link - just be a d
|
||||
"""Start device packets flowing"""
|
||||
self.myInfo = None
|
||||
self.nodes = {} # nodes keyed by ID
|
||||
self._nodesByNum = {} # nodes keyed by nodenum
|
||||
self.nodesByNum = {} # nodes keyed by nodenum
|
||||
self.radioConfig = None
|
||||
self.currentPacketId = None
|
||||
|
||||
@@ -1318,7 +1322,7 @@ noProto – If True, don't try to run our protocol on the link - just be a d
|
||||
self._fixupPosition(node["position"])
|
||||
except:
|
||||
logging.debug("Node without position")
|
||||
self._nodesByNum[node["num"]] = node
|
||||
self.nodesByNum[node["num"]] = node
|
||||
if "user" in node: # Some nodes might not have user/ids assigned yet
|
||||
self.nodes[node["user"]["id"]] = node
|
||||
pub.sendMessage("meshtastic.node.updated", node=node, interface=self)
|
||||
@@ -1359,7 +1363,7 @@ noProto – If True, don't try to run our protocol on the link - just be a d
|
||||
return BROADCAST_ADDR
|
||||
|
||||
try:
|
||||
return self._nodesByNum[num]["user"]["id"]
|
||||
return self.nodesByNum[num]["user"]["id"]
|
||||
except:
|
||||
logging.warn("Node not found for fromId")
|
||||
return None
|
||||
@@ -1369,11 +1373,11 @@ noProto – If True, don't try to run our protocol on the link - just be a d
|
||||
if nodeNum == BROADCAST_NUM:
|
||||
raise Exception("Can not create/find nodenum by the broadcast num")
|
||||
|
||||
if nodeNum in self._nodesByNum:
|
||||
return self._nodesByNum[nodeNum]
|
||||
if nodeNum in self.nodesByNum:
|
||||
return self.nodesByNum[nodeNum]
|
||||
else:
|
||||
n = {"num": nodeNum} # Create a minimial node db entry
|
||||
self._nodesByNum[nodeNum] = n
|
||||
self.nodesByNum[nodeNum] = n
|
||||
return n
|
||||
|
||||
def _handlePacketFromRadio(self, meshPacket):
|
||||
@@ -1500,6 +1504,21 @@ def channelURL(self):
|
||||
return None</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="meshtastic.MeshInterface.getMyNodeInfo"><code class="name flex">
|
||||
<span>def <span class="ident">getMyNodeInfo</span></span>(<span>self)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def getMyNodeInfo(self):
|
||||
if self.myInfo is None:
|
||||
return None
|
||||
return self.nodesByNum.get(self.myInfo.my_node_num)</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="meshtastic.MeshInterface.getMyUser"><code class="name flex">
|
||||
<span>def <span class="ident">getMyUser</span></span>(<span>self)</span>
|
||||
</code></dt>
|
||||
@@ -1510,13 +1529,9 @@ def channelURL(self):
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def getMyUser(self):
|
||||
if self.myInfo is None:
|
||||
return None
|
||||
myId = self.myInfo.my_node_num
|
||||
for _, nodeDict in self.nodes.items():
|
||||
if 'num' in nodeDict and nodeDict['num'] == myId:
|
||||
if 'user' in nodeDict:
|
||||
return nodeDict['user']
|
||||
nodeInfo = self.getMyNodeInfo()
|
||||
if nodeInfo is not None:
|
||||
return nodeInfo.get('user')
|
||||
return None</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
@@ -2225,6 +2240,7 @@ hostname {string} – Hostname/IP address of the device to connect to</p></d
|
||||
<ul class="two-column">
|
||||
<li><code><a title="meshtastic.MeshInterface.channelURL" href="#meshtastic.MeshInterface.channelURL">channelURL</a></code></li>
|
||||
<li><code><a title="meshtastic.MeshInterface.getLongName" href="#meshtastic.MeshInterface.getLongName">getLongName</a></code></li>
|
||||
<li><code><a title="meshtastic.MeshInterface.getMyNodeInfo" href="#meshtastic.MeshInterface.getMyNodeInfo">getMyNodeInfo</a></code></li>
|
||||
<li><code><a title="meshtastic.MeshInterface.getMyUser" href="#meshtastic.MeshInterface.getMyUser">getMyUser</a></code></li>
|
||||
<li><code><a title="meshtastic.MeshInterface.getShortName" href="#meshtastic.MeshInterface.getShortName">getShortName</a></code></li>
|
||||
<li><code><a title="meshtastic.MeshInterface.sendData" href="#meshtastic.MeshInterface.sendData">sendData</a></code></li>
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
|
||||
from . import portnums_pb2
|
||||
from pubsub import pub
|
||||
from pytap2 import TapDevice
|
||||
import logging, threading
|
||||
|
||||
# A new non standard log level that is lower level than DEBUG
|
||||
@@ -118,6 +117,7 @@ class Tunnel:
|
||||
|
||||
logging.debug("creating TUN device")
|
||||
# FIXME - figure out real max MTU, it should be 240 - the overhead bytes for SubPacket and Data
|
||||
from pytap2 import TapDevice
|
||||
self.tun = TapDevice(name="mesh", mtu=200)
|
||||
self.tun.up()
|
||||
self.tun.ifconfig(address=myAddr,netmask=netmask)
|
||||
@@ -348,6 +348,7 @@ subnet is used to construct our network number (normally 10.115.x.x)</p></div>
|
||||
|
||||
logging.debug("creating TUN device")
|
||||
# FIXME - figure out real max MTU, it should be 240 - the overhead bytes for SubPacket and Data
|
||||
from pytap2 import TapDevice
|
||||
self.tun = TapDevice(name="mesh", mtu=200)
|
||||
self.tun.up()
|
||||
self.tun.ifconfig(address=myAddr,netmask=netmask)
|
||||
|
||||
@@ -11,8 +11,6 @@ import pkg_resources
|
||||
|
||||
"""We only import the tunnel code if we are on a platform that can run it"""
|
||||
have_tunnel = platform.system() == 'Linux'
|
||||
if have_tunnel:
|
||||
from . import tunnel
|
||||
|
||||
"""The command line arguments"""
|
||||
args = None
|
||||
@@ -279,6 +277,7 @@ def onConnected(interface):
|
||||
print(url.terminal())
|
||||
|
||||
if have_tunnel and args.tunnel :
|
||||
from . import tunnel
|
||||
closeNow = False # Even if others said we could close, stay open if the user asked for a tunnel
|
||||
tunnel.Tunnel(interface, subnet=args.tunnel_net)
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
|
||||
from . import portnums_pb2
|
||||
from pubsub import pub
|
||||
from pytap2 import TapDevice
|
||||
import logging, threading
|
||||
|
||||
# A new non standard log level that is lower level than DEBUG
|
||||
@@ -90,6 +89,7 @@ class Tunnel:
|
||||
|
||||
logging.debug("creating TUN device")
|
||||
# FIXME - figure out real max MTU, it should be 240 - the overhead bytes for SubPacket and Data
|
||||
from pytap2 import TapDevice
|
||||
self.tun = TapDevice(name="mesh", mtu=200)
|
||||
self.tun.up()
|
||||
self.tun.ifconfig(address=myAddr,netmask=netmask)
|
||||
|
||||
2
setup.py
2
setup.py
@@ -12,7 +12,7 @@ with open("README.md", "r") as fh:
|
||||
# This call to setup() does all the work
|
||||
setup(
|
||||
name="meshtastic",
|
||||
version="1.1.30",
|
||||
version="1.1.31",
|
||||
description="Python API & client shell for talking to Meshtastic devices",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
|
||||
Reference in New Issue
Block a user