-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
52 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,48 @@ | ||
"""Custom EZSP commands.""" | ||
from __future__ import annotations | ||
|
||
import zigpy.types as t | ||
|
||
|
||
class CustomCommand(t.enum8): | ||
CMD_GET_SUPPORTED_FEATURES = 0x00 | ||
class Bytes(bytes): | ||
def serialize(self) -> Bytes: | ||
return self | ||
|
||
@classmethod | ||
def deserialize(cls, data: bytes) -> tuple[Bytes, bytes]: | ||
return cls(data), b"" | ||
|
||
def __repr__(self) -> str: | ||
# Reading byte sequences like \x200\x21 is extremely annoying | ||
# compared to \x20\x30\x21 | ||
escaped = "".join(f"\\x{b:02X}" for b in self) | ||
|
||
return f"b'{escaped}'" | ||
|
||
__str__ = __repr__ | ||
|
||
|
||
class CustomCommandId(t.enum16): | ||
CMD_GET_PROTOCOL_VERSION_REQ = 0x0000 | ||
CMD_GET_PROTOCOL_VERSION_RSP = 0x8000 | ||
|
||
CMD_GET_SUPPORTED_FEATURES_REQ = 0x0001 | ||
CMD_GET_SUPPORTED_FEATURES_RSP = 0x8001 | ||
|
||
|
||
class CustomCommand(t.Struct): | ||
command_id: CustomCommandId | ||
payload: Bytes | ||
|
||
|
||
class FirmwareFeatures(t.bitmap32): | ||
# The firmware passes through all group traffic, regardless of group membership | ||
MEMBER_OF_ALL_GROUPS = 0b00000000_00000000_00000000_00000001 | ||
|
||
|
||
class GetSupportedFeaturesReq(t.Struct): | ||
pass | ||
|
||
|
||
class GetSupportedFeaturesRsp(t.Struct): | ||
features: FirmwareFeatures |