|
12 | 12 | from .api import KEEPALIVE, RoborockClient |
13 | 13 | from .containers import DeviceData, UserData |
14 | 14 | from .exceptions import RoborockException, VacuumError |
15 | | -from .protocol import MessageParser, create_mqtt_params |
| 15 | +from .protocol import Decoder, Encoder, MessageParser, create_mqtt_decoder, create_mqtt_encoder, create_mqtt_params, md5hex |
16 | 16 | from .roborock_future import RoborockFuture |
17 | 17 |
|
18 | 18 | _LOGGER = logging.getLogger(__name__) |
@@ -68,6 +68,8 @@ def __init__(self, user_data: UserData, device_info: DeviceData) -> None: |
68 | 68 | self._mqtt_client.username_pw_set(mqtt_params.username, mqtt_params.password) |
69 | 69 | self._waiting_queue: dict[int, RoborockFuture] = {} |
70 | 70 | self._mutex = Lock() |
| 71 | + self._decoder: Decoder = create_mqtt_decoder(device_info.device.local_key) |
| 72 | + self._encoder: Encoder = create_mqtt_encoder(device_info.device.local_key) |
71 | 73 |
|
72 | 74 | def _mqtt_on_connect(self, *args, **kwargs): |
73 | 75 | _, __, ___, rc, ____ = args |
@@ -96,7 +98,7 @@ def _mqtt_on_connect(self, *args, **kwargs): |
96 | 98 | def _mqtt_on_message(self, *args, **kwargs): |
97 | 99 | client, __, msg = args |
98 | 100 | try: |
99 | | - messages, _ = MessageParser.parse(msg.payload, local_key=self.device_info.device.local_key) |
| 101 | + messages = self._decoder(msg.payload) |
100 | 102 | super().on_message_received(messages) |
101 | 103 | except Exception as ex: |
102 | 104 | self._logger.exception(ex) |
|
0 commit comments