diff --git a/.vscode/launch.json b/.vscode/launch.json index c53d43a..895b0ce 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -58,7 +58,7 @@ "request": "launch", "module": "meshtastic", "justMyCode": true, - "args": ["--seturl", "https://www.meshtastic.org/c/#GAMiENTxuzogKQdZ8Lz_q89Oab8qB0RlZmF1bHQ=" + "args": ["--seturl", "https://www.meshtastic.org/d/#CgIYAw" ] }, { diff --git a/meshtastic/__init__.py b/meshtastic/__init__.py index 851d561..ba966a7 100644 --- a/meshtastic/__init__.py +++ b/meshtastic/__init__.py @@ -391,7 +391,16 @@ class MeshInterface: # URLs are of the form https://www.meshtastic.org/d/#{base64_channel_set} # Split on '/#' to find the base64 encoded channel settings splitURL = url.split("/#") - decodedURL = base64.urlsafe_b64decode(splitURL[-1]) + b64 = splitURL[-1] + + # We normally strip padding to make for a shorter URL, but the python parser doesn't like + # that. So add back any missing padding + # per https://stackoverflow.com/a/9807138 + missing_padding = len(b64) % 4 + if missing_padding: + b64 += '='* (4 - missing_padding) + + decodedURL = base64.urlsafe_b64decode(b64) channelSet = apponly_pb2.ChannelSet() channelSet.ParseFromString(decodedURL)