mirror of
https://github.com/meshtastic/python.git
synced 2026-01-01 20:38:03 -05:00
1.0.6 add a channelURL property
Example usage:
```
meshtastic --setchan tx_power 100 --info
Trigger powerFSM 9
Connected to radio
Setting channel parameter tx_power to 100
Writing modified preferences to device
my_node_num: 2883444536
has_gps: true
num_channels: 13
region: "1.0-US"
hw_model: "tbeam"
firmware_version: "1.0.0"
packet_id_bits: 32
current_packet_id: 816090843
node_num_bits: 32
message_timeout_msec: 300000
min_app_version: 172
preferences {
position_broadcast_secs: 900
send_owner_interval: 4
wait_bluetooth_secs: 120
screen_on_secs: 300
phone_timeout_secs: 900
phone_sds_timeout_sec: 7200
mesh_sds_timeout_secs: 7200
sds_secs: 31536000
ls_secs: 3601
}
channel_settings {
tx_power: 100
modem_config: Bw125Cr48Sf4096
psk: "\324\361\273: )\007Y\360\274\377\253\317Ni\277"
name: "Default"
}
Channel URL https://www.meshtastic.org/c/#CGQYAyIQ1PG7OiApB1nwvP-rz05pvyoHRGVmYXVsdA==
Nodes in mesh:
{'num': 2883444536, 'user': {'id': '!2462abdddf38', 'longName': 'Bob b', 'shortName': 'Bb', 'macaddr': 'JGKr3d84'}, 'position': {'batteryLevel': 100, 'time': 315969731}}
{'num': 682754228, 'user': {'id': '!246f28b200b4', 'longName': 'Bob b', 'shortName': 'Bb', 'macaddr': 'JG8osgC0'}, 'position': {'batteryLevel': 79, 'time': 316593914}, 'snr': 9.5}
{'num': 2441803616, 'user': {'id': '!5002918af760', 'longName': 'ryan', 'shortName': 'r', 'macaddr': 'UAKRivdg'}, 'position': {'batteryLevel': 61, 'time': 316497304}, 'snr': 10.0}
{'num': 862631397, 'user': {'id': '!c44f336ab5e5', 'longName': 'Unknown b5e5', 'shortName': '?E5', 'macaddr': 'xE8zarXl'}, 'position': {'time': 1597965319}, 'snr': 13.25}
{'num': 2441803548, 'user': {'id': '!5002918af71c', 'longName': 'Unknown f71c', 'shortName': '?1C', 'macaddr': 'UAKRivcc'}, 'position': {'batteryLevel': 47, 'time': 316494981}, 'snr': 9.5}
{'num': 82599254, 'user': {'id': '!fd1004ec5d56', 'longName': 'Unknown 5d56', 'shortName': '?56', 'macaddr': '/RAE7F1W'}, 'position': {}, 'snr': 9.25}
{'num': 2885173400, 'user': {'id': '!2462abf84098', 'longName': 'Unknown 4098', 'shortName': '?98', 'macaddr': 'JGKr+ECY'}, 'position': {'batteryLevel': 4, 'time': 315966200}, 'snr': 10.75}
```
This commit is contained in:
@@ -127,6 +127,7 @@ import time
|
||||
import sys
|
||||
import traceback
|
||||
import time
|
||||
import base64
|
||||
from . import mesh_pb2
|
||||
from . import util
|
||||
from pubsub import pub
|
||||
@@ -261,6 +262,14 @@ class MeshInterface:
|
||||
t.set_radio.CopyFrom(self.radioConfig)
|
||||
self._sendToRadio(t)
|
||||
|
||||
@property
|
||||
def channelURL(self):
|
||||
"""The sharable URL that describes the current channel
|
||||
"""
|
||||
bytes = self.radioConfig.channel_settings.SerializeToString()
|
||||
s = base64.urlsafe_b64encode(bytes).decode('ascii')
|
||||
return f"https://www.meshtastic.org/c/#{s}"
|
||||
|
||||
def _generatePacketId(self):
|
||||
"""Get a new unique packet ID"""
|
||||
if self.currentPacketId is None:
|
||||
@@ -704,6 +713,7 @@ class StreamInterface(MeshInterface):
|
||||
<ul class="hlist">
|
||||
<li><code><b><a title="meshtastic.MeshInterface" href="#meshtastic.MeshInterface">MeshInterface</a></b></code>:
|
||||
<ul class="hlist">
|
||||
<li><code><a title="meshtastic.MeshInterface.channelURL" href="#meshtastic.MeshInterface.channelURL">channelURL</a></code></li>
|
||||
<li><code><a title="meshtastic.MeshInterface.sendData" href="#meshtastic.MeshInterface.sendData">sendData</a></code></li>
|
||||
<li><code><a title="meshtastic.MeshInterface.sendPacket" href="#meshtastic.MeshInterface.sendPacket">sendPacket</a></code></li>
|
||||
<li><code><a title="meshtastic.MeshInterface.sendPosition" href="#meshtastic.MeshInterface.sendPosition">sendPosition</a></code></li>
|
||||
@@ -841,6 +851,14 @@ debugOut</p>
|
||||
t.set_radio.CopyFrom(self.radioConfig)
|
||||
self._sendToRadio(t)
|
||||
|
||||
@property
|
||||
def channelURL(self):
|
||||
"""The sharable URL that describes the current channel
|
||||
"""
|
||||
bytes = self.radioConfig.channel_settings.SerializeToString()
|
||||
s = base64.urlsafe_b64encode(bytes).decode('ascii')
|
||||
return f"https://www.meshtastic.org/c/#{s}"
|
||||
|
||||
def _generatePacketId(self):
|
||||
"""Get a new unique packet ID"""
|
||||
if self.currentPacketId is None:
|
||||
@@ -1009,6 +1027,25 @@ debugOut</p>
|
||||
<li><a title="meshtastic.BLEInterface" href="#meshtastic.BLEInterface">BLEInterface</a></li>
|
||||
<li><a title="meshtastic.StreamInterface" href="#meshtastic.StreamInterface">StreamInterface</a></li>
|
||||
</ul>
|
||||
<h3>Instance variables</h3>
|
||||
<dl>
|
||||
<dt id="meshtastic.MeshInterface.channelURL"><code class="name">var <span class="ident">channelURL</span></code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>The sharable URL that describes the current channel</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">@property
|
||||
def channelURL(self):
|
||||
"""The sharable URL that describes the current channel
|
||||
"""
|
||||
bytes = self.radioConfig.channel_settings.SerializeToString()
|
||||
s = base64.urlsafe_b64encode(bytes).decode('ascii')
|
||||
return f"https://www.meshtastic.org/c/#{s}"</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
</dl>
|
||||
<h3>Methods</h3>
|
||||
<dl>
|
||||
<dt id="meshtastic.MeshInterface.sendData"><code class="name flex">
|
||||
@@ -1378,6 +1415,7 @@ start the reading thread later.</p></div>
|
||||
<ul class="hlist">
|
||||
<li><code><b><a title="meshtastic.MeshInterface" href="#meshtastic.MeshInterface">MeshInterface</a></b></code>:
|
||||
<ul class="hlist">
|
||||
<li><code><a title="meshtastic.MeshInterface.channelURL" href="#meshtastic.MeshInterface.channelURL">channelURL</a></code></li>
|
||||
<li><code><a title="meshtastic.MeshInterface.sendData" href="#meshtastic.MeshInterface.sendData">sendData</a></code></li>
|
||||
<li><code><a title="meshtastic.MeshInterface.sendPacket" href="#meshtastic.MeshInterface.sendPacket">sendPacket</a></code></li>
|
||||
<li><code><a title="meshtastic.MeshInterface.sendPosition" href="#meshtastic.MeshInterface.sendPosition">sendPosition</a></code></li>
|
||||
@@ -1423,7 +1461,8 @@ start the reading thread later.</p></div>
|
||||
</li>
|
||||
<li>
|
||||
<h4><code><a title="meshtastic.MeshInterface" href="#meshtastic.MeshInterface">MeshInterface</a></code></h4>
|
||||
<ul class="">
|
||||
<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.sendData" href="#meshtastic.MeshInterface.sendData">sendData</a></code></li>
|
||||
<li><code><a title="meshtastic.MeshInterface.sendPacket" href="#meshtastic.MeshInterface.sendPacket">sendPacket</a></code></li>
|
||||
<li><code><a title="meshtastic.MeshInterface.sendPosition" href="#meshtastic.MeshInterface.sendPosition">sendPosition</a></code></li>
|
||||
|
||||
@@ -56,6 +56,7 @@ import time
|
||||
import sys
|
||||
import traceback
|
||||
import time
|
||||
import base64
|
||||
from . import mesh_pb2
|
||||
from . import util
|
||||
from pubsub import pub
|
||||
@@ -190,6 +191,14 @@ class MeshInterface:
|
||||
t.set_radio.CopyFrom(self.radioConfig)
|
||||
self._sendToRadio(t)
|
||||
|
||||
@property
|
||||
def channelURL(self):
|
||||
"""The sharable URL that describes the current channel
|
||||
"""
|
||||
bytes = self.radioConfig.channel_settings.SerializeToString()
|
||||
s = base64.urlsafe_b64encode(bytes).decode('ascii')
|
||||
return f"https://www.meshtastic.org/c/#{s}"
|
||||
|
||||
def _generatePacketId(self):
|
||||
"""Get a new unique packet ID"""
|
||||
if self.currentPacketId is None:
|
||||
|
||||
@@ -127,6 +127,7 @@ def onConnected(interface):
|
||||
closeNow = True
|
||||
print(interface.myInfo)
|
||||
print(interface.radioConfig)
|
||||
print(f"Channel URL {interface.channelURL}")
|
||||
print("Nodes in mesh:")
|
||||
for n in interface.nodes.values():
|
||||
print(n)
|
||||
|
||||
2
setup.py
2
setup.py
@@ -10,7 +10,7 @@ with open("README.md", "r") as fh:
|
||||
# This call to setup() does all the work
|
||||
setup(
|
||||
name="meshtastic",
|
||||
version="1.0.5",
|
||||
version="1.0.6",
|
||||
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