pymammotion 0.4.0b1__tar.gz → 0.4.0b2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/PKG-INFO +1 -1
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/model/device_info.py +0 -1
- pymammotion-0.4.0b2/pymammotion/data/state_manager.py +177 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/devices/mammotion_bluetooth.py +3 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pyproject.toml +2 -2
- pymammotion-0.4.0b1/pymammotion/data/state_manager.py +0 -173
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/LICENSE +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/README.md +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/__init__.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/aliyun/__init__.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/aliyun/cloud_gateway.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/aliyun/model/aep_response.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/aliyun/model/connect_response.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/aliyun/model/dev_by_account_response.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/aliyun/model/login_by_oauth_response.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/aliyun/model/regions_response.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/aliyun/model/session_by_authcode_response.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/aliyun/model/stream_subscription_response.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/aliyun/tmp_constant.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/bluetooth/__init__.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/bluetooth/ble.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/bluetooth/ble_message.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/bluetooth/const.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/bluetooth/data/__init__.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/bluetooth/data/convert.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/bluetooth/data/framectrldata.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/bluetooth/data/notifydata.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/bluetooth/model/__init__.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/bluetooth/model/atomic_integer.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/const.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/__init__.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/model/__init__.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/model/account.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/model/device.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/model/device_config.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/model/device_limits.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/model/enums.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/model/excute_boarder_params.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/model/execute_boarder.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/model/generate_route_information.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/model/hash_list.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/model/location.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/model/mowing_modes.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/model/plan.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/model/rapid_state.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/model/raw_data.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/model/region_data.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/model/report_info.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/mqtt/__init__.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/mqtt/event.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/mqtt/properties.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/mqtt/status.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/event/__init__.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/event/event.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/http/_init_.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/http/encryption.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/http/http.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/http/model/http.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/__init__.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/commands/__init__.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/commands/abstract_message.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/commands/mammotion_command.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/commands/messages/__init__.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/commands/messages/driver.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/commands/messages/media.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/commands/messages/navigation.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/commands/messages/network.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/commands/messages/ota.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/commands/messages/system.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/commands/messages/video.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/control/__init__.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/control/joystick.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/devices/__init__.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/devices/base.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/devices/mammotion.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/devices/mammotion_cloud.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mqtt/__init__.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mqtt/linkkit/__init__.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mqtt/linkkit/h2client.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mqtt/linkkit/linkkit.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mqtt/mammotion_future.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mqtt/mammotion_mqtt.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/__init__.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/basestation.proto +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/basestation.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/basestation_pb2.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/basestation_pb2.pyi +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/common.proto +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/common.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/common_pb2.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/common_pb2.pyi +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/dev_net.proto +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/dev_net.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/dev_net_pb2.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/dev_net_pb2.pyi +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/luba_msg.proto +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/luba_msg.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/luba_msg_pb2.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/luba_msg_pb2.pyi +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/luba_mul.proto +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/luba_mul.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/luba_mul_pb2.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/luba_mul_pb2.pyi +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/mctrl_driver.proto +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/mctrl_driver.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/mctrl_driver_pb2.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/mctrl_driver_pb2.pyi +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/mctrl_nav.proto +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/mctrl_nav.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/mctrl_nav_pb2.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/mctrl_nav_pb2.pyi +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/mctrl_ota.proto +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/mctrl_ota.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/mctrl_ota_pb2.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/mctrl_ota_pb2.pyi +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/mctrl_pept.proto +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/mctrl_pept.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/mctrl_pept_pb2.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/mctrl_pept_pb2.pyi +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/mctrl_sys.proto +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/mctrl_sys.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/mctrl_sys_pb2.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/proto/mctrl_sys_pb2.pyi +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/py.typed +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/utility/constant/__init__.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/utility/constant/device_constant.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/utility/conversions.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/utility/datatype_converter.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/utility/device_config.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/utility/device_type.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/utility/map.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/utility/movement.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/utility/periodic.py +0 -0
- {pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/utility/rocker_util.py +0 -0
@@ -0,0 +1,177 @@
|
|
1
|
+
"""Manage state from notifications into MowingDevice."""
|
2
|
+
|
3
|
+
from collections.abc import Awaitable, Callable
|
4
|
+
from datetime import datetime
|
5
|
+
import logging
|
6
|
+
from typing import Any
|
7
|
+
|
8
|
+
import betterproto
|
9
|
+
|
10
|
+
from pymammotion.data.model.device import MowingDevice
|
11
|
+
from pymammotion.data.model.device_info import SideLight
|
12
|
+
from pymammotion.data.model.hash_list import AreaHashNameList
|
13
|
+
from pymammotion.data.mqtt.properties import ThingPropertiesMessage
|
14
|
+
from pymammotion.data.mqtt.status import ThingStatusMessage
|
15
|
+
from pymammotion.proto.dev_net import DrvDevInfoResp, DrvDevInfoResult, WifiIotStatusReport
|
16
|
+
from pymammotion.proto.luba_msg import LubaMsg
|
17
|
+
from pymammotion.proto.mctrl_nav import AppGetAllAreaHashName, NavGetCommDataAck, NavGetHashListAck, SvgMessageAckT
|
18
|
+
from pymammotion.proto.mctrl_sys import DeviceFwInfo, DeviceProductTypeInfoT, TimeCtrlLight
|
19
|
+
|
20
|
+
logger = logging.getLogger(__name__)
|
21
|
+
|
22
|
+
|
23
|
+
class StateManager:
|
24
|
+
"""Manage state."""
|
25
|
+
|
26
|
+
_device: MowingDevice
|
27
|
+
last_updated_at: datetime = datetime.now()
|
28
|
+
cloud_gethash_ack_callback: Callable[[NavGetHashListAck], Awaitable[None]] | None = None
|
29
|
+
cloud_get_commondata_ack_callback: Callable[[NavGetCommDataAck | SvgMessageAckT], Awaitable[None]] | None = None
|
30
|
+
cloud_on_notification_callback: Callable[[tuple[str, Any | None]], Awaitable[None]] | None = None
|
31
|
+
|
32
|
+
# possibly don't need anymore
|
33
|
+
cloud_queue_command_callback: Callable[[str, dict[str, Any]], Awaitable[bytes]] | None = None
|
34
|
+
|
35
|
+
ble_gethash_ack_callback: Callable[[NavGetHashListAck], Awaitable[None]] | None = None
|
36
|
+
ble_get_commondata_ack_callback: Callable[[NavGetCommDataAck | SvgMessageAckT], Awaitable[None]] | None = None
|
37
|
+
ble_on_notification_callback: Callable[[tuple[str, Any | None]], Awaitable[None]] | None = None
|
38
|
+
|
39
|
+
# possibly don't need anymore
|
40
|
+
ble_queue_command_callback: Callable[[str, dict[str, Any]], Awaitable[bytes]] | None = None
|
41
|
+
|
42
|
+
def __init__(self, device: MowingDevice) -> None:
|
43
|
+
self._device = device
|
44
|
+
self.last_updated_at = datetime.now()
|
45
|
+
|
46
|
+
def get_device(self) -> MowingDevice:
|
47
|
+
"""Get device."""
|
48
|
+
return self._device
|
49
|
+
|
50
|
+
def set_device(self, device: MowingDevice) -> None:
|
51
|
+
"""Set device."""
|
52
|
+
self._device = device
|
53
|
+
|
54
|
+
def properties(self, thing_properties: ThingPropertiesMessage) -> None:
|
55
|
+
self._device.mqtt_properties = thing_properties
|
56
|
+
|
57
|
+
def status(self, thing_status: ThingStatusMessage) -> None:
|
58
|
+
if not self._device.online:
|
59
|
+
self._device.online = True
|
60
|
+
self._device.status_properties = thing_status
|
61
|
+
|
62
|
+
@property
|
63
|
+
def online(self) -> bool:
|
64
|
+
return self._device.online
|
65
|
+
|
66
|
+
@online.setter
|
67
|
+
def online(self, value: bool) -> None:
|
68
|
+
self._device.online = value
|
69
|
+
|
70
|
+
async def gethash_ack_callback(self, msg: NavGetHashListAck) -> None:
|
71
|
+
if self.cloud_gethash_ack_callback:
|
72
|
+
await self.cloud_gethash_ack_callback(msg)
|
73
|
+
if self.ble_gethash_ack_callback:
|
74
|
+
await self.ble_gethash_ack_callback(msg)
|
75
|
+
|
76
|
+
async def on_notification_callback(self, res: tuple[str, Any | None]) -> None:
|
77
|
+
if self.cloud_on_notification_callback:
|
78
|
+
await self.cloud_on_notification_callback(res)
|
79
|
+
if self.ble_on_notification_callback:
|
80
|
+
await self.ble_on_notification_callback(res)
|
81
|
+
|
82
|
+
async def get_commondata_ack_callback(self, comm_data: NavGetCommDataAck | SvgMessageAckT) -> None:
|
83
|
+
if self.cloud_get_commondata_ack_callback:
|
84
|
+
await self.cloud_get_commondata_ack_callback(comm_data)
|
85
|
+
if self.ble_get_commondata_ack_callback:
|
86
|
+
await self.ble_get_commondata_ack_callback(comm_data)
|
87
|
+
|
88
|
+
async def notification(self, message: LubaMsg) -> None:
|
89
|
+
"""Handle protobuf notifications."""
|
90
|
+
res = betterproto.which_one_of(message, "LubaSubMsg")
|
91
|
+
self.last_updated_at = datetime.now()
|
92
|
+
|
93
|
+
match res[0]:
|
94
|
+
case "nav":
|
95
|
+
await self._update_nav_data(message)
|
96
|
+
case "sys":
|
97
|
+
await self._update_sys_data(message)
|
98
|
+
case "driver":
|
99
|
+
self._update_driver_data(message)
|
100
|
+
case "net":
|
101
|
+
self._update_net_data(message)
|
102
|
+
case "mul":
|
103
|
+
self._update_mul_data(message)
|
104
|
+
case "ota":
|
105
|
+
self._update_ota_data(message)
|
106
|
+
|
107
|
+
await self.on_notification_callback(res)
|
108
|
+
|
109
|
+
async def _update_nav_data(self, message) -> None:
|
110
|
+
"""Update nav data."""
|
111
|
+
nav_msg = betterproto.which_one_of(message.nav, "SubNavMsg")
|
112
|
+
match nav_msg[0]:
|
113
|
+
case "toapp_gethash_ack":
|
114
|
+
hashlist_ack: NavGetHashListAck = nav_msg[1]
|
115
|
+
self._device.map.update_root_hash_list(hashlist_ack)
|
116
|
+
await self.gethash_ack_callback(nav_msg[1])
|
117
|
+
case "toapp_get_commondata_ack":
|
118
|
+
common_data: NavGetCommDataAck = nav_msg[1]
|
119
|
+
updated = self._device.map.update(common_data)
|
120
|
+
if updated:
|
121
|
+
await self.get_commondata_ack_callback(common_data)
|
122
|
+
case "toapp_svg_msg":
|
123
|
+
common_data: SvgMessageAckT = nav_msg[1]
|
124
|
+
updated = self._device.map.update(common_data)
|
125
|
+
if updated:
|
126
|
+
await self.get_commondata_ack_callback(common_data)
|
127
|
+
|
128
|
+
case "toapp_all_hash_name":
|
129
|
+
hash_names: AppGetAllAreaHashName = nav_msg[1]
|
130
|
+
converted_list = [AreaHashNameList(name=item.name, hash=item.hash) for item in hash_names.hashnames]
|
131
|
+
self._device.map.area_name = converted_list
|
132
|
+
|
133
|
+
async def _update_sys_data(self, message) -> None:
|
134
|
+
"""Update system."""
|
135
|
+
sys_msg = betterproto.which_one_of(message.sys, "SubSysMsg")
|
136
|
+
match sys_msg[0]:
|
137
|
+
case "system_update_buf":
|
138
|
+
self._device.buffer(sys_msg[1])
|
139
|
+
case "toapp_report_data":
|
140
|
+
self._device.update_report_data(sys_msg[1])
|
141
|
+
case "mow_to_app_info":
|
142
|
+
self._device.mow_info(sys_msg[1])
|
143
|
+
case "system_tard_state_tunnel":
|
144
|
+
self._device.run_state_update(sys_msg[1])
|
145
|
+
case "todev_time_ctrl_light":
|
146
|
+
ctrl_light: TimeCtrlLight = sys_msg[1]
|
147
|
+
side_led: SideLight = SideLight.from_dict(ctrl_light.to_dict(casing=betterproto.Casing.SNAKE))
|
148
|
+
self._device.mower_state.side_led = side_led
|
149
|
+
case "device_product_type_info":
|
150
|
+
device_product_type: DeviceProductTypeInfoT = sys_msg[1]
|
151
|
+
self._device.mower_state.model_id = device_product_type.main_product_type
|
152
|
+
case "toapp_dev_fw_info":
|
153
|
+
device_fw_info: DeviceFwInfo = sys_msg[1]
|
154
|
+
self._device.device_firmwares.device_version = device_fw_info.version
|
155
|
+
self._device.mower_state.swversion = device_fw_info.version
|
156
|
+
|
157
|
+
def _update_driver_data(self, message) -> None:
|
158
|
+
pass
|
159
|
+
|
160
|
+
def _update_net_data(self, message) -> None:
|
161
|
+
net_msg = betterproto.which_one_of(message.net, "NetSubType")
|
162
|
+
match net_msg[0]:
|
163
|
+
case "toapp_wifi_iot_status":
|
164
|
+
wifi_iot_status: WifiIotStatusReport = net_msg[1]
|
165
|
+
self._device.mower_state.product_key = wifi_iot_status.productkey
|
166
|
+
case "toapp_devinfo_resp":
|
167
|
+
toapp_devinfo_resp: DrvDevInfoResp = net_msg[1]
|
168
|
+
for resp in toapp_devinfo_resp.resp_ids:
|
169
|
+
if resp.res == DrvDevInfoResult.DRV_RESULT_SUC and resp.id == 1 and resp.type == 6:
|
170
|
+
self._device.mower_state.swversion = resp.info
|
171
|
+
self._device.device_firmwares.device_version = resp.info
|
172
|
+
|
173
|
+
def _update_mul_data(self, message) -> None:
|
174
|
+
pass
|
175
|
+
|
176
|
+
def _update_ota_data(self, message) -> None:
|
177
|
+
pass
|
{pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/devices/mammotion_bluetooth.py
RENAMED
@@ -351,6 +351,9 @@ class MammotionBaseBLEDevice(MammotionBaseDevice):
|
|
351
351
|
if self._notify_future and not self._notify_future.done():
|
352
352
|
self._notify_future.set_result(data)
|
353
353
|
|
354
|
+
if self._execute_timed_disconnect is None:
|
355
|
+
await self._execute_forced_disconnect()
|
356
|
+
|
354
357
|
self._reset_disconnect_timer()
|
355
358
|
await self._state_manager.notification(new_msg)
|
356
359
|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "pymammotion"
|
7
|
-
version = "0.4.0-
|
7
|
+
version = "0.4.0-beta2"
|
8
8
|
license = "GPL-3.0"
|
9
9
|
description = ""
|
10
10
|
readme = "README.md"
|
@@ -65,7 +65,7 @@ mypy = "^1.11.2"
|
|
65
65
|
autotyping = "^24.3.0"
|
66
66
|
|
67
67
|
[tool.bumpver]
|
68
|
-
current_version = "0.4.0-
|
68
|
+
current_version = "0.4.0-beta2"
|
69
69
|
version_pattern = "MAJOR.MINOR.PATCH"
|
70
70
|
commit_message = "Bump version {old_version} -> {new_version}"
|
71
71
|
commit = true
|
@@ -1,173 +0,0 @@
|
|
1
|
-
"""Manage state from notifications into MowingDevice."""
|
2
|
-
|
3
|
-
from collections.abc import Awaitable, Callable
|
4
|
-
from datetime import datetime
|
5
|
-
import logging
|
6
|
-
from typing import Any
|
7
|
-
|
8
|
-
import betterproto
|
9
|
-
|
10
|
-
from pymammotion.data.model.device import MowingDevice
|
11
|
-
from pymammotion.data.model.device_info import SideLight
|
12
|
-
from pymammotion.data.model.hash_list import AreaHashNameList
|
13
|
-
from pymammotion.data.mqtt.properties import ThingPropertiesMessage
|
14
|
-
from pymammotion.data.mqtt.status import ThingStatusMessage
|
15
|
-
from pymammotion.proto.dev_net import DrvDevInfoResp, WifiIotStatusReport
|
16
|
-
from pymammotion.proto.luba_msg import LubaMsg
|
17
|
-
from pymammotion.proto.mctrl_nav import AppGetAllAreaHashName, NavGetCommDataAck, NavGetHashListAck, SvgMessageAckT
|
18
|
-
from pymammotion.proto.mctrl_sys import DeviceProductTypeInfoT, TimeCtrlLight
|
19
|
-
|
20
|
-
logger = logging.getLogger(__name__)
|
21
|
-
|
22
|
-
|
23
|
-
class StateManager:
|
24
|
-
"""Manage state."""
|
25
|
-
|
26
|
-
_device: MowingDevice
|
27
|
-
last_updated_at: datetime = datetime.now()
|
28
|
-
|
29
|
-
def __init__(self, device: MowingDevice) -> None:
|
30
|
-
self._device = device
|
31
|
-
self.cloud_gethash_ack_callback: Callable[[NavGetHashListAck], Awaitable[None]] | None = None
|
32
|
-
self.cloud_get_commondata_ack_callback: Callable[[NavGetCommDataAck | SvgMessageAckT], Awaitable[None]] | None = None
|
33
|
-
self.cloud_on_notification_callback: Callable[[tuple[str, Any | None]], Awaitable[None]] | None = None
|
34
|
-
|
35
|
-
# possibly don't need anymore
|
36
|
-
self.cloud_queue_command_callback: Callable[[str, dict[str, Any]], Awaitable[bytes]] | None = None
|
37
|
-
|
38
|
-
self.ble_gethash_ack_callback: Callable[[NavGetHashListAck], Awaitable[None]] | None = None
|
39
|
-
self.ble_get_commondata_ack_callback: Callable[[NavGetCommDataAck | SvgMessageAckT], Awaitable[None]] | None = None
|
40
|
-
self.ble_on_notification_callback: Callable[[tuple[str, Any | None]], Awaitable[None]] | None = None
|
41
|
-
|
42
|
-
# possibly don't need anymore
|
43
|
-
self.ble_queue_command_callback: Callable[[str, dict[str, Any]], Awaitable[bytes]] | None = None
|
44
|
-
self.last_updated_at = datetime.now()
|
45
|
-
|
46
|
-
def get_device(self) -> MowingDevice:
|
47
|
-
"""Get device."""
|
48
|
-
return self._device
|
49
|
-
|
50
|
-
def set_device(self, device: MowingDevice) -> None:
|
51
|
-
"""Set device."""
|
52
|
-
self._device = device
|
53
|
-
|
54
|
-
async def properties(self, properties: ThingPropertiesMessage) -> None:
|
55
|
-
self._device.mqtt_properties = properties
|
56
|
-
|
57
|
-
async def status(self, status: ThingStatusMessage) -> None:
|
58
|
-
if not self._device.online:
|
59
|
-
self._device.online = True
|
60
|
-
self._device.status_properties = status
|
61
|
-
|
62
|
-
@property
|
63
|
-
def online(self) -> bool:
|
64
|
-
return self._device.online
|
65
|
-
|
66
|
-
@online.setter
|
67
|
-
def online(self, value: bool) -> None:
|
68
|
-
self._device.online = value
|
69
|
-
|
70
|
-
async def gethash_ack_callback(self, msg: NavGetHashListAck):
|
71
|
-
if self.cloud_gethash_ack_callback:
|
72
|
-
await self.cloud_gethash_ack_callback(msg)
|
73
|
-
if self.ble_gethash_ack_callback:
|
74
|
-
await self.ble_gethash_ack_callback(msg)
|
75
|
-
|
76
|
-
async def on_notification_callback(self, res: tuple[str, Any | None]):
|
77
|
-
if self.cloud_on_notification_callback:
|
78
|
-
await self.cloud_on_notification_callback(res)
|
79
|
-
if self.ble_on_notification_callback:
|
80
|
-
await self.ble_on_notification_callback(res)
|
81
|
-
|
82
|
-
async def get_commondata_ack_callback(self, comm_data: NavGetCommDataAck | SvgMessageAckT):
|
83
|
-
if self.cloud_get_commondata_ack_callback:
|
84
|
-
await self.cloud_get_commondata_ack_callback(comm_data)
|
85
|
-
if self.ble_get_commondata_ack_callback:
|
86
|
-
await self.ble_get_commondata_ack_callback(comm_data)
|
87
|
-
|
88
|
-
async def notification(self, message: LubaMsg) -> None:
|
89
|
-
"""Handle protobuf notifications."""
|
90
|
-
res = betterproto.which_one_of(message, "LubaSubMsg")
|
91
|
-
self.last_updated_at = datetime.now()
|
92
|
-
|
93
|
-
match res[0]:
|
94
|
-
case "nav":
|
95
|
-
await self._update_nav_data(message)
|
96
|
-
case "sys":
|
97
|
-
await self._update_sys_data(message)
|
98
|
-
case "driver":
|
99
|
-
self._update_driver_data(message)
|
100
|
-
case "net":
|
101
|
-
self._update_net_data(message)
|
102
|
-
case "mul":
|
103
|
-
self._update_mul_data(message)
|
104
|
-
case "ota":
|
105
|
-
self._update_ota_data(message)
|
106
|
-
|
107
|
-
await self.on_notification_callback(res)
|
108
|
-
|
109
|
-
async def _update_nav_data(self, message) -> None:
|
110
|
-
"""Update nav data."""
|
111
|
-
nav_msg = betterproto.which_one_of(message.nav, "SubNavMsg")
|
112
|
-
match nav_msg[0]:
|
113
|
-
case "toapp_gethash_ack":
|
114
|
-
hashlist_ack: NavGetHashListAck = nav_msg[1]
|
115
|
-
self._device.map.update_root_hash_list(hashlist_ack)
|
116
|
-
await self.gethash_ack_callback(nav_msg[1])
|
117
|
-
case "toapp_get_commondata_ack":
|
118
|
-
common_data: NavGetCommDataAck = nav_msg[1]
|
119
|
-
updated = self._device.map.update(common_data)
|
120
|
-
if updated:
|
121
|
-
await self.get_commondata_ack_callback(common_data)
|
122
|
-
case "toapp_svg_msg":
|
123
|
-
common_data: SvgMessageAckT = nav_msg[1]
|
124
|
-
updated = self._device.map.update(common_data)
|
125
|
-
if updated:
|
126
|
-
await self.get_commondata_ack_callback(common_data)
|
127
|
-
|
128
|
-
case "toapp_all_hash_name":
|
129
|
-
hash_names: AppGetAllAreaHashName = nav_msg[1]
|
130
|
-
converted_list = [AreaHashNameList(name=item.name, hash=item.hash) for item in hash_names.hashnames]
|
131
|
-
self._device.map.area_name = converted_list
|
132
|
-
|
133
|
-
async def _update_sys_data(self, message) -> None:
|
134
|
-
"""Update system."""
|
135
|
-
sys_msg = betterproto.which_one_of(message.sys, "SubSysMsg")
|
136
|
-
match sys_msg[0]:
|
137
|
-
case "system_update_buf":
|
138
|
-
self._device.buffer(sys_msg[1])
|
139
|
-
case "toapp_report_data":
|
140
|
-
self._device.update_report_data(sys_msg[1])
|
141
|
-
case "mow_to_app_info":
|
142
|
-
self._device.mow_info(sys_msg[1])
|
143
|
-
case "system_tard_state_tunnel":
|
144
|
-
self._device.run_state_update(sys_msg[1])
|
145
|
-
case "todev_time_ctrl_light":
|
146
|
-
ctrl_light: TimeCtrlLight = sys_msg[1]
|
147
|
-
side_led: SideLight = SideLight.from_dict(ctrl_light.to_dict(casing=betterproto.Casing.SNAKE))
|
148
|
-
self._device.mower_state.side_led = side_led
|
149
|
-
case "device_product_type_info":
|
150
|
-
device_product_type: DeviceProductTypeInfoT = sys_msg[1]
|
151
|
-
self._device.mower_state.model_id = device_product_type.main_product_type
|
152
|
-
|
153
|
-
def _update_driver_data(self, message) -> None:
|
154
|
-
pass
|
155
|
-
|
156
|
-
def _update_net_data(self, message) -> None:
|
157
|
-
net_msg = betterproto.which_one_of(message.net, "NetSubType")
|
158
|
-
match net_msg[0]:
|
159
|
-
case "toapp_wifi_iot_status":
|
160
|
-
wifi_iot_status: WifiIotStatusReport = net_msg[1]
|
161
|
-
self._device.mower_state.product_key = wifi_iot_status.productkey
|
162
|
-
case "toapp_devinfo_resp":
|
163
|
-
toapp_devinfo_resp: DrvDevInfoResp = net_msg[1]
|
164
|
-
for resp in toapp_devinfo_resp.resp_ids:
|
165
|
-
if resp.res == "DRV_RESULT_SUC":
|
166
|
-
self._device.mower_state.swversion = resp.info
|
167
|
-
self._device.device_firmwares.device_version = resp.info
|
168
|
-
|
169
|
-
def _update_mul_data(self, message) -> None:
|
170
|
-
pass
|
171
|
-
|
172
|
-
def _update_ota_data(self, message) -> None:
|
173
|
-
pass
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/aliyun/model/dev_by_account_response.py
RENAMED
File without changes
|
{pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/aliyun/model/login_by_oauth_response.py
RENAMED
File without changes
|
File without changes
|
{pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/aliyun/model/session_by_authcode_response.py
RENAMED
File without changes
|
{pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/aliyun/model/stream_subscription_response.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/data/model/generate_route_information.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/commands/abstract_message.py
RENAMED
File without changes
|
{pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/commands/mammotion_command.py
RENAMED
File without changes
|
{pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/commands/messages/__init__.py
RENAMED
File without changes
|
{pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/commands/messages/driver.py
RENAMED
File without changes
|
{pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/commands/messages/media.py
RENAMED
File without changes
|
{pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/commands/messages/navigation.py
RENAMED
File without changes
|
{pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/commands/messages/network.py
RENAMED
File without changes
|
File without changes
|
{pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/commands/messages/system.py
RENAMED
File without changes
|
{pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/commands/messages/video.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{pymammotion-0.4.0b1 → pymammotion-0.4.0b2}/pymammotion/mammotion/devices/mammotion_cloud.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|