getting channel url works

This commit is contained in:
Kevin Hester
2021-02-27 09:16:50 +08:00
parent d2d8edf61c
commit a78ddffb3e
2 changed files with 11 additions and 2 deletions

View File

@@ -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}"

View File

@@ -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)