Skip to content

Commit 89a0eed

Browse files
committed
fix: potentially fix ping?
1 parent f926359 commit 89a0eed

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

roborock/version_1_apis/roborock_client_v1.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ def on_message_received(self, messages: list[RoborockMessage]) -> None:
449449
)
450450
else:
451451
if data.protocol == RoborockMessageProtocol.GENERAL_RESPONSE and data.payload is None:
452+
# Api will often send blank messages with matching sequences, we can ignore these.
452453
continue
453454
queue = self._waiting_queue.get(data.seq)
454455
if queue:

roborock/version_1_apis/roborock_local_client_v1.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@
2121
_LOGGER = logging.getLogger(__name__)
2222

2323

24-
_PING_REQUEST_MESSAGE = RoborockMessage(
25-
protocol=RoborockMessageProtocol.PING_REQUEST,
26-
seq=2,
27-
random=23,
28-
)
29-
30-
3124
@dataclass
3225
class _LocalProtocol(asyncio.Protocol):
3326
"""Callbacks for the Roborock local client transport."""
@@ -170,11 +163,16 @@ async def hello(self):
170163
raise RoborockException("Failed to connect to device with any known protocol")
171164

172165
async def ping(self) -> None:
166+
self._logger.debug("Ping")
167+
ping_message = RoborockMessage(
168+
protocol=RoborockMessageProtocol.PING_REQUEST,
169+
)
173170
await self._send_message(
174-
roborock_message=_PING_REQUEST_MESSAGE,
175-
request_id=_PING_REQUEST_MESSAGE.seq,
171+
roborock_message=ping_message,
172+
request_id=ping_message.seq,
176173
response_protocol=RoborockMessageProtocol.PING_RESPONSE,
177174
)
175+
self._logger.debug("Pong")
178176

179177
def _send_msg_raw(self, data: bytes):
180178
try:

0 commit comments

Comments
 (0)