Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ All events in MeshCore are represented by the `EventType` enum. These events are
| `ACL_RESPONSE` | `"acl_response"` | Access Control List data | List of keys and permissions |
| **Channel Events** |||
| `CHANNEL_INFO` | `"channel_info"` | Channel configuration | Channel name, secret, index |
| `CHANNEL_FLAG_NOSTORE` | `"channel_flag_nostore"` | State of no-store channel flag | Flag state |
| **Raw Data Events** |||
| `RAW_DATA` | `"raw_data"` | Raw radio data | SNR, RSSI, payload hex |
| `RX_LOG_DATA` | `"rx_log_data"` | RF log data | SNR, RSSI, raw payload |
Expand Down Expand Up @@ -512,6 +513,8 @@ All commands are async methods that return `Event` objects. Commands are organiz
| **Channel Management** ||||
| `get_channel(channel_idx)` | `channel_idx: int` | `CHANNEL_INFO` | Get channel configuration |
| `set_channel(channel_idx, name, secret)` | `channel_idx: int, name: str, secret: bytes` | `OK` | Configure channel (secret must be 16 bytes) |
| `get_channel_flag_nostore(channel_idx)` | `channel_idx: int` | `CHANNEL_FLAG_NOSTORE` | Get state of channel's no-store flag |
| `set_channel_flag_nostore(channel_idx, enabled)` | `channel_idx: int, enabled: bool` | `OK` | Set state of channel's no-store flag |
| **Device Actions** ||||
| `send_advert(flood=False)` | `flood: bool` | `OK` | Send advertisement (optionally flood network) |
| `reboot()` | None | None | Reboot device (no response expected) |
Expand Down
10 changes: 10 additions & 0 deletions src/meshcore/commands/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,13 @@ async def get_stats_packets(self) -> Event:
logger.debug("Getting packet statistics")
# CMD_GET_STATS (56) + STATS_TYPE_PACKETS (2)
return await self.send(b"\x38\x02", [EventType.STATS_PACKETS, EventType.ERROR])

async def get_channel_flag_nostore(self, channel_idx: int) -> Event:
logger.debug(f"Getting channel flag nostore for channel {channel_idx}")
data = b"\x39" + channel_idx.to_bytes(1, "little")
return await self.send(data, [EventType.CHANNEL_FLAG_NOSTORE, EventType.ERROR])

async def set_channel_flag_nostore(self, channel_idx: int, no_store: bool) -> Event:
logger.debug(f"Setting channel flag nostore for channel {channel_idx} to {no_store}")
data = b"\x3a" + channel_idx.to_bytes(1, "little") + no_store.to_bytes(1, "little")
return await self.send(data, [EventType.OK, EventType.ERROR])
1 change: 1 addition & 0 deletions src/meshcore/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class EventType(Enum):
CONTROL_DATA = "control_data"
DISCOVER_RESPONSE = "discover_response"
NEIGHBOURS_RESPONSE = "neighbours_response"
CHANNEL_FLAG_NOSTORE = "channel_flag_nostore"

# Command response types
OK = "command_ok"
Expand Down
1 change: 1 addition & 0 deletions src/meshcore/packets.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class PacketType(Enum):
SIGNATURE = 20
CUSTOM_VARS = 21
STATS = 24
CHANNEL_FLAG_NOSTORE = 25
BINARY_REQ = 50
FACTORY_RESET = 51
PATH_DISCOVERY = 52
Expand Down
7 changes: 7 additions & 0 deletions src/meshcore/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,13 @@ async def handle_rx(self, data: bytearray):
res[psplit[0]] = psplit[1]
logger.debug(f"got custom vars : {res}")
await self.dispatcher.dispatch(Event(EventType.CUSTOM_VARS, res))

elif packet_type_value == PacketType.CHANNEL_FLAG_NOSTORE.value:
logger.debug(f"received channel flag nostore response: {data.hex()}")
res = {}
res["channel_flag_nostore"] = (bool)(dbuf.read(1)[0])
logger.debug(f"got channel flags : {res}")
await self.dispatcher.dispatch(Event(EventType.CHANNEL_FLAG_NOSTORE, res))

elif packet_type_value == PacketType.STATS.value: # RESP_CODE_STATS (24)
logger.debug(f"received stats response: {data.hex()}")
Expand Down