Add functionality to the python ingestor to determine region frequency and modem preset from the connected local node lora config. The following script shows how to get the correct values from the interface (example):
from meshtastic.serial_interface import SerialInterface
from meshtastic.protobuf import config_pb2
iface = SerialInterface("/dev/ttyACM0")
iface.waitForConfig()
cfg = iface.localNode.localConfig
# Find the LoRa submessage (old: cfg.lora, newer: cfg.radio.lora)
lora = None
if hasattr(cfg, "lora") and cfg.HasField("lora"):
lora = cfg.lora
elif hasattr(cfg, "radio") and cfg.HasField("radio") and cfg.radio.HasField("lora"):
lora = cfg.radio.lora
else:
raise RuntimeError("No LoRa config present")
def enum_name_from_field(message, field_name, value):
"""Return the enum name for a numeric enum field value using reflection."""
desc = message.DESCRIPTOR
fld = desc.fields_by_name[field_name]
enum = fld.enum_type
if enum is None:
return str(value)
v = enum.values_by_number.get(value)
return v.name if v else str(value)
# region
region_val = lora.region
region_name = enum_name_from_field(lora, "region", region_val)
# preset can be 'modem_preset' or 'preset' depending on version
preset_field = "modem_preset" if "modem_preset" in lora.DESCRIPTOR.fields_by_name else "preset"
preset_val = getattr(lora, preset_field)
preset_name = enum_name_from_field(lora, preset_field, preset_val)
print("LoRa region:", region_val, region_name)
# => LoRa region: 3 EU_868
print("LoRa preset:", preset_val, preset_name)
# => LoRa preset: 4 MEDIUM_FAST
We want the ingestor to store these values upon launch as LORA_FREQ and MODEM_PRESET. Change the region to an integer that only holds the frequency, e.g. 868. Change the preset to camelcase, e.g. MediumFast. This is constant and will never change during runtime.
Now, each node info update and each message package we receive gets appended the fields lora_freq and modem_preset so that we tag each node for region and preset. Do that before posting them to the potatomesh instance API.
Before: #124
Add functionality to the python ingestor to determine region frequency and modem preset from the connected local node lora config. The following script shows how to get the correct values from the interface (example):
```
from meshtastic.serial_interface import SerialInterface
from meshtastic.protobuf import config_pb2
iface = SerialInterface("/dev/ttyACM0")
iface.waitForConfig()
cfg = iface.localNode.localConfig
# Find the LoRa submessage (old: cfg.lora, newer: cfg.radio.lora)
lora = None
if hasattr(cfg, "lora") and cfg.HasField("lora"):
lora = cfg.lora
elif hasattr(cfg, "radio") and cfg.HasField("radio") and cfg.radio.HasField("lora"):
lora = cfg.radio.lora
else:
raise RuntimeError("No LoRa config present")
def enum_name_from_field(message, field_name, value):
"""Return the enum name for a numeric enum field value using reflection."""
desc = message.DESCRIPTOR
fld = desc.fields_by_name[field_name]
enum = fld.enum_type
if enum is None:
return str(value)
v = enum.values_by_number.get(value)
return v.name if v else str(value)
# region
region_val = lora.region
region_name = enum_name_from_field(lora, "region", region_val)
# preset can be 'modem_preset' or 'preset' depending on version
preset_field = "modem_preset" if "modem_preset" in lora.DESCRIPTOR.fields_by_name else "preset"
preset_val = getattr(lora, preset_field)
preset_name = enum_name_from_field(lora, preset_field, preset_val)
print("LoRa region:", region_val, region_name)
# => LoRa region: 3 EU_868
print("LoRa preset:", preset_val, preset_name)
# => LoRa preset: 4 MEDIUM_FAST
```
We want the ingestor to store these values upon launch as LORA_FREQ and MODEM_PRESET. Change the region to an integer that only holds the frequency, e.g. 868. Change the preset to camelcase, e.g. MediumFast. This is constant and will never change during runtime.
Now, each node info update and each message package we receive gets appended the fields lora_freq and modem_preset so that we tag each node for region and preset. Do that before posting them to the potatomesh instance API.
<!-- github-sync-id:3511371348 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Before: #124
Add functionality to the python ingestor to determine region frequency and modem preset from the connected local node lora config. The following script shows how to get the correct values from the interface (example):
We want the ingestor to store these values upon launch as LORA_FREQ and MODEM_PRESET. Change the region to an integer that only holds the frequency, e.g. 868. Change the preset to camelcase, e.g. MediumFast. This is constant and will never change during runtime.
Now, each node info update and each message package we receive gets appended the fields lora_freq and modem_preset so that we tag each node for region and preset. Do that before posting them to the potatomesh instance API.