From 4b95b0ff30ec43bb7fa53004828cf9d131d57211 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 29 Jun 2022 18:35:06 -0500 Subject: [PATCH] Module config progress --- .vscode/launch.json | 16 +++++ meshtastic/__main__.py | 126 ++++++++++++++++------------------- meshtastic/config_pb2.py | 40 +++++------ meshtastic/mesh_interface.py | 19 +++++- meshtastic/mesh_pb2.py | 95 +++++++++++++------------- meshtastic/node.py | 49 +++++++++++++- proto | 2 +- 7 files changed, 208 insertions(+), 139 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 59d47d9..025d4ef 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -52,6 +52,14 @@ "justMyCode": true, "args": ["--debug", "--get", "power.is_power_saving"] }, + { + "name": "meshtastic debug info", + "type": "python", + "request": "launch", + "module": "meshtastic", + "justMyCode": true, + "args": ["--debug", "--info"] + }, { "name": "meshtastic debug setPref", "type": "python", @@ -60,6 +68,14 @@ "justMyCode": true, "args": ["--debug", "--set", "power.is_power_saving", "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", "type": "python", diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index 47e70ce..f97f976 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -52,13 +52,10 @@ def onConnection(interface, topic=pub.AUTO_TOPIC): # pylint: disable=W0613 print(f"Connection changed: {topic.getName()}") -def getPref(attributes, comp_name): +def getPref(config, comp_name): """Get a channel or preferences value""" - name = comp_name.split(".",1) - if len(name) != 2: - name[0]=comp_name - name.append(comp_name) + name = splitCompoundName(comp_name) camel_name = meshtastic.util.snake_to_camel(name[1]) # Note: protobufs has the keys in snake_case, so snake internally @@ -66,33 +63,17 @@ def getPref(attributes, comp_name): logging.debug(f'snake_name:{snake_name} camel_name:{camel_name}') 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]) pref = False if config_type: pref = config_type.message_type.fields_by_name.get(snake_name) if (not pref) or (not config_type): - if Globals.getInstance().get_camel_case(): - 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 + return False # read the value - config_values = getattr(attributes, config_type.name) + config_values = getattr(config, config_type.name) pref_value = getattr(config_values, pref.name) if Globals.getInstance().get_camel_case(): @@ -101,52 +82,40 @@ def getPref(attributes, comp_name): else: print(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 setPref(attributes, comp_name, valStr): - """Set a channel or preferences value""" - +def splitCompoundName(comp_name): name = comp_name.split(".",1) if len(name) != 2: name[0]=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]) camel_name = meshtastic.util.snake_to_camel(name[1]) logging.debug(f'snake_name:{snake_name}') logging.debug(f'camel_name:{camel_name}') - objDesc = attributes.DESCRIPTOR + objDesc = config.DESCRIPTOR config_type = objDesc.fields_by_name.get(name[0]) pref = False if config_type: pref = config_type.message_type.fields_by_name.get(snake_name) if (not pref) or (not config_type): - if Globals.getInstance().get_camel_case(): - 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 + return False val = meshtastic.util.fromStr(valStr) logging.debug(f'valStr:{valStr} val:{val}') if snake_name == 'psk' and len(valStr) < 8: print(f"Warning: wifi.psk must be 8 or more characters.") - return + return enumType = pref.enum_type # pylint: disable=C0123 @@ -172,11 +141,11 @@ def setPref(attributes, comp_name, valStr): # note: 'ignore_incoming' is a repeating field if snake_name != 'ignore_incoming': try: - config_values = getattr(attributes, config_type.name) + config_values = getattr(config, config_type.name) setattr(config_values, pref.name, val) except TypeError: # 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) else: if val == 0: @@ -191,6 +160,8 @@ def setPref(attributes, comp_name, valStr): print(f"Set {name[0]}.{camel_name} to {valStr}") else: print(f"Set {name[0]}.{snake_name} to {valStr}") + + return True def onConnected(interface): @@ -210,18 +181,18 @@ def onConnected(interface): alt = 0 lat = 0.0 lon = 0.0 - prefs = interface.localNode.localConfig + localConfig = interface.localNode.localConfig if args.setalt: alt = int(args.setalt) - prefs.fixed_position = True + localConfig.fixed_position = True print(f"Fixing altitude at {alt} meters") if args.setlat: lat = float(args.setlat) - prefs.fixed_position = True + localConfig.fixed_position = True print(f"Fixing latitude at {lat} degrees") if args.setlon: lon = float(args.setlon) - prefs.fixed_position = True + localConfig.fixed_position = True print(f"Fixing longitude at {lon} degrees") print("Setting device position") @@ -251,7 +222,7 @@ def onConnected(interface): if args.pos_fields: # If --pos-fields invoked with args, set position fields closeNow = True - prefs = interface.getNode(args.dest).localConfig + localConfig = interface.getNode(args.dest).localConfig allFields = 0 try: @@ -266,18 +237,18 @@ def onConnected(interface): else: 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") interface.getNode(args.dest).writeConfig() elif args.pos_fields is not None: # If --pos-fields invoked without args, read and display current value closeNow = True - prefs = interface.getNode(args.dest).localConfig + localConfig = interface.getNode(args.dest).localConfig fieldNames = [] for bit in config_pb2.PositionFlags.values(): - if prefs.position_flags & bit: + if localConfig.position_flags & bit: fieldNames.append(config_pb2.PositionFlags.Name(bit)) print(' '.join(fieldNames)) @@ -353,11 +324,19 @@ def onConnected(interface): # handle settings if args.set: closeNow = True - prefs = interface.getNode(args.dest).localConfig + node = interface.getNode(args.dest) # Handle the int/float/bool arguments 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]) + + 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("Writing modified preferences to device") interface.getNode(args.dest).writeConfig() @@ -391,35 +370,35 @@ def onConnected(interface): alt = 0 lat = 0.0 lon = 0.0 - prefs = interface.localNode.localConfig + localConfig = interface.localNode.localConfig if 'alt' in configuration['location']: alt = int(configuration['location']['alt']) - prefs.fixed_position = True + localConfig.fixed_position = True print(f"Fixing altitude at {alt} meters") if 'lat' in configuration['location']: lat = float(configuration['location']['lat']) - prefs.fixed_position = True + localConfig.fixed_position = True print(f"Fixing latitude at {lat} degrees") if 'lon' in configuration['location']: lon = float(configuration['location']['lon']) - prefs.fixed_position = True + localConfig.fixed_position = True print(f"Fixing longitude at {lon} degrees") print("Setting device position") interface.sendPosition(lat, lon, alt) interface.localNode.writeConfig() if 'user_prefs' in configuration: - prefs = interface.getNode(args.dest).localConfig + localConfig = interface.getNode(args.dest).localConfig 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") interface.getNode(args.dest).writeConfig() if 'userPrefs' in configuration: - prefs = interface.getNode(args.dest).localConfig + localConfig = interface.getNode(args.dest).localConfig 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") interface.getNode(args.dest).writeConfig() @@ -553,12 +532,21 @@ def onConnected(interface): if args.get: 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 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") if args.nodes: diff --git a/meshtastic/config_pb2.py b/meshtastic/config_pb2.py index 7562de5..55ec10f 100644 --- a/meshtastic/config_pb2.py +++ b/meshtastic/config_pb2.py @@ -14,7 +14,7 @@ _sym_db = _symbol_database.Default() -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0c\x63onfig.proto\"\xd6\x11\n\x06\x43onfig\x12&\n\x06\x64\x65vice\x18\x01 \x01(\x0b\x32\x14.Config.DeviceConfigH\x00\x12*\n\x08position\x18\x02 \x01(\x0b\x32\x16.Config.PositionConfigH\x00\x12$\n\x05power\x18\x03 \x01(\x0b\x32\x13.Config.PowerConfigH\x00\x12\"\n\x04wifi\x18\x04 \x01(\x0b\x32\x12.Config.WiFiConfigH\x00\x12(\n\x07\x64isplay\x18\x05 \x01(\x0b\x32\x15.Config.DisplayConfigH\x00\x12\"\n\x04lora\x18\x06 \x01(\x0b\x32\x12.Config.LoRaConfigH\x00\x1a\xd8\x01\n\x0c\x44\x65viceConfig\x12\'\n\x04role\x18\x01 \x01(\x0e\x32\x19.Config.DeviceConfig.Role\x12\x17\n\x0fserial_disabled\x18\x02 \x01(\x08\x12\x15\n\rfactory_reset\x18\x03 \x01(\x08\x12\x19\n\x11\x64\x65\x62ug_log_enabled\x18\x04 \x01(\x08\x12\x12\n\nntp_server\x18\x05 \x01(\t\"@\n\x04Role\x12\n\n\x06\x43lient\x10\x00\x12\x0e\n\nClientMute\x10\x01\x12\n\n\x06Router\x10\x02\x12\x10\n\x0cRouterClient\x10\x03\x1a\x86\x03\n\x0ePositionConfig\x12\x1f\n\x17position_broadcast_secs\x18\x01 \x01(\r\x12)\n!position_broadcast_smart_disabled\x18\x02 \x01(\x08\x12\x16\n\x0e\x66ixed_position\x18\x03 \x01(\x08\x12\x14\n\x0cgps_disabled\x18\x05 \x01(\x08\x12\x1b\n\x13gps_update_interval\x18\x06 \x01(\r\x12\x18\n\x10gps_attempt_time\x18\x07 \x01(\r\x12\x16\n\x0eposition_flags\x18\n \x01(\r\"\xaa\x01\n\rPositionFlags\x12\x11\n\rPOS_UNDEFINED\x10\x00\x12\x10\n\x0cPOS_ALTITUDE\x10\x01\x12\x0f\n\x0bPOS_ALT_MSL\x10\x02\x12\x0f\n\x0bPOS_GEO_SEP\x10\x04\x12\x0b\n\x07POS_DOP\x10\x08\x12\r\n\tPOS_HVDOP\x10\x10\x12\x11\n\rPOS_SATINVIEW\x10 \x12\x0f\n\x0bPOS_SEQ_NOS\x10@\x12\x12\n\rPOS_TIMESTAMP\x10\x80\x01\x1a\xf4\x03\n\x0bPowerConfig\x12\x39\n\x0e\x63harge_current\x18\x01 \x01(\x0e\x32!.Config.PowerConfig.ChargeCurrent\x12\x17\n\x0fis_power_saving\x18\x02 \x01(\x08\x12&\n\x1eon_battery_shutdown_after_secs\x18\x04 \x01(\r\x12\x1f\n\x17\x61\x64\x63_multiplier_override\x18\x06 \x01(\x02\x12\x1b\n\x13wait_bluetooth_secs\x18\x07 \x01(\r\x12\x1d\n\x15mesh_sds_timeout_secs\x18\t \x01(\r\x12\x10\n\x08sds_secs\x18\n \x01(\r\x12\x0f\n\x07ls_secs\x18\x0b \x01(\r\x12\x15\n\rmin_wake_secs\x18\x0c \x01(\r\"\xd1\x01\n\rChargeCurrent\x12\x0b\n\x07MAUnset\x10\x00\x12\t\n\x05MA100\x10\x01\x12\t\n\x05MA190\x10\x02\x12\t\n\x05MA280\x10\x03\x12\t\n\x05MA360\x10\x04\x12\t\n\x05MA450\x10\x05\x12\t\n\x05MA550\x10\x06\x12\t\n\x05MA630\x10\x07\x12\t\n\x05MA700\x10\x08\x12\t\n\x05MA780\x10\t\x12\t\n\x05MA880\x10\n\x12\t\n\x05MA960\x10\x0b\x12\n\n\x06MA1000\x10\x0c\x12\n\n\x06MA1080\x10\r\x12\n\n\x06MA1160\x10\x0e\x12\n\n\x06MA1240\x10\x0f\x12\n\n\x06MA1320\x10\x10\x1aK\n\nWiFiConfig\x12\x0c\n\x04ssid\x18\x01 \x01(\t\x12\x0b\n\x03psk\x18\x02 \x01(\t\x12\x0f\n\x07\x61p_mode\x18\x03 \x01(\x08\x12\x11\n\tap_hidden\x18\x04 \x01(\x08\x1a\x8f\x02\n\rDisplayConfig\x12\x16\n\x0escreen_on_secs\x18\x01 \x01(\r\x12=\n\ngps_format\x18\x02 \x01(\x0e\x32).Config.DisplayConfig.GpsCoordinateFormat\x12!\n\x19\x61uto_screen_carousel_secs\x18\x03 \x01(\r\"\x83\x01\n\x13GpsCoordinateFormat\x12\x10\n\x0cGpsFormatDec\x10\x00\x12\x10\n\x0cGpsFormatDMS\x10\x01\x12\x10\n\x0cGpsFormatUTM\x10\x02\x12\x11\n\rGpsFormatMGRS\x10\x03\x12\x10\n\x0cGpsFormatOLC\x10\x04\x12\x11\n\rGpsFormatOSGR\x10\x05\x1a\x93\x04\n\nLoRaConfig\x12\x10\n\x08tx_power\x18\x01 \x01(\x05\x12\x34\n\x0cmodem_preset\x18\x02 \x01(\x0e\x32\x1e.Config.LoRaConfig.ModemPreset\x12\x11\n\tbandwidth\x18\x03 \x01(\r\x12\x15\n\rspread_factor\x18\x04 \x01(\r\x12\x13\n\x0b\x63oding_rate\x18\x05 \x01(\r\x12\x18\n\x10\x66requency_offset\x18\x06 \x01(\x02\x12-\n\x06region\x18\x07 \x01(\x0e\x32\x1d.Config.LoRaConfig.RegionCode\x12\x11\n\thop_limit\x18\x08 \x01(\r\x12\x13\n\x0btx_disabled\x18\t \x01(\x08\x12\x17\n\x0fignore_incoming\x18g \x03(\r\"\x81\x01\n\nRegionCode\x12\t\n\x05Unset\x10\x00\x12\x06\n\x02US\x10\x01\x12\t\n\x05\x45U433\x10\x02\x12\t\n\x05\x45U868\x10\x03\x12\x06\n\x02\x43N\x10\x04\x12\x06\n\x02JP\x10\x05\x12\x07\n\x03\x41NZ\x10\x06\x12\x06\n\x02KR\x10\x07\x12\x06\n\x02TW\x10\x08\x12\x06\n\x02RU\x10\t\x12\x06\n\x02IN\x10\n\x12\t\n\x05NZ865\x10\x0b\x12\x06\n\x02TH\x10\x0c\"p\n\x0bModemPreset\x12\x0c\n\x08LongFast\x10\x00\x12\x0c\n\x08LongSlow\x10\x01\x12\r\n\tVLongSlow\x10\x02\x12\x0b\n\x07MidSlow\x10\x03\x12\x0b\n\x07MidFast\x10\x04\x12\r\n\tShortSlow\x10\x05\x12\r\n\tShortFast\x10\x06\x42\x10\n\x0epayloadVariantBH\n\x13\x63om.geeksville.meshB\x0c\x43onfigProtosH\x03Z!github.com/meshtastic/gomeshprotob\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0c\x63onfig.proto\"\xf8\x11\n\x06\x43onfig\x12&\n\x06\x64\x65vice\x18\x01 \x01(\x0b\x32\x14.Config.DeviceConfigH\x00\x12*\n\x08position\x18\x02 \x01(\x0b\x32\x16.Config.PositionConfigH\x00\x12$\n\x05power\x18\x03 \x01(\x0b\x32\x13.Config.PowerConfigH\x00\x12\"\n\x04wifi\x18\x04 \x01(\x0b\x32\x12.Config.WiFiConfigH\x00\x12(\n\x07\x64isplay\x18\x05 \x01(\x0b\x32\x15.Config.DisplayConfigH\x00\x12\"\n\x04lora\x18\x06 \x01(\x0b\x32\x12.Config.LoRaConfigH\x00\x1a\xd8\x01\n\x0c\x44\x65viceConfig\x12\'\n\x04role\x18\x01 \x01(\x0e\x32\x19.Config.DeviceConfig.Role\x12\x17\n\x0fserial_disabled\x18\x02 \x01(\x08\x12\x15\n\rfactory_reset\x18\x03 \x01(\x08\x12\x19\n\x11\x64\x65\x62ug_log_enabled\x18\x04 \x01(\x08\x12\x12\n\nntp_server\x18\x05 \x01(\t\"@\n\x04Role\x12\n\n\x06\x43lient\x10\x00\x12\x0e\n\nClientMute\x10\x01\x12\n\n\x06Router\x10\x02\x12\x10\n\x0cRouterClient\x10\x03\x1a\xa8\x03\n\x0ePositionConfig\x12\x1f\n\x17position_broadcast_secs\x18\x01 \x01(\r\x12)\n!position_broadcast_smart_disabled\x18\x02 \x01(\x08\x12\x16\n\x0e\x66ixed_position\x18\x03 \x01(\x08\x12\x14\n\x0cgps_disabled\x18\x05 \x01(\x08\x12\x1b\n\x13gps_update_interval\x18\x06 \x01(\r\x12\x18\n\x10gps_attempt_time\x18\x07 \x01(\r\x12\x16\n\x0eposition_flags\x18\n \x01(\r\"\xcc\x01\n\rPositionFlags\x12\x11\n\rPOS_UNDEFINED\x10\x00\x12\x10\n\x0cPOS_ALTITUDE\x10\x01\x12\x0f\n\x0bPOS_ALT_MSL\x10\x02\x12\x0f\n\x0bPOS_GEO_SEP\x10\x04\x12\x0b\n\x07POS_DOP\x10\x08\x12\r\n\tPOS_HVDOP\x10\x10\x12\x11\n\rPOS_SATINVIEW\x10 \x12\x0f\n\x0bPOS_SEQ_NOS\x10@\x12\x12\n\rPOS_TIMESTAMP\x10\x80\x01\x12\x10\n\x0bPOS_HEADING\x10\x80\x02\x12\x0e\n\tPOS_SPEED\x10\x80\x04\x1a\xf4\x03\n\x0bPowerConfig\x12\x39\n\x0e\x63harge_current\x18\x01 \x01(\x0e\x32!.Config.PowerConfig.ChargeCurrent\x12\x17\n\x0fis_power_saving\x18\x02 \x01(\x08\x12&\n\x1eon_battery_shutdown_after_secs\x18\x04 \x01(\r\x12\x1f\n\x17\x61\x64\x63_multiplier_override\x18\x06 \x01(\x02\x12\x1b\n\x13wait_bluetooth_secs\x18\x07 \x01(\r\x12\x1d\n\x15mesh_sds_timeout_secs\x18\t \x01(\r\x12\x10\n\x08sds_secs\x18\n \x01(\r\x12\x0f\n\x07ls_secs\x18\x0b \x01(\r\x12\x15\n\rmin_wake_secs\x18\x0c \x01(\r\"\xd1\x01\n\rChargeCurrent\x12\x0b\n\x07MAUnset\x10\x00\x12\t\n\x05MA100\x10\x01\x12\t\n\x05MA190\x10\x02\x12\t\n\x05MA280\x10\x03\x12\t\n\x05MA360\x10\x04\x12\t\n\x05MA450\x10\x05\x12\t\n\x05MA550\x10\x06\x12\t\n\x05MA630\x10\x07\x12\t\n\x05MA700\x10\x08\x12\t\n\x05MA780\x10\t\x12\t\n\x05MA880\x10\n\x12\t\n\x05MA960\x10\x0b\x12\n\n\x06MA1000\x10\x0c\x12\n\n\x06MA1080\x10\r\x12\n\n\x06MA1160\x10\x0e\x12\n\n\x06MA1240\x10\x0f\x12\n\n\x06MA1320\x10\x10\x1aK\n\nWiFiConfig\x12\x0c\n\x04ssid\x18\x01 \x01(\t\x12\x0b\n\x03psk\x18\x02 \x01(\t\x12\x0f\n\x07\x61p_mode\x18\x03 \x01(\x08\x12\x11\n\tap_hidden\x18\x04 \x01(\x08\x1a\x8f\x02\n\rDisplayConfig\x12\x16\n\x0escreen_on_secs\x18\x01 \x01(\r\x12=\n\ngps_format\x18\x02 \x01(\x0e\x32).Config.DisplayConfig.GpsCoordinateFormat\x12!\n\x19\x61uto_screen_carousel_secs\x18\x03 \x01(\r\"\x83\x01\n\x13GpsCoordinateFormat\x12\x10\n\x0cGpsFormatDec\x10\x00\x12\x10\n\x0cGpsFormatDMS\x10\x01\x12\x10\n\x0cGpsFormatUTM\x10\x02\x12\x11\n\rGpsFormatMGRS\x10\x03\x12\x10\n\x0cGpsFormatOLC\x10\x04\x12\x11\n\rGpsFormatOSGR\x10\x05\x1a\x93\x04\n\nLoRaConfig\x12\x10\n\x08tx_power\x18\x01 \x01(\x05\x12\x34\n\x0cmodem_preset\x18\x02 \x01(\x0e\x32\x1e.Config.LoRaConfig.ModemPreset\x12\x11\n\tbandwidth\x18\x03 \x01(\r\x12\x15\n\rspread_factor\x18\x04 \x01(\r\x12\x13\n\x0b\x63oding_rate\x18\x05 \x01(\r\x12\x18\n\x10\x66requency_offset\x18\x06 \x01(\x02\x12-\n\x06region\x18\x07 \x01(\x0e\x32\x1d.Config.LoRaConfig.RegionCode\x12\x11\n\thop_limit\x18\x08 \x01(\r\x12\x13\n\x0btx_disabled\x18\t \x01(\x08\x12\x17\n\x0fignore_incoming\x18g \x03(\r\"\x81\x01\n\nRegionCode\x12\t\n\x05Unset\x10\x00\x12\x06\n\x02US\x10\x01\x12\t\n\x05\x45U433\x10\x02\x12\t\n\x05\x45U868\x10\x03\x12\x06\n\x02\x43N\x10\x04\x12\x06\n\x02JP\x10\x05\x12\x07\n\x03\x41NZ\x10\x06\x12\x06\n\x02KR\x10\x07\x12\x06\n\x02TW\x10\x08\x12\x06\n\x02RU\x10\t\x12\x06\n\x02IN\x10\n\x12\t\n\x05NZ865\x10\x0b\x12\x06\n\x02TH\x10\x0c\"p\n\x0bModemPreset\x12\x0c\n\x08LongFast\x10\x00\x12\x0c\n\x08LongSlow\x10\x01\x12\r\n\tVLongSlow\x10\x02\x12\x0b\n\x07MedSlow\x10\x03\x12\x0b\n\x07MedFast\x10\x04\x12\r\n\tShortSlow\x10\x05\x12\r\n\tShortFast\x10\x06\x42\x10\n\x0epayloadVariantBH\n\x13\x63om.geeksville.meshB\x0c\x43onfigProtosH\x03Z!github.com/meshtastic/gomeshprotob\x06proto3') @@ -91,29 +91,29 @@ if _descriptor._USE_C_DESCRIPTORS == False: DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b'\n\023com.geeksville.meshB\014ConfigProtosH\003Z!github.com/meshtastic/gomeshproto' _CONFIG._serialized_start=17 - _CONFIG._serialized_end=2279 + _CONFIG._serialized_end=2313 _CONFIG_DEVICECONFIG._serialized_start=264 _CONFIG_DEVICECONFIG._serialized_end=480 _CONFIG_DEVICECONFIG_ROLE._serialized_start=416 _CONFIG_DEVICECONFIG_ROLE._serialized_end=480 _CONFIG_POSITIONCONFIG._serialized_start=483 - _CONFIG_POSITIONCONFIG._serialized_end=873 + _CONFIG_POSITIONCONFIG._serialized_end=907 _CONFIG_POSITIONCONFIG_POSITIONFLAGS._serialized_start=703 - _CONFIG_POSITIONCONFIG_POSITIONFLAGS._serialized_end=873 - _CONFIG_POWERCONFIG._serialized_start=876 - _CONFIG_POWERCONFIG._serialized_end=1376 - _CONFIG_POWERCONFIG_CHARGECURRENT._serialized_start=1167 - _CONFIG_POWERCONFIG_CHARGECURRENT._serialized_end=1376 - _CONFIG_WIFICONFIG._serialized_start=1378 - _CONFIG_WIFICONFIG._serialized_end=1453 - _CONFIG_DISPLAYCONFIG._serialized_start=1456 - _CONFIG_DISPLAYCONFIG._serialized_end=1727 - _CONFIG_DISPLAYCONFIG_GPSCOORDINATEFORMAT._serialized_start=1596 - _CONFIG_DISPLAYCONFIG_GPSCOORDINATEFORMAT._serialized_end=1727 - _CONFIG_LORACONFIG._serialized_start=1730 - _CONFIG_LORACONFIG._serialized_end=2261 - _CONFIG_LORACONFIG_REGIONCODE._serialized_start=2018 - _CONFIG_LORACONFIG_REGIONCODE._serialized_end=2147 - _CONFIG_LORACONFIG_MODEMPRESET._serialized_start=2149 - _CONFIG_LORACONFIG_MODEMPRESET._serialized_end=2261 + _CONFIG_POSITIONCONFIG_POSITIONFLAGS._serialized_end=907 + _CONFIG_POWERCONFIG._serialized_start=910 + _CONFIG_POWERCONFIG._serialized_end=1410 + _CONFIG_POWERCONFIG_CHARGECURRENT._serialized_start=1201 + _CONFIG_POWERCONFIG_CHARGECURRENT._serialized_end=1410 + _CONFIG_WIFICONFIG._serialized_start=1412 + _CONFIG_WIFICONFIG._serialized_end=1487 + _CONFIG_DISPLAYCONFIG._serialized_start=1490 + _CONFIG_DISPLAYCONFIG._serialized_end=1761 + _CONFIG_DISPLAYCONFIG_GPSCOORDINATEFORMAT._serialized_start=1630 + _CONFIG_DISPLAYCONFIG_GPSCOORDINATEFORMAT._serialized_end=1761 + _CONFIG_LORACONFIG._serialized_start=1764 + _CONFIG_LORACONFIG._serialized_end=2295 + _CONFIG_LORACONFIG_REGIONCODE._serialized_start=2052 + _CONFIG_LORACONFIG_REGIONCODE._serialized_end=2181 + _CONFIG_LORACONFIG_MODEMPRESET._serialized_start=2183 + _CONFIG_LORACONFIG_MODEMPRESET._serialized_end=2295 # @@protoc_insertion_point(module_scope) diff --git a/meshtastic/mesh_interface.py b/meshtastic/mesh_interface.py index 6db4653..617f2a0 100644 --- a/meshtastic/mesh_interface.py +++ b/meshtastic/mesh_interface.py @@ -532,15 +532,18 @@ class MeshInterface: # stream API fromRadio.config_complete_id logging.debug(f"Config complete ID {self.configId}") self._handleConfigComplete() + elif fromRadio.HasField("packet"): self._handlePacketFromRadio(fromRadio.packet) + elif fromRadio.rebooted: # Tell clients the device went away. Careful not to call the overridden # subclass version that closes the serial port MeshInterface._disconnected(self) self._startConfig() # redownload the node db etc... - elif fromRadio.config: + + elif fromRadio.config or fromRadio.moduleConfig: if fromRadio.config.HasField("device"): self.localNode.localConfig.device.CopyFrom(fromRadio.config.device) elif fromRadio.config.HasField("position"): @@ -553,6 +556,20 @@ class MeshInterface: self.localNode.localConfig.display.CopyFrom(fromRadio.config.display) elif fromRadio.config.HasField("lora"): self.localNode.localConfig.lora.CopyFrom(fromRadio.config.lora) + + 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: logging.debug("Unexpected FromRadio payload") diff --git a/meshtastic/mesh_pb2.py b/meshtastic/mesh_pb2.py index f88cf26..4a872cc 100644 --- a/meshtastic/mesh_pb2.py +++ b/meshtastic/mesh_pb2.py @@ -14,11 +14,12 @@ _sym_db = _symbol_database.Default() from . import config_pb2 as config__pb2 +from . import module_config_pb2 as module__config__pb2 from . import portnums_pb2 as portnums__pb2 from . import telemetry_pb2 as telemetry__pb2 -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\nmesh.proto\x1a\x0c\x63onfig.proto\x1a\x0eportnums.proto\x1a\x0ftelemetry.proto\"\xf1\x05\n\x08Position\x12\x12\n\nlatitude_i\x18\x01 \x01(\x0f\x12\x13\n\x0blongitude_i\x18\x02 \x01(\x0f\x12\x10\n\x08\x61ltitude\x18\x03 \x01(\x05\x12\x0c\n\x04time\x18\t \x01(\x07\x12,\n\x0flocation_source\x18\n \x01(\x0e\x32\x13.Position.LocSource\x12,\n\x0f\x61ltitude_source\x18\x0b \x01(\x0e\x32\x13.Position.AltSource\x12\x15\n\rpos_timestamp\x18\x0c \x01(\x07\x12\x17\n\x0fpos_time_millis\x18\r \x01(\x05\x12\x14\n\x0c\x61ltitude_hae\x18\x0e \x01(\x11\x12\x15\n\ralt_geoid_sep\x18\x0f \x01(\x11\x12\x0c\n\x04PDOP\x18\x10 \x01(\r\x12\x0c\n\x04HDOP\x18\x11 \x01(\r\x12\x0c\n\x04VDOP\x18\x12 \x01(\r\x12\x14\n\x0cgps_accuracy\x18\x13 \x01(\r\x12\x14\n\x0cground_speed\x18\x14 \x01(\r\x12\x14\n\x0cground_track\x18\x15 \x01(\r\x12\x13\n\x0b\x66ix_quality\x18\x16 \x01(\r\x12\x10\n\x08\x66ix_type\x18\x17 \x01(\r\x12\x14\n\x0csats_in_view\x18\x18 \x01(\r\x12\x11\n\tsensor_id\x18\x19 \x01(\r\x12\x17\n\x0fpos_next_update\x18( \x01(\r\x12\x16\n\x0epos_seq_number\x18) \x01(\r\"n\n\tLocSource\x12\x16\n\x12LOCSRC_UNSPECIFIED\x10\x00\x12\x17\n\x13LOCSRC_MANUAL_ENTRY\x10\x01\x12\x17\n\x13LOCSRC_GPS_INTERNAL\x10\x02\x12\x17\n\x13LOCSRC_GPS_EXTERNAL\x10\x03\"\x85\x01\n\tAltSource\x12\x16\n\x12\x41LTSRC_UNSPECIFIED\x10\x00\x12\x17\n\x13\x41LTSRC_MANUAL_ENTRY\x10\x01\x12\x17\n\x13\x41LTSRC_GPS_INTERNAL\x10\x02\x12\x17\n\x13\x41LTSRC_GPS_EXTERNAL\x10\x03\x12\x15\n\x11\x41LTSRC_BAROMETRIC\x10\x04\"\xc2\x01\n\x04User\x12\n\n\x02id\x18\x01 \x01(\t\x12\x11\n\tlong_name\x18\x02 \x01(\t\x12\x12\n\nshort_name\x18\x03 \x01(\t\x12\x0f\n\x07macaddr\x18\x04 \x01(\x0c\x12 \n\x08hw_model\x18\x06 \x01(\x0e\x32\x0e.HardwareModel\x12\x13\n\x0bis_licensed\x18\x07 \x01(\x08\x12\x14\n\x0ctx_power_dbm\x18\n \x01(\r\x12\x14\n\x0c\x61nt_gain_dbi\x18\x0b \x01(\r\x12\x13\n\x0b\x61nt_azimuth\x18\x0c \x01(\r\"\x1f\n\x0eRouteDiscovery\x12\r\n\x05route\x18\x02 \x03(\x07\"\xc5\x02\n\x07Routing\x12(\n\rroute_request\x18\x01 \x01(\x0b\x32\x0f.RouteDiscoveryH\x00\x12&\n\x0broute_reply\x18\x02 \x01(\x0b\x32\x0f.RouteDiscoveryH\x00\x12&\n\x0c\x65rror_reason\x18\x03 \x01(\x0e\x32\x0e.Routing.ErrorH\x00\"\xb4\x01\n\x05\x45rror\x12\x08\n\x04NONE\x10\x00\x12\x0c\n\x08NO_ROUTE\x10\x01\x12\x0b\n\x07GOT_NAK\x10\x02\x12\x0b\n\x07TIMEOUT\x10\x03\x12\x10\n\x0cNO_INTERFACE\x10\x04\x12\x12\n\x0eMAX_RETRANSMIT\x10\x05\x12\x0e\n\nNO_CHANNEL\x10\x06\x12\r\n\tTOO_LARGE\x10\x07\x12\x0f\n\x0bNO_RESPONSE\x10\x08\x12\x0f\n\x0b\x42\x41\x44_REQUEST\x10 \x12\x12\n\x0eNOT_AUTHORIZED\x10!B\t\n\x07variant\"\xb9\x01\n\x04\x44\x61ta\x12\x19\n\x07portnum\x18\x01 \x01(\x0e\x32\x08.PortNum\x12\x0f\n\x07payload\x18\x02 \x01(\x0c\x12\x15\n\rwant_response\x18\x03 \x01(\x08\x12\x0c\n\x04\x64\x65st\x18\x04 \x01(\x07\x12\x0e\n\x06source\x18\x05 \x01(\x07\x12\x12\n\nrequest_id\x18\x06 \x01(\x07\x12\x10\n\x08reply_id\x18\x07 \x01(\x07\x12\r\n\x05\x65moji\x18\x08 \x01(\x07\x12\x1b\n\x08location\x18\t \x01(\x0b\x32\t.Location\"_\n\x08Location\x12\n\n\x02id\x18\x01 \x01(\r\x12\x12\n\nlatitude_i\x18\x02 \x01(\x0f\x12\x13\n\x0blongitude_i\x18\x03 \x01(\x0f\x12\x0e\n\x06\x65xpire\x18\x04 \x01(\r\x12\x0e\n\x06locked\x18\x05 \x01(\x08\"\xca\x03\n\nMeshPacket\x12\x0c\n\x04\x66rom\x18\x01 \x01(\x07\x12\n\n\x02to\x18\x02 \x01(\x07\x12\x0f\n\x07\x63hannel\x18\x03 \x01(\r\x12\x18\n\x07\x64\x65\x63oded\x18\x04 \x01(\x0b\x32\x05.DataH\x00\x12\x13\n\tencrypted\x18\x05 \x01(\x0cH\x00\x12\n\n\x02id\x18\x06 \x01(\x07\x12\x0f\n\x07rx_time\x18\x07 \x01(\x07\x12\x0e\n\x06rx_snr\x18\x08 \x01(\x02\x12\x11\n\thop_limit\x18\n \x01(\r\x12\x10\n\x08want_ack\x18\x0b \x01(\x08\x12&\n\x08priority\x18\x0c \x01(\x0e\x32\x14.MeshPacket.Priority\x12\x0f\n\x07rx_rssi\x18\r \x01(\x05\x12$\n\x07\x64\x65layed\x18\x0f \x01(\x0e\x32\x13.MeshPacket.Delayed\"[\n\x08Priority\x12\t\n\x05UNSET\x10\x00\x12\x07\n\x03MIN\x10\x01\x12\x0e\n\nBACKGROUND\x10\n\x12\x0b\n\x07\x44\x45\x46\x41ULT\x10@\x12\x0c\n\x08RELIABLE\x10\x46\x12\x07\n\x03\x41\x43K\x10x\x12\x07\n\x03MAX\x10\x7f\"B\n\x07\x44\x65layed\x12\x0c\n\x08NO_DELAY\x10\x00\x12\x15\n\x11\x44\x45LAYED_BROADCAST\x10\x01\x12\x12\n\x0e\x44\x45LAYED_DIRECT\x10\x02\x42\x10\n\x0epayloadVariant\"\x92\x01\n\x08NodeInfo\x12\x0b\n\x03num\x18\x01 \x01(\r\x12\x13\n\x04user\x18\x02 \x01(\x0b\x32\x05.User\x12\x1b\n\x08position\x18\x03 \x01(\x0b\x32\t.Position\x12\x0b\n\x03snr\x18\x04 \x01(\x02\x12\x12\n\nlast_heard\x18\x05 \x01(\x07\x12&\n\x0e\x64\x65vice_metrics\x18\x06 \x01(\x0b\x32\x0e.DeviceMetrics\"\x86\x03\n\nMyNodeInfo\x12\x13\n\x0bmy_node_num\x18\x01 \x01(\r\x12\x0f\n\x07has_gps\x18\x02 \x01(\x08\x12\x14\n\x0cmax_channels\x18\x0f \x01(\r\x12\x18\n\x10\x66irmware_version\x18\x06 \x01(\t\x12&\n\nerror_code\x18\x07 \x01(\x0e\x32\x12.CriticalErrorCode\x12\x15\n\rerror_address\x18\x08 \x01(\r\x12\x13\n\x0b\x65rror_count\x18\t \x01(\r\x12\x14\n\x0creboot_count\x18\n \x01(\r\x12\x0f\n\x07\x62itrate\x18\x0b \x01(\x02\x12\x1c\n\x14message_timeout_msec\x18\r \x01(\r\x12\x17\n\x0fmin_app_version\x18\x0e \x01(\r\x12\x15\n\rair_period_tx\x18\x10 \x03(\r\x12\x15\n\rair_period_rx\x18\x11 \x03(\r\x12\x10\n\x08has_wifi\x18\x12 \x01(\x08\x12\x1b\n\x13\x63hannel_utilization\x18\x13 \x01(\x02\x12\x13\n\x0b\x61ir_util_tx\x18\x14 \x01(\x02\"\xb5\x01\n\tLogRecord\x12\x0f\n\x07message\x18\x01 \x01(\t\x12\x0c\n\x04time\x18\x02 \x01(\x07\x12\x0e\n\x06source\x18\x03 \x01(\t\x12\x1f\n\x05level\x18\x04 \x01(\x0e\x32\x10.LogRecord.Level\"X\n\x05Level\x12\t\n\x05UNSET\x10\x00\x12\x0c\n\x08\x43RITICAL\x10\x32\x12\t\n\x05\x45RROR\x10(\x12\x0b\n\x07WARNING\x10\x1e\x12\x08\n\x04INFO\x10\x14\x12\t\n\x05\x44\x45\x42UG\x10\n\x12\t\n\x05TRACE\x10\x05\"\xfd\x01\n\tFromRadio\x12\n\n\x02id\x18\x01 \x01(\r\x12\x1d\n\x06packet\x18\x0b \x01(\x0b\x32\x0b.MeshPacketH\x00\x12\x1e\n\x07my_info\x18\x03 \x01(\x0b\x32\x0b.MyNodeInfoH\x00\x12\x1e\n\tnode_info\x18\x04 \x01(\x0b\x32\t.NodeInfoH\x00\x12\x19\n\x06\x63onfig\x18\x06 \x01(\x0b\x32\x07.ConfigH\x00\x12 \n\nlog_record\x18\x07 \x01(\x0b\x32\n.LogRecordH\x00\x12\x1c\n\x12\x63onfig_complete_id\x18\x08 \x01(\rH\x00\x12\x12\n\x08rebooted\x18\t \x01(\x08H\x00\x42\x10\n\x0epayloadVariantJ\x04\x08\x02\x10\x03\"\xe1\x01\n\x07ToRadio\x12\x1d\n\x06packet\x18\x02 \x01(\x0b\x32\x0b.MeshPacketH\x00\x12&\n\tpeer_info\x18\x03 \x01(\x0b\x32\x11.ToRadio.PeerInfoH\x00\x12\x18\n\x0ewant_config_id\x18\x64 \x01(\rH\x00\x12\x14\n\ndisconnect\x18h \x01(\x08H\x00\x1a\x35\n\x08PeerInfo\x12\x13\n\x0b\x61pp_version\x18\x01 \x01(\r\x12\x14\n\x0cmqtt_gateway\x18\x02 \x01(\x08\x42\x10\n\x0epayloadVariantJ\x04\x08\x01\x10\x02J\x04\x08\x65\x10\x66J\x04\x08\x66\x10gJ\x04\x08g\x10h\"5\n\nCompressed\x12\x19\n\x07portnum\x18\x01 \x01(\x0e\x32\x08.PortNum\x12\x0c\n\x04\x64\x61ta\x18\x02 \x01(\x0c*\x97\x03\n\rHardwareModel\x12\t\n\x05UNSET\x10\x00\x12\x0c\n\x08TLORA_V2\x10\x01\x12\x0c\n\x08TLORA_V1\x10\x02\x12\x12\n\x0eTLORA_V2_1_1p6\x10\x03\x12\t\n\x05TBEAM\x10\x04\x12\x0f\n\x0bHELTEC_V2_0\x10\x05\x12\x0c\n\x08TBEAM0p7\x10\x06\x12\n\n\x06T_ECHO\x10\x07\x12\x10\n\x0cTLORA_V1_1p3\x10\x08\x12\x0b\n\x07RAK4631\x10\t\x12\x0f\n\x0bHELTEC_V2_1\x10\n\x12\r\n\tHELTEC_V1\x10\x0b\x12\x11\n\rLORA_RELAY_V1\x10 \x12\x0e\n\nNRF52840DK\x10!\x12\x07\n\x03PPR\x10\"\x12\x0f\n\x0bGENIEBLOCKS\x10#\x12\x11\n\rNRF52_UNKNOWN\x10$\x12\r\n\tPORTDUINO\x10%\x12\x0f\n\x0b\x41NDROID_SIM\x10&\x12\n\n\x06\x44IY_V1\x10\'\x12\x0c\n\x08RAK11200\x10(\x12\x0b\n\x07NANO_G1\x10)\x12\x15\n\x11NRF52840_PCA10059\x10*\x12\n\n\x06\x44R_DEV\x10+\x12\x0b\n\x07M5STACK\x10,\x12\x0f\n\nPRIVATE_HW\x10\xff\x01*.\n\tConstants\x12\n\n\x06Unused\x10\x00\x12\x15\n\x10\x44\x41TA_PAYLOAD_LEN\x10\xed\x01*\xe1\x01\n\x11\x43riticalErrorCode\x12\x08\n\x04None\x10\x00\x12\x0e\n\nTxWatchdog\x10\x01\x12\x12\n\x0eSleepEnterWait\x10\x02\x12\x0b\n\x07NoRadio\x10\x03\x12\x0f\n\x0bUnspecified\x10\x04\x12\x13\n\x0fUBloxInitFailed\x10\x05\x12\x0c\n\x08NoAXP192\x10\x06\x12\x17\n\x13InvalidRadioSetting\x10\x07\x12\x12\n\x0eTransmitFailed\x10\x08\x12\x0c\n\x08\x42rownout\x10\t\x12\x11\n\rSX1262Failure\x10\n\x12\x0f\n\x0bRadioSpiBug\x10\x0b\x42\x46\n\x13\x63om.geeksville.meshB\nMeshProtosH\x03Z!github.com/meshtastic/gomeshprotob\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\nmesh.proto\x1a\x0c\x63onfig.proto\x1a\x13module_config.proto\x1a\x0eportnums.proto\x1a\x0ftelemetry.proto\"\xf1\x05\n\x08Position\x12\x12\n\nlatitude_i\x18\x01 \x01(\x0f\x12\x13\n\x0blongitude_i\x18\x02 \x01(\x0f\x12\x10\n\x08\x61ltitude\x18\x03 \x01(\x05\x12\x0c\n\x04time\x18\t \x01(\x07\x12,\n\x0flocation_source\x18\n \x01(\x0e\x32\x13.Position.LocSource\x12,\n\x0f\x61ltitude_source\x18\x0b \x01(\x0e\x32\x13.Position.AltSource\x12\x15\n\rpos_timestamp\x18\x0c \x01(\x07\x12\x17\n\x0fpos_time_millis\x18\r \x01(\x05\x12\x14\n\x0c\x61ltitude_hae\x18\x0e \x01(\x11\x12\x15\n\ralt_geoid_sep\x18\x0f \x01(\x11\x12\x0c\n\x04PDOP\x18\x10 \x01(\r\x12\x0c\n\x04HDOP\x18\x11 \x01(\r\x12\x0c\n\x04VDOP\x18\x12 \x01(\r\x12\x14\n\x0cgps_accuracy\x18\x13 \x01(\r\x12\x14\n\x0cground_speed\x18\x14 \x01(\r\x12\x14\n\x0cground_track\x18\x15 \x01(\r\x12\x13\n\x0b\x66ix_quality\x18\x16 \x01(\r\x12\x10\n\x08\x66ix_type\x18\x17 \x01(\r\x12\x14\n\x0csats_in_view\x18\x18 \x01(\r\x12\x11\n\tsensor_id\x18\x19 \x01(\r\x12\x17\n\x0fpos_next_update\x18( \x01(\r\x12\x16\n\x0epos_seq_number\x18) \x01(\r\"n\n\tLocSource\x12\x16\n\x12LOCSRC_UNSPECIFIED\x10\x00\x12\x17\n\x13LOCSRC_MANUAL_ENTRY\x10\x01\x12\x17\n\x13LOCSRC_GPS_INTERNAL\x10\x02\x12\x17\n\x13LOCSRC_GPS_EXTERNAL\x10\x03\"\x85\x01\n\tAltSource\x12\x16\n\x12\x41LTSRC_UNSPECIFIED\x10\x00\x12\x17\n\x13\x41LTSRC_MANUAL_ENTRY\x10\x01\x12\x17\n\x13\x41LTSRC_GPS_INTERNAL\x10\x02\x12\x17\n\x13\x41LTSRC_GPS_EXTERNAL\x10\x03\x12\x15\n\x11\x41LTSRC_BAROMETRIC\x10\x04\"\xc2\x01\n\x04User\x12\n\n\x02id\x18\x01 \x01(\t\x12\x11\n\tlong_name\x18\x02 \x01(\t\x12\x12\n\nshort_name\x18\x03 \x01(\t\x12\x0f\n\x07macaddr\x18\x04 \x01(\x0c\x12 \n\x08hw_model\x18\x06 \x01(\x0e\x32\x0e.HardwareModel\x12\x13\n\x0bis_licensed\x18\x07 \x01(\x08\x12\x14\n\x0ctx_power_dbm\x18\n \x01(\r\x12\x14\n\x0c\x61nt_gain_dbi\x18\x0b \x01(\r\x12\x13\n\x0b\x61nt_azimuth\x18\x0c \x01(\r\"\x1f\n\x0eRouteDiscovery\x12\r\n\x05route\x18\x02 \x03(\x07\"\xc5\x02\n\x07Routing\x12(\n\rroute_request\x18\x01 \x01(\x0b\x32\x0f.RouteDiscoveryH\x00\x12&\n\x0broute_reply\x18\x02 \x01(\x0b\x32\x0f.RouteDiscoveryH\x00\x12&\n\x0c\x65rror_reason\x18\x03 \x01(\x0e\x32\x0e.Routing.ErrorH\x00\"\xb4\x01\n\x05\x45rror\x12\x08\n\x04NONE\x10\x00\x12\x0c\n\x08NO_ROUTE\x10\x01\x12\x0b\n\x07GOT_NAK\x10\x02\x12\x0b\n\x07TIMEOUT\x10\x03\x12\x10\n\x0cNO_INTERFACE\x10\x04\x12\x12\n\x0eMAX_RETRANSMIT\x10\x05\x12\x0e\n\nNO_CHANNEL\x10\x06\x12\r\n\tTOO_LARGE\x10\x07\x12\x0f\n\x0bNO_RESPONSE\x10\x08\x12\x0f\n\x0b\x42\x41\x44_REQUEST\x10 \x12\x12\n\x0eNOT_AUTHORIZED\x10!B\t\n\x07variant\"\xb9\x01\n\x04\x44\x61ta\x12\x19\n\x07portnum\x18\x01 \x01(\x0e\x32\x08.PortNum\x12\x0f\n\x07payload\x18\x02 \x01(\x0c\x12\x15\n\rwant_response\x18\x03 \x01(\x08\x12\x0c\n\x04\x64\x65st\x18\x04 \x01(\x07\x12\x0e\n\x06source\x18\x05 \x01(\x07\x12\x12\n\nrequest_id\x18\x06 \x01(\x07\x12\x10\n\x08reply_id\x18\x07 \x01(\x07\x12\r\n\x05\x65moji\x18\x08 \x01(\x07\x12\x1b\n\x08location\x18\t \x01(\x0b\x32\t.Location\"_\n\x08Location\x12\n\n\x02id\x18\x01 \x01(\r\x12\x12\n\nlatitude_i\x18\x02 \x01(\x0f\x12\x13\n\x0blongitude_i\x18\x03 \x01(\x0f\x12\x0e\n\x06\x65xpire\x18\x04 \x01(\r\x12\x0e\n\x06locked\x18\x05 \x01(\x08\"\xca\x03\n\nMeshPacket\x12\x0c\n\x04\x66rom\x18\x01 \x01(\x07\x12\n\n\x02to\x18\x02 \x01(\x07\x12\x0f\n\x07\x63hannel\x18\x03 \x01(\r\x12\x18\n\x07\x64\x65\x63oded\x18\x04 \x01(\x0b\x32\x05.DataH\x00\x12\x13\n\tencrypted\x18\x05 \x01(\x0cH\x00\x12\n\n\x02id\x18\x06 \x01(\x07\x12\x0f\n\x07rx_time\x18\x07 \x01(\x07\x12\x0e\n\x06rx_snr\x18\x08 \x01(\x02\x12\x11\n\thop_limit\x18\n \x01(\r\x12\x10\n\x08want_ack\x18\x0b \x01(\x08\x12&\n\x08priority\x18\x0c \x01(\x0e\x32\x14.MeshPacket.Priority\x12\x0f\n\x07rx_rssi\x18\r \x01(\x05\x12$\n\x07\x64\x65layed\x18\x0f \x01(\x0e\x32\x13.MeshPacket.Delayed\"[\n\x08Priority\x12\t\n\x05UNSET\x10\x00\x12\x07\n\x03MIN\x10\x01\x12\x0e\n\nBACKGROUND\x10\n\x12\x0b\n\x07\x44\x45\x46\x41ULT\x10@\x12\x0c\n\x08RELIABLE\x10\x46\x12\x07\n\x03\x41\x43K\x10x\x12\x07\n\x03MAX\x10\x7f\"B\n\x07\x44\x65layed\x12\x0c\n\x08NO_DELAY\x10\x00\x12\x15\n\x11\x44\x45LAYED_BROADCAST\x10\x01\x12\x12\n\x0e\x44\x45LAYED_DIRECT\x10\x02\x42\x10\n\x0epayloadVariant\"\x92\x01\n\x08NodeInfo\x12\x0b\n\x03num\x18\x01 \x01(\r\x12\x13\n\x04user\x18\x02 \x01(\x0b\x32\x05.User\x12\x1b\n\x08position\x18\x03 \x01(\x0b\x32\t.Position\x12\x0b\n\x03snr\x18\x04 \x01(\x02\x12\x12\n\nlast_heard\x18\x05 \x01(\x07\x12&\n\x0e\x64\x65vice_metrics\x18\x06 \x01(\x0b\x32\x0e.DeviceMetrics\"\x86\x03\n\nMyNodeInfo\x12\x13\n\x0bmy_node_num\x18\x01 \x01(\r\x12\x0f\n\x07has_gps\x18\x02 \x01(\x08\x12\x14\n\x0cmax_channels\x18\x0f \x01(\r\x12\x18\n\x10\x66irmware_version\x18\x06 \x01(\t\x12&\n\nerror_code\x18\x07 \x01(\x0e\x32\x12.CriticalErrorCode\x12\x15\n\rerror_address\x18\x08 \x01(\r\x12\x13\n\x0b\x65rror_count\x18\t \x01(\r\x12\x14\n\x0creboot_count\x18\n \x01(\r\x12\x0f\n\x07\x62itrate\x18\x0b \x01(\x02\x12\x1c\n\x14message_timeout_msec\x18\r \x01(\r\x12\x17\n\x0fmin_app_version\x18\x0e \x01(\r\x12\x15\n\rair_period_tx\x18\x10 \x03(\r\x12\x15\n\rair_period_rx\x18\x11 \x03(\r\x12\x10\n\x08has_wifi\x18\x12 \x01(\x08\x12\x1b\n\x13\x63hannel_utilization\x18\x13 \x01(\x02\x12\x13\n\x0b\x61ir_util_tx\x18\x14 \x01(\x02\"\xb5\x01\n\tLogRecord\x12\x0f\n\x07message\x18\x01 \x01(\t\x12\x0c\n\x04time\x18\x02 \x01(\x07\x12\x0e\n\x06source\x18\x03 \x01(\t\x12\x1f\n\x05level\x18\x04 \x01(\x0e\x32\x10.LogRecord.Level\"X\n\x05Level\x12\t\n\x05UNSET\x10\x00\x12\x0c\n\x08\x43RITICAL\x10\x32\x12\t\n\x05\x45RROR\x10(\x12\x0b\n\x07WARNING\x10\x1e\x12\x08\n\x04INFO\x10\x14\x12\t\n\x05\x44\x45\x42UG\x10\n\x12\t\n\x05TRACE\x10\x05\"\xa4\x02\n\tFromRadio\x12\n\n\x02id\x18\x01 \x01(\r\x12\x1d\n\x06packet\x18\x0b \x01(\x0b\x32\x0b.MeshPacketH\x00\x12\x1e\n\x07my_info\x18\x03 \x01(\x0b\x32\x0b.MyNodeInfoH\x00\x12\x1e\n\tnode_info\x18\x04 \x01(\x0b\x32\t.NodeInfoH\x00\x12\x19\n\x06\x63onfig\x18\x06 \x01(\x0b\x32\x07.ConfigH\x00\x12 \n\nlog_record\x18\x07 \x01(\x0b\x32\n.LogRecordH\x00\x12\x1c\n\x12\x63onfig_complete_id\x18\x08 \x01(\rH\x00\x12\x12\n\x08rebooted\x18\t \x01(\x08H\x00\x12%\n\x0cmoduleConfig\x18\n \x01(\x0b\x32\r.ModuleConfigH\x00\x42\x10\n\x0epayloadVariantJ\x04\x08\x02\x10\x03\"\xe1\x01\n\x07ToRadio\x12\x1d\n\x06packet\x18\x02 \x01(\x0b\x32\x0b.MeshPacketH\x00\x12&\n\tpeer_info\x18\x03 \x01(\x0b\x32\x11.ToRadio.PeerInfoH\x00\x12\x18\n\x0ewant_config_id\x18\x64 \x01(\rH\x00\x12\x14\n\ndisconnect\x18h \x01(\x08H\x00\x1a\x35\n\x08PeerInfo\x12\x13\n\x0b\x61pp_version\x18\x01 \x01(\r\x12\x14\n\x0cmqtt_gateway\x18\x02 \x01(\x08\x42\x10\n\x0epayloadVariantJ\x04\x08\x01\x10\x02J\x04\x08\x65\x10\x66J\x04\x08\x66\x10gJ\x04\x08g\x10h\"5\n\nCompressed\x12\x19\n\x07portnum\x18\x01 \x01(\x0e\x32\x08.PortNum\x12\x0c\n\x04\x64\x61ta\x18\x02 \x01(\x0c*\x97\x03\n\rHardwareModel\x12\t\n\x05UNSET\x10\x00\x12\x0c\n\x08TLORA_V2\x10\x01\x12\x0c\n\x08TLORA_V1\x10\x02\x12\x12\n\x0eTLORA_V2_1_1p6\x10\x03\x12\t\n\x05TBEAM\x10\x04\x12\x0f\n\x0bHELTEC_V2_0\x10\x05\x12\x0c\n\x08TBEAM0p7\x10\x06\x12\n\n\x06T_ECHO\x10\x07\x12\x10\n\x0cTLORA_V1_1p3\x10\x08\x12\x0b\n\x07RAK4631\x10\t\x12\x0f\n\x0bHELTEC_V2_1\x10\n\x12\r\n\tHELTEC_V1\x10\x0b\x12\x11\n\rLORA_RELAY_V1\x10 \x12\x0e\n\nNRF52840DK\x10!\x12\x07\n\x03PPR\x10\"\x12\x0f\n\x0bGENIEBLOCKS\x10#\x12\x11\n\rNRF52_UNKNOWN\x10$\x12\r\n\tPORTDUINO\x10%\x12\x0f\n\x0b\x41NDROID_SIM\x10&\x12\n\n\x06\x44IY_V1\x10\'\x12\x0c\n\x08RAK11200\x10(\x12\x0b\n\x07NANO_G1\x10)\x12\x15\n\x11NRF52840_PCA10059\x10*\x12\n\n\x06\x44R_DEV\x10+\x12\x0b\n\x07M5STACK\x10,\x12\x0f\n\nPRIVATE_HW\x10\xff\x01*.\n\tConstants\x12\n\n\x06Unused\x10\x00\x12\x15\n\x10\x44\x41TA_PAYLOAD_LEN\x10\xed\x01*\xe1\x01\n\x11\x43riticalErrorCode\x12\x08\n\x04None\x10\x00\x12\x0e\n\nTxWatchdog\x10\x01\x12\x12\n\x0eSleepEnterWait\x10\x02\x12\x0b\n\x07NoRadio\x10\x03\x12\x0f\n\x0bUnspecified\x10\x04\x12\x13\n\x0fUBloxInitFailed\x10\x05\x12\x0c\n\x08NoAXP192\x10\x06\x12\x17\n\x13InvalidRadioSetting\x10\x07\x12\x12\n\x0eTransmitFailed\x10\x08\x12\x0c\n\x08\x42rownout\x10\t\x12\x11\n\rSX1262Failure\x10\n\x12\x0f\n\x0bRadioSpiBug\x10\x0b\x42\x46\n\x13\x63om.geeksville.meshB\nMeshProtosH\x03Z!github.com/meshtastic/gomeshprotob\x06proto3') _HARDWAREMODEL = DESCRIPTOR.enum_types_by_name['HardwareModel'] HardwareModel = enum_type_wrapper.EnumTypeWrapper(_HARDWAREMODEL) @@ -191,50 +192,50 @@ if _descriptor._USE_C_DESCRIPTORS == False: DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b'\n\023com.geeksville.meshB\nMeshProtosH\003Z!github.com/meshtastic/gomeshproto' - _HARDWAREMODEL._serialized_start=3387 - _HARDWAREMODEL._serialized_end=3794 - _CONSTANTS._serialized_start=3796 - _CONSTANTS._serialized_end=3842 - _CRITICALERRORCODE._serialized_start=3845 - _CRITICALERRORCODE._serialized_end=4070 - _POSITION._serialized_start=62 - _POSITION._serialized_end=815 - _POSITION_LOCSOURCE._serialized_start=569 - _POSITION_LOCSOURCE._serialized_end=679 - _POSITION_ALTSOURCE._serialized_start=682 - _POSITION_ALTSOURCE._serialized_end=815 - _USER._serialized_start=818 - _USER._serialized_end=1012 - _ROUTEDISCOVERY._serialized_start=1014 - _ROUTEDISCOVERY._serialized_end=1045 - _ROUTING._serialized_start=1048 - _ROUTING._serialized_end=1373 - _ROUTING_ERROR._serialized_start=1182 - _ROUTING_ERROR._serialized_end=1362 - _DATA._serialized_start=1376 - _DATA._serialized_end=1561 - _LOCATION._serialized_start=1563 - _LOCATION._serialized_end=1658 - _MESHPACKET._serialized_start=1661 - _MESHPACKET._serialized_end=2119 - _MESHPACKET_PRIORITY._serialized_start=1942 - _MESHPACKET_PRIORITY._serialized_end=2033 - _MESHPACKET_DELAYED._serialized_start=2035 - _MESHPACKET_DELAYED._serialized_end=2101 - _NODEINFO._serialized_start=2122 - _NODEINFO._serialized_end=2268 - _MYNODEINFO._serialized_start=2271 - _MYNODEINFO._serialized_end=2661 - _LOGRECORD._serialized_start=2664 - _LOGRECORD._serialized_end=2845 - _LOGRECORD_LEVEL._serialized_start=2757 - _LOGRECORD_LEVEL._serialized_end=2845 - _FROMRADIO._serialized_start=2848 - _FROMRADIO._serialized_end=3101 - _TORADIO._serialized_start=3104 - _TORADIO._serialized_end=3329 - _TORADIO_PEERINFO._serialized_start=3234 - _TORADIO_PEERINFO._serialized_end=3287 - _COMPRESSED._serialized_start=3331 - _COMPRESSED._serialized_end=3384 + _HARDWAREMODEL._serialized_start=3447 + _HARDWAREMODEL._serialized_end=3854 + _CONSTANTS._serialized_start=3856 + _CONSTANTS._serialized_end=3902 + _CRITICALERRORCODE._serialized_start=3905 + _CRITICALERRORCODE._serialized_end=4130 + _POSITION._serialized_start=83 + _POSITION._serialized_end=836 + _POSITION_LOCSOURCE._serialized_start=590 + _POSITION_LOCSOURCE._serialized_end=700 + _POSITION_ALTSOURCE._serialized_start=703 + _POSITION_ALTSOURCE._serialized_end=836 + _USER._serialized_start=839 + _USER._serialized_end=1033 + _ROUTEDISCOVERY._serialized_start=1035 + _ROUTEDISCOVERY._serialized_end=1066 + _ROUTING._serialized_start=1069 + _ROUTING._serialized_end=1394 + _ROUTING_ERROR._serialized_start=1203 + _ROUTING_ERROR._serialized_end=1383 + _DATA._serialized_start=1397 + _DATA._serialized_end=1582 + _LOCATION._serialized_start=1584 + _LOCATION._serialized_end=1679 + _MESHPACKET._serialized_start=1682 + _MESHPACKET._serialized_end=2140 + _MESHPACKET_PRIORITY._serialized_start=1963 + _MESHPACKET_PRIORITY._serialized_end=2054 + _MESHPACKET_DELAYED._serialized_start=2056 + _MESHPACKET_DELAYED._serialized_end=2122 + _NODEINFO._serialized_start=2143 + _NODEINFO._serialized_end=2289 + _MYNODEINFO._serialized_start=2292 + _MYNODEINFO._serialized_end=2682 + _LOGRECORD._serialized_start=2685 + _LOGRECORD._serialized_end=2866 + _LOGRECORD_LEVEL._serialized_start=2778 + _LOGRECORD_LEVEL._serialized_end=2866 + _FROMRADIO._serialized_start=2869 + _FROMRADIO._serialized_end=3161 + _TORADIO._serialized_start=3164 + _TORADIO._serialized_end=3389 + _TORADIO_PEERINFO._serialized_start=3294 + _TORADIO_PEERINFO._serialized_end=3347 + _COMPRESSED._serialized_start=3391 + _COMPRESSED._serialized_end=3444 # @@protoc_insertion_point(module_scope) diff --git a/meshtastic/node.py b/meshtastic/node.py index 387b3d0..45b3be9 100644 --- a/meshtastic/node.py +++ b/meshtastic/node.py @@ -12,7 +12,7 @@ from meshtastic.util import pskToString, stripnl, Timeout, our_exit, fromPSK class Node: """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): @@ -20,6 +20,7 @@ class Node: self.iface = iface self.nodeNum = nodeNum self.localConfig = localonly_pb2.LocalConfig() + self.moduleConfig = localonly_pb2.LocalModuleConfig() self.channels = None self._timeout = Timeout(maxSecs=300) self.partialChannels = None @@ -57,6 +58,10 @@ class Node: if self.localConfig: prefs = stripnl(MessageToJson(self.localConfig)) print(f"Preferences: {prefs}\n") + prefs = "" + if self.moduleConfig: + prefs = stripnl(MessageToJson(self.moduleConfig)) + print(f"Module preferences: {prefs}\n") self.showChannels() def requestConfig(self): @@ -118,6 +123,48 @@ class Node: self._sendAdmin(p) logging.debug("Wrote lora") + 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") + + 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") + + 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") + + 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") + + 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") + + 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") + + 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") + def writeChannel(self, channelIndex, adminIndex=0): """Write the current (edited) channel to the device""" diff --git a/proto b/proto index 274aa01..c63a16c 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 274aa01a3862ee83b1ae791c36205e661c4af7ca +Subproject commit c63a16c32f0a7b41fc348a8f42c9c13a024d2700