pymammotion 0.4.0a5__py3-none-any.whl → 0.4.0a6__py3-none-any.whl
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/aliyun/cloud_gateway.py +7 -1
- pymammotion/data/model/device.py +4 -4
- pymammotion/data/model/device_info.py +2 -1
- pymammotion/data/state_manager.py +8 -9
- pymammotion/mqtt/linkkit/__init__.py +1 -1
- pymammotion/mqtt/linkkit/h2client.py +171 -135
- pymammotion/mqtt/linkkit/linkkit.py +448 -451
- pymammotion/mqtt/mammotion_mqtt.py +7 -7
- pymammotion/utility/device_config.py +657 -25
- pymammotion/utility/device_type.py +13 -1
- {pymammotion-0.4.0a5.dist-info → pymammotion-0.4.0a6.dist-info}/METADATA +3 -1
- {pymammotion-0.4.0a5.dist-info → pymammotion-0.4.0a6.dist-info}/RECORD +14 -14
- {pymammotion-0.4.0a5.dist-info → pymammotion-0.4.0a6.dist-info}/LICENSE +0 -0
- {pymammotion-0.4.0a5.dist-info → pymammotion-0.4.0a6.dist-info}/WHEEL +0 -0
@@ -57,6 +57,8 @@ class AuthRefreshException(Exception):
|
|
57
57
|
class DeviceOfflineException(Exception):
|
58
58
|
"""Raise exception when device is offline."""
|
59
59
|
|
60
|
+
class GatewayTimeoutException(Exception):
|
61
|
+
"""Raise exception when the gateway times out."""
|
60
62
|
|
61
63
|
class LoginException(Exception):
|
62
64
|
"""Raise exception when library cannot log in."""
|
@@ -657,7 +659,7 @@ class CloudIOTGateway:
|
|
657
659
|
iot_token=self._session_by_authcode_response.data.iotToken,
|
658
660
|
)
|
659
661
|
|
660
|
-
# TODO move to using
|
662
|
+
# TODO move to using InvokeThingServiceRequest()
|
661
663
|
|
662
664
|
message_id = str(uuid.uuid4())
|
663
665
|
|
@@ -689,6 +691,10 @@ class CloudIOTGateway:
|
|
689
691
|
str(response_body_dict.get("code")),
|
690
692
|
str(response_body_dict.get("message")),
|
691
693
|
)
|
694
|
+
if response_body_dict.get("code") == 20056:
|
695
|
+
logger.debug("Gateway timeout.")
|
696
|
+
raise GatewayTimeoutException(response_body_dict.get("code"))
|
697
|
+
|
692
698
|
if response_body_dict.get("code") == 29003:
|
693
699
|
logger.debug(self._session_by_authcode_response.data.identityId)
|
694
700
|
self.sign_out()
|
pymammotion/data/model/device.py
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
"""MowingDevice class to wrap around the betterproto dataclasses."""
|
2
2
|
|
3
3
|
from dataclasses import dataclass, field
|
4
|
-
from typing import Optional
|
5
4
|
|
6
5
|
import betterproto
|
7
6
|
from mashumaro.mixins.orjson import DataClassORJSONMixin
|
8
7
|
|
9
8
|
from pymammotion.data.model import HashList, RapidState
|
10
|
-
from pymammotion.data.model.device_info import
|
9
|
+
from pymammotion.data.model.device_info import DeviceFirmwares, MowerInfo
|
11
10
|
from pymammotion.data.model.location import Location
|
12
11
|
from pymammotion.data.model.report_info import ReportData
|
13
12
|
from pymammotion.data.mqtt.properties import ThingPropertiesMessage
|
14
13
|
from pymammotion.http.model.http import ErrorInfo
|
15
14
|
from pymammotion.proto.mctrl_sys import (
|
15
|
+
DeviceFwInfo,
|
16
16
|
MowToAppInfoT,
|
17
17
|
ReportInfoData,
|
18
18
|
SystemRapidStateTunnelMsg,
|
19
|
-
SystemUpdateBufMsg,
|
19
|
+
SystemUpdateBufMsg,
|
20
20
|
)
|
21
21
|
from pymammotion.utility.constant import WorkMode
|
22
22
|
from pymammotion.utility.conversions import parse_double
|
@@ -35,7 +35,7 @@ class MowingDevice(DataClassORJSONMixin):
|
|
35
35
|
report_data: ReportData = field(default_factory=ReportData)
|
36
36
|
device_firmwares: DeviceFirmwares = field(default_factory=DeviceFirmwares)
|
37
37
|
err_code_list: list = field(default_factory=list)
|
38
|
-
err_code_list_time:
|
38
|
+
err_code_list_time: list | None = field(default_factory=list)
|
39
39
|
error_codes: dict[str, ErrorInfo] = field(default_factory=dict)
|
40
40
|
|
41
41
|
def buffer(self, buffer_list: SystemUpdateBufMsg) -> None:
|
@@ -24,6 +24,7 @@ class MowerInfo(DataClassORJSONMixin):
|
|
24
24
|
product_key: str = ""
|
25
25
|
model_id: str = ""
|
26
26
|
|
27
|
+
|
27
28
|
@dataclass
|
28
29
|
class DeviceFirmwares(DataClassORJSONMixin):
|
29
30
|
device_version: str = ""
|
@@ -34,4 +35,4 @@ class DeviceFirmwares(DataClassORJSONMixin):
|
|
34
35
|
right_motor_driver: str = ""
|
35
36
|
rtk_rover_station: str = ""
|
36
37
|
rtk_version: str = ""
|
37
|
-
version: str = ""
|
38
|
+
version: str = ""
|
@@ -1,8 +1,9 @@
|
|
1
1
|
"""Manage state from notifications into MowingDevice."""
|
2
2
|
|
3
3
|
import logging
|
4
|
+
from collections.abc import Awaitable, Callable
|
4
5
|
from datetime import datetime
|
5
|
-
from typing import Any
|
6
|
+
from typing import Any
|
6
7
|
|
7
8
|
import betterproto
|
8
9
|
|
@@ -10,7 +11,7 @@ from pymammotion.data.model.device import MowingDevice
|
|
10
11
|
from pymammotion.data.model.device_info import SideLight
|
11
12
|
from pymammotion.data.model.hash_list import AreaHashNameList
|
12
13
|
from pymammotion.data.mqtt.properties import ThingPropertiesMessage
|
13
|
-
from pymammotion.proto.dev_net import
|
14
|
+
from pymammotion.proto.dev_net import DrvDevInfoResp, WifiIotStatusReport
|
14
15
|
from pymammotion.proto.luba_msg import LubaMsg
|
15
16
|
from pymammotion.proto.mctrl_nav import AppGetAllAreaHashName, NavGetCommDataAck, NavGetHashListAck, SvgMessageAckT
|
16
17
|
from pymammotion.proto.mctrl_sys import DeviceProductTypeInfoT, TimeCtrlLight
|
@@ -26,12 +27,10 @@ class StateManager:
|
|
26
27
|
|
27
28
|
def __init__(self, device: MowingDevice) -> None:
|
28
29
|
self._device = device
|
29
|
-
self.gethash_ack_callback:
|
30
|
-
self.get_commondata_ack_callback:
|
31
|
-
|
32
|
-
|
33
|
-
self.on_notification_callback: Optional[Callable[[tuple[str, Any | None]], Awaitable[None]]] = None
|
34
|
-
self.queue_command_callback: Optional[Callable[[str, dict[str, Any]], Awaitable[bytes]]] = None
|
30
|
+
self.gethash_ack_callback: Callable[[NavGetHashListAck], Awaitable[None]] | None = None
|
31
|
+
self.get_commondata_ack_callback: Callable[[NavGetCommDataAck | SvgMessageAckT], Awaitable[None]] | None = None
|
32
|
+
self.on_notification_callback: Callable[[tuple[str, Any | None]], Awaitable[None]] | None = None
|
33
|
+
self.queue_command_callback: Callable[[str, dict[str, Any]], Awaitable[bytes]] | None = None
|
35
34
|
self.last_updated_at = datetime.now()
|
36
35
|
|
37
36
|
def get_device(self) -> MowingDevice:
|
@@ -124,7 +123,7 @@ class StateManager:
|
|
124
123
|
case "toapp_devinfo_resp":
|
125
124
|
toapp_devinfo_resp: DrvDevInfoResp = net_msg[1]
|
126
125
|
for resp in toapp_devinfo_resp.resp_ids:
|
127
|
-
if resp.res
|
126
|
+
if resp.res == "DRV_RESULT_SUC":
|
128
127
|
self._device.mower_state.swversion = resp.info
|
129
128
|
self._device.device_firmwares.device_version = resp.info
|
130
129
|
|