pymammotion 0.4.0a2__py3-none-any.whl → 0.5.51__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.

Potentially problematic release.


This version of pymammotion might be problematic. Click here for more details.

Files changed (133) hide show
  1. pymammotion/__init__.py +5 -4
  2. pymammotion/aliyun/client.py +235 -0
  3. pymammotion/aliyun/cloud_gateway.py +312 -64
  4. pymammotion/aliyun/model/aep_response.py +1 -2
  5. pymammotion/aliyun/model/dev_by_account_response.py +170 -23
  6. pymammotion/aliyun/model/login_by_oauth_response.py +2 -3
  7. pymammotion/aliyun/model/regions_response.py +3 -3
  8. pymammotion/aliyun/model/session_by_authcode_response.py +2 -2
  9. pymammotion/aliyun/model/thing_response.py +12 -0
  10. pymammotion/aliyun/regions.py +62 -0
  11. pymammotion/aliyun/tea/core.py +297 -0
  12. pymammotion/bluetooth/ble.py +7 -9
  13. pymammotion/bluetooth/ble_message.py +10 -14
  14. pymammotion/const.py +3 -0
  15. pymammotion/data/model/__init__.py +1 -2
  16. pymammotion/data/model/device.py +95 -27
  17. pymammotion/data/model/device_config.py +4 -4
  18. pymammotion/data/model/device_info.py +35 -0
  19. pymammotion/data/model/device_limits.py +10 -10
  20. pymammotion/data/model/enums.py +12 -2
  21. pymammotion/data/model/errors.py +12 -0
  22. pymammotion/data/model/events.py +14 -0
  23. pymammotion/data/model/generate_geojson.py +521 -0
  24. pymammotion/data/model/generate_route_information.py +2 -2
  25. pymammotion/data/model/hash_list.py +370 -57
  26. pymammotion/data/model/location.py +4 -4
  27. pymammotion/data/model/mowing_modes.py +17 -1
  28. pymammotion/data/model/raw_data.py +2 -10
  29. pymammotion/data/model/region_data.py +10 -11
  30. pymammotion/data/model/report_info.py +31 -5
  31. pymammotion/data/model/work.py +27 -0
  32. pymammotion/data/mower_state_manager.py +316 -0
  33. pymammotion/data/mqtt/event.py +73 -28
  34. pymammotion/data/mqtt/mammotion_properties.py +257 -0
  35. pymammotion/data/mqtt/properties.py +93 -78
  36. pymammotion/data/mqtt/status.py +18 -17
  37. pymammotion/event/event.py +27 -6
  38. pymammotion/homeassistant/__init__.py +3 -0
  39. pymammotion/homeassistant/mower_api.py +484 -0
  40. pymammotion/homeassistant/rtk_api.py +54 -0
  41. pymammotion/http/encryption.py +5 -6
  42. pymammotion/http/http.py +574 -28
  43. pymammotion/http/model/__init__.py +0 -0
  44. pymammotion/{aliyun/model/stream_subscription_response.py → http/model/camera_stream.py} +14 -2
  45. pymammotion/http/model/http.py +129 -4
  46. pymammotion/http/model/response_factory.py +61 -0
  47. pymammotion/http/model/rtk.py +16 -0
  48. pymammotion/mammotion/commands/abstract_message.py +7 -5
  49. pymammotion/mammotion/commands/mammotion_command.py +30 -1
  50. pymammotion/mammotion/commands/messages/basestation.py +43 -0
  51. pymammotion/mammotion/commands/messages/driver.py +61 -29
  52. pymammotion/mammotion/commands/messages/media.py +68 -15
  53. pymammotion/mammotion/commands/messages/navigation.py +61 -25
  54. pymammotion/mammotion/commands/messages/network.py +17 -23
  55. pymammotion/mammotion/commands/messages/ota.py +18 -18
  56. pymammotion/mammotion/commands/messages/system.py +32 -49
  57. pymammotion/mammotion/commands/messages/video.py +15 -16
  58. pymammotion/mammotion/devices/__init__.py +27 -3
  59. pymammotion/mammotion/devices/base.py +40 -131
  60. pymammotion/mammotion/devices/mammotion.py +436 -201
  61. pymammotion/mammotion/devices/mammotion_bluetooth.py +57 -47
  62. pymammotion/mammotion/devices/mammotion_cloud.py +134 -105
  63. pymammotion/mammotion/devices/mammotion_mower_ble.py +49 -0
  64. pymammotion/mammotion/devices/mammotion_mower_cloud.py +39 -0
  65. pymammotion/mammotion/devices/managers/managers.py +81 -0
  66. pymammotion/mammotion/devices/mower_device.py +124 -0
  67. pymammotion/mammotion/devices/mower_manager.py +107 -0
  68. pymammotion/mammotion/devices/rtk_ble.py +89 -0
  69. pymammotion/mammotion/devices/rtk_cloud.py +113 -0
  70. pymammotion/mammotion/devices/rtk_device.py +50 -0
  71. pymammotion/mammotion/devices/rtk_manager.py +122 -0
  72. pymammotion/mqtt/__init__.py +2 -1
  73. pymammotion/mqtt/aliyun_mqtt.py +232 -0
  74. pymammotion/mqtt/linkkit/__init__.py +5 -0
  75. pymammotion/mqtt/linkkit/h2client.py +585 -0
  76. pymammotion/mqtt/linkkit/linkkit.py +3023 -0
  77. pymammotion/mqtt/mammotion_mqtt.py +176 -169
  78. pymammotion/mqtt/mqtt_models.py +66 -0
  79. pymammotion/proto/__init__.py +4839 -4
  80. pymammotion/proto/basestation.proto +8 -0
  81. pymammotion/proto/basestation_pb2.py +11 -9
  82. pymammotion/proto/basestation_pb2.pyi +16 -2
  83. pymammotion/proto/dev_net.proto +79 -55
  84. pymammotion/proto/dev_net_pb2.py +60 -56
  85. pymammotion/proto/dev_net_pb2.pyi +49 -6
  86. pymammotion/proto/luba_msg.proto +2 -1
  87. pymammotion/proto/luba_msg_pb2.py +6 -6
  88. pymammotion/proto/luba_msg_pb2.pyi +1 -0
  89. pymammotion/proto/luba_mul.proto +62 -1
  90. pymammotion/proto/luba_mul_pb2.py +38 -22
  91. pymammotion/proto/luba_mul_pb2.pyi +94 -7
  92. pymammotion/proto/mctrl_driver.proto +44 -4
  93. pymammotion/proto/mctrl_driver_pb2.py +26 -14
  94. pymammotion/proto/mctrl_driver_pb2.pyi +66 -11
  95. pymammotion/proto/mctrl_nav.proto +93 -52
  96. pymammotion/proto/mctrl_nav_pb2.py +75 -67
  97. pymammotion/proto/mctrl_nav_pb2.pyi +142 -56
  98. pymammotion/proto/mctrl_ota.proto +40 -2
  99. pymammotion/proto/mctrl_ota_pb2.py +23 -13
  100. pymammotion/proto/mctrl_ota_pb2.pyi +67 -4
  101. pymammotion/proto/mctrl_pept.proto +8 -3
  102. pymammotion/proto/mctrl_pept_pb2.py +8 -6
  103. pymammotion/proto/mctrl_pept_pb2.pyi +14 -6
  104. pymammotion/proto/mctrl_sys.proto +325 -86
  105. pymammotion/proto/mctrl_sys_pb2.py +162 -98
  106. pymammotion/proto/mctrl_sys_pb2.pyi +451 -25
  107. pymammotion/proto/message_pool.py +3 -0
  108. pymammotion/proto/py.typed +0 -0
  109. pymammotion/utility/constant/device_constant.py +29 -5
  110. pymammotion/utility/datatype_converter.py +13 -12
  111. pymammotion/utility/device_config.py +522 -130
  112. pymammotion/utility/device_type.py +218 -21
  113. pymammotion/utility/map.py +238 -51
  114. pymammotion/utility/mur_mur_hash.py +159 -0
  115. {pymammotion-0.4.0a2.dist-info → pymammotion-0.5.51.dist-info}/METADATA +26 -31
  116. pymammotion-0.5.51.dist-info/RECORD +152 -0
  117. {pymammotion-0.4.0a2.dist-info → pymammotion-0.5.51.dist-info}/WHEEL +1 -1
  118. pymammotion/aliyun/cloud_service.py +0 -65
  119. pymammotion/data/model/plan.py +0 -58
  120. pymammotion/data/state_manager.py +0 -129
  121. pymammotion/proto/basestation.py +0 -59
  122. pymammotion/proto/common.py +0 -12
  123. pymammotion/proto/dev_net.py +0 -381
  124. pymammotion/proto/luba_msg.py +0 -81
  125. pymammotion/proto/luba_mul.py +0 -76
  126. pymammotion/proto/mctrl_driver.py +0 -100
  127. pymammotion/proto/mctrl_nav.py +0 -664
  128. pymammotion/proto/mctrl_ota.py +0 -48
  129. pymammotion/proto/mctrl_pept.py +0 -41
  130. pymammotion/proto/mctrl_sys.py +0 -574
  131. pymammotion-0.4.0a2.dist-info/RECORD +0 -131
  132. /pymammotion/http/{_init_.py → __init__.py} +0 -0
  133. {pymammotion-0.4.0a2.dist-info → pymammotion-0.5.51.dist-info/licenses}/LICENSE +0 -0
@@ -1,16 +1,19 @@
1
1
  # === sendOrderMsg_Nav ===
2
+ from abc import ABC
2
3
  import logging
3
4
  import time
4
- from abc import ABC
5
5
 
6
6
  from pymammotion.data.model import GenerateRouteInformation
7
- from pymammotion.data.model.plan import Plan
7
+ from pymammotion.data.model.hash_list import Plan
8
8
  from pymammotion.data.model.region_data import RegionData
9
9
  from pymammotion.mammotion.commands.abstract_message import AbstractMessage
10
- from pymammotion.proto.luba_msg import LubaMsg, MsgAttr, MsgCmdType, MsgDevice
11
- from pymammotion.proto.mctrl_nav import (
10
+ from pymammotion.proto import (
12
11
  AppRequestCoverPathsT,
12
+ LubaMsg,
13
13
  MctlNav,
14
+ MsgAttr,
15
+ MsgCmdType,
16
+ MsgDevice,
14
17
  NavGetCommData,
15
18
  NavGetHashList,
16
19
  NavMapNameMsg,
@@ -30,24 +33,24 @@ logger = logging.getLogger(__name__)
30
33
 
31
34
 
32
35
  class MessageNavigation(AbstractMessage, ABC):
33
- def send_order_msg_nav(self, build) -> bytes:
36
+ def send_order_msg_nav(self, build: MctlNav) -> bytes:
34
37
  luba_msg = LubaMsg(
35
- msgtype=MsgCmdType.MSG_CMD_TYPE_NAV,
38
+ msgtype=MsgCmdType.NAV,
36
39
  sender=MsgDevice.DEV_MOBILEAPP,
37
- rcver=self.get_msg_device(MsgCmdType.MSG_CMD_TYPE_NAV, MsgDevice.DEV_MAINCTL),
38
- msgattr=MsgAttr.MSG_ATTR_REQ,
39
- seqs=1,
40
+ rcver=self.get_msg_device(MsgCmdType.NAV, MsgDevice.DEV_MAINCTL),
41
+ msgattr=MsgAttr.REQ,
42
+ seqs=self.seqs.increment_and_get() & 255,
40
43
  version=1,
41
- subtype=1,
44
+ subtype=self.user_account,
42
45
  nav=build,
43
46
  timestamp=round(time.time() * 1000),
44
47
  )
45
48
 
46
49
  return luba_msg.SerializeToString()
47
50
 
48
- def allpowerfull_rw_adapter_x3(self, id: int, context: int, rw: int) -> bytes:
49
- build = MctlNav(nav_sys_param_cmd=NavSysParamMsg(id=id, context=context, rw=rw))
50
- logger.debug(f"Send command--9 general read and write command id={id}, context={context}, rw={rw}")
51
+ def allpowerfull_rw_adapter_x3(self, rw_id: int, context: int, rw: int) -> bytes:
52
+ build = MctlNav(nav_sys_param_cmd=NavSysParamMsg(id=rw_id, context=context, rw=rw))
53
+ logger.debug(f"Send command--x3 general read and write command id={rw_id}, context={context}, rw={rw}")
51
54
  return self.send_order_msg_nav(build)
52
55
 
53
56
  def along_border(self) -> bytes:
@@ -203,9 +206,9 @@ class MessageNavigation(AbstractMessage, ABC):
203
206
  reserved=plan_bean.reserved,
204
207
  weeks=plan_bean.weeks,
205
208
  start_date=plan_bean.start_date,
206
- trigger_type=plan_bean.job_type,
207
- day=plan_bean.interval_days,
208
- toward_included_angle=plan_bean.demond_angle,
209
+ trigger_type=plan_bean.trigger_type,
210
+ day=plan_bean.day,
211
+ toward_included_angle=plan_bean.toward_included_angle,
209
212
  toward_mode=0,
210
213
  )
211
214
  logger.debug(f"Send read job plan command planBean={plan_bean}")
@@ -242,6 +245,35 @@ class MessageNavigation(AbstractMessage, ABC):
242
245
  logger.debug(f"Send command--Read plan time {sub_cmd}")
243
246
  return self.send_order_msg_nav(build2)
244
247
 
248
+ def read_job_not_not_disturb(self) -> bytes:
249
+ build = NavUnableTimeSet(sub_cmd=2)
250
+ build2 = MctlNav(todev_unable_time_set=build)
251
+ logger.debug(f"Send command--Read job dnd {2}")
252
+ return self.send_order_msg_nav(build2)
253
+
254
+ def job_animal_protect_read(self) -> bytes:
255
+ """Read animal protection settings."""
256
+ build = NavUnableTimeSet(sub_cmd=2, trigger=99)
257
+ build2 = MctlNav(todev_unable_time_set=build)
258
+ logger.debug(f"Send command - Read job do not disturb time subCmd2 {build}")
259
+ return self.send_order_msg_nav(build2)
260
+
261
+ def job_do_not_disturb(self, unable_start_time: str, unable_end_time: str) -> bytes:
262
+ """Set do not disturb time period."""
263
+ build = MctlNav(
264
+ todev_unable_time_set=NavUnableTimeSet(
265
+ sub_cmd=1, trigger=1, unable_start_time=unable_start_time, unable_end_time=unable_end_time
266
+ )
267
+ )
268
+ logger.debug(f"Send command - Set job do not disturb time: {unable_start_time} - {unable_end_time}")
269
+ return self.send_order_msg_nav(build)
270
+
271
+ def job_do_not_disturb_del(self) -> bytes:
272
+ """Delete do not disturb settings."""
273
+ build = MctlNav(todev_unable_time_set=NavUnableTimeSet(sub_cmd=1, trigger=0))
274
+ logger.debug("Send command - Turn off do not disturb time")
275
+ return self.send_order_msg_nav(build)
276
+
245
277
  def query_job_history(self) -> bytes:
246
278
  return self.send_order_msg_nav(MctlNav(todev_work_report_update_cmd=WorkReportUpdateCmd(sub_cmd=1)))
247
279
 
@@ -259,7 +291,7 @@ class MessageNavigation(AbstractMessage, ABC):
259
291
  toapp_map_name_msg=NavMapNameMsg(
260
292
  hash=0,
261
293
  result=0,
262
- device_id=device_id, # iotId or ???
294
+ device_id=device_id, # iot_id
263
295
  rw=0,
264
296
  )
265
297
  )
@@ -268,7 +300,7 @@ class MessageNavigation(AbstractMessage, ABC):
268
300
  logger.debug("Send command--Get area name list")
269
301
  return self.send_order_msg_nav(mctl_nav)
270
302
 
271
- def set_area_name(self, device_id, hash_id: int, name: str) -> bytes:
303
+ def set_area_name(self, device_id: str, hash_id: int, name: str) -> bytes:
272
304
  # Build the NavMapNameMsg with the specified parameters
273
305
  mctl_nav = MctlNav(
274
306
  toapp_map_name_msg=NavMapNameMsg(hash=hash_id, name=name, result=0, device_id=device_id, rw=1)
@@ -280,7 +312,7 @@ class MessageNavigation(AbstractMessage, ABC):
280
312
 
281
313
  def get_all_boundary_hash_list(self, sub_cmd: int) -> bytes:
282
314
  build = MctlNav(todev_gethash=NavGetHashList(pver=1, sub_cmd=sub_cmd))
283
- logger.debug(f"Area loading=====================:Get area hash list++Bluetooth:{sub_cmd}")
315
+ logger.debug(f"Area loading=====================:Get area hash list:{sub_cmd}")
284
316
  return self.send_order_msg_nav(build)
285
317
 
286
318
  def get_hash_response(self, total_frame: int, current_frame: int) -> bytes:
@@ -294,7 +326,7 @@ class MessageNavigation(AbstractMessage, ABC):
294
326
 
295
327
  def synchronize_hash_data(self, hash_num: int) -> bytes:
296
328
  build = MctlNav(todev_get_commondata=NavGetCommData(pver=1, action=8, hash=hash_num, sub_cmd=1))
297
- logger.debug(f"Send command--209,hash synchronize area data hash:{hash}")
329
+ logger.debug(f"Send command--209,hash synchronize area data hash:{hash_num}")
298
330
  return self.send_order_msg_nav(build)
299
331
 
300
332
  def get_area_to_be_transferred(self) -> bytes:
@@ -327,9 +359,9 @@ class MessageNavigation(AbstractMessage, ABC):
327
359
  logger.debug(f"Send command--Send tool command id={param_id},values={values}")
328
360
  return self.send_order_msg_nav(build)
329
361
 
330
- def end_draw_border(self, type: int) -> bytes:
362
+ def end_draw_border(self, type: int) -> bytes | None:
331
363
  if type == -1:
332
- return
364
+ return None
333
365
  build = MctlNav(todev_get_commondata=NavGetCommData(pver=1, action=1, type=type))
334
366
  logger.debug(f"Send command--End drawing boundary, obstacle, channel command type={type}")
335
367
  return self.send_order_msg_nav(build)
@@ -339,9 +371,9 @@ class MessageNavigation(AbstractMessage, ABC):
339
371
  logger.debug("Send command--Cancel current recording (boundary, obstacle)")
340
372
  return self.send_order_msg_nav(build)
341
373
 
342
- def delete_map_elements(self, type: int, hash_num: int) -> bytes:
374
+ def delete_map_elements(self, type: int, hash_num: int) -> bytes | None:
343
375
  if type == -1:
344
- return
376
+ return None
345
377
  build = MctlNav(todev_get_commondata=NavGetCommData(pver=1, action=6, type=type, hash=hash_num))
346
378
  logger.debug(f"Send command--Delete boundary or obstacle or channel command type={type},hash={hash}")
347
379
  return self.send_order_msg_nav(build)
@@ -387,7 +419,7 @@ class MessageNavigation(AbstractMessage, ABC):
387
419
  generate_route_information}")
388
420
  return self.send_order_msg_nav(MctlNav(bidire_reqconver_path=build))
389
421
 
390
- def modify_generate_route_information(self, generate_route_information: GenerateRouteInformation) -> bytes:
422
+ def modify_route_information(self, generate_route_information: GenerateRouteInformation) -> bytes:
391
423
  logger.debug(f"Generate route data source: {generate_route_information}")
392
424
  build = NavReqCoverPath(
393
425
  pver=1,
@@ -429,7 +461,11 @@ class MessageNavigation(AbstractMessage, ABC):
429
461
  return self.send_order_msg_nav(build)
430
462
 
431
463
  def get_line_info_list(self, hash_list: list[int], transaction_id: int) -> bytes:
464
+ """Get route information (mow path) corresponding to the specified hash list based on time.
465
+ e.g transaction_id = int(time.time() * 1000)
466
+ """
432
467
  logger.debug(f"Sending==========Get route command: {hash_list}")
468
+
433
469
  build = MctlNav(
434
470
  app_request_cover_paths=AppRequestCoverPathsT(
435
471
  pver=1, hash_list=hash_list, transaction_id=transaction_id, sub_cmd=0
@@ -1,11 +1,10 @@
1
1
  # === sendOrderMsg_Net ===
2
- import time
3
2
  from abc import ABC
3
+ import time
4
4
 
5
5
  from pymammotion import logger
6
6
  from pymammotion.mammotion.commands.abstract_message import AbstractMessage
7
- from pymammotion.mammotion.commands.messages.navigation import MessageNavigation
8
- from pymammotion.proto.dev_net import (
7
+ from pymammotion.proto import (
9
8
  DevNet,
10
9
  DrvDebugDdsZmq,
11
10
  DrvDevInfoReq,
@@ -18,26 +17,26 @@ from pymammotion.proto.dev_net import (
18
17
  DrvWifiUpload,
19
18
  GetNetworkInfoReq,
20
19
  IotConctrlType,
20
+ LubaMsg,
21
21
  MnetCfg,
22
+ MsgAttr,
23
+ MsgCmdType,
24
+ MsgDevice,
22
25
  NetType,
23
26
  SetMnetCfgReq,
24
27
  )
25
- from pymammotion.proto.luba_msg import LubaMsg, MsgAttr, MsgCmdType, MsgDevice
26
28
 
27
29
 
28
30
  class MessageNetwork(AbstractMessage, ABC):
29
- messageNavigation: MessageNavigation = MessageNavigation()
30
-
31
- @staticmethod
32
- def send_order_msg_net(build: DevNet) -> bytes:
31
+ def send_order_msg_net(self, build: DevNet) -> bytes:
33
32
  luba_msg = LubaMsg(
34
- msgtype=MsgCmdType.MSG_CMD_TYPE_ESP,
33
+ msgtype=MsgCmdType.ESP,
35
34
  sender=MsgDevice.DEV_MOBILEAPP,
36
35
  rcver=MsgDevice.DEV_COMM_ESP,
37
- msgattr=MsgAttr.MSG_ATTR_REQ,
38
- seqs=1,
36
+ msgattr=MsgAttr.REQ,
37
+ seqs=self.seqs.increment_and_get() & 255,
39
38
  version=1,
40
- subtype=1,
39
+ subtype=self.user_account,
41
40
  net=build,
42
41
  timestamp=round(time.time() * 1000),
43
42
  )
@@ -76,7 +75,7 @@ class MessageNetwork(AbstractMessage, ABC):
76
75
 
77
76
  def set_zmq_enable(self) -> bytes:
78
77
  build = DevNet(
79
- todev_set_dds2zmq=DrvDebugDdsZmq(
78
+ todev_set_dds2_zmq=DrvDebugDdsZmq(
80
79
  is_enable=True,
81
80
  rx_topic_name="perception_post_result",
82
81
  tx_zmq_url="tcp://0.0.0.0:5555",
@@ -164,7 +163,7 @@ class MessageNetwork(AbstractMessage, ABC):
164
163
  todev_ble_sync=1,
165
164
  todev_set_mnet_cfg_req=SetMnetCfgReq(
166
165
  cfg=MnetCfg(
167
- type=NetType.NET_TYPE_WIFI,
166
+ type=NetType.WIFI,
168
167
  inet_enable=new_4g_status,
169
168
  mnet_enable=new_4g_status,
170
169
  )
@@ -177,7 +176,7 @@ class MessageNetwork(AbstractMessage, ABC):
177
176
  def set_device_wifi_enable_status(self, new_wifi_status: bool) -> bytes:
178
177
  build = DevNet(
179
178
  todev_ble_sync=1,
180
- todev__wifi__configuration=DrvWifiSet(config_param=4, wifi_enable=new_wifi_status),
179
+ todev_wifi_configuration=DrvWifiSet(config_param=4, wifi_enable=new_wifi_status),
181
180
  )
182
181
  logger.debug(f"szNetwork: Send command - set network (on/off status). newWifiStatus={new_wifi_status}")
183
182
  return self.send_order_msg_net(build)
@@ -185,25 +184,20 @@ class MessageNetwork(AbstractMessage, ABC):
185
184
  def wifi_connectinfo_update(self) -> bytes:
186
185
  build = DevNet(
187
186
  todev_ble_sync=1,
188
- todev__wifi_msg_upload=DrvWifiUpload(wifi_msg_upload=1),
187
+ todev_wifi_msg_upload=DrvWifiUpload(wifi_msg_upload=1),
189
188
  )
190
189
  logger.debug("Send command - get Wifi connection information")
191
190
  return self.send_order_msg_net(build)
192
191
 
193
- def wifi_connectinfo_update2(self) -> None:
194
- hash_map = {"getMsgCmd": 1}
195
- # self.post_custom_data(self.get_json_string(
196
- # 68, hash_map)) # ToDo: Fix this
197
-
198
192
  def get_record_wifi_list(self) -> bytes:
199
- build = DevNet(todev_ble_sync=1, todev__wifi_list_upload=DrvWifiList())
193
+ build = DevNet(todev_ble_sync=1, todev_wifi_list_upload=DrvWifiList())
200
194
  logger.debug("Send command - get memorized WiFi list upload command")
201
195
  return self.send_order_msg_net(build)
202
196
 
203
197
  def close_clear_connect_current_wifi(self, ssid: str, status: int) -> bytes:
204
198
  build = DevNet(
205
199
  todev_ble_sync=1,
206
- todev__wifi__configuration=DrvWifiSet(config_param=status, confssid=ssid),
200
+ todev_wifi_configuration=DrvWifiSet(config_param=status, confssid=ssid),
207
201
  )
208
202
  logger.debug(
209
203
  f"Send command - set network (disconnect, direct connect, forget, no operation reconnect) operation command (downlink ssid={ssid}, status={status})"
@@ -1,38 +1,38 @@
1
1
  # === sendOrderMsg_Ota ===
2
2
  from abc import ABC
3
+ import logging
3
4
 
4
5
  from pymammotion.mammotion.commands.abstract_message import AbstractMessage
5
- from pymammotion.proto import luba_msg_pb2, mctrl_ota_pb2
6
- from pymammotion.proto.luba_msg import MsgCmdType, MsgDevice
6
+ from pymammotion.proto import GetInfoReq, InfoType, LubaMsg, MctlOta, MsgAttr, MsgCmdType, MsgDevice
7
+
8
+ _LOGGER = logging.getLogger(__name__)
7
9
 
8
10
 
9
11
  class MessageOta(AbstractMessage, ABC):
12
+ """Message OTA class."""
13
+
10
14
  def send_order_msg_ota(self, ota):
11
- luba_msg = luba_msg_pb2.LubaMsg(
12
- msgtype=luba_msg_pb2.MSG_CMD_TYPE_EMBED_OTA,
13
- sender=luba_msg_pb2.DEV_MOBILEAPP,
14
- rcver=self.get_msg_device(MsgCmdType.MSG_CMD_TYPE_EMBED_OTA, MsgDevice.DEV_MAINCTL),
15
- msgattr=luba_msg_pb2.MSG_ATTR_REQ,
16
- seqs=1,
15
+ luba_msg = LubaMsg(
16
+ msgtype=MsgCmdType.EMBED_OTA,
17
+ sender=MsgDevice.DEV_MOBILEAPP,
18
+ rcver=self.get_msg_device(MsgCmdType.EMBED_OTA, MsgDevice.DEV_MAINCTL),
19
+ msgattr=MsgAttr.REQ,
20
+ seqs=self.seqs.increment_and_get() & 255,
17
21
  version=1,
18
- subtype=1,
22
+ subtype=self.user_account,
19
23
  ota=ota,
20
24
  )
21
25
 
22
26
  return luba_msg.SerializeToString()
23
27
 
24
28
  def get_device_ota_info(self, log_type: int):
25
- todev_get_info_req = mctrl_ota_pb2.MctlOta(
26
- todev_get_info_req=mctrl_ota_pb2.getInfoReq(type=mctrl_ota_pb2.IT_OTA)
27
- )
29
+ todev_get_info_req = MctlOta(todev_get_info_req=GetInfoReq(type=InfoType.IT_OTA))
28
30
 
29
- print("===Send command to get upgrade details===logType:" + str(log_type))
31
+ _LOGGER.debug("===Send command to get upgrade details===logType:" + str(log_type))
30
32
  return self.send_order_msg_ota(todev_get_info_req)
31
33
 
32
- def get_device_info_new(self):
34
+ def get_device_info_new(self) -> bytes:
33
35
  """New device call for OTA upgrade information."""
34
- todev_get_info_req = mctrl_ota_pb2.MctlOta(
35
- todev_get_info_req=mctrl_ota_pb2.getInfoReq(type=mctrl_ota_pb2.IT_BASE)
36
- )
37
- print("Send to get OTA upgrade information", "Get device information")
36
+ todev_get_info_req = MctlOta(todev_get_info_req=GetInfoReq(type=InfoType.IT_BASE))
37
+ _LOGGER.debug("Send to get OTA upgrade information", "Get device information")
38
38
  return self.send_order_msg_ota(todev_get_info_req)
@@ -1,17 +1,19 @@
1
1
  # === sendOrderMsg_Sys ===
2
+ from abc import ABC
2
3
  import datetime
3
4
  import time
4
- from abc import ABC
5
5
 
6
6
  from pymammotion import logger
7
7
  from pymammotion.mammotion.commands.abstract_message import AbstractMessage
8
- from pymammotion.mammotion.commands.messages.navigation import MessageNavigation
9
- from pymammotion.proto.luba_msg import LubaMsg, MsgAttr, MsgCmdType, MsgDevice
10
- from pymammotion.proto.mctrl_sys import (
8
+ from pymammotion.proto import (
11
9
  DeviceProductTypeInfoT,
12
10
  LoraCfgReq,
11
+ LubaMsg,
13
12
  MctlSys,
14
13
  MCtrlSimulationCmdData,
14
+ MsgAttr,
15
+ MsgCmdType,
16
+ MsgDevice,
15
17
  ReportInfoCfg,
16
18
  RptAct,
17
19
  RptInfoType,
@@ -20,44 +22,40 @@ from pymammotion.proto.mctrl_sys import (
20
22
  SysSetDateTime,
21
23
  TimeCtrlLight,
22
24
  )
23
- from pymammotion.utility.device_type import DeviceType
24
25
 
25
26
 
26
27
  class MessageSystem(AbstractMessage, ABC):
27
- messageNavigation: MessageNavigation = MessageNavigation()
28
-
29
- def send_order_msg_sys(self, sys):
28
+ def send_order_msg_sys(self, sys) -> bytes:
30
29
  luba_msg = LubaMsg(
31
- msgtype=MsgCmdType.MSG_CMD_TYPE_EMBED_SYS,
32
- msgattr=MsgAttr.MSG_ATTR_REQ,
30
+ msgtype=MsgCmdType.EMBED_SYS,
31
+ msgattr=MsgAttr.REQ,
33
32
  sender=MsgDevice.DEV_MOBILEAPP,
34
- rcver=self.get_msg_device(MsgCmdType.MSG_CMD_TYPE_EMBED_SYS, MsgDevice.DEV_MAINCTL),
33
+ rcver=self.get_msg_device(MsgCmdType.EMBED_SYS, MsgDevice.DEV_MAINCTL),
35
34
  sys=sys,
36
- seqs=1,
35
+ seqs=self.seqs.increment_and_get() & 255,
37
36
  version=1,
38
- subtype=1,
37
+ subtype=self.user_account,
39
38
  timestamp=round(time.time() * 1000),
40
39
  )
41
40
 
42
41
  return luba_msg.SerializeToString()
43
42
 
44
- @staticmethod
45
- def send_order_msg_sys_legacy(sys):
43
+ def send_order_msg_sys_legacy(self, sys) -> bytes:
46
44
  luba_msg = LubaMsg(
47
- msgtype=MsgCmdType.MSG_CMD_TYPE_EMBED_SYS,
48
- msgattr=MsgAttr.MSG_ATTR_REQ,
45
+ msgtype=MsgCmdType.EMBED_SYS,
46
+ msgattr=MsgAttr.REQ,
49
47
  sender=MsgDevice.DEV_MOBILEAPP,
50
48
  rcver=MsgDevice.DEV_MAINCTL,
51
49
  sys=sys,
52
- seqs=1,
50
+ seqs=self.seqs.increment_and_get() & 255,
53
51
  version=1,
54
- subtype=1,
52
+ subtype=self.user_account,
55
53
  timestamp=round(time.time() * 1000),
56
54
  )
57
55
 
58
56
  return luba_msg.SerializeToString()
59
57
 
60
- def reset_system(self):
58
+ def reset_system(self) -> bytes:
61
59
  build = MctlSys(todev_reset_system=1)
62
60
  logger.debug("Send command - send factory reset")
63
61
  return self.send_order_msg_sys(build)
@@ -102,7 +100,7 @@ class MessageSystem(AbstractMessage, ABC):
102
100
  is_sidelight}, operate:{operate}, timeCtrlLight:{build}")
103
101
  return self.send_order_msg_sys(build2)
104
102
 
105
- def test_tool_order_to_sys(self, sub_cmd: int, param_id: int, param_value: list[int]):
103
+ def test_tool_order_to_sys(self, sub_cmd: int, param_id: int, param_value: list[int]) -> bytes:
106
104
  build = MCtrlSimulationCmdData(sub_cmd=sub_cmd, param_id=param_id, param_value=param_value)
107
105
  logger.debug(f"Send tool test command: subCmd={sub_cmd}, param_id:{
108
106
  param_id}, param_value={param_value}")
@@ -111,32 +109,16 @@ class MessageSystem(AbstractMessage, ABC):
111
109
  param_id}, param_value={param_value}")
112
110
  return self.send_order_msg_sys(build2)
113
111
 
114
- def read_and_set_rtk_paring_code(self, op: int, cgf: str | None = None):
112
+ def read_and_set_rtk_paring_code(self, op: int, cgf: str | None = None) -> bytes:
115
113
  logger.debug(f"Send read and write base station configuration quality op:{
116
114
  op}, cgf:{cgf}")
117
115
  return self.send_order_msg_sys(MctlSys(todev_lora_cfg_req=LoraCfgReq(op=op, cfg=cgf)))
118
116
 
119
- def allpowerfull_rw(self, id: int, context: int, rw: int) -> bytes:
120
- if (id == 6 or id == 3 or id == 7) and DeviceType.is_luba_2(self.get_device_name()):
121
- return self.messageNavigation.allpowerfull_rw_adapter_x3(id, context, rw)
122
- build = MctlSys(bidire_comm_cmd=SysCommCmd(id=id, context=context, rw=rw))
123
- logger.debug(f"Send command - 9 general read and write command id={id}, context={context}, rw={rw}")
124
- if id == 5:
125
- # TODO investigate if the original code makes any difference to this call.
126
- """
127
- LubaMsgOuterClass.LubaMsg.Builder protoBufBuilderSet = getProtoBufBuilderSet(LubaMsgOuterClass.MsgCmdType.MSG_CMD_TYPE_EMBED_SYS, LubaMsgOuterClass.MsgDevice.DEV_MAINCTL, LubaMsgOuterClass.MsgAttr.MSG_ATTR_REQ);
128
- protoBufBuilderSet.setSys(build);
129
- sendMsg(protoBufBuilderSet, 122, true, "发送指令--9通用读写命令id=" + i + ",context=" + i2 + ",rw=" + i3);
130
- """
131
- return self.send_order_msg_sys(build)
117
+ def allpowerfull_rw(self, rw_id: int, context: int, rw: int) -> bytes:
118
+ build = MctlSys(bidire_comm_cmd=SysCommCmd(id=rw_id, context=context, rw=rw))
119
+ logger.debug(f"Send command - 9 general read and write command id={rw_id}, context={context}, rw={rw}")
132
120
  return self.send_order_msg_sys(build)
133
121
 
134
- def traverse_mode(self, id: int) -> bytes:
135
- """Sets the traversal mode back to charger."""
136
- # 0 direct
137
- # 1 follow the perimeter
138
- return self.allpowerfull_rw(7, id, 1)
139
-
140
122
  # Commented out as not needed and too many refs to try fix up
141
123
  # def factory_test_order(self, test_id: int, test_duration: int, expect: str):
142
124
  # new_builder = mow_to_app_qctools_info_t.Builder()
@@ -198,6 +180,7 @@ class MessageSystem(AbstractMessage, ABC):
198
180
  # return self.send_order_msg_sys(build2)
199
181
 
200
182
  def send_sys_set_date_time(self) -> bytes:
183
+ # TODO get HA timezone
201
184
  calendar = datetime.datetime.now()
202
185
  i = calendar.year
203
186
  i2 = calendar.month
@@ -298,13 +281,13 @@ class MessageSystem(AbstractMessage, ABC):
298
281
  mctl_sys.todev_report_cfg.sub.append(RptInfoType.RIT_VISION_STATISTIC)
299
282
 
300
283
  luba_msg = LubaMsg(
301
- msgtype=MsgCmdType.MSG_CMD_TYPE_EMBED_SYS,
284
+ msgtype=MsgCmdType.EMBED_SYS,
302
285
  sender=MsgDevice.DEV_MOBILEAPP,
303
286
  rcver=MsgDevice.DEV_MAINCTL,
304
- msgattr=MsgAttr.MSG_ATTR_REQ,
305
- seqs=1,
287
+ msgattr=MsgAttr.REQ,
288
+ seqs=self.seqs.increment_and_get() & 255,
306
289
  version=1,
307
- subtype=1,
290
+ subtype=self.user_account,
308
291
  sys=mctl_sys,
309
292
  timestamp=round(time.time() * 1000),
310
293
  )
@@ -334,13 +317,13 @@ class MessageSystem(AbstractMessage, ABC):
334
317
  mctl_sys.todev_report_cfg.sub.append(RptInfoType.RIT_BASESTATION_INFO)
335
318
 
336
319
  luba_msg = LubaMsg(
337
- msgtype=MsgCmdType.MSG_CMD_TYPE_EMBED_SYS,
320
+ msgtype=MsgCmdType.EMBED_SYS,
338
321
  sender=MsgDevice.DEV_MOBILEAPP,
339
322
  rcver=MsgDevice.DEV_MAINCTL,
340
- msgattr=MsgAttr.MSG_ATTR_REQ,
341
- seqs=1,
323
+ msgattr=MsgAttr.REQ,
324
+ seqs=self.seqs.increment_and_get() & 255,
342
325
  version=1,
343
- subtype=1,
326
+ subtype=self.user_account,
344
327
  sys=mctl_sys,
345
328
  timestamp=round(time.time() * 1000),
346
329
  )
@@ -1,24 +1,23 @@
1
1
  # === sendOrderMsg_Video ===
2
- import time
3
2
  from abc import ABC
3
+ import time
4
4
 
5
5
  from pymammotion.mammotion.commands.abstract_message import AbstractMessage
6
- from pymammotion.proto import luba_msg_pb2, luba_mul_pb2
7
- from pymammotion.proto.luba_msg import MsgAttr, MsgCmdType, MsgDevice
6
+ from pymammotion.proto import LubaMsg, MsgAttr, MsgCmdType, MsgDevice, MulCameraPosition, MulSetVideo, SocMul
8
7
  from pymammotion.utility.device_type import DeviceType
9
8
 
10
9
 
11
10
  class MessageVideo(AbstractMessage, ABC):
12
- async def send_order_msg_video(self, mul):
13
- luba_msg = luba_msg_pb2.LubaMsg(
14
- msgtype=luba_msg_pb2.MSG_CMD_TYPE_MUL,
15
- msgattr=MsgAttr.MSG_ATTR_REQ,
16
- sender=luba_msg_pb2.DEV_MOBILEAPP,
17
- rcver=self.get_msg_device(MsgCmdType.MSG_CMD_TYPE_MUL, MsgDevice.SOC_MODULE_MULTIMEDIA),
11
+ def send_order_msg_video(self, mul: SocMul):
12
+ luba_msg = LubaMsg(
13
+ msgtype=MsgCmdType.MUL,
14
+ msgattr=MsgAttr.REQ,
15
+ sender=MsgDevice.DEV_MOBILEAPP,
16
+ rcver=self.get_msg_device(MsgCmdType.MUL, MsgDevice.SOC_MODULE_MULTIMEDIA),
18
17
  mul=mul,
19
- seqs=1,
18
+ seqs=self.seqs.increment_and_get() & 255,
20
19
  version=1,
21
- subtype=1,
20
+ subtype=self.user_account,
22
21
  timestamp=round(time.time() * 1000),
23
22
  )
24
23
 
@@ -26,9 +25,9 @@ class MessageVideo(AbstractMessage, ABC):
26
25
 
27
26
  def device_agora_join_channel_with_position(self, enter_state: int):
28
27
  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
28
+ MulCameraPosition.ALL
29
+ if DeviceType.value_of_str(self.get_device_name()).get_value() == DeviceType.LUBA_YUKA.get_value()
30
+ else MulCameraPosition.LEFT
32
31
  )
33
- mctl_sys = luba_mul_pb2.SocMul(set_video=luba_mul_pb2.MulSetVideo(position=position, vi_switch=enter_state))
34
- return self.send_order_msg_video(mctl_sys)
32
+ soc_mul = SocMul(set_video=MulSetVideo(position=position, vi_switch=enter_state))
33
+ return self.send_order_msg_video(soc_mul)
@@ -1,5 +1,29 @@
1
- """mqtt init."""
1
+ """Mammotion devices module."""
2
2
 
3
- from .mammotion import MammotionBaseBLEDevice
3
+ from .mammotion import Mammotion, MammotionDeviceManager
4
+ from .mammotion_bluetooth import MammotionBaseBLEDevice
5
+ from .mammotion_cloud import MammotionBaseCloudDevice, MammotionCloud
6
+ from .mammotion_mower_ble import MammotionMowerBLEDevice
7
+ from .mammotion_mower_cloud import MammotionMowerCloudDevice
8
+ from .mower_device import MammotionMowerDevice
9
+ from .mower_manager import MammotionMowerDeviceManager
10
+ from .rtk_ble import MammotionRTKBLEDevice
11
+ from .rtk_cloud import MammotionRTKCloudDevice
12
+ from .rtk_device import MammotionRTKDevice
13
+ from .rtk_manager import MammotionRTKDeviceManager
4
14
 
5
- __all__ = ["MammotionBaseBLEDevice"]
15
+ __all__ = [
16
+ "Mammotion",
17
+ "MammotionDeviceManager",
18
+ "MammotionMowerDeviceManager",
19
+ "MammotionBaseBLEDevice",
20
+ "MammotionBaseCloudDevice",
21
+ "MammotionCloud",
22
+ "MammotionMowerBLEDevice",
23
+ "MammotionMowerCloudDevice",
24
+ "MammotionMowerDevice",
25
+ "MammotionRTKBLEDevice",
26
+ "MammotionRTKCloudDevice",
27
+ "MammotionRTKDevice",
28
+ "MammotionRTKDeviceManager",
29
+ ]