From f7aa3b56176c2924d31903536b2b26740542822d Mon Sep 17 00:00:00 2001 From: pdxlocations Date: Sun, 31 Mar 2024 07:43:36 -0700 Subject: [PATCH] refactor --- get-channels.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 get-channels.py diff --git a/get-channels.py b/get-channels.py new file mode 100644 index 0000000..4d7e8f6 --- /dev/null +++ b/get-channels.py @@ -0,0 +1,19 @@ +import meshtastic.serial_interface +import base64 + +# Initialize Meshtastic interface +interface = meshtastic.serial_interface.SerialInterface() + +# Get node information +node = interface.getNode('^local') +channels = node.channels +print (channels) +if channels: + print("Channels:") + for channel in channels: + if channel.role: + psk_base64 = base64.b64encode(channel.settings.psk).decode('utf-8') + print(f"Index: {channel.index}, Role: {channel.role}, PSK (Base64): {psk_base64}, Name: {channel.settings.name}") +else: + print("No channels found.") +