pymammotion 0.4.0a9__py3-none-any.whl → 0.4.0b2__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.
@@ -35,4 +35,3 @@ class DeviceFirmwares(DataClassORJSONMixin):
35
35
  right_motor_driver: str = ""
36
36
  rtk_rover_station: str = ""
37
37
  rtk_version: str = ""
38
- version: str = ""
@@ -12,10 +12,10 @@ from pymammotion.data.model.device_info import SideLight
12
12
  from pymammotion.data.model.hash_list import AreaHashNameList
13
13
  from pymammotion.data.mqtt.properties import ThingPropertiesMessage
14
14
  from pymammotion.data.mqtt.status import ThingStatusMessage
15
- from pymammotion.proto.dev_net import DrvDevInfoResp, WifiIotStatusReport
15
+ from pymammotion.proto.dev_net import DrvDevInfoResp, DrvDevInfoResult, WifiIotStatusReport
16
16
  from pymammotion.proto.luba_msg import LubaMsg
17
17
  from pymammotion.proto.mctrl_nav import AppGetAllAreaHashName, NavGetCommDataAck, NavGetHashListAck, SvgMessageAckT
18
- from pymammotion.proto.mctrl_sys import DeviceProductTypeInfoT, TimeCtrlLight
18
+ from pymammotion.proto.mctrl_sys import DeviceFwInfo, DeviceProductTypeInfoT, TimeCtrlLight
19
19
 
20
20
  logger = logging.getLogger(__name__)
21
21
 
@@ -25,13 +25,22 @@ class StateManager:
25
25
 
26
26
  _device: MowingDevice
27
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
28
41
 
29
42
  def __init__(self, device: MowingDevice) -> None:
30
43
  self._device = device
31
- self.gethash_ack_callback: Callable[[NavGetHashListAck], Awaitable[None]] | None = None
32
- self.get_commondata_ack_callback: Callable[[NavGetCommDataAck | SvgMessageAckT], Awaitable[None]] | None = None
33
- self.on_notification_callback: Callable[[tuple[str, Any | None]], Awaitable[None]] | None = None
34
- self.queue_command_callback: Callable[[str, dict[str, Any]], Awaitable[bytes]] | None = None
35
44
  self.last_updated_at = datetime.now()
36
45
 
37
46
  def get_device(self) -> MowingDevice:
@@ -42,13 +51,13 @@ class StateManager:
42
51
  """Set device."""
43
52
  self._device = device
44
53
 
45
- async def properties(self, properties: ThingPropertiesMessage) -> None:
46
- self._device.mqtt_properties = properties
54
+ def properties(self, thing_properties: ThingPropertiesMessage) -> None:
55
+ self._device.mqtt_properties = thing_properties
47
56
 
48
- async def status(self, status: ThingStatusMessage) -> None:
57
+ def status(self, thing_status: ThingStatusMessage) -> None:
49
58
  if not self._device.online:
50
59
  self._device.online = True
51
- self._device.status_properties = status
60
+ self._device.status_properties = thing_status
52
61
 
53
62
  @property
54
63
  def online(self) -> bool:
@@ -58,6 +67,24 @@ class StateManager:
58
67
  def online(self, value: bool) -> None:
59
68
  self._device.online = value
60
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
+
61
88
  async def notification(self, message: LubaMsg) -> None:
62
89
  """Handle protobuf notifications."""
63
90
  res = betterproto.which_one_of(message, "LubaSubMsg")
@@ -77,8 +104,7 @@ class StateManager:
77
104
  case "ota":
78
105
  self._update_ota_data(message)
79
106
 
80
- if self.on_notification_callback:
81
- await self.on_notification_callback(res)
107
+ await self.on_notification_callback(res)
82
108
 
83
109
  async def _update_nav_data(self, message) -> None:
84
110
  """Update nav data."""
@@ -123,6 +149,10 @@ class StateManager:
123
149
  case "device_product_type_info":
124
150
  device_product_type: DeviceProductTypeInfoT = sys_msg[1]
125
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
126
156
 
127
157
  def _update_driver_data(self, message) -> None:
128
158
  pass
@@ -136,7 +166,7 @@ class StateManager:
136
166
  case "toapp_devinfo_resp":
137
167
  toapp_devinfo_resp: DrvDevInfoResp = net_msg[1]
138
168
  for resp in toapp_devinfo_resp.resp_ids:
139
- if resp.res == "DRV_RESULT_SUC":
169
+ if resp.res == DrvDevInfoResult.DRV_RESULT_SUC and resp.id == 1 and resp.type == 6:
140
170
  self._device.mower_state.swversion = resp.info
141
171
  self._device.device_firmwares.device_version = resp.info
142
172
 
@@ -5,6 +5,7 @@ import time
5
5
  from pymammotion.mammotion.commands.abstract_message import AbstractMessage
6
6
  from pymammotion.proto import luba_msg_pb2, luba_mul_pb2
7
7
  from pymammotion.proto.luba_msg import MsgAttr, MsgCmdType, MsgDevice
8
+ from pymammotion.proto.luba_mul import MUL_CAMERA_POSITION
8
9
  from pymammotion.utility.device_type import DeviceType
9
10
 
10
11
 
@@ -25,10 +26,6 @@ class MessageVideo(AbstractMessage, ABC):
25
26
  return luba_msg.SerializeToString()
26
27
 
27
28
  def device_agora_join_channel_with_position(self, enter_state: int):
28
- position = (
29
- luba_mul_pb2.MUL_CAMERA_POSITION.ALL
30
- if DeviceType.is_yuka(self.get_device_name())
31
- else luba_mul_pb2.MUL_CAMERA_POSITION.LEFT
32
- )
29
+ position = MUL_CAMERA_POSITION.ALL if DeviceType.is_yuka(self.get_device_name()) else MUL_CAMERA_POSITION.LEFT
33
30
  mctl_sys = luba_mul_pb2.SocMul(set_video=luba_mul_pb2.MulSetVideo(position=position, vi_switch=enter_state))
34
31
  return self.send_order_msg_video(mctl_sys)
@@ -1,6 +1,5 @@
1
1
  from abc import abstractmethod
2
2
  import asyncio
3
- from collections.abc import Awaitable, Callable
4
3
  import logging
5
4
  from typing import Any
6
5
 
@@ -41,17 +40,9 @@ class MammotionBaseDevice:
41
40
  self._state_manager = state_manager
42
41
  self._raw_data = dict()
43
42
  self._raw_mower_data: RawMowerData = RawMowerData()
44
- self._state_manager.gethash_ack_callback = self.datahash_response
45
- self._state_manager.get_commondata_ack_callback = self.commdata_response
46
43
  self._notify_future: asyncio.Future[bytes] | None = None
47
44
  self._cloud_device = cloud_device
48
45
 
49
- def set_notification_callback(self, func: Callable[[tuple[str, Any | None]], Awaitable[None]]) -> None:
50
- self._state_manager.on_notification_callback = func
51
-
52
- def set_queue_callback(self, func: Callable[[str, dict[str, Any]], Awaitable[bytes]]) -> None:
53
- self._state_manager.queue_command_callback = func
54
-
55
46
  async def datahash_response(self, hash_ack: NavGetHashListAck) -> None:
56
47
  """Handle datahash responses."""
57
48
  current_frame = hash_ack.current_frame
@@ -1,4 +1,5 @@
1
1
  import asyncio
2
+ from collections.abc import Awaitable, Callable
2
3
  import logging
3
4
  from typing import Any, cast
4
5
  from uuid import UUID
@@ -89,9 +90,17 @@ class MammotionBaseBLEDevice(MammotionBaseDevice):
89
90
  self._operation_lock = asyncio.Lock()
90
91
  self._key: str | None = None
91
92
  self.set_queue_callback(self.queue_command)
93
+ self._state_manager.ble_gethash_ack_callback = self.datahash_response
94
+ self._state_manager.ble_get_commondata_ack_callback = self.commdata_response
92
95
  loop = asyncio.get_event_loop()
93
96
  loop.create_task(self.process_queue())
94
97
 
98
+ def set_notification_callback(self, func: Callable[[tuple[str, Any | None]], Awaitable[None]]) -> None:
99
+ self._state_manager.ble_on_notification_callback = func
100
+
101
+ def set_queue_callback(self, func: Callable[[str, dict[str, Any]], Awaitable[bytes]]) -> None:
102
+ self._state_manager.ble_queue_command_callback = func
103
+
95
104
  def update_device(self, device: BLEDevice) -> None:
96
105
  """Update the BLE device."""
97
106
  self.ble_device = device
@@ -342,6 +351,9 @@ class MammotionBaseBLEDevice(MammotionBaseDevice):
342
351
  if self._notify_future and not self._notify_future.done():
343
352
  self._notify_future.set_result(data)
344
353
 
354
+ if self._execute_timed_disconnect is None:
355
+ await self._execute_forced_disconnect()
356
+
345
357
  self._reset_disconnect_timer()
346
358
  await self._state_manager.notification(new_msg)
347
359
 
@@ -172,6 +172,8 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
172
172
  self._mqtt.on_ready_event.add_subscribers(self.on_ready)
173
173
  self._mqtt.on_disconnected_event.add_subscribers(self.on_disconnect)
174
174
  self._mqtt.on_connected_event.add_subscribers(self.on_connect)
175
+ self._state_manager.cloud_gethash_ack_callback = self.datahash_response
176
+ self._state_manager.cloud_get_commondata_ack_callback = self.commdata_response
175
177
  self.set_queue_callback(self.queue_command)
176
178
 
177
179
  if self._mqtt.is_ready:
@@ -185,6 +187,12 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
185
187
  if self._ble_sync_task:
186
188
  self._ble_sync_task.cancel()
187
189
 
190
+ def set_notification_callback(self, func: Callable[[tuple[str, Any | None]], Awaitable[None]]) -> None:
191
+ self._state_manager.cloud_on_notification_callback = func
192
+
193
+ def set_queue_callback(self, func: Callable[[str, dict[str, Any]], Awaitable[bytes]]) -> None:
194
+ self._state_manager.cloud_queue_command_callback = func
195
+
188
196
  async def on_ready(self) -> None:
189
197
  """Callback for when MQTT is subscribed to events."""
190
198
  if self.stopped:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pymammotion
3
- Version: 0.4.0a9
3
+ Version: 0.4.0b2
4
4
  Summary:
5
5
  License: GPL-3.0
6
6
  Author: Michael Arthur
@@ -25,7 +25,7 @@ pymammotion/data/model/__init__.py,sha256=aSyroxYQQS-WMRi6WmWm2js4wLa9nmsi160gx9
25
25
  pymammotion/data/model/account.py,sha256=vJM-KTf2q6eBfVC-UlNHBSmJvqHiCawZ40vnuhXhaz8,140
26
26
  pymammotion/data/model/device.py,sha256=lZEuWfEr4My0BUjY3OdIpUui91t9KbONhBc2t9oS2ro,6883
27
27
  pymammotion/data/model/device_config.py,sha256=wjayKnzoPDmBhqWZKTPDSueNEPCIWCB20tFEDSGIUsM,2602
28
- pymammotion/data/model/device_info.py,sha256=8FxHok09_uy99qBmgPiZw-MYbyqxXolF9eEw-8cQxSw,899
28
+ pymammotion/data/model/device_info.py,sha256=p7fXL4ozWUF8rD4QSfrmyLK1Jv-uXXxcJ5mXiDjp6Fo,877
29
29
  pymammotion/data/model/device_limits.py,sha256=saW3iUvGq8WEn6CASn5hS5tVJpSeak4FDy_gnHtYqTQ,1955
30
30
  pymammotion/data/model/enums.py,sha256=EpKmO8yVUZyEnTY4yH0DMMVKYNQM42zpW1maUu0i3IE,1582
31
31
  pymammotion/data/model/excute_boarder_params.py,sha256=9CpUqrygcle1C_1hDW-riLmm4map4ZbE842NXjcomEI,1394
@@ -43,7 +43,7 @@ pymammotion/data/mqtt/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdr
43
43
  pymammotion/data/mqtt/event.py,sha256=r14gzZVxmlGVAwFdZQ1CUsMZFHHwRKnbt2VHnjugP28,5123
44
44
  pymammotion/data/mqtt/properties.py,sha256=pX5JRVmmpVO04CSPm5xAGcSWA_OeLd0JnBagLsfiSEc,3755
45
45
  pymammotion/data/mqtt/status.py,sha256=DuNC3JdewLPKNqNHx76_FPXRvheYSiM-CdiVTCCYY8s,1079
46
- pymammotion/data/state_manager.py,sha256=GrzKjBuz2CB70FGqnBdExgd3IHUheBTWH-FSR1N14nI,6140
46
+ pymammotion/data/state_manager.py,sha256=J7QbfCge1mGlz2jzcRfqix560tybG1E1x2inVgVqt-I,7810
47
47
  pymammotion/event/__init__.py,sha256=mgATR6vPHACNQ-0zH5fi7NdzeTCDV1CZyaWPmtUusi8,115
48
48
  pymammotion/event/event.py,sha256=bj2RirSIRyBs0QvkcrOtwZWUX_8F3m1sySuHVyKmZLs,2143
49
49
  pymammotion/http/_init_.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -61,14 +61,14 @@ pymammotion/mammotion/commands/messages/navigation.py,sha256=BE5h8xN2XCkcfynb5cQ
61
61
  pymammotion/mammotion/commands/messages/network.py,sha256=vUjBvuiBhRkOA4nftqTFw6rFdXNjho-ZA9Y37hL2q5Q,7623
62
62
  pymammotion/mammotion/commands/messages/ota.py,sha256=g937HT_-OQXV6A3zUiZ53b45cOX6y-rzs5m-4b0IcTk,1473
63
63
  pymammotion/mammotion/commands/messages/system.py,sha256=CYf_Ju5nMK9cFd0r5jOzEJ_w4k70PzassdhE8xLeSJU,14371
64
- pymammotion/mammotion/commands/messages/video.py,sha256=OtuSCy_5TQQx460etLvIu30FrjlnCug5tseicgAsNS8,1319
64
+ pymammotion/mammotion/commands/messages/video.py,sha256=JBPyK1C9gZ6B3QcNe3IUTUnn0QWNXR4Pwj9W0qNO9Ps,1304
65
65
  pymammotion/mammotion/control/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
66
66
  pymammotion/mammotion/control/joystick.py,sha256=QfBVxM_gxpWsZAGO90whtgxCI2tIZ3TTad9wHIPsU9s,5640
67
67
  pymammotion/mammotion/devices/__init__.py,sha256=f2qQFPgLGmV85W2hSlMUh5BYuht9o_Ar_JEAAMD4fsE,102
68
- pymammotion/mammotion/devices/base.py,sha256=ZWQVOZu4R_ERXubE3kNx7-zAUxeuaAVX1VsdivlWhUg,10790
68
+ pymammotion/mammotion/devices/base.py,sha256=evNKt1PDDGPkm4wleIEC2dtHuyDP_nHRCg35nrQg6qg,10260
69
69
  pymammotion/mammotion/devices/mammotion.py,sha256=-x9hf_M-_3fp5srHGBuMmO5DBsSDnwVGMyEiAEz5dW8,12685
70
- pymammotion/mammotion/devices/mammotion_bluetooth.py,sha256=HUOKnjYUWTGjksyQDCPKF_u3dWo2ddgrWCBXnJ2VkwA,18963
71
- pymammotion/mammotion/devices/mammotion_cloud.py,sha256=8DrVNs9QbUuH7VMs-Wi1HgHkyMLzLNIV_emnqjVSjXE,13329
70
+ pymammotion/mammotion/devices/mammotion_bluetooth.py,sha256=G7gprsdvKiBHr4S2myRuLL-PWldtsnlLIsiW8yWvpP0,19613
71
+ pymammotion/mammotion/devices/mammotion_cloud.py,sha256=nd1Uj6rF8UKHJbHC6nlPRrNQPggPXxfpydT0o0cWbMM,13835
72
72
  pymammotion/mqtt/__init__.py,sha256=Ocs5e-HLJvTuDpVXyECEsWIvwsUaxzj7lZ9mSYutNDY,105
73
73
  pymammotion/mqtt/linkkit/__init__.py,sha256=ENgc3ynd2kd9gMQR3-kgmCu6Ed9Y6XCIzU0zFReUlkk,80
74
74
  pymammotion/mqtt/linkkit/h2client.py,sha256=w9Nvi_nY4CLD_fw-pHtYChwQf7e2TiAGeqkY_sF4cf0,19659
@@ -127,7 +127,7 @@ pymammotion/utility/map.py,sha256=GYscVMg2cX3IPlNpCBNHDW0S55yS1WGRf1iHnNZ7TfQ,22
127
127
  pymammotion/utility/movement.py,sha256=N75oAoAgFydqoaOedYIxGUHmuTCtPzAOtb-d_29tpfI,615
128
128
  pymammotion/utility/periodic.py,sha256=MbeSb9cfhxzYmdT_RiE0dZe3H9IfbQW_zSqhmSX2RUc,3321
129
129
  pymammotion/utility/rocker_util.py,sha256=6tX7sS87qoQC_tsxbx3NLL-HgS08wtzXiZkhDiz7uo0,7179
130
- pymammotion-0.4.0a9.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
131
- pymammotion-0.4.0a9.dist-info/METADATA,sha256=-U5a_GhF8fugM_IcnsvR7zsHyH5oX55wduoZIvKum-s,3886
132
- pymammotion-0.4.0a9.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
133
- pymammotion-0.4.0a9.dist-info/RECORD,,
130
+ pymammotion-0.4.0b2.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
131
+ pymammotion-0.4.0b2.dist-info/METADATA,sha256=_g95yCpcFO-w6GISykIZO69Jo-COe2h7-GD6dVTOkCk,3886
132
+ pymammotion-0.4.0b2.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
133
+ pymammotion-0.4.0b2.dist-info/RECORD,,