From b787f4640459571285ea3f9e2824d9d5a6f93b91 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Wed, 28 Apr 2021 15:17:00 +0800 Subject: [PATCH] fix --noproto exiting to quickly --- meshtastic/__main__.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index 83b7d23..c369075 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -5,6 +5,7 @@ import platform import logging import sys import codecs +import time import base64 import os from . import SerialInterface, TCPInterface, BLEInterface, test, remote_hardware @@ -213,7 +214,7 @@ def onConnected(interface): closeNow = True print( f"Setting HAM ID to {args.set_ham} and turning off encryption") - getNode().setOwner(args.set_ham, is_licensed = True) + getNode().setOwner(args.set_ham, is_licensed=True) # Must turn off crypt on primary channel ch = getNode().channels[0] ch.settings.psk = fromPSK("none") @@ -258,7 +259,7 @@ def onConnected(interface): """A closure to handle the response packet""" hw = packet["decoded"]["remotehw"] print(f'GPIO read response gpio_value={hw["gpioValue"]}') - sys.exit(0) # Just force an exit (FIXME - ugly) + sys.exit(0) # Just force an exit (FIXME - ugly) rhc.readGPIOs(args.dest, bitmask, onResponse) @@ -394,7 +395,8 @@ def onConnected(interface): except Exception as ex: print(f"Aborting due to: {ex}") - interface.close() # close the connection now, so that our app exits + interface.close() # close the connection now, so that our app exits + def onNode(node): """Callback invoked when the node DB changes""" @@ -435,7 +437,7 @@ def common(): if not args.seriallog: if args.noproto: - args.seriallog = "stdout" + args.seriallog = "stdout" else: args.seriallog = "none" # assume no debug output in this case @@ -467,10 +469,14 @@ def common(): else: client = SerialInterface( args.port, debugOut=logfile, noProto=args.noproto) - + # We assume client is fully connected now onConnected(client) + if args.noproto: # loop until someone presses ctrlc + while True: + time.sleep(1000) + # don't call exit, background threads might be running still # sys.exit(0)