Skip to content

Commit 0cd1df5

Browse files
committed
Realtime map updates
1 parent e6e6534 commit 0cd1df5

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

  • deebot_client/messages/xml

deebot_client/messages/xml/map.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from typing import TYPE_CHECKING
66

7-
from deebot_client.events.map import MapTraceEvent
7+
from deebot_client.events.map import MapTraceEvent, MinorMapEvent
88
from deebot_client.message import HandlingResult
99
from deebot_client.messages.xml.common import XmlMessage
1010

@@ -23,15 +23,17 @@ class MapP(XmlMessage):
2323
NAME = "MapP"
2424

2525
@classmethod
26-
def _handle_xml(cls, _event_bus: EventBus, _xml: Element) -> HandlingResult:
26+
def _handle_xml(cls, event_bus: EventBus, xml: Element) -> HandlingResult:
2727
"""Handle xml message and notify the correct event subscribers.
2828
2929
b"<ctl td='MapP' i='1245233875' pid='27' p='XQAABAAQJwAAAABv/f//o7f/Rz5IFXI5YVG4kYRDU5g6Z4W8UflplyVyfWyHmYdt2YVgA/k3ENxVye1lEM...fqEp3pept9Re5qT0lZFDWpoFg4D51VXQopPSDLSo2ZpM/zQ4IAhvgWIKnp7zlwcd6Ekj7U2FnOTTAQeWq3DPT+MTrAVO2wL/6mmGODzk4hBtA/wjZzOujPgEA=='/>"
3030
31-
This is currently ignored as we prefer to pull map pieces
3231
:return: A message response
3332
"""
34-
return HandlingResult.success()
33+
if (pid := xml.attrib.get("pid")) and (piece := xml.attrib.get("p")):
34+
event_bus.notify(MinorMapEvent(index=int(pid), value=piece))
35+
return HandlingResult.success()
36+
return HandlingResult.analyse()
3537

3638

3739
class Trace(XmlMessage):

0 commit comments

Comments
 (0)