tutk_protocol.py
TutkWyzeProtocolHeader
Struct representing the first 16 bytes of messages sent back and forth between the camera and a client over a TutkIOCtrlMux.
Attributes:
Name | Type | Description |
---|---|---|
prefix |
str |
the first two bytes of the header, always |
protocol |
int |
the protocol version being spoken by the client or camera. This varies quite a bit depending on the firmware version of the camera. |
code |
int |
The 2-byte "command" being issued, either by the camera, or the client. By convention, it appears commands sent from a client to the camera are even numbered 'codes', whereas responses from the camera back to the client are always odd. |
txt_len |
int |
the length of the payload of the message, i.e. the contents just after this header |
TutkWyzeProtocolMessage
An abstract class representing a command sent from the client to the camera. Subclasses implement particular codes.
Attributes:
Name | Type | Description |
---|---|---|
code |
int |
the 2 digit code representing this message |
expected_response_code |
Optional[int] |
the code of the message expected to be the 'response' to this one, from the camera. |
Methods
encode(self)
Translates this protocol message into a series of bytes, including the appropriate 16 byte header.
Source code in wyzecam/tutk/tutk_protocol.py
def encode(self) -> bytes:
"""
Translates this protocol message into a series of bytes,
including the appropriate
[16 byte header][wyzecam.tutk.tutk_protocol.TutkWyzeProtocolHeader].
"""
return encode(self.code, 0, None)
parse_response(self, resp_data)
Called by TutkIOCtrlMux upon receipt of the corresponding expected_response_code of this message.
Source code in wyzecam/tutk/tutk_protocol.py
def parse_response(self, resp_data: bytes) -> typing.Any:
"""
Called by [TutkIOCtrlMux][wyzecam.tutk.tutk_ioctl_mux.TutkIOCtrlMux] upon receipt
of the corresponding
[expected_response_code][wyzecam.tutk.tutk_protocol.TutkWyzeProtocolMessage]
of this message.
"""
return resp_data