mirror of
https://github.com/meshtastic/python.git
synced 2025-12-26 01:17:51 -05:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5159f1156 | ||
|
|
593b05dbcd | ||
|
|
f519d1f2d2 | ||
|
|
8b36561406 | ||
|
|
e2b4948d45 | ||
|
|
7e3d347b63 | ||
|
|
c6efccdbd2 | ||
|
|
2b10459db0 |
22
.github/CONTRIBUTING.md
vendored
Normal file
22
.github/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
# Contributing to Meshtastic Python
|
||||
|
||||
## Development resources
|
||||
- [API Documentation](https://python.meshtastic.org/)
|
||||
- [Meshtastic Python Development](https://meshtastic.org/docs/development/python/)
|
||||
- [Building Meshtastic Python](https://meshtastic.org/docs/development/python/building/)
|
||||
- [Using the Meshtastic Python Library](https://meshtastic.org/docs/development/python/library/)
|
||||
|
||||
## How to check your code (pytest/pylint) before a PR
|
||||
- [Pre-requisites](https://meshtastic.org/docs/development/python/building/#pre-requisites)
|
||||
- also execute `poetry install --all-extras --with dev,powermon` for all optional dependencies
|
||||
- check your code with github ci actions locally
|
||||
- You need to have act installed. You can get it at https://nektosact.com/
|
||||
- on linux: `act -P ubuntu-latest=-self-hosted --matrix "python-version:3.12"`
|
||||
- on windows:
|
||||
- linux checks (linux docker): `act --matrix "python-version:3.12"`
|
||||
- windows checks (windows host): `act -P ubuntu-latest=-self-hosted --matrix "python-version:3.12"`
|
||||
- or run all locally:
|
||||
- run `poetry run pylint meshtastic examples/ --ignore-patterns ".*_pb2.pyi?$"`
|
||||
- run `poetry run mypy meshtastic/`
|
||||
- run `poetry run pytest`
|
||||
- more commands see [CI workflow](https://github.com/meshtastic/python/blob/master/.github/workflows/ci.yml)
|
||||
@@ -59,7 +59,7 @@ except ImportError as e:
|
||||
have_powermon = False
|
||||
powermon_exception = e
|
||||
meter = None
|
||||
from meshtastic.protobuf import channel_pb2, config_pb2, portnums_pb2
|
||||
from meshtastic.protobuf import channel_pb2, config_pb2, portnums_pb2, mesh_pb2
|
||||
from meshtastic.version import get_active_version
|
||||
|
||||
def onReceive(packet, interface) -> None:
|
||||
@@ -377,16 +377,22 @@ def onConnected(interface):
|
||||
if args.set_canned_message:
|
||||
closeNow = True
|
||||
waitForAckNak = True
|
||||
print(f"Setting canned plugin message to {args.set_canned_message}")
|
||||
interface.getNode(args.dest, False, **getNode_kwargs).set_canned_message(
|
||||
args.set_canned_message
|
||||
)
|
||||
node = interface.getNode(args.dest, False, **getNode_kwargs)
|
||||
if node.module_available(mesh_pb2.CANNEDMSG_CONFIG):
|
||||
print(f"Setting canned plugin message to {args.set_canned_message}")
|
||||
node.set_canned_message(args.set_canned_message)
|
||||
else:
|
||||
print("Canned Message module is excluded by firmware; skipping set.")
|
||||
|
||||
if args.set_ringtone:
|
||||
closeNow = True
|
||||
waitForAckNak = True
|
||||
print(f"Setting ringtone to {args.set_ringtone}")
|
||||
interface.getNode(args.dest, False, **getNode_kwargs).set_ringtone(args.set_ringtone)
|
||||
node = interface.getNode(args.dest, False, **getNode_kwargs)
|
||||
if node.module_available(mesh_pb2.EXTNOTIF_CONFIG):
|
||||
print(f"Setting ringtone to {args.set_ringtone}")
|
||||
node.set_ringtone(args.set_ringtone)
|
||||
else:
|
||||
print("External Notification is excluded by firmware; skipping ringtone set.")
|
||||
|
||||
if args.pos_fields:
|
||||
# If --pos-fields invoked with args, set position fields
|
||||
|
||||
@@ -51,6 +51,16 @@ class Node:
|
||||
r += ")"
|
||||
return r
|
||||
|
||||
def module_available(self, excluded_bit: int) -> bool:
|
||||
"""Check DeviceMetadata.excluded_modules to see if a module is available."""
|
||||
meta = getattr(self.iface, "metadata", None)
|
||||
if meta is None:
|
||||
return True
|
||||
try:
|
||||
return (meta.excluded_modules & excluded_bit) == 0
|
||||
except Exception:
|
||||
return True
|
||||
|
||||
def showChannels(self):
|
||||
"""Show human readable description of our channels."""
|
||||
print("Channels:")
|
||||
@@ -441,6 +451,10 @@ class Node:
|
||||
def get_ringtone(self):
|
||||
"""Get the ringtone. Concatenate all pieces together and return a single string."""
|
||||
logging.debug(f"in get_ringtone()")
|
||||
if not self.module_available(mesh_pb2.EXTNOTIF_CONFIG):
|
||||
logging.warning("External Notification module not present (excluded by firmware)")
|
||||
return None
|
||||
|
||||
if not self.ringtone:
|
||||
p1 = admin_pb2.AdminMessage()
|
||||
p1.get_ringtone_request = True
|
||||
@@ -462,6 +476,9 @@ class Node:
|
||||
|
||||
def set_ringtone(self, ringtone):
|
||||
"""Set the ringtone. The ringtone length must be less than 230 character."""
|
||||
if not self.module_available(mesh_pb2.EXTNOTIF_CONFIG):
|
||||
logging.warning("External Notification module not present (excluded by firmware)")
|
||||
return None
|
||||
|
||||
if len(ringtone) > 230:
|
||||
our_exit("Warning: The ringtone must be less than 230 characters.")
|
||||
@@ -512,6 +529,9 @@ class Node:
|
||||
def get_canned_message(self):
|
||||
"""Get the canned message string. Concatenate all pieces together and return a single string."""
|
||||
logging.debug(f"in get_canned_message()")
|
||||
if not self.module_available(mesh_pb2.CANNEDMSG_CONFIG):
|
||||
logging.warning("Canned Message module not present (excluded by firmware)")
|
||||
return None
|
||||
if not self.cannedPluginMessage:
|
||||
p1 = admin_pb2.AdminMessage()
|
||||
p1.get_canned_message_module_messages_request = True
|
||||
@@ -537,6 +557,9 @@ class Node:
|
||||
|
||||
def set_canned_message(self, message):
|
||||
"""Set the canned message. The canned messages length must be less than 200 character."""
|
||||
if not self.module_available(mesh_pb2.CANNEDMSG_CONFIG):
|
||||
logging.warning("Canned Message module not present (excluded by firmware)")
|
||||
return None
|
||||
|
||||
if len(message) > 200:
|
||||
our_exit("Warning: The canned message must be less than 200 characters.")
|
||||
|
||||
44
meshtastic/protobuf/config_pb2.py
generated
44
meshtastic/protobuf/config_pb2.py
generated
File diff suppressed because one or more lines are too long
16
meshtastic/protobuf/config_pb2.pyi
generated
16
meshtastic/protobuf/config_pb2.pyi
generated
@@ -1048,12 +1048,12 @@ class Config(google.protobuf.message.Message):
|
||||
"""
|
||||
OLED_SH1107: Config.DisplayConfig._OledType.ValueType # 3
|
||||
"""
|
||||
Can not be auto detected but set by proto. Used for 128x128 screens
|
||||
"""
|
||||
OLED_SH1107_128_64: Config.DisplayConfig._OledType.ValueType # 4
|
||||
"""
|
||||
Can not be auto detected but set by proto. Used for 128x64 screens
|
||||
"""
|
||||
OLED_SH1107_128_128: Config.DisplayConfig._OledType.ValueType # 4
|
||||
"""
|
||||
Can not be auto detected but set by proto. Used for 128x128 screens
|
||||
"""
|
||||
|
||||
class OledType(_OledType, metaclass=_OledTypeEnumTypeWrapper):
|
||||
"""
|
||||
@@ -1074,12 +1074,12 @@ class Config(google.protobuf.message.Message):
|
||||
"""
|
||||
OLED_SH1107: Config.DisplayConfig.OledType.ValueType # 3
|
||||
"""
|
||||
Can not be auto detected but set by proto. Used for 128x128 screens
|
||||
"""
|
||||
OLED_SH1107_128_64: Config.DisplayConfig.OledType.ValueType # 4
|
||||
"""
|
||||
Can not be auto detected but set by proto. Used for 128x64 screens
|
||||
"""
|
||||
OLED_SH1107_128_128: Config.DisplayConfig.OledType.ValueType # 4
|
||||
"""
|
||||
Can not be auto detected but set by proto. Used for 128x128 screens
|
||||
"""
|
||||
|
||||
class _DisplayMode:
|
||||
ValueType = typing.NewType("ValueType", builtins.int)
|
||||
|
||||
20
meshtastic/protobuf/mesh_pb2.py
generated
20
meshtastic/protobuf/mesh_pb2.py
generated
File diff suppressed because one or more lines are too long
8
meshtastic/protobuf/mesh_pb2.pyi
generated
8
meshtastic/protobuf/mesh_pb2.pyi
generated
@@ -486,6 +486,10 @@ class _HardwareModelEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._
|
||||
MeshSolar is an integrated power management and communication solution designed for outdoor low-power devices.
|
||||
https://heltec.org/project/meshsolar/
|
||||
"""
|
||||
T_ECHO_LITE: _HardwareModel.ValueType # 109
|
||||
"""
|
||||
Lilygo T-Echo Lite
|
||||
"""
|
||||
PRIVATE_HW: _HardwareModel.ValueType # 255
|
||||
"""
|
||||
------------------------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -955,6 +959,10 @@ HELTEC_MESH_SOLAR: HardwareModel.ValueType # 108
|
||||
MeshSolar is an integrated power management and communication solution designed for outdoor low-power devices.
|
||||
https://heltec.org/project/meshsolar/
|
||||
"""
|
||||
T_ECHO_LITE: HardwareModel.ValueType # 109
|
||||
"""
|
||||
Lilygo T-Echo Lite
|
||||
"""
|
||||
PRIVATE_HW: HardwareModel.ValueType # 255
|
||||
"""
|
||||
------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
30
meshtastic/protobuf/module_config_pb2.py
generated
30
meshtastic/protobuf/module_config_pb2.py
generated
File diff suppressed because one or more lines are too long
9
meshtastic/protobuf/module_config_pb2.pyi
generated
9
meshtastic/protobuf/module_config_pb2.pyi
generated
@@ -824,6 +824,7 @@ class ModuleConfig(google.protobuf.message.Message):
|
||||
ENABLED_FIELD_NUMBER: builtins.int
|
||||
SENDER_FIELD_NUMBER: builtins.int
|
||||
SAVE_FIELD_NUMBER: builtins.int
|
||||
CLEAR_ON_REBOOT_FIELD_NUMBER: builtins.int
|
||||
enabled: builtins.bool
|
||||
"""
|
||||
Enable the Range Test Module
|
||||
@@ -837,14 +838,20 @@ class ModuleConfig(google.protobuf.message.Message):
|
||||
Bool value indicating that this node should save a RangeTest.csv file.
|
||||
ESP32 Only
|
||||
"""
|
||||
clear_on_reboot: builtins.bool
|
||||
"""
|
||||
Bool indicating that the node should cleanup / destroy it's RangeTest.csv file.
|
||||
ESP32 Only
|
||||
"""
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
enabled: builtins.bool = ...,
|
||||
sender: builtins.int = ...,
|
||||
save: builtins.bool = ...,
|
||||
clear_on_reboot: builtins.bool = ...,
|
||||
) -> None: ...
|
||||
def ClearField(self, field_name: typing.Literal["enabled", b"enabled", "save", b"save", "sender", b"sender"]) -> None: ...
|
||||
def ClearField(self, field_name: typing.Literal["clear_on_reboot", b"clear_on_reboot", "enabled", b"enabled", "save", b"save", "sender", b"sender"]) -> None: ...
|
||||
|
||||
@typing.final
|
||||
class TelemetryConfig(google.protobuf.message.Message):
|
||||
|
||||
4
meshtastic/protobuf/telemetry_pb2.py
generated
4
meshtastic/protobuf/telemetry_pb2.py
generated
File diff suppressed because one or more lines are too long
8
meshtastic/protobuf/telemetry_pb2.pyi
generated
8
meshtastic/protobuf/telemetry_pb2.pyi
generated
@@ -199,6 +199,10 @@ class _TelemetrySensorTypeEnumTypeWrapper(google.protobuf.internal.enum_type_wra
|
||||
"""
|
||||
SEN5X PM SENSORS
|
||||
"""
|
||||
TSL2561: _TelemetrySensorType.ValueType # 44
|
||||
"""
|
||||
TSL2561 light sensor
|
||||
"""
|
||||
|
||||
class TelemetrySensorType(_TelemetrySensorType, metaclass=_TelemetrySensorTypeEnumTypeWrapper):
|
||||
"""
|
||||
@@ -381,6 +385,10 @@ SEN5X: TelemetrySensorType.ValueType # 43
|
||||
"""
|
||||
SEN5X PM SENSORS
|
||||
"""
|
||||
TSL2561: TelemetrySensorType.ValueType # 44
|
||||
"""
|
||||
TSL2561 light sensor
|
||||
"""
|
||||
global___TelemetrySensorType = TelemetrySensorType
|
||||
|
||||
@typing.final
|
||||
|
||||
1
nanopb
1
nanopb
Submodule nanopb deleted from 4380dd9e94
Submodule protobufs updated: e2c0831aa3...34f0c8115d
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "meshtastic"
|
||||
version = "2.7.1"
|
||||
version = "2.7.2"
|
||||
description = "Python API & client shell for talking to Meshtastic devices"
|
||||
authors = ["Meshtastic Developers <contact@meshtastic.org>"]
|
||||
license = "GPL-3.0-only"
|
||||
|
||||
Reference in New Issue
Block a user