mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-11-01 10:12:03 +00:00
start using CommandType instead of raw values
This commit is contained in:
@@ -328,7 +328,7 @@ class MessagingCommands(CommandHandlerBase):
|
|||||||
return Event(EventType.ERROR, {"reason": "unsupported_path_type"})
|
return Event(EventType.ERROR, {"reason": "unsupported_path_type"})
|
||||||
|
|
||||||
# Prepare the command packet: CMD(1) + tag(4) + auth_code(4) + flags(1) + [path]
|
# Prepare the command packet: CMD(1) + tag(4) + auth_code(4) + flags(1) + [path]
|
||||||
cmd_data = bytearray([36]) # CMD_SEND_TRACE_PATH
|
cmd_data = bytearray([CommandType.SEND_TRACE_PATH.value]) # CMD_SEND_TRACE_PATH
|
||||||
cmd_data.extend(tag.to_bytes(4, "little"))
|
cmd_data.extend(tag.to_bytes(4, "little"))
|
||||||
cmd_data.extend(auth_code.to_bytes(4, "little"))
|
cmd_data.extend(auth_code.to_bytes(4, "little"))
|
||||||
cmd_data.append(flags)
|
cmd_data.append(flags)
|
||||||
@@ -366,7 +366,7 @@ class MessagingCommands(CommandHandlerBase):
|
|||||||
if len(payload) < 4:
|
if len(payload) < 4:
|
||||||
raise ValueError("payload must be at least 4 bytes")
|
raise ValueError("payload must be at least 4 bytes")
|
||||||
path = bytes(path)
|
path = bytes(path)
|
||||||
data = bytes([0x19, len(path)]) + path + bytes(payload)
|
data = bytes([CommandType.SEND_RAW_DATA.value, len(path)]) + path + bytes(payload)
|
||||||
return await self.send(data, [EventType.OK, EventType.ERROR])
|
return await self.send(data, [EventType.OK, EventType.ERROR])
|
||||||
|
|
||||||
async def send_channel_data(
|
async def send_channel_data(
|
||||||
@@ -401,7 +401,7 @@ class MessagingCommands(CommandHandlerBase):
|
|||||||
if len(path) >= 0xFF:
|
if len(path) >= 0xFF:
|
||||||
raise ValueError("path must be shorter than 255 bytes")
|
raise ValueError("path must be shorter than 255 bytes")
|
||||||
path_bytes = bytes([len(path)]) + path
|
path_bytes = bytes([len(path)]) + path
|
||||||
data = bytes([0x3E, chan]) + path_bytes + data_type.to_bytes(2, "little") + bytes(payload)
|
data = bytes([CommandType.SEND_CHANNEL_DATA.value, chan]) + path_bytes + data_type.to_bytes(2, "little") + bytes(payload)
|
||||||
return await self.send(data, [EventType.OK, EventType.ERROR])
|
return await self.send(data, [EventType.OK, EventType.ERROR])
|
||||||
|
|
||||||
async def set_flood_scope(self, scope, force_unscoped=False):
|
async def set_flood_scope(self, scope, force_unscoped=False):
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ class CommandType(Enum):
|
|||||||
GET_ALLOWED_REPEAT_FREQ = 60
|
GET_ALLOWED_REPEAT_FREQ = 60
|
||||||
GET_STATS = 56 # R04: CMD_GET_STATS — used by get_stats_core/radio/packets
|
GET_STATS = 56 # R04: CMD_GET_STATS — used by get_stats_core/radio/packets
|
||||||
SET_PATH_HASH_MODE = 61
|
SET_PATH_HASH_MODE = 61
|
||||||
|
SEND_CHANNEL_DATA = 62
|
||||||
SET_DEFAULT_FLOOD_SCOPE = 63
|
SET_DEFAULT_FLOOD_SCOPE = 63
|
||||||
GET_DEFAULT_FLOOD_SCOPE = 64
|
GET_DEFAULT_FLOOD_SCOPE = 64
|
||||||
SEND_RAW_PACKET = 65
|
SEND_RAW_PACKET = 65
|
||||||
|
|||||||
Reference in New Issue
Block a user