feat(core): create pairing state if branch

M1nd3r/thp6
M1nd3r 3 weeks ago
parent 707361fccb
commit 7963cb12c3

@ -211,6 +211,10 @@ class Channel(Context):
if state is ChannelState.TH2:
await self._handle_state_TH2(message_length, sync_bit)
return
if is_channel_state_pairing(state):
await self._handle_pairing(message_length)
return
raise ThpError("Unimplemented channel state")
async def _handle_state_TH1(
self, payload_length: int, message_length: int, sync_bit: int
@ -279,6 +283,9 @@ class Channel(Context):
)
)
async def _handle_pairing(self, message_length: int) -> None:
pass
def _handle_channel_message(self, message_length: int, message_type: int) -> None:
buf = self.buffer[INIT_DATA_OFFSET + 3 : message_length - CHECKSUM_LENGTH]
@ -580,6 +587,18 @@ def _is_ctrl_byte_ack(ctrl_byte: int) -> bool:
return ctrl_byte & 0xEF == ACK_MESSAGE
def is_channel_state_pairing(state: int) -> bool:
if state in (
ChannelState.TP1,
ChannelState.TP2,
ChannelState.TP3,
ChannelState.TP4,
ChannelState.TP5,
):
return True
return False
def _state_to_str(state: int) -> str:
if state == ChannelState.ENCRYPTED_TRANSPORT:
return "state: encrypted transport"

Loading…
Cancel
Save