mirror of
https://github.com/meshtastic/python.git
synced 2026-01-03 13:28:02 -05:00
fix set url
This commit is contained in:
@@ -131,7 +131,7 @@ class MeshInterface:
|
||||
self.noProto = noProto
|
||||
self.myInfo = None # We don't have device info yet
|
||||
self.responseHandlers = {} # A map from request ID to the handler
|
||||
self.failure = None # If we've encountered a fatal exception it will be kept here
|
||||
self.failure = None # If we've encountered a fatal exception it will be kept here
|
||||
random.seed() # FIXME, we should not clobber the random seedval here, instead tell user they must call it
|
||||
self.currentPacketId = random.randint(0, 0xffffffff)
|
||||
self._startConfig()
|
||||
@@ -290,8 +290,8 @@ class MeshInterface:
|
||||
p.set_radio.CopyFrom(self.radioConfig)
|
||||
|
||||
self.sendData(p, self.myInfo.my_node_num,
|
||||
portNum=portnums_pb2.PortNum.ADMIN_APP,
|
||||
wantAck=True)
|
||||
portNum=portnums_pb2.PortNum.ADMIN_APP,
|
||||
wantAck=True)
|
||||
logging.debug("Wrote config")
|
||||
|
||||
def writeChannel(self, channelIndex):
|
||||
@@ -301,9 +301,9 @@ class MeshInterface:
|
||||
p.set_channel.CopyFrom(self.channels[channelIndex])
|
||||
|
||||
self.sendData(p, self.myInfo.my_node_num,
|
||||
portNum=portnums_pb2.PortNum.ADMIN_APP,
|
||||
wantAck=True)
|
||||
logging.debug("Wrote channel {channelIndex}")
|
||||
portNum=portnums_pb2.PortNum.ADMIN_APP,
|
||||
wantAck=True)
|
||||
logging.debug("Wrote channel {channelIndex}")
|
||||
|
||||
def getMyNodeInfo(self):
|
||||
if self.myInfo is None:
|
||||
@@ -384,8 +384,16 @@ class MeshInterface:
|
||||
decodedURL = base64.urlsafe_b64decode(splitURL[-1])
|
||||
channelSet = apponly_pb2.ChannelSet()
|
||||
channelSet.ParseFromString(decodedURL)
|
||||
fixme("set self.channels, see https://developers.google.com/protocol-buffers/docs/reference/python-generated?csw=1#repeated-fields")
|
||||
self._writeChannels()
|
||||
|
||||
i = 0
|
||||
for chs in channelSet.settings:
|
||||
ch = channel_pb2.Channel()
|
||||
ch.role = channel_pb2.Channel.Role.PRIMARY if i == 0 else channel_pb2.Channel.Role.SECONDARY
|
||||
ch.index = i
|
||||
ch.settings.CopyFrom(chs)
|
||||
self.channels[ch.index] = ch
|
||||
self.writeChannel(ch.index)
|
||||
i = i + 1
|
||||
|
||||
def _waitConnected(self):
|
||||
"""Block until the initial node db download is complete, or timeout
|
||||
@@ -520,7 +528,7 @@ class MeshInterface:
|
||||
|
||||
if failmsg:
|
||||
self.failure = Exception(failmsg)
|
||||
self.isConnected.set() # let waitConnected return this exception
|
||||
self.isConnected.set() # let waitConnected return this exception
|
||||
self.close()
|
||||
|
||||
elif fromRadio.HasField("node_info"):
|
||||
|
||||
@@ -28,6 +28,7 @@ parser = argparse.ArgumentParser()
|
||||
|
||||
channelIndex = 0
|
||||
|
||||
|
||||
def onReceive(packet, interface):
|
||||
"""Callback invoked when a packet arrives"""
|
||||
logging.debug(f"Received: {packet}")
|
||||
@@ -94,6 +95,8 @@ never = 0xffffffff
|
||||
oneday = 24 * 60 * 60
|
||||
|
||||
# Returns formatted value
|
||||
|
||||
|
||||
def formatFloat(value, formatStr="{:.2f}", unit="", default="N/A"):
|
||||
return formatStr.format(value)+unit if value else default
|
||||
|
||||
@@ -128,6 +131,7 @@ def printNodes(nodes):
|
||||
table.setData(tableData)
|
||||
table.displayTable()
|
||||
|
||||
|
||||
def setPref(attributes, name, valStr):
|
||||
"""Set a channel or preferences value"""
|
||||
val = fromStr(valStr)
|
||||
@@ -143,6 +147,7 @@ def setPref(attributes, name, valStr):
|
||||
except Exception as ex:
|
||||
print(f"Can't set {name} due to {ex}")
|
||||
|
||||
|
||||
def onConnected(interface):
|
||||
"""Callback invoked when we connect to a radio"""
|
||||
closeNow = False # Should we drop the connection after we finish?
|
||||
@@ -230,6 +235,10 @@ def onConnected(interface):
|
||||
print("Writing modified preferences to device")
|
||||
interface.writeConfig()
|
||||
|
||||
if args.seturl:
|
||||
closeNow = True
|
||||
interface.setURL(args.seturl)
|
||||
|
||||
# handle changing channels
|
||||
if args.setchan or args.setch_longslow or args.setch_shortfast \
|
||||
or args.seturl != None:
|
||||
@@ -334,7 +343,8 @@ def common():
|
||||
args.seriallog = "stdout" # default to stdout
|
||||
|
||||
if args.router != None:
|
||||
logging.error('--set-router has been deprecated. Use "--set router true" or "--set router false" instead')
|
||||
logging.error(
|
||||
'--set-router has been deprecated. Use "--set router true" or "--set router false" instead')
|
||||
elif args.test:
|
||||
test.testAll()
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user