mirror of
https://github.com/meshtastic/python.git
synced 2025-12-26 17:37:51 -05:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5cc0dae394 | ||
|
|
1a50377d34 | ||
|
|
2a44be9269 |
@@ -7,7 +7,7 @@ import time
|
|||||||
|
|
||||||
from typing import Optional, Union, List
|
from typing import Optional, Union, List
|
||||||
|
|
||||||
from meshtastic.protobuf import admin_pb2, apponly_pb2, channel_pb2, localonly_pb2, mesh_pb2, portnums_pb2
|
from meshtastic.protobuf import admin_pb2, apponly_pb2, channel_pb2, config_pb2, localonly_pb2, mesh_pb2, portnums_pb2
|
||||||
from meshtastic.util import (
|
from meshtastic.util import (
|
||||||
Timeout,
|
Timeout,
|
||||||
camel_to_snake,
|
camel_to_snake,
|
||||||
@@ -18,6 +18,7 @@ from meshtastic.util import (
|
|||||||
message_to_json,
|
message_to_json,
|
||||||
generate_channel_hash,
|
generate_channel_hash,
|
||||||
to_node_num,
|
to_node_num,
|
||||||
|
flags_to_list,
|
||||||
)
|
)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -54,6 +55,16 @@ class Node:
|
|||||||
r += ")"
|
r += ")"
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def position_flags_list(position_flags: int) -> List[str]:
|
||||||
|
"Return a list of position flags from the given flags integer"
|
||||||
|
return flags_to_list(config_pb2.Config.PositionConfig.PositionFlags, position_flags)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def excluded_modules_list(excluded_modules: int) -> List[str]:
|
||||||
|
"Return a list of excluded modules from the given flags integer"
|
||||||
|
return flags_to_list(mesh_pb2.ExcludedModules, excluded_modules)
|
||||||
|
|
||||||
def module_available(self, excluded_bit: int) -> bool:
|
def module_available(self, excluded_bit: int) -> bool:
|
||||||
"""Check DeviceMetadata.excluded_modules to see if a module is available."""
|
"""Check DeviceMetadata.excluded_modules to see if a module is available."""
|
||||||
meta = getattr(self.iface, "metadata", None)
|
meta = getattr(self.iface, "metadata", None)
|
||||||
@@ -902,6 +913,18 @@ class Node:
|
|||||||
logger.debug(f"Received metadata {stripnl(c)}")
|
logger.debug(f"Received metadata {stripnl(c)}")
|
||||||
print(f"\nfirmware_version: {c.firmware_version}")
|
print(f"\nfirmware_version: {c.firmware_version}")
|
||||||
print(f"device_state_version: {c.device_state_version}")
|
print(f"device_state_version: {c.device_state_version}")
|
||||||
|
if c.role in config_pb2.Config.DeviceConfig.Role.values():
|
||||||
|
print(f"role: {config_pb2.Config.DeviceConfig.Role.Name(c.role)}")
|
||||||
|
else:
|
||||||
|
print(f"role: {c.role}")
|
||||||
|
print(f"position_flags: {self.position_flags_list(c.position_flags)}")
|
||||||
|
if c.hw_model in mesh_pb2.HardwareModel.values():
|
||||||
|
print(f"hw_model: {mesh_pb2.HardwareModel.Name(c.hw_model)}")
|
||||||
|
else:
|
||||||
|
print(f"hw_model: {c.hw_model}")
|
||||||
|
print(f"hasPKC: {c.hasPKC}")
|
||||||
|
if c.excluded_modules > 0:
|
||||||
|
print(f"excluded_modules: {self.excluded_modules_list(c.excluded_modules)}")
|
||||||
|
|
||||||
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()"""
|
||||||
|
|||||||
2
meshtastic/protobuf/admin_pb2.py
generated
2
meshtastic/protobuf/admin_pb2.py
generated
File diff suppressed because one or more lines are too long
5
meshtastic/protobuf/admin_pb2.pyi
generated
5
meshtastic/protobuf/admin_pb2.pyi
generated
@@ -515,9 +515,10 @@ class AdminMessage(google.protobuf.message.Message):
|
|||||||
"""
|
"""
|
||||||
Tell the node to factory reset config; all device state and configuration will be returned to factory defaults; BLE bonds will be preserved.
|
Tell the node to factory reset config; all device state and configuration will be returned to factory defaults; BLE bonds will be preserved.
|
||||||
"""
|
"""
|
||||||
nodedb_reset: builtins.int
|
nodedb_reset: builtins.bool
|
||||||
"""
|
"""
|
||||||
Tell the node to reset the nodedb.
|
Tell the node to reset the nodedb.
|
||||||
|
When true, favorites are preserved through reset.
|
||||||
"""
|
"""
|
||||||
@property
|
@property
|
||||||
def get_channel_response(self) -> meshtastic.protobuf.channel_pb2.Channel:
|
def get_channel_response(self) -> meshtastic.protobuf.channel_pb2.Channel:
|
||||||
@@ -689,7 +690,7 @@ class AdminMessage(google.protobuf.message.Message):
|
|||||||
reboot_seconds: builtins.int = ...,
|
reboot_seconds: builtins.int = ...,
|
||||||
shutdown_seconds: builtins.int = ...,
|
shutdown_seconds: builtins.int = ...,
|
||||||
factory_reset_config: builtins.int = ...,
|
factory_reset_config: builtins.int = ...,
|
||||||
nodedb_reset: builtins.int = ...,
|
nodedb_reset: builtins.bool = ...,
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def HasField(self, field_name: typing.Literal["add_contact", b"add_contact", "backup_preferences", b"backup_preferences", "begin_edit_settings", b"begin_edit_settings", "commit_edit_settings", b"commit_edit_settings", "delete_file_request", b"delete_file_request", "enter_dfu_mode_request", b"enter_dfu_mode_request", "exit_simulator", b"exit_simulator", "factory_reset_config", b"factory_reset_config", "factory_reset_device", b"factory_reset_device", "get_canned_message_module_messages_request", b"get_canned_message_module_messages_request", "get_canned_message_module_messages_response", b"get_canned_message_module_messages_response", "get_channel_request", b"get_channel_request", "get_channel_response", b"get_channel_response", "get_config_request", b"get_config_request", "get_config_response", b"get_config_response", "get_device_connection_status_request", b"get_device_connection_status_request", "get_device_connection_status_response", b"get_device_connection_status_response", "get_device_metadata_request", b"get_device_metadata_request", "get_device_metadata_response", b"get_device_metadata_response", "get_module_config_request", b"get_module_config_request", "get_module_config_response", b"get_module_config_response", "get_node_remote_hardware_pins_request", b"get_node_remote_hardware_pins_request", "get_node_remote_hardware_pins_response", b"get_node_remote_hardware_pins_response", "get_owner_request", b"get_owner_request", "get_owner_response", b"get_owner_response", "get_ringtone_request", b"get_ringtone_request", "get_ringtone_response", b"get_ringtone_response", "get_ui_config_request", b"get_ui_config_request", "get_ui_config_response", b"get_ui_config_response", "key_verification", b"key_verification", "nodedb_reset", b"nodedb_reset", "payload_variant", b"payload_variant", "reboot_ota_seconds", b"reboot_ota_seconds", "reboot_seconds", b"reboot_seconds", "remove_backup_preferences", b"remove_backup_preferences", "remove_by_nodenum", b"remove_by_nodenum", "remove_favorite_node", b"remove_favorite_node", "remove_fixed_position", b"remove_fixed_position", "remove_ignored_node", b"remove_ignored_node", "restore_preferences", b"restore_preferences", "send_input_event", b"send_input_event", "set_canned_message_module_messages", b"set_canned_message_module_messages", "set_channel", b"set_channel", "set_config", b"set_config", "set_favorite_node", b"set_favorite_node", "set_fixed_position", b"set_fixed_position", "set_ham_mode", b"set_ham_mode", "set_ignored_node", b"set_ignored_node", "set_module_config", b"set_module_config", "set_owner", b"set_owner", "set_ringtone_message", b"set_ringtone_message", "set_scale", b"set_scale", "set_time_only", b"set_time_only", "shutdown_seconds", b"shutdown_seconds", "store_ui_config", b"store_ui_config"]) -> builtins.bool: ...
|
def HasField(self, field_name: typing.Literal["add_contact", b"add_contact", "backup_preferences", b"backup_preferences", "begin_edit_settings", b"begin_edit_settings", "commit_edit_settings", b"commit_edit_settings", "delete_file_request", b"delete_file_request", "enter_dfu_mode_request", b"enter_dfu_mode_request", "exit_simulator", b"exit_simulator", "factory_reset_config", b"factory_reset_config", "factory_reset_device", b"factory_reset_device", "get_canned_message_module_messages_request", b"get_canned_message_module_messages_request", "get_canned_message_module_messages_response", b"get_canned_message_module_messages_response", "get_channel_request", b"get_channel_request", "get_channel_response", b"get_channel_response", "get_config_request", b"get_config_request", "get_config_response", b"get_config_response", "get_device_connection_status_request", b"get_device_connection_status_request", "get_device_connection_status_response", b"get_device_connection_status_response", "get_device_metadata_request", b"get_device_metadata_request", "get_device_metadata_response", b"get_device_metadata_response", "get_module_config_request", b"get_module_config_request", "get_module_config_response", b"get_module_config_response", "get_node_remote_hardware_pins_request", b"get_node_remote_hardware_pins_request", "get_node_remote_hardware_pins_response", b"get_node_remote_hardware_pins_response", "get_owner_request", b"get_owner_request", "get_owner_response", b"get_owner_response", "get_ringtone_request", b"get_ringtone_request", "get_ringtone_response", b"get_ringtone_response", "get_ui_config_request", b"get_ui_config_request", "get_ui_config_response", b"get_ui_config_response", "key_verification", b"key_verification", "nodedb_reset", b"nodedb_reset", "payload_variant", b"payload_variant", "reboot_ota_seconds", b"reboot_ota_seconds", "reboot_seconds", b"reboot_seconds", "remove_backup_preferences", b"remove_backup_preferences", "remove_by_nodenum", b"remove_by_nodenum", "remove_favorite_node", b"remove_favorite_node", "remove_fixed_position", b"remove_fixed_position", "remove_ignored_node", b"remove_ignored_node", "restore_preferences", b"restore_preferences", "send_input_event", b"send_input_event", "set_canned_message_module_messages", b"set_canned_message_module_messages", "set_channel", b"set_channel", "set_config", b"set_config", "set_favorite_node", b"set_favorite_node", "set_fixed_position", b"set_fixed_position", "set_ham_mode", b"set_ham_mode", "set_ignored_node", b"set_ignored_node", "set_module_config", b"set_module_config", "set_owner", b"set_owner", "set_ringtone_message", b"set_ringtone_message", "set_scale", b"set_scale", "set_time_only", b"set_time_only", "shutdown_seconds", b"shutdown_seconds", "store_ui_config", b"store_ui_config"]) -> builtins.bool: ...
|
||||||
def ClearField(self, field_name: typing.Literal["add_contact", b"add_contact", "backup_preferences", b"backup_preferences", "begin_edit_settings", b"begin_edit_settings", "commit_edit_settings", b"commit_edit_settings", "delete_file_request", b"delete_file_request", "enter_dfu_mode_request", b"enter_dfu_mode_request", "exit_simulator", b"exit_simulator", "factory_reset_config", b"factory_reset_config", "factory_reset_device", b"factory_reset_device", "get_canned_message_module_messages_request", b"get_canned_message_module_messages_request", "get_canned_message_module_messages_response", b"get_canned_message_module_messages_response", "get_channel_request", b"get_channel_request", "get_channel_response", b"get_channel_response", "get_config_request", b"get_config_request", "get_config_response", b"get_config_response", "get_device_connection_status_request", b"get_device_connection_status_request", "get_device_connection_status_response", b"get_device_connection_status_response", "get_device_metadata_request", b"get_device_metadata_request", "get_device_metadata_response", b"get_device_metadata_response", "get_module_config_request", b"get_module_config_request", "get_module_config_response", b"get_module_config_response", "get_node_remote_hardware_pins_request", b"get_node_remote_hardware_pins_request", "get_node_remote_hardware_pins_response", b"get_node_remote_hardware_pins_response", "get_owner_request", b"get_owner_request", "get_owner_response", b"get_owner_response", "get_ringtone_request", b"get_ringtone_request", "get_ringtone_response", b"get_ringtone_response", "get_ui_config_request", b"get_ui_config_request", "get_ui_config_response", b"get_ui_config_response", "key_verification", b"key_verification", "nodedb_reset", b"nodedb_reset", "payload_variant", b"payload_variant", "reboot_ota_seconds", b"reboot_ota_seconds", "reboot_seconds", b"reboot_seconds", "remove_backup_preferences", b"remove_backup_preferences", "remove_by_nodenum", b"remove_by_nodenum", "remove_favorite_node", b"remove_favorite_node", "remove_fixed_position", b"remove_fixed_position", "remove_ignored_node", b"remove_ignored_node", "restore_preferences", b"restore_preferences", "send_input_event", b"send_input_event", "session_passkey", b"session_passkey", "set_canned_message_module_messages", b"set_canned_message_module_messages", "set_channel", b"set_channel", "set_config", b"set_config", "set_favorite_node", b"set_favorite_node", "set_fixed_position", b"set_fixed_position", "set_ham_mode", b"set_ham_mode", "set_ignored_node", b"set_ignored_node", "set_module_config", b"set_module_config", "set_owner", b"set_owner", "set_ringtone_message", b"set_ringtone_message", "set_scale", b"set_scale", "set_time_only", b"set_time_only", "shutdown_seconds", b"shutdown_seconds", "store_ui_config", b"store_ui_config"]) -> None: ...
|
def ClearField(self, field_name: typing.Literal["add_contact", b"add_contact", "backup_preferences", b"backup_preferences", "begin_edit_settings", b"begin_edit_settings", "commit_edit_settings", b"commit_edit_settings", "delete_file_request", b"delete_file_request", "enter_dfu_mode_request", b"enter_dfu_mode_request", "exit_simulator", b"exit_simulator", "factory_reset_config", b"factory_reset_config", "factory_reset_device", b"factory_reset_device", "get_canned_message_module_messages_request", b"get_canned_message_module_messages_request", "get_canned_message_module_messages_response", b"get_canned_message_module_messages_response", "get_channel_request", b"get_channel_request", "get_channel_response", b"get_channel_response", "get_config_request", b"get_config_request", "get_config_response", b"get_config_response", "get_device_connection_status_request", b"get_device_connection_status_request", "get_device_connection_status_response", b"get_device_connection_status_response", "get_device_metadata_request", b"get_device_metadata_request", "get_device_metadata_response", b"get_device_metadata_response", "get_module_config_request", b"get_module_config_request", "get_module_config_response", b"get_module_config_response", "get_node_remote_hardware_pins_request", b"get_node_remote_hardware_pins_request", "get_node_remote_hardware_pins_response", b"get_node_remote_hardware_pins_response", "get_owner_request", b"get_owner_request", "get_owner_response", b"get_owner_response", "get_ringtone_request", b"get_ringtone_request", "get_ringtone_response", b"get_ringtone_response", "get_ui_config_request", b"get_ui_config_request", "get_ui_config_response", b"get_ui_config_response", "key_verification", b"key_verification", "nodedb_reset", b"nodedb_reset", "payload_variant", b"payload_variant", "reboot_ota_seconds", b"reboot_ota_seconds", "reboot_seconds", b"reboot_seconds", "remove_backup_preferences", b"remove_backup_preferences", "remove_by_nodenum", b"remove_by_nodenum", "remove_favorite_node", b"remove_favorite_node", "remove_fixed_position", b"remove_fixed_position", "remove_ignored_node", b"remove_ignored_node", "restore_preferences", b"restore_preferences", "send_input_event", b"send_input_event", "session_passkey", b"session_passkey", "set_canned_message_module_messages", b"set_canned_message_module_messages", "set_channel", b"set_channel", "set_config", b"set_config", "set_favorite_node", b"set_favorite_node", "set_fixed_position", b"set_fixed_position", "set_ham_mode", b"set_ham_mode", "set_ignored_node", b"set_ignored_node", "set_module_config", b"set_module_config", "set_owner", b"set_owner", "set_ringtone_message", b"set_ringtone_message", "set_scale", b"set_scale", "set_time_only", b"set_time_only", "shutdown_seconds", b"shutdown_seconds", "store_ui_config", b"store_ui_config"]) -> None: ...
|
||||||
|
|||||||
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
12
meshtastic/protobuf/mesh_pb2.pyi
generated
12
meshtastic/protobuf/mesh_pb2.pyi
generated
@@ -523,6 +523,10 @@ class _HardwareModelEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._
|
|||||||
"""
|
"""
|
||||||
RAK3401
|
RAK3401
|
||||||
"""
|
"""
|
||||||
|
RAK6421: _HardwareModel.ValueType # 118
|
||||||
|
"""
|
||||||
|
RAK6421 Hat+
|
||||||
|
"""
|
||||||
PRIVATE_HW: _HardwareModel.ValueType # 255
|
PRIVATE_HW: _HardwareModel.ValueType # 255
|
||||||
"""
|
"""
|
||||||
------------------------------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -1029,6 +1033,10 @@ RAK3401: HardwareModel.ValueType # 117
|
|||||||
"""
|
"""
|
||||||
RAK3401
|
RAK3401
|
||||||
"""
|
"""
|
||||||
|
RAK6421: HardwareModel.ValueType # 118
|
||||||
|
"""
|
||||||
|
RAK6421 Hat+
|
||||||
|
"""
|
||||||
PRIVATE_HW: HardwareModel.ValueType # 255
|
PRIVATE_HW: HardwareModel.ValueType # 255
|
||||||
"""
|
"""
|
||||||
------------------------------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -2557,6 +2565,10 @@ class MeshPacket(google.protobuf.message.Message):
|
|||||||
to: builtins.int
|
to: builtins.int
|
||||||
"""
|
"""
|
||||||
The (immediate) destination for this packet
|
The (immediate) destination for this packet
|
||||||
|
If the value is 4,294,967,295 (maximum value of an unsigned 32bit integer), this indicates that the packet was
|
||||||
|
not destined for a specific node, but for a channel as indicated by the value of `channel` below.
|
||||||
|
If the value is another, this indicates that the packet was destined for a specific
|
||||||
|
node (i.e. a kind of "Direct Message" to this node) and not broadcast on a channel.
|
||||||
"""
|
"""
|
||||||
channel: builtins.int
|
channel: builtins.int
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -735,3 +735,16 @@ def to_node_num(node_id: Union[int, str]) -> int:
|
|||||||
return int(s, 10)
|
return int(s, 10)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return int(s, 16)
|
return int(s, 16)
|
||||||
|
|
||||||
|
def flags_to_list(flag_type, flags: int) -> List[str]:
|
||||||
|
"""Given a flag_type that's a protobuf EnumTypeWrapper, and a flag int, give a list of flags enabled."""
|
||||||
|
ret = []
|
||||||
|
for key in flag_type.keys():
|
||||||
|
if key == "EXCLUDED_NONE":
|
||||||
|
continue
|
||||||
|
if flags & flag_type.Value(key):
|
||||||
|
ret.append(key)
|
||||||
|
flags = flags - flag_type.Value(key)
|
||||||
|
if flags > 0:
|
||||||
|
ret.append(f"UNKNOWN_ADDITIONAL_FLAGS({flags})")
|
||||||
|
return ret
|
||||||
|
|||||||
Submodule protobufs updated: fbe1538c21...7eb3258fa0
Reference in New Issue
Block a user