mirror of
https://github.com/meshtastic/python.git
synced 2026-01-01 12:27:59 -05:00
getting channel url works
This commit is contained in:
@@ -346,8 +346,11 @@ class MeshInterface:
|
||||
def channelURL(self):
|
||||
"""The sharable URL that describes the current channel
|
||||
"""
|
||||
# Only keep the primary/secondary channels, assume primary is first
|
||||
channelSet = apponly_pb2.ChannelSet()
|
||||
fixme("fill channelSet from self.channels")
|
||||
for c in self.channels:
|
||||
if c.role != mesh_pb2.Channel.Role.DISABLED:
|
||||
channelSet.settings.append(c.settings)
|
||||
bytes = channelSet.SerializeToString()
|
||||
s = base64.urlsafe_b64encode(bytes).decode('ascii')
|
||||
return f"https://www.meshtastic.org/c/#{s}"
|
||||
|
||||
@@ -15,6 +15,7 @@ import traceback
|
||||
import pkg_resources
|
||||
from datetime import datetime
|
||||
from easy_table import EasyTable
|
||||
from google.protobuf.json_format import MessageToJson
|
||||
|
||||
"""We only import the tunnel code if we are on a platform that can run it"""
|
||||
have_tunnel = platform.system() == 'Linux'
|
||||
@@ -317,7 +318,12 @@ def onConnected(interface):
|
||||
closeNow = True
|
||||
print(interface.myInfo)
|
||||
print(interface.radioConfig)
|
||||
print(f"Channel URL {interface.channelURL}")
|
||||
print("Channels:")
|
||||
for c in interface.channels:
|
||||
if c.role != mesh_pb2.Channel.Role.DISABLED:
|
||||
cStr = MessageToJson(c.settings).replace("\n", "")
|
||||
print(f" {mesh_pb2.Channel.Role.Name(c.role)} {cStr}")
|
||||
print(f"\nChannel URL {interface.channelURL}")
|
||||
print("Nodes in mesh:")
|
||||
for n in interface.nodes.values():
|
||||
print(n)
|
||||
|
||||
Reference in New Issue
Block a user