Skip to content

Commit

Permalink
1.0.6 add a channelURL property
Browse files Browse the repository at this point in the history
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}
```
  • Loading branch information
geeksville committed Sep 16, 2020
1 parent 6f942c2 commit 1214482
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
41 changes: 40 additions & 1 deletion docs/meshtastic/index.html
Expand Up @@ -127,6 +127,7 @@ <h1 id="example-usage">Example Usage</h1>
import sys
import traceback
import time
import base64
from . import mesh_pb2
from . import util
from pubsub import pub
Expand Down Expand Up @@ -261,6 +262,14 @@ <h1 id="example-usage">Example Usage</h1>
t.set_radio.CopyFrom(self.radioConfig)
self._sendToRadio(t)

@property
def channelURL(self):
&#34;&#34;&#34;The sharable URL that describes the current channel
&#34;&#34;&#34;
bytes = self.radioConfig.channel_settings.SerializeToString()
s = base64.urlsafe_b64encode(bytes).decode(&#39;ascii&#39;)
return f&#34;https://www.meshtastic.org/c/#{s}&#34;

def _generatePacketId(self):
&#34;&#34;&#34;Get a new unique packet ID&#34;&#34;&#34;
if self.currentPacketId is None:
Expand Down Expand Up @@ -704,6 +713,7 @@ <h3>Inherited members</h3>
<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>
Expand Down Expand Up @@ -841,6 +851,14 @@ <h3>Inherited members</h3>
t.set_radio.CopyFrom(self.radioConfig)
self._sendToRadio(t)

@property
def channelURL(self):
&#34;&#34;&#34;The sharable URL that describes the current channel
&#34;&#34;&#34;
bytes = self.radioConfig.channel_settings.SerializeToString()
s = base64.urlsafe_b64encode(bytes).decode(&#39;ascii&#39;)
return f&#34;https://www.meshtastic.org/c/#{s}&#34;

def _generatePacketId(self):
&#34;&#34;&#34;Get a new unique packet ID&#34;&#34;&#34;
if self.currentPacketId is None:
Expand Down Expand Up @@ -1009,6 +1027,25 @@ <h3>Subclasses</h3>
<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):
&#34;&#34;&#34;The sharable URL that describes the current channel
&#34;&#34;&#34;
bytes = self.radioConfig.channel_settings.SerializeToString()
s = base64.urlsafe_b64encode(bytes).decode(&#39;ascii&#39;)
return f&#34;https://www.meshtastic.org/c/#{s}&#34;</code></pre>
</details>
</dd>
</dl>
<h3>Methods</h3>
<dl>
<dt id="meshtastic.MeshInterface.sendData"><code class="name flex">
Expand Down Expand Up @@ -1378,6 +1415,7 @@ <h3>Inherited members</h3>
<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>
Expand Down Expand Up @@ -1423,7 +1461,8 @@ <h4><code><a title="meshtastic.BLEInterface" href="#meshtastic.BLEInterface">BLE
</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>
Expand Down
9 changes: 9 additions & 0 deletions meshtastic/__init__.py
Expand Up @@ -56,6 +56,7 @@ def onConnection(interface, topic=pub.AUTO_TOPIC): # called when we (re)connect
import sys
import traceback
import time
import base64
from . import mesh_pb2
from . import util
from pubsub import pub
Expand Down Expand Up @@ -190,6 +191,14 @@ def writeConfig(self):
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:
Expand Down
1 change: 1 addition & 0 deletions meshtastic/__main__.py
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -10,7 +10,7 @@
# 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",
Expand Down

1 comment on commit 1214482

@geeksville
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Meshtastic. There might be relevant details there:

https://meshtastic.discourse.group/t/new-python-command-line-options-for-setting-channel-parameters/1319/1

Please sign in to comment.