mirror of
https://github.com/meshtastic/python.git
synced 2025-12-26 01:17:51 -05:00
Compare commits
16 Commits
1.3alpha.8
...
1.3alpha.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19b607b3f2 | ||
|
|
1d827ab2bf | ||
|
|
7af886cf07 | ||
|
|
a76ad6c686 | ||
|
|
3d9a55add3 | ||
|
|
4ceac5e847 | ||
|
|
0939022cb4 | ||
|
|
f7afb9ff15 | ||
|
|
13fd4ba614 | ||
|
|
2f80c9866a | ||
|
|
e2bca647ae | ||
|
|
ec2467486c | ||
|
|
3332271a97 | ||
|
|
7fdfd782d8 | ||
|
|
af7bf7ff7f | ||
|
|
ef9441e7d2 |
14
examples/tcp_gps_example.py
Normal file
14
examples/tcp_gps_example.py
Normal file
@@ -0,0 +1,14 @@
|
||||
"""Demonstration of how to look up a radio's location via its LAN connection.
|
||||
Before running, connect your machine to the same WiFi network as the radio.
|
||||
"""
|
||||
|
||||
import meshtastic
|
||||
import meshtastic.tcp_interface
|
||||
|
||||
radio_hostname = "meshtastic.local" # Can also be an IP
|
||||
iface = meshtastic.tcp_interface.TCPInterface(radio_hostname)
|
||||
my_node_num = iface.myInfo.my_node_num
|
||||
pos = iface.nodesByNum[my_node_num]["position"]
|
||||
print (pos)
|
||||
|
||||
iface.close()
|
||||
@@ -119,6 +119,10 @@ def setPref(attributes, name, valStr):
|
||||
val = meshtastic.util.fromStr(valStr)
|
||||
logging.debug(f'valStr:{valStr} val:{val}')
|
||||
|
||||
if snake_name == 'wifi_password' and len(valStr) < 8:
|
||||
print(f"Warning: wifi_password must be 8 or more characters.")
|
||||
return
|
||||
|
||||
enumType = field.enum_type
|
||||
# pylint: disable=C0123
|
||||
if enumType and type(val) == str:
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -72,7 +72,11 @@ techo_1 = SupportedDevice(name="T-Echo", version="1", for_firmware="t-echo-1", d
|
||||
rak4631_5005 = SupportedDevice(name="RAK 4631 5005", version="", for_firmware="rak4631_5005",
|
||||
device_class="nrf52",
|
||||
baseport_on_linux="ttyACM", baseport_on_mac="cu.usbmodem",
|
||||
usb_vendor_id_in_hex="239a", usb_product_id_in_hex="0029")
|
||||
usb_vendor_id_in_hex="239a", usb_product_id_in_hex="8029")
|
||||
rak4631_5005_epaper = SupportedDevice(name="RAK 4631 5005 14000 epaper", version="", for_firmware="rak4631_5005_epaper",
|
||||
device_class="nrf52",
|
||||
baseport_on_linux="ttyACM", baseport_on_mac="cu.usbmodem",
|
||||
usb_vendor_id_in_hex="239a", usb_product_id_in_hex="8029")
|
||||
# Note: The 19003 reports same product id as 5005 in boot mode
|
||||
rak4631_19003 = SupportedDevice(name="RAK 4631 19003", version="", for_firmware="rak4631_19003",
|
||||
device_class="nrf52",
|
||||
@@ -82,5 +86,5 @@ rak4631_19003 = SupportedDevice(name="RAK 4631 19003", version="", for_firmware=
|
||||
supported_devices = [tbeam_v0_7, tbeam_v1_1, tbeam_M8N, tbeam_M8N_SX1262,
|
||||
tlora_v1, tlora_v1_3, tlora_v2, tlora_v2_1_1_6,
|
||||
heltec_v1, heltec_v2_0, heltec_v2_1,
|
||||
meshtastic_diy_v1, techo_1, rak4631_5005, rak4631_19003,
|
||||
meshtastic_diy_v1, techo_1, rak4631_5005, rak4631_5005_epaper, rak4631_19003,
|
||||
rak11200]
|
||||
|
||||
@@ -17,57 +17,109 @@ DESCRIPTOR = _descriptor.FileDescriptor(
|
||||
name='telemetry.proto',
|
||||
package='',
|
||||
syntax='proto3',
|
||||
serialized_options=b'Z!github.com/meshtastic/gomeshproto',
|
||||
serialized_pb=b'\n\x0ftelemetry.proto\"\x92\x01\n\tTelemetry\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\x42#Z!github.com/meshtastic/gomeshprotob\x06proto3'
|
||||
serialized_options=b'\n\023com.geeksville.meshB\017TelemetryProtosH\003Z!github.com/meshtastic/gomeshproto',
|
||||
serialized_pb=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\x07variantBK\n\x13\x63om.geeksville.meshB\x0fTelemetryProtosH\x03Z!github.com/meshtastic/gomeshprotob\x06proto3'
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
_TELEMETRY = _descriptor.Descriptor(
|
||||
name='Telemetry',
|
||||
full_name='Telemetry',
|
||||
_DEVICEMETRICS = _descriptor.Descriptor(
|
||||
name='DeviceMetrics',
|
||||
full_name='DeviceMetrics',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='temperature', full_name='Telemetry.temperature', index=0,
|
||||
number=1, type=2, cpp_type=6, label=1,
|
||||
has_default_value=False, default_value=float(0),
|
||||
name='battery_level', full_name='DeviceMetrics.battery_level', index=0,
|
||||
number=1, type=13, cpp_type=3, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='relative_humidity', full_name='Telemetry.relative_humidity', index=1,
|
||||
name='voltage', full_name='DeviceMetrics.voltage', index=1,
|
||||
number=2, type=2, cpp_type=6, label=1,
|
||||
has_default_value=False, default_value=float(0),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='barometric_pressure', full_name='Telemetry.barometric_pressure', index=2,
|
||||
name='channel_utilization', full_name='DeviceMetrics.channel_utilization', index=2,
|
||||
number=3, type=2, cpp_type=6, label=1,
|
||||
has_default_value=False, default_value=float(0),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='gas_resistance', full_name='Telemetry.gas_resistance', index=3,
|
||||
name='air_util_tx', full_name='DeviceMetrics.air_util_tx', index=3,
|
||||
number=4, type=2, cpp_type=6, label=1,
|
||||
has_default_value=False, default_value=float(0),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
serialized_options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=19,
|
||||
serialized_end=124,
|
||||
)
|
||||
|
||||
|
||||
_ENVIRONMENTMETRICS = _descriptor.Descriptor(
|
||||
name='EnvironmentMetrics',
|
||||
full_name='EnvironmentMetrics',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='temperature', full_name='EnvironmentMetrics.temperature', index=0,
|
||||
number=1, type=2, cpp_type=6, label=1,
|
||||
has_default_value=False, default_value=float(0),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='relative_humidity', full_name='EnvironmentMetrics.relative_humidity', index=1,
|
||||
number=2, type=2, cpp_type=6, label=1,
|
||||
has_default_value=False, default_value=float(0),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='barometric_pressure', full_name='EnvironmentMetrics.barometric_pressure', index=2,
|
||||
number=3, type=2, cpp_type=6, label=1,
|
||||
has_default_value=False, default_value=float(0),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='gas_resistance', full_name='EnvironmentMetrics.gas_resistance', index=3,
|
||||
number=4, type=2, cpp_type=6, label=1,
|
||||
has_default_value=False, default_value=float(0),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='voltage', full_name='Telemetry.voltage', index=4,
|
||||
name='voltage', full_name='EnvironmentMetrics.voltage', index=4,
|
||||
number=5, type=2, cpp_type=6, label=1,
|
||||
has_default_value=False, default_value=float(0),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='current', full_name='Telemetry.current', index=5,
|
||||
name='current', full_name='EnvironmentMetrics.current', index=5,
|
||||
number=6, type=2, cpp_type=6, label=1,
|
||||
has_default_value=False, default_value=float(0),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
@@ -85,13 +137,85 @@ _TELEMETRY = _descriptor.Descriptor(
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=20,
|
||||
serialized_end=166,
|
||||
serialized_start=127,
|
||||
serialized_end=282,
|
||||
)
|
||||
|
||||
|
||||
_TELEMETRY = _descriptor.Descriptor(
|
||||
name='Telemetry',
|
||||
full_name='Telemetry',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='time', full_name='Telemetry.time', index=0,
|
||||
number=1, type=7, cpp_type=3, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='device_metrics', full_name='Telemetry.device_metrics', index=1,
|
||||
number=2, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='environment_metrics', full_name='Telemetry.environment_metrics', index=2,
|
||||
number=3, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
serialized_options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
_descriptor.OneofDescriptor(
|
||||
name='variant', full_name='Telemetry.variant',
|
||||
index=0, containing_type=None, fields=[]),
|
||||
],
|
||||
serialized_start=285,
|
||||
serialized_end=415,
|
||||
)
|
||||
|
||||
_TELEMETRY.fields_by_name['device_metrics'].message_type = _DEVICEMETRICS
|
||||
_TELEMETRY.fields_by_name['environment_metrics'].message_type = _ENVIRONMENTMETRICS
|
||||
_TELEMETRY.oneofs_by_name['variant'].fields.append(
|
||||
_TELEMETRY.fields_by_name['device_metrics'])
|
||||
_TELEMETRY.fields_by_name['device_metrics'].containing_oneof = _TELEMETRY.oneofs_by_name['variant']
|
||||
_TELEMETRY.oneofs_by_name['variant'].fields.append(
|
||||
_TELEMETRY.fields_by_name['environment_metrics'])
|
||||
_TELEMETRY.fields_by_name['environment_metrics'].containing_oneof = _TELEMETRY.oneofs_by_name['variant']
|
||||
DESCRIPTOR.message_types_by_name['DeviceMetrics'] = _DEVICEMETRICS
|
||||
DESCRIPTOR.message_types_by_name['EnvironmentMetrics'] = _ENVIRONMENTMETRICS
|
||||
DESCRIPTOR.message_types_by_name['Telemetry'] = _TELEMETRY
|
||||
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
|
||||
|
||||
DeviceMetrics = _reflection.GeneratedProtocolMessageType('DeviceMetrics', (_message.Message,), {
|
||||
'DESCRIPTOR' : _DEVICEMETRICS,
|
||||
'__module__' : 'telemetry_pb2'
|
||||
# @@protoc_insertion_point(class_scope:DeviceMetrics)
|
||||
})
|
||||
_sym_db.RegisterMessage(DeviceMetrics)
|
||||
|
||||
EnvironmentMetrics = _reflection.GeneratedProtocolMessageType('EnvironmentMetrics', (_message.Message,), {
|
||||
'DESCRIPTOR' : _ENVIRONMENTMETRICS,
|
||||
'__module__' : 'telemetry_pb2'
|
||||
# @@protoc_insertion_point(class_scope:EnvironmentMetrics)
|
||||
})
|
||||
_sym_db.RegisterMessage(EnvironmentMetrics)
|
||||
|
||||
Telemetry = _reflection.GeneratedProtocolMessageType('Telemetry', (_message.Message,), {
|
||||
'DESCRIPTOR' : _TELEMETRY,
|
||||
'__module__' : 'telemetry_pb2'
|
||||
|
||||
@@ -902,6 +902,27 @@ def test_main_set_valid_wifi_passwd(capsys):
|
||||
mo.assert_called()
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
@pytest.mark.usefixtures("reset_globals")
|
||||
def test_main_set_invalid_wifi_passwd(capsys):
|
||||
"""Test --set with an invalid value (password must be 8 or more characters)"""
|
||||
sys.argv = ['', '--set', 'wifi_password', '1234567']
|
||||
Globals.getInstance().set_args(sys.argv)
|
||||
|
||||
mocked_node = MagicMock(autospec=Node)
|
||||
|
||||
iface = MagicMock(autospec=SerialInterface)
|
||||
iface.getNode.return_value = mocked_node
|
||||
|
||||
with patch('meshtastic.serial_interface.SerialInterface', return_value=iface) as mo:
|
||||
main()
|
||||
out, err = capsys.readouterr()
|
||||
assert re.search(r'Connected to radio', out, re.MULTILINE)
|
||||
assert not re.search(r'Set wifi_password to 1234567', out, re.MULTILINE)
|
||||
assert re.search(r'Warning: wifi_password must be 8 or more characters.', out, re.MULTILINE)
|
||||
assert err == ''
|
||||
mo.assert_called()
|
||||
|
||||
@pytest.mark.unit
|
||||
@pytest.mark.usefixtures("reset_globals")
|
||||
def test_main_set_valid_camel_case(capsys):
|
||||
@@ -2205,12 +2226,12 @@ def test_main_setPref_valid_field_invalid_enum_where_enums_are_camel_cased_value
|
||||
prefs = radioConfig.preferences
|
||||
|
||||
with caplog.at_level(logging.DEBUG):
|
||||
setPref(prefs, 'location_share', 'foo')
|
||||
setPref(prefs, 'region', 'foo')
|
||||
out, err = capsys.readouterr()
|
||||
assert re.search(r'location_share does not have an enum called foo', out, re.MULTILINE)
|
||||
assert re.search(r'region does not have an enum called foo', out, re.MULTILINE)
|
||||
assert re.search(r'Choices in sorted order are', out, re.MULTILINE)
|
||||
assert re.search(r'LocDisabled', out, re.MULTILINE)
|
||||
assert re.search(r'LocEnabled', out, re.MULTILINE)
|
||||
assert re.search(r'ANZ', out, re.MULTILINE)
|
||||
assert re.search(r'CN', out, re.MULTILINE)
|
||||
assert err == ''
|
||||
|
||||
|
||||
|
||||
2
proto
2
proto
Submodule proto updated: 441303d531...99ce57802d
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
|
||||
setup(
|
||||
name="meshtastic",
|
||||
version="1.3alpha.7",
|
||||
version="1.3alpha.9",
|
||||
description="Python API & client shell for talking to Meshtastic devices",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
|
||||
Reference in New Issue
Block a user