add --qr to show qr code

This commit is contained in:
geeksville
2020-09-15 17:51:15 -07:00
parent 1214482ccf
commit 73cae01c32
2 changed files with 13 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ import logging
import sys
from pubsub import pub
import google.protobuf.json_format
import pyqrcode
"""The command line arguments"""
args = None
@@ -131,6 +132,12 @@ def onConnected(interface):
print("Nodes in mesh:")
for n in interface.nodes.values():
print(n)
if args.qr:
closeNow = True
print(f"Channel URL {interface.channelURL}")
url = pyqrcode.create(interface.channelURL)
print(url.terminal())
except Exception as ex:
print(ex)
@@ -168,6 +175,9 @@ def main():
parser.add_argument("--info", help="Read and display the radio config information",
action="store_true")
parser.add_argument("--qr", help="Display the QR code that corresponds to the current channel",
action="store_true")
parser.add_argument(
"--set", help="Set a numeric preferences field", nargs=2, action='append')
@@ -206,7 +216,7 @@ def main():
args = parser.parse_args()
logging.basicConfig(level=logging.DEBUG if args.debug else logging.INFO)
if (not args.seriallog) and (args.info or args.set or args.setstr or args.setchan or args.sendtext):
if (not args.seriallog) and (args.info or args.set or args.setstr or args.setchan or args.sendtext or args.qr):
args.seriallog = "none" # assume no debug output in this case
if args.test:

View File

@@ -10,7 +10,7 @@ with open("README.md", "r") as fh:
# This call to setup() does all the work
setup(
name="meshtastic",
version="1.0.6",
version="1.0.7",
description="Python API & client shell for talking to Meshtastic devices",
long_description=long_description,
long_description_content_type="text/markdown",
@@ -26,7 +26,7 @@ setup(
packages=["meshtastic"],
include_package_data=True,
install_requires=["pyserial>=3.4", "protobuf>=3.6.1",
"pypubsub>=4.0.3", "dotmap>=1.3.14", "pexpect>=4.6.0",
"pypubsub>=4.0.3", "dotmap>=1.3.14", "pexpect>=4.6.0", "PyQRCode>=1.2.1"
"pygatt>=4.0.5"],
python_requires='>=3.4',
entry_points={