mirror of
https://github.com/meshtastic/python.git
synced 2025-12-26 09:27:52 -05:00
Compare commits
33 Commits
patch-1
...
channel-ur
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59fc294d66 | ||
|
|
7473b4e18c | ||
|
|
58aafcf3f1 | ||
|
|
776fc57c35 | ||
|
|
b3f752a3c4 | ||
|
|
4965ec7f1d | ||
|
|
0746acd34f | ||
|
|
49b1c4816e | ||
|
|
7c6e87e161 | ||
|
|
b548700c0b | ||
|
|
f278a30003 | ||
|
|
22bbe67d24 | ||
|
|
a2861a133e | ||
|
|
03aab10786 | ||
|
|
95e768efd5 | ||
|
|
6644e86be9 | ||
|
|
c8363cd476 | ||
|
|
62efe1ab7f | ||
|
|
01e643ad2f | ||
|
|
e4078e84d7 | ||
|
|
abfcbe2a90 | ||
|
|
e06d8bbc06 | ||
|
|
a78cdde86f | ||
|
|
10517ac94d | ||
|
|
a572699588 | ||
|
|
d11fb47734 | ||
|
|
92c7b2db69 | ||
|
|
ff94ad968c | ||
|
|
c6071c57ec | ||
|
|
e3e3562c2c | ||
|
|
06b5b8fa83 | ||
|
|
4b95b0ff30 | ||
|
|
42f2ed571d |
64
.vscode/launch.json
vendored
64
.vscode/launch.json
vendored
@@ -52,6 +52,46 @@
|
|||||||
"justMyCode": true,
|
"justMyCode": true,
|
||||||
"args": ["--debug", "--get", "power.is_power_saving"]
|
"args": ["--debug", "--get", "power.is_power_saving"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "meshtastic debug getPref telemetry",
|
||||||
|
"type": "python",
|
||||||
|
"request": "launch",
|
||||||
|
"module": "meshtastic",
|
||||||
|
"justMyCode": true,
|
||||||
|
"args": ["--debug", "--get", "telemetry.environment_update_interval"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "meshtastic debug info",
|
||||||
|
"type": "python",
|
||||||
|
"request": "launch",
|
||||||
|
"module": "meshtastic",
|
||||||
|
"justMyCode": true,
|
||||||
|
"args": ["--debug", "--info"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "meshtastic debug set region",
|
||||||
|
"type": "python",
|
||||||
|
"request": "launch",
|
||||||
|
"module": "meshtastic",
|
||||||
|
"justMyCode": true,
|
||||||
|
"args": ["--debug", "--set", "lora.region", "TW"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "meshtastic debug set bluetooth fixed pin",
|
||||||
|
"type": "python",
|
||||||
|
"request": "launch",
|
||||||
|
"module": "meshtastic",
|
||||||
|
"justMyCode": true,
|
||||||
|
"args": ["--debug", "--set", "bluetooth.fixed_pin", "555555"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "meshtastic debug get bluetooth fixed pin",
|
||||||
|
"type": "python",
|
||||||
|
"request": "launch",
|
||||||
|
"module": "meshtastic",
|
||||||
|
"justMyCode": true,
|
||||||
|
"args": ["--debug", "--get", "bluetooth.fixed_pin"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "meshtastic debug setPref",
|
"name": "meshtastic debug setPref",
|
||||||
"type": "python",
|
"type": "python",
|
||||||
@@ -60,6 +100,30 @@
|
|||||||
"justMyCode": true,
|
"justMyCode": true,
|
||||||
"args": ["--debug", "--set", "power.is_power_saving", "1"]
|
"args": ["--debug", "--set", "power.is_power_saving", "1"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "meshtastic debug setPref telemetry.environment_measurement_enabled",
|
||||||
|
"type": "python",
|
||||||
|
"request": "launch",
|
||||||
|
"module": "meshtastic",
|
||||||
|
"justMyCode": true,
|
||||||
|
"args": ["--debug", "--set", "telemetry.environment_measurement_enabled", "1"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "meshtastic debug setPref telemetry.environment_screen_enabled",
|
||||||
|
"type": "python",
|
||||||
|
"request": "launch",
|
||||||
|
"module": "meshtastic",
|
||||||
|
"justMyCode": true,
|
||||||
|
"args": ["--debug", "--set", "telemetry.environment_screen_enabled", "1"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "meshtastic debug setPref telemetry",
|
||||||
|
"type": "python",
|
||||||
|
"request": "launch",
|
||||||
|
"module": "meshtastic",
|
||||||
|
"justMyCode": true,
|
||||||
|
"args": ["--debug", "--set", "telemetry.environment_measurement_enabled", "1"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "meshtastic setpref",
|
"name": "meshtastic setpref",
|
||||||
"type": "python",
|
"type": "python",
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import yaml
|
|||||||
from pubsub import pub
|
from pubsub import pub
|
||||||
import pyqrcode
|
import pyqrcode
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
from google.protobuf.json_format import MessageToDict
|
||||||
import meshtastic.util
|
import meshtastic.util
|
||||||
import meshtastic.test
|
import meshtastic.test
|
||||||
from meshtastic import remote_hardware
|
from meshtastic import remote_hardware
|
||||||
@@ -52,13 +53,10 @@ def onConnection(interface, topic=pub.AUTO_TOPIC): # pylint: disable=W0613
|
|||||||
print(f"Connection changed: {topic.getName()}")
|
print(f"Connection changed: {topic.getName()}")
|
||||||
|
|
||||||
|
|
||||||
def getPref(attributes, comp_name):
|
def getPref(config, comp_name):
|
||||||
"""Get a channel or preferences value"""
|
"""Get a channel or preferences value"""
|
||||||
|
|
||||||
name = comp_name.split(".",1)
|
name = splitCompoundName(comp_name)
|
||||||
if len(name) != 2:
|
|
||||||
name[0]=comp_name
|
|
||||||
name.append(comp_name)
|
|
||||||
|
|
||||||
camel_name = meshtastic.util.snake_to_camel(name[1])
|
camel_name = meshtastic.util.snake_to_camel(name[1])
|
||||||
# Note: protobufs has the keys in snake_case, so snake internally
|
# Note: protobufs has the keys in snake_case, so snake internally
|
||||||
@@ -66,33 +64,17 @@ def getPref(attributes, comp_name):
|
|||||||
logging.debug(f'snake_name:{snake_name} camel_name:{camel_name}')
|
logging.debug(f'snake_name:{snake_name} camel_name:{camel_name}')
|
||||||
logging.debug(f'use camel:{Globals.getInstance().get_camel_case()}')
|
logging.debug(f'use camel:{Globals.getInstance().get_camel_case()}')
|
||||||
|
|
||||||
objDesc = attributes.DESCRIPTOR
|
objDesc = config.DESCRIPTOR
|
||||||
config_type = objDesc.fields_by_name.get(name[0])
|
config_type = objDesc.fields_by_name.get(name[0])
|
||||||
pref = False
|
pref = False
|
||||||
if config_type:
|
if config_type:
|
||||||
pref = config_type.message_type.fields_by_name.get(snake_name)
|
pref = config_type.message_type.fields_by_name.get(snake_name)
|
||||||
|
|
||||||
if (not pref) or (not config_type):
|
if (not pref) or (not config_type):
|
||||||
if Globals.getInstance().get_camel_case():
|
return False
|
||||||
print(f"{attributes.__class__.__name__} does not have an attribute called {name[0]}.{camel_name}, so you can not get it.")
|
|
||||||
else:
|
|
||||||
print(f"{attributes.__class__.__name__} does not have an attribute called {name[0]}.{snake_name}, so you can not get it.")
|
|
||||||
print(f"Choices in sorted order are:")
|
|
||||||
names = []
|
|
||||||
for f in objDesc.fields:
|
|
||||||
tmp_path = f'{f.name}'
|
|
||||||
if(f.message_type):
|
|
||||||
for ff in f.message_type.fields:
|
|
||||||
tmp_name = f'{ff.name}'
|
|
||||||
if Globals.getInstance().get_camel_case():
|
|
||||||
tmp_name = meshtastic.util.snake_to_camel(tmp_name)
|
|
||||||
names.append(tmp_path + "." +tmp_name)
|
|
||||||
for temp_name in sorted(names):
|
|
||||||
print(f" {temp_name}")
|
|
||||||
return
|
|
||||||
|
|
||||||
# read the value
|
# read the value
|
||||||
config_values = getattr(attributes, config_type.name)
|
config_values = getattr(config, config_type.name)
|
||||||
pref_value = getattr(config_values, pref.name)
|
pref_value = getattr(config_values, pref.name)
|
||||||
|
|
||||||
if Globals.getInstance().get_camel_case():
|
if Globals.getInstance().get_camel_case():
|
||||||
@@ -101,52 +83,41 @@ def getPref(attributes, comp_name):
|
|||||||
else:
|
else:
|
||||||
print(f"{str(config_type.name)}.{snake_name}: {str(pref_value)}")
|
print(f"{str(config_type.name)}.{snake_name}: {str(pref_value)}")
|
||||||
logging.debug(f"{str(config_type.name)}.{snake_name}: {str(pref_value)}")
|
logging.debug(f"{str(config_type.name)}.{snake_name}: {str(pref_value)}")
|
||||||
|
return True
|
||||||
|
|
||||||
|
def splitCompoundName(comp_name):
|
||||||
def setPref(attributes, comp_name, valStr):
|
"""Split compound (dot separated) preference name into parts"""
|
||||||
"""Set a channel or preferences value"""
|
|
||||||
|
|
||||||
name = comp_name.split(".",1)
|
name = comp_name.split(".",1)
|
||||||
if len(name) != 2:
|
if len(name) != 2:
|
||||||
name[0]=comp_name
|
name[0]=comp_name
|
||||||
name.append(comp_name)
|
name.append(comp_name)
|
||||||
|
return name
|
||||||
|
|
||||||
|
def setPref(config, comp_name, valStr):
|
||||||
|
"""Set a channel or preferences value"""
|
||||||
|
|
||||||
|
name = splitCompoundName(comp_name)
|
||||||
|
|
||||||
snake_name = meshtastic.util.camel_to_snake(name[1])
|
snake_name = meshtastic.util.camel_to_snake(name[1])
|
||||||
camel_name = meshtastic.util.snake_to_camel(name[1])
|
camel_name = meshtastic.util.snake_to_camel(name[1])
|
||||||
logging.debug(f'snake_name:{snake_name}')
|
logging.debug(f'snake_name:{snake_name}')
|
||||||
logging.debug(f'camel_name:{camel_name}')
|
logging.debug(f'camel_name:{camel_name}')
|
||||||
|
|
||||||
objDesc = attributes.DESCRIPTOR
|
objDesc = config.DESCRIPTOR
|
||||||
config_type = objDesc.fields_by_name.get(name[0])
|
config_type = objDesc.fields_by_name.get(name[0])
|
||||||
pref = False
|
pref = False
|
||||||
if config_type:
|
if config_type:
|
||||||
pref = config_type.message_type.fields_by_name.get(snake_name)
|
pref = config_type.message_type.fields_by_name.get(snake_name)
|
||||||
|
|
||||||
if (not pref) or (not config_type):
|
if (not pref) or (not config_type):
|
||||||
if Globals.getInstance().get_camel_case():
|
return False
|
||||||
print(f"{attributes.__class__.__name__} does not have an attribute called {name[0]}.{camel_name}, so you can not set it.")
|
|
||||||
else:
|
|
||||||
print(f"{attributes.__class__.__name__} does not have an attribute called {name[0]}.{snake_name}, so you can not set it.")
|
|
||||||
print(f"Choices in sorted order are:")
|
|
||||||
names = []
|
|
||||||
for f in objDesc.fields:
|
|
||||||
tmp_path = f'{f.name}'
|
|
||||||
if(f.message_type):
|
|
||||||
for ff in f.message_type.fields:
|
|
||||||
tmp_name = f'{ff.name}'
|
|
||||||
if Globals.getInstance().get_camel_case():
|
|
||||||
tmp_name = meshtastic.util.snake_to_camel(tmp_name)
|
|
||||||
names.append(tmp_path + "." + tmp_name)
|
|
||||||
for temp_name in sorted(names):
|
|
||||||
print(f" {temp_name}")
|
|
||||||
return
|
|
||||||
|
|
||||||
val = meshtastic.util.fromStr(valStr)
|
val = meshtastic.util.fromStr(valStr)
|
||||||
logging.debug(f'valStr:{valStr} val:{val}')
|
logging.debug(f'valStr:{valStr} val:{val}')
|
||||||
|
|
||||||
if snake_name == 'psk' and len(valStr) < 8:
|
if snake_name == 'psk' and len(valStr) < 8:
|
||||||
print(f"Warning: wifi.psk must be 8 or more characters.")
|
print(f"Warning: wifi.psk must be 8 or more characters.")
|
||||||
return
|
return False
|
||||||
|
|
||||||
enumType = pref.enum_type
|
enumType = pref.enum_type
|
||||||
# pylint: disable=C0123
|
# pylint: disable=C0123
|
||||||
@@ -167,16 +138,16 @@ def setPref(attributes, comp_name, valStr):
|
|||||||
names.append(f'{f.name}')
|
names.append(f'{f.name}')
|
||||||
for temp_name in sorted(names):
|
for temp_name in sorted(names):
|
||||||
print(f" {temp_name}")
|
print(f" {temp_name}")
|
||||||
return
|
return False
|
||||||
|
|
||||||
# note: 'ignore_incoming' is a repeating field
|
# note: 'ignore_incoming' is a repeating field
|
||||||
if snake_name != 'ignore_incoming':
|
if snake_name != 'ignore_incoming':
|
||||||
try:
|
try:
|
||||||
config_values = getattr(attributes, config_type.name)
|
config_values = getattr(config, config_type.name)
|
||||||
setattr(config_values, pref.name, val)
|
setattr(config_values, pref.name, val)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
# The setter didn't like our arg type guess try again as a string
|
# The setter didn't like our arg type guess try again as a string
|
||||||
config_values = getattr(attributes, config_type.name)
|
config_values = getattr(config, config_type.name)
|
||||||
setattr(config_values, pref.name, valStr)
|
setattr(config_values, pref.name, valStr)
|
||||||
else:
|
else:
|
||||||
if val == 0:
|
if val == 0:
|
||||||
@@ -192,6 +163,8 @@ def setPref(attributes, comp_name, valStr):
|
|||||||
else:
|
else:
|
||||||
print(f"Set {name[0]}.{snake_name} to {valStr}")
|
print(f"Set {name[0]}.{snake_name} to {valStr}")
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def onConnected(interface):
|
def onConnected(interface):
|
||||||
"""Callback invoked when we connect to a radio"""
|
"""Callback invoked when we connect to a radio"""
|
||||||
@@ -210,18 +183,18 @@ def onConnected(interface):
|
|||||||
alt = 0
|
alt = 0
|
||||||
lat = 0.0
|
lat = 0.0
|
||||||
lon = 0.0
|
lon = 0.0
|
||||||
prefs = interface.localNode.localConfig
|
localConfig = interface.localNode.localConfig
|
||||||
if args.setalt:
|
if args.setalt:
|
||||||
alt = int(args.setalt)
|
alt = int(args.setalt)
|
||||||
prefs.fixed_position = True
|
localConfig.fixed_position = True
|
||||||
print(f"Fixing altitude at {alt} meters")
|
print(f"Fixing altitude at {alt} meters")
|
||||||
if args.setlat:
|
if args.setlat:
|
||||||
lat = float(args.setlat)
|
lat = float(args.setlat)
|
||||||
prefs.fixed_position = True
|
localConfig.fixed_position = True
|
||||||
print(f"Fixing latitude at {lat} degrees")
|
print(f"Fixing latitude at {lat} degrees")
|
||||||
if args.setlon:
|
if args.setlon:
|
||||||
lon = float(args.setlon)
|
lon = float(args.setlon)
|
||||||
prefs.fixed_position = True
|
localConfig.fixed_position = True
|
||||||
print(f"Fixing longitude at {lon} degrees")
|
print(f"Fixing longitude at {lon} degrees")
|
||||||
|
|
||||||
print("Setting device position")
|
print("Setting device position")
|
||||||
@@ -251,7 +224,7 @@ def onConnected(interface):
|
|||||||
if args.pos_fields:
|
if args.pos_fields:
|
||||||
# If --pos-fields invoked with args, set position fields
|
# If --pos-fields invoked with args, set position fields
|
||||||
closeNow = True
|
closeNow = True
|
||||||
prefs = interface.getNode(args.dest).localConfig
|
localConfig = interface.getNode(args.dest).localConfig
|
||||||
allFields = 0
|
allFields = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -266,18 +239,18 @@ def onConnected(interface):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
print(f"Setting position fields to {allFields}")
|
print(f"Setting position fields to {allFields}")
|
||||||
setPref(prefs, 'position_flags', f'{allFields:d}')
|
setPref(localConfig, 'position_flags', f'{allFields:d}')
|
||||||
print("Writing modified preferences to device")
|
print("Writing modified preferences to device")
|
||||||
interface.getNode(args.dest).writeConfig()
|
interface.getNode(args.dest).writeConfig()
|
||||||
|
|
||||||
elif args.pos_fields is not None:
|
elif args.pos_fields is not None:
|
||||||
# If --pos-fields invoked without args, read and display current value
|
# If --pos-fields invoked without args, read and display current value
|
||||||
closeNow = True
|
closeNow = True
|
||||||
prefs = interface.getNode(args.dest).localConfig
|
localConfig = interface.getNode(args.dest).localConfig
|
||||||
|
|
||||||
fieldNames = []
|
fieldNames = []
|
||||||
for bit in config_pb2.PositionFlags.values():
|
for bit in config_pb2.PositionFlags.values():
|
||||||
if prefs.position_flags & bit:
|
if localConfig.position_flags & bit:
|
||||||
fieldNames.append(config_pb2.PositionFlags.Name(bit))
|
fieldNames.append(config_pb2.PositionFlags.Name(bit))
|
||||||
print(' '.join(fieldNames))
|
print(' '.join(fieldNames))
|
||||||
|
|
||||||
@@ -295,6 +268,10 @@ def onConnected(interface):
|
|||||||
if args.shutdown:
|
if args.shutdown:
|
||||||
closeNow = True
|
closeNow = True
|
||||||
interface.getNode(args.dest).shutdown()
|
interface.getNode(args.dest).shutdown()
|
||||||
|
|
||||||
|
if args.device_metadata:
|
||||||
|
closeNow = True
|
||||||
|
interface.getNode(args.dest).getMetadata()
|
||||||
|
|
||||||
if args.sendtext:
|
if args.sendtext:
|
||||||
closeNow = True
|
closeNow = True
|
||||||
@@ -353,14 +330,23 @@ def onConnected(interface):
|
|||||||
# handle settings
|
# handle settings
|
||||||
if args.set:
|
if args.set:
|
||||||
closeNow = True
|
closeNow = True
|
||||||
prefs = interface.getNode(args.dest).localConfig
|
node = interface.getNode(args.dest)
|
||||||
|
|
||||||
# Handle the int/float/bool arguments
|
# Handle the int/float/bool arguments
|
||||||
|
pref = None
|
||||||
for pref in args.set:
|
for pref in args.set:
|
||||||
setPref(prefs, pref[0], pref[1])
|
found = setPref(node.localConfig, pref[0], pref[1])
|
||||||
|
if not found:
|
||||||
|
found = setPref(node.moduleConfig, pref[0], pref[1])
|
||||||
|
|
||||||
print("Writing modified preferences to device")
|
if found:
|
||||||
interface.getNode(args.dest).writeConfig()
|
print("Writing modified preferences to device")
|
||||||
|
interface.getNode(args.dest).writeConfig(splitCompoundName(pref[0].lower())[0])
|
||||||
|
else:
|
||||||
|
if Globals.getInstance().get_camel_case():
|
||||||
|
print(f"{node.localConfig.__class__.__name__} and {node.moduleConfig.__class__.__name__} do not have an attribute {pref[0]}.")
|
||||||
|
else:
|
||||||
|
print(f"{node.localConfig.__class__.__name__} and {node.moduleConfig.__class__.__name__} do not have attribute {pref[0]}.")
|
||||||
|
|
||||||
if args.configure:
|
if args.configure:
|
||||||
with open(args.configure[0], encoding='utf8') as file:
|
with open(args.configure[0], encoding='utf8') as file:
|
||||||
@@ -391,35 +377,35 @@ def onConnected(interface):
|
|||||||
alt = 0
|
alt = 0
|
||||||
lat = 0.0
|
lat = 0.0
|
||||||
lon = 0.0
|
lon = 0.0
|
||||||
prefs = interface.localNode.localConfig
|
localConfig = interface.localNode.localConfig
|
||||||
|
|
||||||
if 'alt' in configuration['location']:
|
if 'alt' in configuration['location']:
|
||||||
alt = int(configuration['location']['alt'])
|
alt = int(configuration['location']['alt'])
|
||||||
prefs.fixed_position = True
|
localConfig.fixed_position = True
|
||||||
print(f"Fixing altitude at {alt} meters")
|
print(f"Fixing altitude at {alt} meters")
|
||||||
if 'lat' in configuration['location']:
|
if 'lat' in configuration['location']:
|
||||||
lat = float(configuration['location']['lat'])
|
lat = float(configuration['location']['lat'])
|
||||||
prefs.fixed_position = True
|
localConfig.fixed_position = True
|
||||||
print(f"Fixing latitude at {lat} degrees")
|
print(f"Fixing latitude at {lat} degrees")
|
||||||
if 'lon' in configuration['location']:
|
if 'lon' in configuration['location']:
|
||||||
lon = float(configuration['location']['lon'])
|
lon = float(configuration['location']['lon'])
|
||||||
prefs.fixed_position = True
|
localConfig.fixed_position = True
|
||||||
print(f"Fixing longitude at {lon} degrees")
|
print(f"Fixing longitude at {lon} degrees")
|
||||||
print("Setting device position")
|
print("Setting device position")
|
||||||
interface.sendPosition(lat, lon, alt)
|
interface.sendPosition(lat, lon, alt)
|
||||||
interface.localNode.writeConfig()
|
interface.localNode.writeConfig()
|
||||||
|
|
||||||
if 'user_prefs' in configuration:
|
if 'user_prefs' in configuration:
|
||||||
prefs = interface.getNode(args.dest).localConfig
|
localConfig = interface.getNode(args.dest).localConfig
|
||||||
for pref in configuration['user_prefs']:
|
for pref in configuration['user_prefs']:
|
||||||
setPref(prefs, pref, str(configuration['user_prefs'][pref]))
|
setPref(localConfig, pref, str(configuration['user_prefs'][pref]))
|
||||||
print("Writing modified preferences to device")
|
print("Writing modified preferences to device")
|
||||||
interface.getNode(args.dest).writeConfig()
|
interface.getNode(args.dest).writeConfig()
|
||||||
|
|
||||||
if 'userPrefs' in configuration:
|
if 'userPrefs' in configuration:
|
||||||
prefs = interface.getNode(args.dest).localConfig
|
localConfig = interface.getNode(args.dest).localConfig
|
||||||
for pref in configuration['userPrefs']:
|
for pref in configuration['userPrefs']:
|
||||||
setPref(prefs, pref, str(configuration['userPrefs'][pref]))
|
setPref(localConfig, pref, str(configuration['userPrefs'][pref]))
|
||||||
print("Writing modified preferences to device")
|
print("Writing modified preferences to device")
|
||||||
interface.getNode(args.dest).writeConfig()
|
interface.getNode(args.dest).writeConfig()
|
||||||
|
|
||||||
@@ -470,12 +456,10 @@ def onConnected(interface):
|
|||||||
|
|
||||||
def setSimpleConfig(modem_preset):
|
def setSimpleConfig(modem_preset):
|
||||||
"""Set one of the simple modem_config"""
|
"""Set one of the simple modem_config"""
|
||||||
# Completely new radio settings
|
# Overwrite modem_preset
|
||||||
chs = config_pb2.Config.LoRaConfig()
|
|
||||||
chs.modem_preset = modem_preset
|
|
||||||
prefs = interface.getNode(args.dest).localConfig
|
prefs = interface.getNode(args.dest).localConfig
|
||||||
prefs.lora.CopyFrom(chs)
|
prefs.lora.modem_preset = modem_preset
|
||||||
interface.getNode(args.dest).writeConfig()
|
interface.getNode(args.dest).writeConfig('lora')
|
||||||
|
|
||||||
# handle the simple radio set commands
|
# handle the simple radio set commands
|
||||||
if args.ch_vlongslow:
|
if args.ch_vlongslow:
|
||||||
@@ -553,11 +537,20 @@ def onConnected(interface):
|
|||||||
|
|
||||||
if args.get:
|
if args.get:
|
||||||
closeNow = True
|
closeNow = True
|
||||||
prefs = interface.getNode(args.dest).localConfig
|
localConfig = interface.getNode(args.dest).localConfig
|
||||||
|
moduleConfig = interface.getNode(args.dest).moduleConfig
|
||||||
|
|
||||||
# Handle the int/float/bool arguments
|
# Handle the int/float/bool arguments
|
||||||
for pref in args.get:
|
for pref in args.get:
|
||||||
getPref(prefs, pref[0])
|
found = getPref(localConfig, pref[0])
|
||||||
|
if not found:
|
||||||
|
found = getPref(moduleConfig, pref[0])
|
||||||
|
|
||||||
|
if not found:
|
||||||
|
if Globals.getInstance().get_camel_case():
|
||||||
|
print(f"{localConfig.__class__.__name__} and {moduleConfig.__class__.__name__} do not have an attribute {pref[0]}.")
|
||||||
|
else:
|
||||||
|
print(f"{localConfig.__class__.__name__} and {moduleConfig.__class__.__name__} do not have attribute {pref[0]}.")
|
||||||
|
|
||||||
print("Completed getting preferences")
|
print("Completed getting preferences")
|
||||||
|
|
||||||
@@ -610,6 +603,8 @@ def subscribe():
|
|||||||
|
|
||||||
def export_config(interface):
|
def export_config(interface):
|
||||||
"""used in--export-config"""
|
"""used in--export-config"""
|
||||||
|
configObj = {}
|
||||||
|
|
||||||
owner = interface.getLongName()
|
owner = interface.getLongName()
|
||||||
owner_short = interface.getShortName()
|
owner_short = interface.getShortName()
|
||||||
channel_url = interface.localNode.getURL()
|
channel_url = interface.localNode.getURL()
|
||||||
@@ -623,38 +618,34 @@ def export_config(interface):
|
|||||||
lon = pos.get('longitude')
|
lon = pos.get('longitude')
|
||||||
alt = pos.get('altitude')
|
alt = pos.get('altitude')
|
||||||
|
|
||||||
config = "# start of Meshtastic configure yaml\n"
|
|
||||||
if owner:
|
if owner:
|
||||||
config += f"owner: {owner}\n\n"
|
configObj["owner"] = owner
|
||||||
if owner_short:
|
if owner_short:
|
||||||
config += f"owner_short: {owner_short}\n\n"
|
configObj["owner_short"] = owner_short
|
||||||
if channel_url:
|
if channel_url:
|
||||||
if Globals.getInstance().get_camel_case():
|
if Globals.getInstance().get_camel_case():
|
||||||
config += f"channelUrl: {channel_url}\n\n"
|
configObj["channelUrl"] = channel_url
|
||||||
else:
|
else:
|
||||||
config += f"channel_url: {channel_url}\n\n"
|
configObj["channel_url"] = channel_url
|
||||||
if lat or lon or alt:
|
if lat or lon or alt:
|
||||||
config += "location:\n"
|
configObj["location"] = { "lat": lat, "lon": lon, "alt": alt }
|
||||||
if lat:
|
preferences = MessageToDict(interface.localNode.localConfig)
|
||||||
config += f" lat: {lat}\n"
|
if preferences:
|
||||||
if lon:
|
# Convert inner keys to correct snake/camelCase
|
||||||
config += f" lon: {lon}\n"
|
prefs = {}
|
||||||
if alt:
|
for pref in preferences:
|
||||||
config += f" alt: {alt}\n"
|
|
||||||
config += "\n"
|
|
||||||
preferences = f'{interface.localNode.localConfig}'
|
|
||||||
prefs = preferences.splitlines()
|
|
||||||
if prefs:
|
|
||||||
if Globals.getInstance().get_camel_case():
|
|
||||||
config += "userPrefs:\n"
|
|
||||||
else:
|
|
||||||
config += "user_prefs:\n"
|
|
||||||
for pref in prefs:
|
|
||||||
if Globals.getInstance().get_camel_case():
|
if Globals.getInstance().get_camel_case():
|
||||||
# Note: This may not work if the value has '_'
|
prefs[meshtastic.util.snake_to_camel(pref)] = preferences[pref]
|
||||||
config += f" {meshtastic.util.snake_to_camel(meshtastic.util.quoteBooleans(pref))}\n"
|
|
||||||
else:
|
else:
|
||||||
config += f" {meshtastic.util.quoteBooleans(pref)}\n"
|
# TODO: Possibly convert camel to snake?
|
||||||
|
prefs[pref] = preferences[pref]
|
||||||
|
if Globals.getInstance().get_camel_case():
|
||||||
|
configObj["userPrefs"] = preferences
|
||||||
|
else:
|
||||||
|
configObj["user_prefs"] = preferences
|
||||||
|
|
||||||
|
config = "# start of Meshtastic configure yaml\n"
|
||||||
|
config += yaml.dump(configObj)
|
||||||
print(config)
|
print(config)
|
||||||
return config
|
return config
|
||||||
|
|
||||||
@@ -868,6 +859,9 @@ def initParser():
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--shutdown", help="Tell the destination node to shutdown", action="store_true")
|
"--shutdown", help="Tell the destination node to shutdown", action="store_true")
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"--device-metadata", help="Get the device metadata from the node", action="store_true")
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--reply", help="Reply to received messages",
|
"--reply", help="Reply to received messages",
|
||||||
action="store_true")
|
action="store_true")
|
||||||
|
|||||||
@@ -14,11 +14,12 @@ _sym_db = _symbol_database.Default()
|
|||||||
|
|
||||||
from . import channel_pb2 as channel__pb2
|
from . import channel_pb2 as channel__pb2
|
||||||
from . import config_pb2 as config__pb2
|
from . import config_pb2 as config__pb2
|
||||||
|
from . import device_metadata_pb2 as device__metadata__pb2
|
||||||
from . import mesh_pb2 as mesh__pb2
|
from . import mesh_pb2 as mesh__pb2
|
||||||
from . import module_config_pb2 as module__config__pb2
|
from . import module_config_pb2 as module__config__pb2
|
||||||
|
|
||||||
|
|
||||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0b\x61\x64min.proto\x1a\rchannel.proto\x1a\x0c\x63onfig.proto\x1a\nmesh.proto\x1a\x13module_config.proto\"\xc4\x0c\n\x0c\x41\x64minMessage\x12\x1a\n\tset_owner\x18\x02 \x01(\x0b\x32\x05.UserH\x00\x12\x1f\n\x0bset_channel\x18\x03 \x01(\x0b\x32\x08.ChannelH\x00\x12\x1d\n\x13get_channel_request\x18\x06 \x01(\rH\x00\x12(\n\x14get_channel_response\x18\x07 \x01(\x0b\x32\x08.ChannelH\x00\x12\x1b\n\x11get_owner_request\x18\x08 \x01(\x08H\x00\x12#\n\x12get_owner_response\x18\t \x01(\x0b\x32\x05.UserH\x00\x12\x36\n\x12get_config_request\x18\n \x01(\x0e\x32\x18.AdminMessage.ConfigTypeH\x00\x12&\n\x13get_config_response\x18\x0b \x01(\x0b\x32\x07.ConfigH\x00\x12\x1d\n\nset_config\x18\x0c \x01(\x0b\x32\x07.ConfigH\x00\x12\x1c\n\x12\x63onfirm_set_config\x18\r \x01(\x08H\x00\x12\x43\n\x19get_module_config_request\x18\x0e \x01(\x0e\x32\x1e.AdminMessage.ModuleConfigTypeH\x00\x12\x33\n\x1aget_module_config_response\x18\x0f \x01(\x0b\x32\r.ModuleConfigH\x00\x12*\n\x11set_module_config\x18\x10 \x01(\x0b\x32\r.ModuleConfigH\x00\x12#\n\x19\x63onfirm_set_module_config\x18\x11 \x01(\x08H\x00\x12\x1d\n\x13\x63onfirm_set_channel\x18 \x01(\x08H\x00\x12\x1b\n\x11\x63onfirm_set_radio\x18! \x01(\x08H\x00\x12\x18\n\x0e\x65xit_simulator\x18\" \x01(\x08H\x00\x12\x18\n\x0ereboot_seconds\x18# \x01(\x05H\x00\x12\x31\n\'get_canned_message_module_part1_request\x18$ \x01(\x08H\x00\x12\x32\n(get_canned_message_module_part1_response\x18% \x01(\tH\x00\x12\x31\n\'get_canned_message_module_part2_request\x18& \x01(\x08H\x00\x12\x32\n(get_canned_message_module_part2_response\x18\' \x01(\tH\x00\x12\x31\n\'get_canned_message_module_part3_request\x18( \x01(\x08H\x00\x12\x32\n(get_canned_message_module_part3_response\x18) \x01(\tH\x00\x12\x31\n\'get_canned_message_module_part4_request\x18* \x01(\x08H\x00\x12\x32\n(get_canned_message_module_part4_response\x18+ \x01(\tH\x00\x12)\n\x1fset_canned_message_module_part1\x18, \x01(\tH\x00\x12)\n\x1fset_canned_message_module_part2\x18- \x01(\tH\x00\x12)\n\x1fset_canned_message_module_part3\x18. \x01(\tH\x00\x12)\n\x1fset_canned_message_module_part4\x18/ \x01(\tH\x00\x12\x1a\n\x10shutdown_seconds\x18\x33 \x01(\x05H\x00\"|\n\nConfigType\x12\x11\n\rDEVICE_CONFIG\x10\x00\x12\x13\n\x0fPOSITION_CONFIG\x10\x01\x12\x10\n\x0cPOWER_CONFIG\x10\x02\x12\x0f\n\x0bWIFI_CONFIG\x10\x03\x12\x12\n\x0e\x44ISPLAY_CONFIG\x10\x04\x12\x0f\n\x0bLORA_CONFIG\x10\x05\"\xa6\x01\n\x10ModuleConfigType\x12\x0f\n\x0bMQTT_CONFIG\x10\x00\x12\x11\n\rSERIAL_CONFIG\x10\x01\x12\x13\n\x0f\x45XTNOTIF_CONFIG\x10\x02\x12\x17\n\x13STOREFORWARD_CONFIG\x10\x03\x12\x14\n\x10RANGETEST_CONFIG\x10\x04\x12\x14\n\x10TELEMETRY_CONFIG\x10\x05\x12\x14\n\x10\x43\x41NNEDMSG_CONFIG\x10\x06\x42\t\n\x07variantBG\n\x13\x63om.geeksville.meshB\x0b\x41\x64minProtosH\x03Z!github.com/meshtastic/gomeshprotob\x06proto3')
|
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0b\x61\x64min.proto\x1a\rchannel.proto\x1a\x0c\x63onfig.proto\x1a\x15\x64\x65vice_metadata.proto\x1a\nmesh.proto\x1a\x13module_config.proto\"\xb1\n\n\x0c\x41\x64minMessage\x12\x1a\n\tset_owner\x18\x02 \x01(\x0b\x32\x05.UserH\x00\x12\x1f\n\x0bset_channel\x18\x03 \x01(\x0b\x32\x08.ChannelH\x00\x12\x1d\n\x13get_channel_request\x18\x06 \x01(\rH\x00\x12(\n\x14get_channel_response\x18\x07 \x01(\x0b\x32\x08.ChannelH\x00\x12\x1b\n\x11get_owner_request\x18\x08 \x01(\x08H\x00\x12#\n\x12get_owner_response\x18\t \x01(\x0b\x32\x05.UserH\x00\x12\x36\n\x12get_config_request\x18\n \x01(\x0e\x32\x18.AdminMessage.ConfigTypeH\x00\x12&\n\x13get_config_response\x18\x0b \x01(\x0b\x32\x07.ConfigH\x00\x12\x1d\n\nset_config\x18\x0c \x01(\x0b\x32\x07.ConfigH\x00\x12\x1c\n\x12\x63onfirm_set_config\x18\r \x01(\x08H\x00\x12\x43\n\x19get_module_config_request\x18\x0e \x01(\x0e\x32\x1e.AdminMessage.ModuleConfigTypeH\x00\x12\x33\n\x1aget_module_config_response\x18\x0f \x01(\x0b\x32\r.ModuleConfigH\x00\x12*\n\x11set_module_config\x18\x10 \x01(\x0b\x32\r.ModuleConfigH\x00\x12#\n\x19\x63onfirm_set_module_config\x18\x11 \x01(\x08H\x00\x12!\n\x17get_all_channel_request\x18\x12 \x01(\x08H\x00\x12\x1d\n\x13\x63onfirm_set_channel\x18 \x01(\x08H\x00\x12\x1b\n\x11\x63onfirm_set_radio\x18! \x01(\x08H\x00\x12\x18\n\x0e\x65xit_simulator\x18\" \x01(\x08H\x00\x12\x18\n\x0ereboot_seconds\x18# \x01(\x05H\x00\x12\x34\n*get_canned_message_module_messages_request\x18$ \x01(\x08H\x00\x12\x35\n+get_canned_message_module_messages_response\x18% \x01(\tH\x00\x12,\n\"set_canned_message_module_messages\x18, \x01(\tH\x00\x12\x1a\n\x10shutdown_seconds\x18\x33 \x01(\x05H\x00\x12%\n\x1bget_device_metadata_request\x18\x34 \x01(\rH\x00\x12\x37\n\x1cget_device_metadata_response\x18\x35 \x01(\x0b\x32\x0f.DeviceMetadataH\x00\"\x92\x01\n\nConfigType\x12\x11\n\rDEVICE_CONFIG\x10\x00\x12\x13\n\x0fPOSITION_CONFIG\x10\x01\x12\x10\n\x0cPOWER_CONFIG\x10\x02\x12\x0f\n\x0bWIFI_CONFIG\x10\x03\x12\x12\n\x0e\x44ISPLAY_CONFIG\x10\x04\x12\x0f\n\x0bLORA_CONFIG\x10\x05\x12\x14\n\x10\x42LUETOOTH_CONFIG\x10\x06\"\xa6\x01\n\x10ModuleConfigType\x12\x0f\n\x0bMQTT_CONFIG\x10\x00\x12\x11\n\rSERIAL_CONFIG\x10\x01\x12\x13\n\x0f\x45XTNOTIF_CONFIG\x10\x02\x12\x17\n\x13STOREFORWARD_CONFIG\x10\x03\x12\x14\n\x10RANGETEST_CONFIG\x10\x04\x12\x14\n\x10TELEMETRY_CONFIG\x10\x05\x12\x14\n\x10\x43\x41NNEDMSG_CONFIG\x10\x06\x42\t\n\x07variantBG\n\x13\x63om.geeksville.meshB\x0b\x41\x64minProtosH\x03Z!github.com/meshtastic/gomeshprotob\x06proto3')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -36,10 +37,10 @@ if _descriptor._USE_C_DESCRIPTORS == False:
|
|||||||
|
|
||||||
DESCRIPTOR._options = None
|
DESCRIPTOR._options = None
|
||||||
DESCRIPTOR._serialized_options = b'\n\023com.geeksville.meshB\013AdminProtosH\003Z!github.com/meshtastic/gomeshproto'
|
DESCRIPTOR._serialized_options = b'\n\023com.geeksville.meshB\013AdminProtosH\003Z!github.com/meshtastic/gomeshproto'
|
||||||
_ADMINMESSAGE._serialized_start=78
|
_ADMINMESSAGE._serialized_start=101
|
||||||
_ADMINMESSAGE._serialized_end=1682
|
_ADMINMESSAGE._serialized_end=1430
|
||||||
_ADMINMESSAGE_CONFIGTYPE._serialized_start=1378
|
_ADMINMESSAGE_CONFIGTYPE._serialized_start=1104
|
||||||
_ADMINMESSAGE_CONFIGTYPE._serialized_end=1502
|
_ADMINMESSAGE_CONFIGTYPE._serialized_end=1250
|
||||||
_ADMINMESSAGE_MODULECONFIGTYPE._serialized_start=1505
|
_ADMINMESSAGE_MODULECONFIGTYPE._serialized_start=1253
|
||||||
_ADMINMESSAGE_MODULECONFIGTYPE._serialized_end=1671
|
_ADMINMESSAGE_MODULECONFIGTYPE._serialized_end=1419
|
||||||
# @@protoc_insertion_point(module_scope)
|
# @@protoc_insertion_point(module_scope)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ _sym_db = _symbol_database.Default()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x14\x63\x61nnedmessages.proto\"w\n\x19\x43\x61nnedMessageModuleConfig\x12\x15\n\rmessagesPart1\x18\x0b \x01(\t\x12\x15\n\rmessagesPart2\x18\x0c \x01(\t\x12\x15\n\rmessagesPart3\x18\r \x01(\t\x12\x15\n\rmessagesPart4\x18\x0e \x01(\tBU\n\x13\x63om.geeksville.meshB\x19\x43\x61nnedMessageConfigProtosH\x03Z!github.com/meshtastic/gomeshprotob\x06proto3')
|
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x14\x63\x61nnedmessages.proto\"-\n\x19\x43\x61nnedMessageModuleConfig\x12\x10\n\x08messages\x18\x01 \x01(\tBU\n\x13\x63om.geeksville.meshB\x19\x43\x61nnedMessageConfigProtosH\x03Z!github.com/meshtastic/gomeshprotob\x06proto3')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -31,5 +31,5 @@ if _descriptor._USE_C_DESCRIPTORS == False:
|
|||||||
DESCRIPTOR._options = None
|
DESCRIPTOR._options = None
|
||||||
DESCRIPTOR._serialized_options = b'\n\023com.geeksville.meshB\031CannedMessageConfigProtosH\003Z!github.com/meshtastic/gomeshproto'
|
DESCRIPTOR._serialized_options = b'\n\023com.geeksville.meshB\031CannedMessageConfigProtosH\003Z!github.com/meshtastic/gomeshproto'
|
||||||
_CANNEDMESSAGEMODULECONFIG._serialized_start=24
|
_CANNEDMESSAGEMODULECONFIG._serialized_start=24
|
||||||
_CANNEDMESSAGEMODULECONFIG._serialized_end=143
|
_CANNEDMESSAGEMODULECONFIG._serialized_end=69
|
||||||
# @@protoc_insertion_point(module_scope)
|
# @@protoc_insertion_point(module_scope)
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
35
meshtastic/device_metadata_pb2.py
Normal file
35
meshtastic/device_metadata_pb2.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||||
|
# source: device_metadata.proto
|
||||||
|
"""Generated protocol buffer code."""
|
||||||
|
from google.protobuf import descriptor as _descriptor
|
||||||
|
from google.protobuf import descriptor_pool as _descriptor_pool
|
||||||
|
from google.protobuf import message as _message
|
||||||
|
from google.protobuf import reflection as _reflection
|
||||||
|
from google.protobuf import symbol_database as _symbol_database
|
||||||
|
# @@protoc_insertion_point(imports)
|
||||||
|
|
||||||
|
_sym_db = _symbol_database.Default()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x15\x64\x65vice_metadata.proto\"H\n\x0e\x44\x65viceMetadata\x12\x18\n\x10\x66irmware_version\x18\x01 \x01(\t\x12\x1c\n\x14\x64\x65vice_state_version\x18\x02 \x01(\rBP\n\x13\x63om.geeksville.meshB\x14\x44\x65viceMetadataProtosH\x03Z!github.com/meshtastic/gomeshprotob\x06proto3')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
_DEVICEMETADATA = DESCRIPTOR.message_types_by_name['DeviceMetadata']
|
||||||
|
DeviceMetadata = _reflection.GeneratedProtocolMessageType('DeviceMetadata', (_message.Message,), {
|
||||||
|
'DESCRIPTOR' : _DEVICEMETADATA,
|
||||||
|
'__module__' : 'device_metadata_pb2'
|
||||||
|
# @@protoc_insertion_point(class_scope:DeviceMetadata)
|
||||||
|
})
|
||||||
|
_sym_db.RegisterMessage(DeviceMetadata)
|
||||||
|
|
||||||
|
if _descriptor._USE_C_DESCRIPTORS == False:
|
||||||
|
|
||||||
|
DESCRIPTOR._options = None
|
||||||
|
DESCRIPTOR._serialized_options = b'\n\023com.geeksville.meshB\024DeviceMetadataProtosH\003Z!github.com/meshtastic/gomeshproto'
|
||||||
|
_DEVICEMETADATA._serialized_start=25
|
||||||
|
_DEVICEMETADATA._serialized_end=97
|
||||||
|
# @@protoc_insertion_point(module_scope)
|
||||||
@@ -16,7 +16,7 @@ from . import config_pb2 as config__pb2
|
|||||||
from . import module_config_pb2 as module__config__pb2
|
from . import module_config_pb2 as module__config__pb2
|
||||||
|
|
||||||
|
|
||||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0flocalonly.proto\x1a\x0c\x63onfig.proto\x1a\x13module_config.proto\"\xfe\x01\n\x0bLocalConfig\x12$\n\x06\x64\x65vice\x18\x01 \x01(\x0b\x32\x14.Config.DeviceConfig\x12(\n\x08position\x18\x02 \x01(\x0b\x32\x16.Config.PositionConfig\x12\"\n\x05power\x18\x03 \x01(\x0b\x32\x13.Config.PowerConfig\x12 \n\x04wifi\x18\x04 \x01(\x0b\x32\x12.Config.WiFiConfig\x12&\n\x07\x64isplay\x18\x05 \x01(\x0b\x32\x15.Config.DisplayConfig\x12 \n\x04lora\x18\x06 \x01(\x0b\x32\x12.Config.LoRaConfig\x12\x0f\n\x07version\x18\x07 \x01(\r\"\x9a\x03\n\x11LocalModuleConfig\x12&\n\x04mqtt\x18\x01 \x01(\x0b\x32\x18.ModuleConfig.MQTTConfig\x12*\n\x06serial\x18\x02 \x01(\x0b\x32\x1a.ModuleConfig.SerialConfig\x12G\n\x15\x65xternal_notification\x18\x03 \x01(\x0b\x32(.ModuleConfig.ExternalNotificationConfig\x12\x37\n\rstore_forward\x18\x04 \x01(\x0b\x32 .ModuleConfig.StoreForwardConfig\x12\x31\n\nrange_test\x18\x05 \x01(\x0b\x32\x1d.ModuleConfig.RangeTestConfig\x12\x30\n\ttelemetry\x18\x06 \x01(\x0b\x32\x1d.ModuleConfig.TelemetryConfig\x12\x39\n\x0e\x63\x61nned_message\x18\x07 \x01(\x0b\x32!.ModuleConfig.CannedMessageConfig\x12\x0f\n\x07version\x18\x08 \x01(\rBK\n\x13\x63om.geeksville.meshB\x0fLocalOnlyProtosH\x03Z!github.com/meshtastic/gomeshprotob\x06proto3')
|
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0flocalonly.proto\x1a\x0c\x63onfig.proto\x1a\x13module_config.proto\"\xaa\x02\n\x0bLocalConfig\x12$\n\x06\x64\x65vice\x18\x01 \x01(\x0b\x32\x14.Config.DeviceConfig\x12(\n\x08position\x18\x02 \x01(\x0b\x32\x16.Config.PositionConfig\x12\"\n\x05power\x18\x03 \x01(\x0b\x32\x13.Config.PowerConfig\x12 \n\x04wifi\x18\x04 \x01(\x0b\x32\x12.Config.WiFiConfig\x12&\n\x07\x64isplay\x18\x05 \x01(\x0b\x32\x15.Config.DisplayConfig\x12 \n\x04lora\x18\x06 \x01(\x0b\x32\x12.Config.LoRaConfig\x12*\n\tbluetooth\x18\x07 \x01(\x0b\x32\x17.Config.BluetoothConfig\x12\x0f\n\x07version\x18\x08 \x01(\r\"\x9a\x03\n\x11LocalModuleConfig\x12&\n\x04mqtt\x18\x01 \x01(\x0b\x32\x18.ModuleConfig.MQTTConfig\x12*\n\x06serial\x18\x02 \x01(\x0b\x32\x1a.ModuleConfig.SerialConfig\x12G\n\x15\x65xternal_notification\x18\x03 \x01(\x0b\x32(.ModuleConfig.ExternalNotificationConfig\x12\x37\n\rstore_forward\x18\x04 \x01(\x0b\x32 .ModuleConfig.StoreForwardConfig\x12\x31\n\nrange_test\x18\x05 \x01(\x0b\x32\x1d.ModuleConfig.RangeTestConfig\x12\x30\n\ttelemetry\x18\x06 \x01(\x0b\x32\x1d.ModuleConfig.TelemetryConfig\x12\x39\n\x0e\x63\x61nned_message\x18\x07 \x01(\x0b\x32!.ModuleConfig.CannedMessageConfig\x12\x0f\n\x07version\x18\x08 \x01(\rBK\n\x13\x63om.geeksville.meshB\x0fLocalOnlyProtosH\x03Z!github.com/meshtastic/gomeshprotob\x06proto3')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ if _descriptor._USE_C_DESCRIPTORS == False:
|
|||||||
DESCRIPTOR._options = None
|
DESCRIPTOR._options = None
|
||||||
DESCRIPTOR._serialized_options = b'\n\023com.geeksville.meshB\017LocalOnlyProtosH\003Z!github.com/meshtastic/gomeshproto'
|
DESCRIPTOR._serialized_options = b'\n\023com.geeksville.meshB\017LocalOnlyProtosH\003Z!github.com/meshtastic/gomeshproto'
|
||||||
_LOCALCONFIG._serialized_start=55
|
_LOCALCONFIG._serialized_start=55
|
||||||
_LOCALCONFIG._serialized_end=309
|
_LOCALCONFIG._serialized_end=353
|
||||||
_LOCALMODULECONFIG._serialized_start=312
|
_LOCALMODULECONFIG._serialized_start=356
|
||||||
_LOCALMODULECONFIG._serialized_end=722
|
_LOCALMODULECONFIG._serialized_end=766
|
||||||
# @@protoc_insertion_point(module_scope)
|
# @@protoc_insertion_point(module_scope)
|
||||||
|
|||||||
@@ -532,15 +532,18 @@ class MeshInterface:
|
|||||||
# stream API fromRadio.config_complete_id
|
# stream API fromRadio.config_complete_id
|
||||||
logging.debug(f"Config complete ID {self.configId}")
|
logging.debug(f"Config complete ID {self.configId}")
|
||||||
self._handleConfigComplete()
|
self._handleConfigComplete()
|
||||||
|
|
||||||
elif fromRadio.HasField("packet"):
|
elif fromRadio.HasField("packet"):
|
||||||
self._handlePacketFromRadio(fromRadio.packet)
|
self._handlePacketFromRadio(fromRadio.packet)
|
||||||
|
|
||||||
elif fromRadio.rebooted:
|
elif fromRadio.rebooted:
|
||||||
# Tell clients the device went away. Careful not to call the overridden
|
# Tell clients the device went away. Careful not to call the overridden
|
||||||
# subclass version that closes the serial port
|
# subclass version that closes the serial port
|
||||||
MeshInterface._disconnected(self)
|
MeshInterface._disconnected(self)
|
||||||
|
|
||||||
self._startConfig() # redownload the node db etc...
|
self._startConfig() # redownload the node db etc...
|
||||||
elif fromRadio.config:
|
|
||||||
|
elif fromRadio.config or fromRadio.moduleConfig:
|
||||||
if fromRadio.config.HasField("device"):
|
if fromRadio.config.HasField("device"):
|
||||||
self.localNode.localConfig.device.CopyFrom(fromRadio.config.device)
|
self.localNode.localConfig.device.CopyFrom(fromRadio.config.device)
|
||||||
elif fromRadio.config.HasField("position"):
|
elif fromRadio.config.HasField("position"):
|
||||||
@@ -553,6 +556,22 @@ class MeshInterface:
|
|||||||
self.localNode.localConfig.display.CopyFrom(fromRadio.config.display)
|
self.localNode.localConfig.display.CopyFrom(fromRadio.config.display)
|
||||||
elif fromRadio.config.HasField("lora"):
|
elif fromRadio.config.HasField("lora"):
|
||||||
self.localNode.localConfig.lora.CopyFrom(fromRadio.config.lora)
|
self.localNode.localConfig.lora.CopyFrom(fromRadio.config.lora)
|
||||||
|
elif fromRadio.config.HasField("bluetooth"):
|
||||||
|
self.localNode.localConfig.bluetooth.CopyFrom(fromRadio.config.bluetooth)
|
||||||
|
|
||||||
|
elif fromRadio.moduleConfig.HasField("mqtt"):
|
||||||
|
self.localNode.moduleConfig.mqtt.CopyFrom(fromRadio.moduleConfig.mqtt)
|
||||||
|
elif fromRadio.moduleConfig.HasField("serial"):
|
||||||
|
self.localNode.moduleConfig.serial.CopyFrom(fromRadio.moduleConfig.serial)
|
||||||
|
elif fromRadio.moduleConfig.HasField("external_notification"):
|
||||||
|
self.localNode.moduleConfig.external_notification.CopyFrom(fromRadio.moduleConfig.external_notification)
|
||||||
|
elif fromRadio.moduleConfig.HasField("range_test"):
|
||||||
|
self.localNode.moduleConfig.range_test.CopyFrom(fromRadio.moduleConfig.range_test)
|
||||||
|
elif fromRadio.moduleConfig.HasField("telemetry"):
|
||||||
|
self.localNode.moduleConfig.telemetry.CopyFrom(fromRadio.moduleConfig.telemetry)
|
||||||
|
elif fromRadio.moduleConfig.HasField("canned_message"):
|
||||||
|
self.localNode.moduleConfig.canned_message.CopyFrom(fromRadio.moduleConfig.canned_message)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logging.debug("Unexpected FromRadio payload")
|
logging.debug("Unexpected FromRadio payload")
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -15,7 +15,7 @@ _sym_db = _symbol_database.Default()
|
|||||||
from . import telemetry_pb2 as telemetry__pb2
|
from . import telemetry_pb2 as telemetry__pb2
|
||||||
|
|
||||||
|
|
||||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x13module_config.proto\x1a\x0ftelemetry.proto\"\xd7\x12\n\x0cModuleConfig\x12(\n\x04mqtt\x18\x01 \x01(\x0b\x32\x18.ModuleConfig.MQTTConfigH\x00\x12,\n\x06serial\x18\x02 \x01(\x0b\x32\x1a.ModuleConfig.SerialConfigH\x00\x12I\n\x15\x65xternal_notification\x18\x03 \x01(\x0b\x32(.ModuleConfig.ExternalNotificationConfigH\x00\x12\x39\n\rstore_forward\x18\x04 \x01(\x0b\x32 .ModuleConfig.StoreForwardConfigH\x00\x12\x33\n\nrange_test\x18\x05 \x01(\x0b\x32\x1d.ModuleConfig.RangeTestConfigH\x00\x12\x32\n\ttelemetry\x18\x06 \x01(\x0b\x32\x1d.ModuleConfig.TelemetryConfigH\x00\x12;\n\x0e\x63\x61nned_message\x18\x07 \x01(\x0b\x32!.ModuleConfig.CannedMessageConfigH\x00\x1ao\n\nMQTTConfig\x12\x10\n\x08\x64isabled\x18\x01 \x01(\x08\x12\x0f\n\x07\x61\x64\x64ress\x18\x02 \x01(\t\x12\x10\n\x08username\x18\x03 \x01(\t\x12\x10\n\x08password\x18\x04 \x01(\t\x12\x1a\n\x12\x65ncryption_enabled\x18\x05 \x01(\x08\x1a\x93\x04\n\x0cSerialConfig\x12\x0f\n\x07\x65nabled\x18\x01 \x01(\x08\x12\x0c\n\x04\x65\x63ho\x18\x02 \x01(\x08\x12\x0b\n\x03rxd\x18\x03 \x01(\r\x12\x0b\n\x03txd\x18\x04 \x01(\r\x12\x34\n\x04\x62\x61ud\x18\x05 \x01(\x0e\x32&.ModuleConfig.SerialConfig.Serial_Baud\x12\x0f\n\x07timeout\x18\x06 \x01(\r\x12\x34\n\x04mode\x18\x07 \x01(\x0e\x32&.ModuleConfig.SerialConfig.Serial_Mode\"\x8a\x02\n\x0bSerial_Baud\x12\x10\n\x0c\x42\x41UD_Default\x10\x00\x12\x0c\n\x08\x42\x41UD_110\x10\x01\x12\x0c\n\x08\x42\x41UD_300\x10\x02\x12\x0c\n\x08\x42\x41UD_600\x10\x03\x12\r\n\tBAUD_1200\x10\x04\x12\r\n\tBAUD_2400\x10\x05\x12\r\n\tBAUD_4800\x10\x06\x12\r\n\tBAUD_9600\x10\x07\x12\x0e\n\nBAUD_19200\x10\x08\x12\x0e\n\nBAUD_38400\x10\t\x12\x0e\n\nBAUD_57600\x10\n\x12\x0f\n\x0b\x42\x41UD_115200\x10\x0b\x12\x0f\n\x0b\x42\x41UD_230400\x10\x0c\x12\x0f\n\x0b\x42\x41UD_460800\x10\r\x12\x0f\n\x0b\x42\x41UD_576000\x10\x0e\x12\x0f\n\x0b\x42\x41UD_921600\x10\x0f\"@\n\x0bSerial_Mode\x12\x10\n\x0cMODE_Default\x10\x00\x12\x0f\n\x0bMODE_SIMPLE\x10\x01\x12\x0e\n\nMODE_PROTO\x10\x02\x1a\x8b\x01\n\x1a\x45xternalNotificationConfig\x12\x0f\n\x07\x65nabled\x18\x01 \x01(\x08\x12\x11\n\toutput_ms\x18\x02 \x01(\r\x12\x0e\n\x06output\x18\x03 \x01(\r\x12\x0e\n\x06\x61\x63tive\x18\x04 \x01(\x08\x12\x15\n\ralert_message\x18\x05 \x01(\x08\x12\x12\n\nalert_bell\x18\x06 \x01(\x08\x1a\x84\x01\n\x12StoreForwardConfig\x12\x0f\n\x07\x65nabled\x18\x01 \x01(\x08\x12\x11\n\theartbeat\x18\x02 \x01(\x08\x12\x0f\n\x07records\x18\x03 \x01(\r\x12\x1a\n\x12history_return_max\x18\x04 \x01(\r\x12\x1d\n\x15history_return_window\x18\x05 \x01(\r\x1a@\n\x0fRangeTestConfig\x12\x0f\n\x07\x65nabled\x18\x01 \x01(\x08\x12\x0e\n\x06sender\x18\x02 \x01(\r\x12\x0c\n\x04save\x18\x03 \x01(\x08\x1a\xf9\x02\n\x0fTelemetryConfig\x12\x1e\n\x16\x64\x65vice_update_interval\x18\x01 \x01(\r\x12#\n\x1b\x65nvironment_update_interval\x18\x02 \x01(\r\x12\'\n\x1f\x65nvironment_measurement_enabled\x18\x03 \x01(\x08\x12\"\n\x1a\x65nvironment_screen_enabled\x18\x04 \x01(\x08\x12.\n&environment_read_error_count_threshold\x18\x05 \x01(\r\x12%\n\x1d\x65nvironment_recovery_interval\x18\x06 \x01(\r\x12&\n\x1e\x65nvironment_display_fahrenheit\x18\x07 \x01(\x08\x12\x35\n\x17\x65nvironment_sensor_type\x18\x08 \x01(\x0e\x32\x14.TelemetrySensorType\x12\x1e\n\x16\x65nvironment_sensor_pin\x18\t \x01(\r\x1a\xd6\x04\n\x13\x43\x61nnedMessageConfig\x12\x17\n\x0frotary1_enabled\x18\x01 \x01(\x08\x12\x19\n\x11inputbroker_pin_a\x18\x02 \x01(\r\x12\x19\n\x11inputbroker_pin_b\x18\x03 \x01(\r\x12\x1d\n\x15inputbroker_pin_press\x18\x04 \x01(\r\x12N\n\x14inputbroker_event_cw\x18\x05 \x01(\x0e\x32\x30.ModuleConfig.CannedMessageConfig.InputEventChar\x12O\n\x15inputbroker_event_ccw\x18\x06 \x01(\x0e\x32\x30.ModuleConfig.CannedMessageConfig.InputEventChar\x12Q\n\x17inputbroker_event_press\x18\x07 \x01(\x0e\x32\x30.ModuleConfig.CannedMessageConfig.InputEventChar\x12\x17\n\x0fupdown1_enabled\x18\x08 \x01(\x08\x12\x0f\n\x07\x65nabled\x18\t \x01(\x08\x12\x1a\n\x12\x61llow_input_source\x18\n \x01(\t\x12\x11\n\tsend_bell\x18\x0b \x01(\x08\"\x83\x01\n\x0eInputEventChar\x12\x0c\n\x08KEY_NONE\x10\x00\x12\n\n\x06KEY_UP\x10\x11\x12\x0c\n\x08KEY_DOWN\x10\x12\x12\x0c\n\x08KEY_LEFT\x10\x13\x12\r\n\tKEY_RIGHT\x10\x14\x12\x0e\n\nKEY_SELECT\x10\n\x12\x0c\n\x08KEY_BACK\x10\x1b\x12\x0e\n\nKEY_CANCEL\x10\x18\x42\x10\n\x0epayloadVariantBN\n\x13\x63om.geeksville.meshB\x12ModuleConfigProtosH\x03Z!github.com/meshtastic/gomeshprotob\x06proto3')
|
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x13module_config.proto\x1a\x0ftelemetry.proto\"\xa8\x11\n\x0cModuleConfig\x12(\n\x04mqtt\x18\x01 \x01(\x0b\x32\x18.ModuleConfig.MQTTConfigH\x00\x12,\n\x06serial\x18\x02 \x01(\x0b\x32\x1a.ModuleConfig.SerialConfigH\x00\x12I\n\x15\x65xternal_notification\x18\x03 \x01(\x0b\x32(.ModuleConfig.ExternalNotificationConfigH\x00\x12\x39\n\rstore_forward\x18\x04 \x01(\x0b\x32 .ModuleConfig.StoreForwardConfigH\x00\x12\x33\n\nrange_test\x18\x05 \x01(\x0b\x32\x1d.ModuleConfig.RangeTestConfigH\x00\x12\x32\n\ttelemetry\x18\x06 \x01(\x0b\x32\x1d.ModuleConfig.TelemetryConfigH\x00\x12;\n\x0e\x63\x61nned_message\x18\x07 \x01(\x0b\x32!.ModuleConfig.CannedMessageConfigH\x00\x1an\n\nMQTTConfig\x12\x0f\n\x07\x65nabled\x18\x01 \x01(\x08\x12\x0f\n\x07\x61\x64\x64ress\x18\x02 \x01(\t\x12\x10\n\x08username\x18\x03 \x01(\t\x12\x10\n\x08password\x18\x04 \x01(\t\x12\x1a\n\x12\x65ncryption_enabled\x18\x05 \x01(\x08\x1a\x93\x04\n\x0cSerialConfig\x12\x0f\n\x07\x65nabled\x18\x01 \x01(\x08\x12\x0c\n\x04\x65\x63ho\x18\x02 \x01(\x08\x12\x0b\n\x03rxd\x18\x03 \x01(\r\x12\x0b\n\x03txd\x18\x04 \x01(\r\x12\x34\n\x04\x62\x61ud\x18\x05 \x01(\x0e\x32&.ModuleConfig.SerialConfig.Serial_Baud\x12\x0f\n\x07timeout\x18\x06 \x01(\r\x12\x34\n\x04mode\x18\x07 \x01(\x0e\x32&.ModuleConfig.SerialConfig.Serial_Mode\"\x8a\x02\n\x0bSerial_Baud\x12\x10\n\x0c\x42\x41UD_Default\x10\x00\x12\x0c\n\x08\x42\x41UD_110\x10\x01\x12\x0c\n\x08\x42\x41UD_300\x10\x02\x12\x0c\n\x08\x42\x41UD_600\x10\x03\x12\r\n\tBAUD_1200\x10\x04\x12\r\n\tBAUD_2400\x10\x05\x12\r\n\tBAUD_4800\x10\x06\x12\r\n\tBAUD_9600\x10\x07\x12\x0e\n\nBAUD_19200\x10\x08\x12\x0e\n\nBAUD_38400\x10\t\x12\x0e\n\nBAUD_57600\x10\n\x12\x0f\n\x0b\x42\x41UD_115200\x10\x0b\x12\x0f\n\x0b\x42\x41UD_230400\x10\x0c\x12\x0f\n\x0b\x42\x41UD_460800\x10\r\x12\x0f\n\x0b\x42\x41UD_576000\x10\x0e\x12\x0f\n\x0b\x42\x41UD_921600\x10\x0f\"@\n\x0bSerial_Mode\x12\x10\n\x0cMODE_Default\x10\x00\x12\x0f\n\x0bMODE_SIMPLE\x10\x01\x12\x0e\n\nMODE_PROTO\x10\x02\x1a\x8b\x01\n\x1a\x45xternalNotificationConfig\x12\x0f\n\x07\x65nabled\x18\x01 \x01(\x08\x12\x11\n\toutput_ms\x18\x02 \x01(\r\x12\x0e\n\x06output\x18\x03 \x01(\r\x12\x0e\n\x06\x61\x63tive\x18\x04 \x01(\x08\x12\x15\n\ralert_message\x18\x05 \x01(\x08\x12\x12\n\nalert_bell\x18\x06 \x01(\x08\x1a\x84\x01\n\x12StoreForwardConfig\x12\x0f\n\x07\x65nabled\x18\x01 \x01(\x08\x12\x11\n\theartbeat\x18\x02 \x01(\x08\x12\x0f\n\x07records\x18\x03 \x01(\r\x12\x1a\n\x12history_return_max\x18\x04 \x01(\r\x12\x1d\n\x15history_return_window\x18\x05 \x01(\r\x1a@\n\x0fRangeTestConfig\x12\x0f\n\x07\x65nabled\x18\x01 \x01(\x08\x12\x0e\n\x06sender\x18\x02 \x01(\r\x12\x0c\n\x04save\x18\x03 \x01(\x08\x1a\xcb\x01\n\x0fTelemetryConfig\x12\x1e\n\x16\x64\x65vice_update_interval\x18\x01 \x01(\r\x12#\n\x1b\x65nvironment_update_interval\x18\x02 \x01(\r\x12\'\n\x1f\x65nvironment_measurement_enabled\x18\x03 \x01(\x08\x12\"\n\x1a\x65nvironment_screen_enabled\x18\x04 \x01(\x08\x12&\n\x1e\x65nvironment_display_fahrenheit\x18\x07 \x01(\x08\x1a\xd6\x04\n\x13\x43\x61nnedMessageConfig\x12\x17\n\x0frotary1_enabled\x18\x01 \x01(\x08\x12\x19\n\x11inputbroker_pin_a\x18\x02 \x01(\r\x12\x19\n\x11inputbroker_pin_b\x18\x03 \x01(\r\x12\x1d\n\x15inputbroker_pin_press\x18\x04 \x01(\r\x12N\n\x14inputbroker_event_cw\x18\x05 \x01(\x0e\x32\x30.ModuleConfig.CannedMessageConfig.InputEventChar\x12O\n\x15inputbroker_event_ccw\x18\x06 \x01(\x0e\x32\x30.ModuleConfig.CannedMessageConfig.InputEventChar\x12Q\n\x17inputbroker_event_press\x18\x07 \x01(\x0e\x32\x30.ModuleConfig.CannedMessageConfig.InputEventChar\x12\x17\n\x0fupdown1_enabled\x18\x08 \x01(\x08\x12\x0f\n\x07\x65nabled\x18\t \x01(\x08\x12\x1a\n\x12\x61llow_input_source\x18\n \x01(\t\x12\x11\n\tsend_bell\x18\x0b \x01(\x08\"\x83\x01\n\x0eInputEventChar\x12\x0c\n\x08KEY_NONE\x10\x00\x12\n\n\x06KEY_UP\x10\x11\x12\x0c\n\x08KEY_DOWN\x10\x12\x12\x0c\n\x08KEY_LEFT\x10\x13\x12\r\n\tKEY_RIGHT\x10\x14\x12\x0e\n\nKEY_SELECT\x10\n\x12\x0c\n\x08KEY_BACK\x10\x1b\x12\x0e\n\nKEY_CANCEL\x10\x18\x42\x10\n\x0epayloadVariantBN\n\x13\x63om.geeksville.meshB\x12ModuleConfigProtosH\x03Z!github.com/meshtastic/gomeshprotob\x06proto3')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -98,25 +98,25 @@ if _descriptor._USE_C_DESCRIPTORS == False:
|
|||||||
DESCRIPTOR._options = None
|
DESCRIPTOR._options = None
|
||||||
DESCRIPTOR._serialized_options = b'\n\023com.geeksville.meshB\022ModuleConfigProtosH\003Z!github.com/meshtastic/gomeshproto'
|
DESCRIPTOR._serialized_options = b'\n\023com.geeksville.meshB\022ModuleConfigProtosH\003Z!github.com/meshtastic/gomeshproto'
|
||||||
_MODULECONFIG._serialized_start=41
|
_MODULECONFIG._serialized_start=41
|
||||||
_MODULECONFIG._serialized_end=2432
|
_MODULECONFIG._serialized_end=2257
|
||||||
_MODULECONFIG_MQTTCONFIG._serialized_start=445
|
_MODULECONFIG_MQTTCONFIG._serialized_start=445
|
||||||
_MODULECONFIG_MQTTCONFIG._serialized_end=556
|
_MODULECONFIG_MQTTCONFIG._serialized_end=555
|
||||||
_MODULECONFIG_SERIALCONFIG._serialized_start=559
|
_MODULECONFIG_SERIALCONFIG._serialized_start=558
|
||||||
_MODULECONFIG_SERIALCONFIG._serialized_end=1090
|
_MODULECONFIG_SERIALCONFIG._serialized_end=1089
|
||||||
_MODULECONFIG_SERIALCONFIG_SERIAL_BAUD._serialized_start=758
|
_MODULECONFIG_SERIALCONFIG_SERIAL_BAUD._serialized_start=757
|
||||||
_MODULECONFIG_SERIALCONFIG_SERIAL_BAUD._serialized_end=1024
|
_MODULECONFIG_SERIALCONFIG_SERIAL_BAUD._serialized_end=1023
|
||||||
_MODULECONFIG_SERIALCONFIG_SERIAL_MODE._serialized_start=1026
|
_MODULECONFIG_SERIALCONFIG_SERIAL_MODE._serialized_start=1025
|
||||||
_MODULECONFIG_SERIALCONFIG_SERIAL_MODE._serialized_end=1090
|
_MODULECONFIG_SERIALCONFIG_SERIAL_MODE._serialized_end=1089
|
||||||
_MODULECONFIG_EXTERNALNOTIFICATIONCONFIG._serialized_start=1093
|
_MODULECONFIG_EXTERNALNOTIFICATIONCONFIG._serialized_start=1092
|
||||||
_MODULECONFIG_EXTERNALNOTIFICATIONCONFIG._serialized_end=1232
|
_MODULECONFIG_EXTERNALNOTIFICATIONCONFIG._serialized_end=1231
|
||||||
_MODULECONFIG_STOREFORWARDCONFIG._serialized_start=1235
|
_MODULECONFIG_STOREFORWARDCONFIG._serialized_start=1234
|
||||||
_MODULECONFIG_STOREFORWARDCONFIG._serialized_end=1367
|
_MODULECONFIG_STOREFORWARDCONFIG._serialized_end=1366
|
||||||
_MODULECONFIG_RANGETESTCONFIG._serialized_start=1369
|
_MODULECONFIG_RANGETESTCONFIG._serialized_start=1368
|
||||||
_MODULECONFIG_RANGETESTCONFIG._serialized_end=1433
|
_MODULECONFIG_RANGETESTCONFIG._serialized_end=1432
|
||||||
_MODULECONFIG_TELEMETRYCONFIG._serialized_start=1436
|
_MODULECONFIG_TELEMETRYCONFIG._serialized_start=1435
|
||||||
_MODULECONFIG_TELEMETRYCONFIG._serialized_end=1813
|
_MODULECONFIG_TELEMETRYCONFIG._serialized_end=1638
|
||||||
_MODULECONFIG_CANNEDMESSAGECONFIG._serialized_start=1816
|
_MODULECONFIG_CANNEDMESSAGECONFIG._serialized_start=1641
|
||||||
_MODULECONFIG_CANNEDMESSAGECONFIG._serialized_end=2414
|
_MODULECONFIG_CANNEDMESSAGECONFIG._serialized_end=2239
|
||||||
_MODULECONFIG_CANNEDMESSAGECONFIG_INPUTEVENTCHAR._serialized_start=2283
|
_MODULECONFIG_CANNEDMESSAGECONFIG_INPUTEVENTCHAR._serialized_start=2108
|
||||||
_MODULECONFIG_CANNEDMESSAGECONFIG_INPUTEVENTCHAR._serialized_end=2414
|
_MODULECONFIG_CANNEDMESSAGECONFIG_INPUTEVENTCHAR._serialized_end=2239
|
||||||
# @@protoc_insertion_point(module_scope)
|
# @@protoc_insertion_point(module_scope)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from meshtastic.util import pskToString, stripnl, Timeout, our_exit, fromPSK
|
|||||||
class Node:
|
class Node:
|
||||||
"""A model of a (local or remote) node in the mesh
|
"""A model of a (local or remote) node in the mesh
|
||||||
|
|
||||||
Includes methods for localConfig and channels
|
Includes methods for localConfig, moduleConfig and channels
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, iface, nodeNum, noProto=False):
|
def __init__(self, iface, nodeNum, noProto=False):
|
||||||
@@ -20,17 +20,14 @@ class Node:
|
|||||||
self.iface = iface
|
self.iface = iface
|
||||||
self.nodeNum = nodeNum
|
self.nodeNum = nodeNum
|
||||||
self.localConfig = localonly_pb2.LocalConfig()
|
self.localConfig = localonly_pb2.LocalConfig()
|
||||||
|
self.moduleConfig = localonly_pb2.LocalModuleConfig()
|
||||||
self.channels = None
|
self.channels = None
|
||||||
self._timeout = Timeout(maxSecs=300)
|
self._timeout = Timeout(maxSecs=300)
|
||||||
self.partialChannels = None
|
self.partialChannels = None
|
||||||
self.noProto = noProto
|
self.noProto = noProto
|
||||||
|
|
||||||
self.cannedPluginMessage = None
|
self.cannedPluginMessage = None
|
||||||
|
|
||||||
self.cannedPluginMessagePart1 = None
|
self.cannedPluginMessageMessages = None
|
||||||
self.cannedPluginMessagePart2 = None
|
|
||||||
self.cannedPluginMessagePart3 = None
|
|
||||||
self.cannedPluginMessagePart4 = None
|
|
||||||
|
|
||||||
self.gotResponse = None
|
self.gotResponse = None
|
||||||
|
|
||||||
@@ -57,6 +54,10 @@ class Node:
|
|||||||
if self.localConfig:
|
if self.localConfig:
|
||||||
prefs = stripnl(MessageToJson(self.localConfig))
|
prefs = stripnl(MessageToJson(self.localConfig))
|
||||||
print(f"Preferences: {prefs}\n")
|
print(f"Preferences: {prefs}\n")
|
||||||
|
prefs = ""
|
||||||
|
if self.moduleConfig:
|
||||||
|
prefs = stripnl(MessageToJson(self.moduleConfig))
|
||||||
|
print(f"Module preferences: {prefs}\n")
|
||||||
self.showChannels()
|
self.showChannels()
|
||||||
|
|
||||||
def requestConfig(self):
|
def requestConfig(self):
|
||||||
@@ -87,43 +88,145 @@ class Node:
|
|||||||
p.set_config.device.CopyFrom(self.localConfig.device)
|
p.set_config.device.CopyFrom(self.localConfig.device)
|
||||||
self._sendAdmin(p)
|
self._sendAdmin(p)
|
||||||
logging.debug("Wrote device")
|
logging.debug("Wrote device")
|
||||||
|
time.sleep(0.3)
|
||||||
|
|
||||||
if self.localConfig.position:
|
if self.localConfig.position:
|
||||||
p = admin_pb2.AdminMessage()
|
p = admin_pb2.AdminMessage()
|
||||||
p.set_config.position.CopyFrom(self.localConfig.position)
|
p.set_config.position.CopyFrom(self.localConfig.position)
|
||||||
self._sendAdmin(p)
|
self._sendAdmin(p)
|
||||||
logging.debug("Wrote position")
|
logging.debug("Wrote position")
|
||||||
|
time.sleep(0.3)
|
||||||
|
|
||||||
if self.localConfig.power:
|
if self.localConfig.power:
|
||||||
p = admin_pb2.AdminMessage()
|
p = admin_pb2.AdminMessage()
|
||||||
p.set_config.power.CopyFrom(self.localConfig.power)
|
p.set_config.power.CopyFrom(self.localConfig.power)
|
||||||
self._sendAdmin(p)
|
self._sendAdmin(p)
|
||||||
logging.debug("Wrote power")
|
logging.debug("Wrote power")
|
||||||
|
time.sleep(0.3)
|
||||||
|
|
||||||
if self.localConfig.wifi:
|
if self.localConfig.wifi:
|
||||||
p = admin_pb2.AdminMessage()
|
p = admin_pb2.AdminMessage()
|
||||||
p.set_config.wifi.CopyFrom(self.localConfig.wifi)
|
p.set_config.wifi.CopyFrom(self.localConfig.wifi)
|
||||||
self._sendAdmin(p)
|
self._sendAdmin(p)
|
||||||
logging.debug("Wrote wifi")
|
logging.debug("Wrote wifi")
|
||||||
|
time.sleep(0.3)
|
||||||
|
|
||||||
if self.localConfig.display:
|
if self.localConfig.display:
|
||||||
p = admin_pb2.AdminMessage()
|
p = admin_pb2.AdminMessage()
|
||||||
p.set_config.display.CopyFrom(self.localConfig.display)
|
p.set_config.display.CopyFrom(self.localConfig.display)
|
||||||
self._sendAdmin(p)
|
self._sendAdmin(p)
|
||||||
logging.debug("Wrote display")
|
logging.debug("Wrote display")
|
||||||
|
time.sleep(0.3)
|
||||||
|
|
||||||
if self.localConfig.lora:
|
if self.localConfig.lora:
|
||||||
p = admin_pb2.AdminMessage()
|
p = admin_pb2.AdminMessage()
|
||||||
p.set_config.lora.CopyFrom(self.localConfig.lora)
|
p.set_config.lora.CopyFrom(self.localConfig.lora)
|
||||||
self._sendAdmin(p)
|
self._sendAdmin(p)
|
||||||
logging.debug("Wrote lora")
|
logging.debug("Wrote lora")
|
||||||
|
time.sleep(0.3)
|
||||||
|
|
||||||
|
if self.localConfig.bluetooth:
|
||||||
|
p = admin_pb2.AdminMessage()
|
||||||
|
p.set_config.bluetooth.CopyFrom(self.localConfig.bluetooth)
|
||||||
|
self._sendAdmin(p)
|
||||||
|
logging.debug("Wrote bluetooth")
|
||||||
|
time.sleep(0.3)
|
||||||
|
|
||||||
|
if self.moduleConfig.mqtt:
|
||||||
|
p = admin_pb2.AdminMessage()
|
||||||
|
p.set_module_config.mqtt.CopyFrom(self.moduleConfig.mqtt)
|
||||||
|
self._sendAdmin(p)
|
||||||
|
logging.debug("Wrote module: mqtt")
|
||||||
|
time.sleep(0.3)
|
||||||
|
|
||||||
|
if self.moduleConfig.serial:
|
||||||
|
p = admin_pb2.AdminMessage()
|
||||||
|
p.set_module_config.serial.CopyFrom(self.moduleConfig.serial)
|
||||||
|
self._sendAdmin(p)
|
||||||
|
logging.debug("Wrote module: serial")
|
||||||
|
time.sleep(0.3)
|
||||||
|
|
||||||
|
if self.moduleConfig.external_notification:
|
||||||
|
p = admin_pb2.AdminMessage()
|
||||||
|
p.set_module_config.external_notification.CopyFrom(self.moduleConfig.external_notification)
|
||||||
|
self._sendAdmin(p)
|
||||||
|
logging.debug("Wrote module: external_notification")
|
||||||
|
time.sleep(0.3)
|
||||||
|
|
||||||
|
if self.moduleConfig.store_forward:
|
||||||
|
p = admin_pb2.AdminMessage()
|
||||||
|
p.set_module_config.store_forward.CopyFrom(self.moduleConfig.store_forward)
|
||||||
|
self._sendAdmin(p)
|
||||||
|
logging.debug("Wrote module: store_forward")
|
||||||
|
time.sleep(0.3)
|
||||||
|
|
||||||
|
if self.moduleConfig.range_test:
|
||||||
|
p = admin_pb2.AdminMessage()
|
||||||
|
p.set_module_config.range_test.CopyFrom(self.moduleConfig.range_test)
|
||||||
|
self._sendAdmin(p)
|
||||||
|
logging.debug("Wrote module: range_test")
|
||||||
|
time.sleep(0.3)
|
||||||
|
|
||||||
|
if self.moduleConfig.telemetry:
|
||||||
|
p = admin_pb2.AdminMessage()
|
||||||
|
p.set_module_config.telemetry.CopyFrom(self.moduleConfig.telemetry)
|
||||||
|
self._sendAdmin(p)
|
||||||
|
logging.debug("Wrote module: telemetry")
|
||||||
|
time.sleep(0.3)
|
||||||
|
|
||||||
|
if self.moduleConfig.canned_message:
|
||||||
|
p = admin_pb2.AdminMessage()
|
||||||
|
p.set_module_config.canned_message.CopyFrom(self.moduleConfig.canned_message)
|
||||||
|
self._sendAdmin(p)
|
||||||
|
logging.debug("Wrote module: canned_message")
|
||||||
|
time.sleep(0.3)
|
||||||
|
|
||||||
|
def writeConfig(self, config_name):
|
||||||
|
"""Write the current (edited) localConfig to the device"""
|
||||||
|
if self.localConfig is None:
|
||||||
|
our_exit("Error: No localConfig has been read")
|
||||||
|
|
||||||
|
p = admin_pb2.AdminMessage()
|
||||||
|
|
||||||
|
if config_name == 'device':
|
||||||
|
p.set_config.device.CopyFrom(self.localConfig.device)
|
||||||
|
elif config_name == 'position':
|
||||||
|
p.set_config.position.CopyFrom(self.localConfig.position)
|
||||||
|
elif config_name == 'power':
|
||||||
|
p.set_config.power.CopyFrom(self.localConfig.power)
|
||||||
|
elif config_name == 'wifi':
|
||||||
|
p.set_config.wifi.CopyFrom(self.localConfig.wifi)
|
||||||
|
elif config_name == 'display':
|
||||||
|
p.set_config.display.CopyFrom(self.localConfig.display)
|
||||||
|
elif config_name == 'lora':
|
||||||
|
p.set_config.lora.CopyFrom(self.localConfig.lora)
|
||||||
|
elif config_name == 'bluetooth':
|
||||||
|
p.set_config.bluetooth.CopyFrom(self.localConfig.bluetooth)
|
||||||
|
elif config_name == 'mqtt':
|
||||||
|
p.set_module_config.mqtt.CopyFrom(self.moduleConfig.mqtt)
|
||||||
|
elif config_name == 'serial':
|
||||||
|
p.set_module_config.serial.CopyFrom(self.moduleConfig.serial)
|
||||||
|
elif config_name == 'external_notification':
|
||||||
|
p.set_module_config.external_notification.CopyFrom(self.moduleConfig.external_notification)
|
||||||
|
elif config_name == 'store_forward':
|
||||||
|
p.set_module_config.store_forward.CopyFrom(self.moduleConfig.store_forward)
|
||||||
|
elif config_name == 'range_test':
|
||||||
|
p.set_module_config.range_test.CopyFrom(self.moduleConfig.range_test)
|
||||||
|
elif config_name == 'telemetry':
|
||||||
|
p.set_module_config.telemetry.CopyFrom(self.moduleConfig.telemetry)
|
||||||
|
elif config_name == 'canned_message':
|
||||||
|
p.set_module_config.canned_message.CopyFrom(self.moduleConfig.canned_message)
|
||||||
|
else:
|
||||||
|
our_exit(f"Error: No valid config with name {config_name}")
|
||||||
|
|
||||||
|
logging.debug(f"Wrote: {config_name}")
|
||||||
|
self._sendAdmin(p)
|
||||||
|
|
||||||
def writeChannel(self, channelIndex, adminIndex=0):
|
def writeChannel(self, channelIndex, adminIndex=0):
|
||||||
"""Write the current (edited) channel to the device"""
|
"""Write the current (edited) channel to the device"""
|
||||||
|
|
||||||
p = admin_pb2.AdminMessage()
|
p = admin_pb2.AdminMessage()
|
||||||
p.set_channel.CopyFrom(self.channels[channelIndex])
|
p.set_channel.CopyFrom(self.channels[channelIndex])
|
||||||
|
|
||||||
self._sendAdmin(p, adminIndex=adminIndex)
|
self._sendAdmin(p, adminIndex=adminIndex)
|
||||||
logging.debug(f"Wrote channel {channelIndex}")
|
logging.debug(f"Wrote channel {channelIndex}")
|
||||||
|
|
||||||
@@ -228,9 +331,12 @@ class Node:
|
|||||||
for c in self.channels:
|
for c in self.channels:
|
||||||
if c.role == channel_pb2.Channel.Role.PRIMARY or (includeAll and c.role == channel_pb2.Channel.Role.SECONDARY):
|
if c.role == channel_pb2.Channel.Role.PRIMARY or (includeAll and c.role == channel_pb2.Channel.Role.SECONDARY):
|
||||||
channelSet.settings.append(c.settings)
|
channelSet.settings.append(c.settings)
|
||||||
|
|
||||||
|
channelSet.lora_config.CopyFrom(self.localConfig.lora)
|
||||||
some_bytes = channelSet.SerializeToString()
|
some_bytes = channelSet.SerializeToString()
|
||||||
s = base64.urlsafe_b64encode(some_bytes).decode('ascii')
|
s = base64.urlsafe_b64encode(some_bytes).decode('ascii')
|
||||||
return f"https://www.meshtastic.org/e/#{s}".replace("=", "")
|
s = s.replace("=", "").replace("+", "-").replace("/", "_")
|
||||||
|
return f"https://www.meshtastic.org/e/#{s}"
|
||||||
|
|
||||||
def setURL(self, url):
|
def setURL(self, url):
|
||||||
"""Set mesh network URL"""
|
"""Set mesh network URL"""
|
||||||
@@ -268,9 +374,13 @@ class Node:
|
|||||||
self.writeChannel(ch.index)
|
self.writeChannel(ch.index)
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
||||||
def onResponseRequestCannedMessagePluginMessagePart1(self, p):
|
p = admin_pb2.AdminMessage()
|
||||||
|
p.set_config.lora.CopyFrom(channelSet.lora_config)
|
||||||
|
self._sendAdmin(p)
|
||||||
|
|
||||||
|
def onResponseRequestCannedMessagePluginMessageMessages(self, p):
|
||||||
"""Handle the response packet for requesting canned message plugin message part 1"""
|
"""Handle the response packet for requesting canned message plugin message part 1"""
|
||||||
logging.debug(f'onResponseRequestCannedMessagePluginMessagePart1() p:{p}')
|
logging.debug(f'onResponseRequestCannedMessagePluginMessageMessages() p:{p}')
|
||||||
errorFound = False
|
errorFound = False
|
||||||
if "routing" in p["decoded"]:
|
if "routing" in p["decoded"]:
|
||||||
if p["decoded"]["routing"]["errorReason"] != "NONE":
|
if p["decoded"]["routing"]["errorReason"] != "NONE":
|
||||||
@@ -280,57 +390,10 @@ class Node:
|
|||||||
if "decoded" in p:
|
if "decoded" in p:
|
||||||
if "admin" in p["decoded"]:
|
if "admin" in p["decoded"]:
|
||||||
if "raw" in p["decoded"]["admin"]:
|
if "raw" in p["decoded"]["admin"]:
|
||||||
self.cannedPluginMessagePart1 = p["decoded"]["admin"]["raw"].get_canned_message_module_part1_response
|
self.cannedPluginMessageMessages = p["decoded"]["admin"]["raw"].get_canned_message_module_messages_response
|
||||||
logging.debug(f'self.cannedPluginMessagePart1:{self.cannedPluginMessagePart1}')
|
logging.debug(f'self.cannedPluginMessageMessages:{self.cannedPluginMessageMessages}')
|
||||||
self.gotResponse = True
|
self.gotResponse = True
|
||||||
|
|
||||||
def onResponseRequestCannedMessagePluginMessagePart2(self, p):
|
|
||||||
"""Handle the response packet for requesting canned message plugin message part 2"""
|
|
||||||
logging.debug(f'onResponseRequestCannedMessagePluginMessagePart2() p:{p}')
|
|
||||||
errorFound = False
|
|
||||||
if "routing" in p["decoded"]:
|
|
||||||
if p["decoded"]["routing"]["errorReason"] != "NONE":
|
|
||||||
errorFound = True
|
|
||||||
print(f'Error on response: {p["decoded"]["routing"]["errorReason"]}')
|
|
||||||
if errorFound is False:
|
|
||||||
if "decoded" in p:
|
|
||||||
if "admin" in p["decoded"]:
|
|
||||||
if "raw" in p["decoded"]["admin"]:
|
|
||||||
self.cannedPluginMessagePart2 = p["decoded"]["admin"]["raw"].get_canned_message_module_part2_response
|
|
||||||
logging.debug(f'self.cannedPluginMessagePart2:{self.cannedPluginMessagePart2}')
|
|
||||||
self.gotResponse = True
|
|
||||||
|
|
||||||
def onResponseRequestCannedMessagePluginMessagePart3(self, p):
|
|
||||||
"""Handle the response packet for requesting canned message plugin message part 3"""
|
|
||||||
logging.debug(f'onResponseRequestCannedMessagePluginMessagePart3() p:{p}')
|
|
||||||
errorFound = False
|
|
||||||
if "routing" in p["decoded"]:
|
|
||||||
if p["decoded"]["routing"]["errorReason"] != "NONE":
|
|
||||||
errorFound = True
|
|
||||||
print(f'Error on response: {p["decoded"]["routing"]["errorReason"]}')
|
|
||||||
if errorFound is False:
|
|
||||||
if "decoded" in p:
|
|
||||||
if "admin" in p["decoded"]:
|
|
||||||
if "raw" in p["decoded"]["admin"]:
|
|
||||||
self.cannedPluginMessagePart3 = p["decoded"]["admin"]["raw"].get_canned_message_module_part3_response
|
|
||||||
logging.debug(f'self.cannedPluginMessagePart3:{self.cannedPluginMessagePart3}')
|
|
||||||
self.gotResponse = True
|
|
||||||
|
|
||||||
def onResponseRequestCannedMessagePluginMessagePart4(self, p):
|
|
||||||
"""Handle the response packet for requesting canned message plugin message part 4"""
|
|
||||||
logging.debug(f'onResponseRequestCannedMessagePluginMessagePart4() p:{p}')
|
|
||||||
errorFound = False
|
|
||||||
if "routing" in p["decoded"]:
|
|
||||||
if p["decoded"]["routing"]["errorReason"] != "NONE":
|
|
||||||
errorFound = True
|
|
||||||
print(f'Error on response: {p["decoded"]["routing"]["errorReason"]}')
|
|
||||||
if errorFound is False:
|
|
||||||
if "decoded" in p:
|
|
||||||
if "admin" in p["decoded"]:
|
|
||||||
if "raw" in p["decoded"]["admin"]:
|
|
||||||
self.cannedPluginMessagePart4 = p["decoded"]["admin"]["raw"].get_canned_message_module_part4_response
|
|
||||||
logging.debug(f'self.cannedPluginMessagePart4:{self.cannedPluginMessagePart4}')
|
|
||||||
self.gotResponse = True
|
|
||||||
|
|
||||||
def get_canned_message(self):
|
def get_canned_message(self):
|
||||||
"""Get the canned message string. Concatenate all pieces together and return a single string."""
|
"""Get the canned message string. Concatenate all pieces together and return a single string."""
|
||||||
@@ -338,61 +401,27 @@ class Node:
|
|||||||
if not self.cannedPluginMessage:
|
if not self.cannedPluginMessage:
|
||||||
|
|
||||||
p1 = admin_pb2.AdminMessage()
|
p1 = admin_pb2.AdminMessage()
|
||||||
p1.get_canned_message_module_part1_request = True
|
p1.get_canned_message_module_messages_request = True
|
||||||
self.gotResponse = False
|
self.gotResponse = False
|
||||||
self._sendAdmin(p1, wantResponse=True, onResponse=self.onResponseRequestCannedMessagePluginMessagePart1)
|
self._sendAdmin(p1, wantResponse=True, onResponse=self.onResponseRequestCannedMessagePluginMessageMessages)
|
||||||
while self.gotResponse is False:
|
while self.gotResponse is False:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
p2 = admin_pb2.AdminMessage()
|
logging.debug(f'self.cannedPluginMessageMessages:{self.cannedPluginMessageMessages}')
|
||||||
p2.get_canned_message_module_part2_request = True
|
|
||||||
self.gotResponse = False
|
|
||||||
self._sendAdmin(p2, wantResponse=True, onResponse=self.onResponseRequestCannedMessagePluginMessagePart2)
|
|
||||||
while self.gotResponse is False:
|
|
||||||
time.sleep(0.1)
|
|
||||||
|
|
||||||
p3 = admin_pb2.AdminMessage()
|
|
||||||
p3.get_canned_message_module_part3_request = True
|
|
||||||
self.gotResponse = False
|
|
||||||
self._sendAdmin(p3, wantResponse=True, onResponse=self.onResponseRequestCannedMessagePluginMessagePart3)
|
|
||||||
while self.gotResponse is False:
|
|
||||||
time.sleep(0.1)
|
|
||||||
|
|
||||||
p4 = admin_pb2.AdminMessage()
|
|
||||||
p4.get_canned_message_module_part4_request = True
|
|
||||||
self.gotResponse = False
|
|
||||||
self._sendAdmin(p4, wantResponse=True, onResponse=self.onResponseRequestCannedMessagePluginMessagePart4)
|
|
||||||
while self.gotResponse is False:
|
|
||||||
time.sleep(0.1)
|
|
||||||
|
|
||||||
# TODO: This feels wrong to have a sleep here. Is there a way to ensure that
|
|
||||||
# all requests are complete? Perhaps change to a while loop any parts are None... maybe?
|
|
||||||
time.sleep(3)
|
|
||||||
|
|
||||||
logging.debug(f'self.cannedPluginMessagePart1:{self.cannedPluginMessagePart1}')
|
|
||||||
logging.debug(f'self.cannedPluginMessagePart2:{self.cannedPluginMessagePart2}')
|
|
||||||
logging.debug(f'self.cannedPluginMessagePart3:{self.cannedPluginMessagePart3}')
|
|
||||||
logging.debug(f'self.cannedPluginMessagePart4:{self.cannedPluginMessagePart4}')
|
|
||||||
|
|
||||||
self.cannedPluginMessage = ""
|
self.cannedPluginMessage = ""
|
||||||
if self.cannedPluginMessagePart1:
|
if self.cannedPluginMessageMessages:
|
||||||
self.cannedPluginMessage += self.cannedPluginMessagePart1
|
self.cannedPluginMessage += self.cannedPluginMessageMessages
|
||||||
if self.cannedPluginMessagePart2:
|
|
||||||
self.cannedPluginMessage += self.cannedPluginMessagePart2
|
|
||||||
if self.cannedPluginMessagePart3:
|
|
||||||
self.cannedPluginMessage += self.cannedPluginMessagePart3
|
|
||||||
if self.cannedPluginMessagePart4:
|
|
||||||
self.cannedPluginMessage += self.cannedPluginMessagePart4
|
|
||||||
|
|
||||||
print(f'canned_plugin_message:{self.cannedPluginMessage}')
|
print(f'canned_plugin_message:{self.cannedPluginMessage}')
|
||||||
logging.debug(f'canned_plugin_message:{self.cannedPluginMessage}')
|
logging.debug(f'canned_plugin_message:{self.cannedPluginMessage}')
|
||||||
return self.cannedPluginMessage
|
return self.cannedPluginMessage
|
||||||
|
|
||||||
def set_canned_message(self, message):
|
def set_canned_message(self, message):
|
||||||
"""Set the canned message. Split into parts of 200 chars each."""
|
"""Set the canned message. The canned messages length must be less than 200 character."""
|
||||||
|
|
||||||
if len(message) > 800:
|
if len(message) > 200:
|
||||||
our_exit("Warning: The canned message must be less than 800 characters.")
|
our_exit("Warning: The canned message must be less than 200 characters.")
|
||||||
|
|
||||||
# split into chunks
|
# split into chunks
|
||||||
chunks = []
|
chunks = []
|
||||||
@@ -407,13 +436,7 @@ class Node:
|
|||||||
|
|
||||||
# TODO: should be a way to improve this
|
# TODO: should be a way to improve this
|
||||||
if i == 0:
|
if i == 0:
|
||||||
p.set_canned_message_module_part1 = chunk
|
p.set_canned_message_module_messages = chunk
|
||||||
elif i == 1:
|
|
||||||
p.set_canned_message_module_part2 = chunk
|
|
||||||
elif i == 2:
|
|
||||||
p.set_canned_message_module_part3 = chunk
|
|
||||||
elif i == 3:
|
|
||||||
p.set_canned_message_module_part4 = chunk
|
|
||||||
|
|
||||||
logging.debug(f"Setting canned message '{chunk}' part {i+1}")
|
logging.debug(f"Setting canned message '{chunk}' part {i+1}")
|
||||||
self._sendAdmin(p)
|
self._sendAdmin(p)
|
||||||
@@ -443,6 +466,14 @@ class Node:
|
|||||||
|
|
||||||
return self._sendAdmin(p)
|
return self._sendAdmin(p)
|
||||||
|
|
||||||
|
def getMetadata(self, secs: int = 10):
|
||||||
|
"""Tell the node to shutdown."""
|
||||||
|
p = admin_pb2.AdminMessage()
|
||||||
|
p.get_device_metadata_request = True
|
||||||
|
logging.info(f"Requesting device metadata")
|
||||||
|
|
||||||
|
return self._sendAdmin(p, wantResponse=True, onResponse=self.onRequestGetMetadata)
|
||||||
|
|
||||||
def _fixupChannels(self):
|
def _fixupChannels(self):
|
||||||
"""Fixup indexes and add disabled channels as needed"""
|
"""Fixup indexes and add disabled channels as needed"""
|
||||||
|
|
||||||
@@ -466,6 +497,15 @@ class Node:
|
|||||||
index += 1
|
index += 1
|
||||||
|
|
||||||
|
|
||||||
|
def onRequestGetMetadata(self, p):
|
||||||
|
"""Handle the response packet for requesting device metadata getMetadata()"""
|
||||||
|
logging.debug(f'onRequestGetMetadata() p:{p}')
|
||||||
|
c = p["decoded"]["admin"]["raw"].get_device_metadata_response
|
||||||
|
self._timeout.reset() # We made foreward progress
|
||||||
|
logging.debug(f"Received metadata {stripnl(c)}")
|
||||||
|
print(f"\nfirmware_version: {c.firmware_version}")
|
||||||
|
print(f"device_state_version: {c.device_state_version}")
|
||||||
|
|
||||||
def onResponseRequestChannel(self, p):
|
def onResponseRequestChannel(self, p):
|
||||||
"""Handle the response packet for requesting a channel _requestChannel()"""
|
"""Handle the response packet for requesting a channel _requestChannel()"""
|
||||||
logging.debug(f'onResponseRequestChannel() p:{p}')
|
logging.debug(f'onResponseRequestChannel() p:{p}')
|
||||||
|
|||||||
@@ -15,22 +15,17 @@ _sym_db = _symbol_database.Default()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0ftelemetry.proto\"i\n\rDeviceMetrics\x12\x15\n\rbattery_level\x18\x01 \x01(\r\x12\x0f\n\x07voltage\x18\x02 \x01(\x02\x12\x1b\n\x13\x63hannel_utilization\x18\x03 \x01(\x02\x12\x13\n\x0b\x61ir_util_tx\x18\x04 \x01(\x02\"\x9b\x01\n\x12\x45nvironmentMetrics\x12\x13\n\x0btemperature\x18\x01 \x01(\x02\x12\x19\n\x11relative_humidity\x18\x02 \x01(\x02\x12\x1b\n\x13\x62\x61rometric_pressure\x18\x03 \x01(\x02\x12\x16\n\x0egas_resistance\x18\x04 \x01(\x02\x12\x0f\n\x07voltage\x18\x05 \x01(\x02\x12\x0f\n\x07\x63urrent\x18\x06 \x01(\x02\"\x82\x01\n\tTelemetry\x12\x0c\n\x04time\x18\x01 \x01(\x07\x12(\n\x0e\x64\x65vice_metrics\x18\x02 \x01(\x0b\x32\x0e.DeviceMetricsH\x00\x12\x32\n\x13\x65nvironment_metrics\x18\x03 \x01(\x0b\x32\x13.EnvironmentMetricsH\x00\x42\t\n\x07variant*\xa2\x01\n\x13TelemetrySensorType\x12\n\n\x06NotSet\x10\x00\x12\t\n\x05\x44HT11\x10\x01\x12\x0b\n\x07\x44S18B20\x10\x02\x12\t\n\x05\x44HT12\x10\x03\x12\t\n\x05\x44HT21\x10\x04\x12\t\n\x05\x44HT22\x10\x05\x12\n\n\x06\x42ME280\x10\x06\x12\n\n\x06\x42ME680\x10\x07\x12\x0b\n\x07MCP9808\x10\x08\x12\t\n\x05SHTC3\x10\t\x12\n\n\x06INA260\x10\n\x12\n\n\x06INA219\x10\x0b\x42K\n\x13\x63om.geeksville.meshB\x0fTelemetryProtosH\x03Z!github.com/meshtastic/gomeshprotob\x06proto3')
|
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0ftelemetry.proto\"i\n\rDeviceMetrics\x12\x15\n\rbattery_level\x18\x01 \x01(\r\x12\x0f\n\x07voltage\x18\x02 \x01(\x02\x12\x1b\n\x13\x63hannel_utilization\x18\x03 \x01(\x02\x12\x13\n\x0b\x61ir_util_tx\x18\x04 \x01(\x02\"\x9b\x01\n\x12\x45nvironmentMetrics\x12\x13\n\x0btemperature\x18\x01 \x01(\x02\x12\x19\n\x11relative_humidity\x18\x02 \x01(\x02\x12\x1b\n\x13\x62\x61rometric_pressure\x18\x03 \x01(\x02\x12\x16\n\x0egas_resistance\x18\x04 \x01(\x02\x12\x0f\n\x07voltage\x18\x05 \x01(\x02\x12\x0f\n\x07\x63urrent\x18\x06 \x01(\x02\"\x82\x01\n\tTelemetry\x12\x0c\n\x04time\x18\x01 \x01(\x07\x12(\n\x0e\x64\x65vice_metrics\x18\x02 \x01(\x0b\x32\x0e.DeviceMetricsH\x00\x12\x32\n\x13\x65nvironment_metrics\x18\x03 \x01(\x0b\x32\x13.EnvironmentMetricsH\x00\x42\t\n\x07variant*j\n\x13TelemetrySensorType\x12\n\n\x06NotSet\x10\x00\x12\n\n\x06\x42ME280\x10\x01\x12\n\n\x06\x42ME680\x10\x02\x12\x0b\n\x07MCP9808\x10\x03\x12\n\n\x06INA260\x10\x04\x12\n\n\x06INA219\x10\x05\x12\n\n\x06\x42MP280\x10\x06\x42K\n\x13\x63om.geeksville.meshB\x0fTelemetryProtosH\x03Z!github.com/meshtastic/gomeshprotob\x06proto3')
|
||||||
|
|
||||||
_TELEMETRYSENSORTYPE = DESCRIPTOR.enum_types_by_name['TelemetrySensorType']
|
_TELEMETRYSENSORTYPE = DESCRIPTOR.enum_types_by_name['TelemetrySensorType']
|
||||||
TelemetrySensorType = enum_type_wrapper.EnumTypeWrapper(_TELEMETRYSENSORTYPE)
|
TelemetrySensorType = enum_type_wrapper.EnumTypeWrapper(_TELEMETRYSENSORTYPE)
|
||||||
NotSet = 0
|
NotSet = 0
|
||||||
DHT11 = 1
|
BME280 = 1
|
||||||
DS18B20 = 2
|
BME680 = 2
|
||||||
DHT12 = 3
|
MCP9808 = 3
|
||||||
DHT21 = 4
|
INA260 = 4
|
||||||
DHT22 = 5
|
INA219 = 5
|
||||||
BME280 = 6
|
BMP280 = 6
|
||||||
BME680 = 7
|
|
||||||
MCP9808 = 8
|
|
||||||
SHTC3 = 9
|
|
||||||
INA260 = 10
|
|
||||||
INA219 = 11
|
|
||||||
|
|
||||||
|
|
||||||
_DEVICEMETRICS = DESCRIPTOR.message_types_by_name['DeviceMetrics']
|
_DEVICEMETRICS = DESCRIPTOR.message_types_by_name['DeviceMetrics']
|
||||||
@@ -61,8 +56,8 @@ if _descriptor._USE_C_DESCRIPTORS == False:
|
|||||||
|
|
||||||
DESCRIPTOR._options = None
|
DESCRIPTOR._options = None
|
||||||
DESCRIPTOR._serialized_options = b'\n\023com.geeksville.meshB\017TelemetryProtosH\003Z!github.com/meshtastic/gomeshproto'
|
DESCRIPTOR._serialized_options = b'\n\023com.geeksville.meshB\017TelemetryProtosH\003Z!github.com/meshtastic/gomeshproto'
|
||||||
_TELEMETRYSENSORTYPE._serialized_start=418
|
_TELEMETRYSENSORTYPE._serialized_start=417
|
||||||
_TELEMETRYSENSORTYPE._serialized_end=580
|
_TELEMETRYSENSORTYPE._serialized_end=523
|
||||||
_DEVICEMETRICS._serialized_start=19
|
_DEVICEMETRICS._serialized_start=19
|
||||||
_DEVICEMETRICS._serialized_end=124
|
_DEVICEMETRICS._serialized_end=124
|
||||||
_ENVIRONMENTMETRICS._serialized_start=127
|
_ENVIRONMENTMETRICS._serialized_start=127
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ def fromStr(valstr):
|
|||||||
elif valstr.startswith('0x'):
|
elif valstr.startswith('0x'):
|
||||||
# if needed convert to string with asBytes.decode('utf-8')
|
# if needed convert to string with asBytes.decode('utf-8')
|
||||||
val = bytes.fromhex(valstr[2:])
|
val = bytes.fromhex(valstr[2:])
|
||||||
|
elif valstr.startswith('base64:'):
|
||||||
|
val = base64.b64decode(valstr[7:])
|
||||||
elif valstr.lower() in {"t", "true", "yes"}:
|
elif valstr.lower() in {"t", "true", "yes"}:
|
||||||
val = True
|
val = True
|
||||||
elif valstr.lower() in {"f", "false", "no"}:
|
elif valstr.lower() in {"f", "false", "no"}:
|
||||||
|
|||||||
2
proto
2
proto
Submodule proto updated: 274aa01a38...5793089473
2
setup.py
2
setup.py
@@ -12,7 +12,7 @@ with open("README.md", "r") as fh:
|
|||||||
# This call to setup() does all the work
|
# This call to setup() does all the work
|
||||||
setup(
|
setup(
|
||||||
name="meshtastic",
|
name="meshtastic",
|
||||||
version="1.3alpha.18",
|
version="1.3alpha.24",
|
||||||
description="Python API & client shell for talking to Meshtastic devices",
|
description="Python API & client shell for talking to Meshtastic devices",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
|
|||||||
Reference in New Issue
Block a user