Skip to content

Commit

Permalink
Merge branch 'dev' into patch-32
Browse files Browse the repository at this point in the history
  • Loading branch information
Hedda authored May 2, 2024
2 parents 4f1a392 + b008ccf commit c6aae31
Show file tree
Hide file tree
Showing 39 changed files with 264 additions and 1,478 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ jobs:
CACHE_VERSION: 2
PYTHON_VERSION_DEFAULT: 3.9.15
PRE_COMMIT_CACHE_PATH: ~/.cache/pre-commit
MINIMUM_COVERAGE_PERCENTAGE: 99
MINIMUM_COVERAGE_PERCENTAGE: 99
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion bellows/cli/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def cb(frame_name, response):
hdr = pure_pcapy.Pkthdr(ts_sec, ts_usec, len(data), len(data))

try:
pcap.dump(hdr, data)
pcap.dump(hdr, bytes(data))
except BrokenPipeError:
done_event.set()

Expand Down
2 changes: 1 addition & 1 deletion bellows/cli/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def cb(fut, frame_name, response):
if isinstance(extended_pan_id, str):
extended_pan_id = util.parse_epan(extended_pan_id)
if extended_pan_id is None:
extended_pan_id = t.fixed_list(8, t.uint8_t)([t.uint8_t(0)] * 8)
extended_pan_id = t.FixedList[t.uint8_t, 8]([t.uint8_t(0)] * 8)

v = await util.network_init(s)

Expand Down
2 changes: 1 addition & 1 deletion bellows/cli/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ async def network_init(s):
def parse_epan(epan):
"""Parse a user specified extended PAN ID"""
epan_list = [t.uint8_t(x, 16) for x in epan.split(":")]
return t.fixed_list(8, t.uint8_t)(epan_list)
return t.FixedList[t.uint8_t, 8](epan_list)


async def basic_tc_permits(s):
Expand Down
6 changes: 3 additions & 3 deletions bellows/ezsp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,14 +379,14 @@ async def _get_nv3_restored_eui64_key(self) -> t.NV3KeyId | None:
t.NV3KeyId.NVM3KEY_STACK_RESTORED_EUI64, # RCP firmware
):
try:
status, data = await self.getTokenData(key, 0)
rsp = await self.getTokenData(key, 0)
except (InvalidCommandError, AttributeError):
# Either the command doesn't exist in the EZSP version, or the command
# is not implemented in the firmware
return None

if status == t.EmberStatus.SUCCESS:
nv3_restored_eui64, _ = t.EUI64.deserialize(data)
if rsp.status == t.EmberStatus.SUCCESS:
nv3_restored_eui64, _ = t.EUI64.deserialize(rsp.value)
LOGGER.debug("NV3 restored EUI64: %s=%s", key, nv3_restored_eui64)

return key
Expand Down
13 changes: 8 additions & 5 deletions bellows/ezsp/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ async def command(self, name, *args) -> Any:
LOGGER.debug("Send command %s: %s", name, args)
data = self._ezsp_frame(name, *args)
self._gw.data(data)
c = self.COMMANDS[name]
future = asyncio.Future()
self._awaiting[self._seq] = (c[0], c[2], future)
cmd_id, _, rx_schema = self.COMMANDS[name]
future = asyncio.get_running_loop().create_future()
self._awaiting[self._seq] = (cmd_id, rx_schema, future)
self._seq = (self._seq + 1) % 256

async with asyncio_timeout(EZSP_CMD_TIMEOUT):
Expand All @@ -89,7 +89,7 @@ def __call__(self, data: bytes) -> None:
sequence, frame_id, data = self._ezsp_frame_rx(data)

try:
frame_name, _, schema = self.COMMANDS_BY_ID[frame_id]
frame_name, _, rx_schema = self.COMMANDS_BY_ID[frame_id]
except KeyError:
LOGGER.warning(
"Unknown application frame 0x%04X received: %s (%s). This is a bug!",
Expand All @@ -100,7 +100,10 @@ def __call__(self, data: bytes) -> None:
return

try:
result, data = self.types.deserialize(data, schema)
if isinstance(rx_schema, tuple):
result, data = self.types.deserialize(data, rx_schema)
else:
result, data = rx_schema.deserialize(data)
except Exception:
LOGGER.warning(
"Failed to parse frame %s: %s", frame_name, binascii.hexlify(data)
Expand Down
Loading

0 comments on commit c6aae31

Please sign in to comment.