pymammotion 0.2.62__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 (135) hide show
  1. pymammotion/__init__.py +9 -6
  2. pymammotion/aliyun/client.py +235 -0
  3. pymammotion/aliyun/cloud_gateway.py +320 -69
  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 +11 -15
  13. pymammotion/bluetooth/ble_message.py +389 -106
  14. pymammotion/bluetooth/model/atomic_integer.py +54 -0
  15. pymammotion/const.py +3 -0
  16. pymammotion/data/model/__init__.py +1 -2
  17. pymammotion/data/model/device.py +92 -240
  18. pymammotion/data/model/device_config.py +10 -24
  19. pymammotion/data/model/device_info.py +35 -0
  20. pymammotion/data/model/device_limits.py +49 -0
  21. pymammotion/data/model/enums.py +12 -2
  22. pymammotion/data/model/errors.py +12 -0
  23. pymammotion/data/model/events.py +14 -0
  24. pymammotion/data/model/generate_geojson.py +521 -0
  25. pymammotion/data/model/generate_route_information.py +3 -4
  26. pymammotion/data/model/hash_list.py +384 -48
  27. pymammotion/data/model/location.py +4 -4
  28. pymammotion/data/model/mowing_modes.py +24 -1
  29. pymammotion/data/model/raw_data.py +215 -0
  30. pymammotion/data/model/region_data.py +10 -11
  31. pymammotion/data/model/report_info.py +62 -6
  32. pymammotion/data/model/work.py +27 -0
  33. pymammotion/data/mower_state_manager.py +316 -0
  34. pymammotion/data/mqtt/event.py +73 -28
  35. pymammotion/data/mqtt/mammotion_properties.py +257 -0
  36. pymammotion/data/mqtt/properties.py +93 -78
  37. pymammotion/data/mqtt/status.py +18 -17
  38. pymammotion/event/event.py +32 -8
  39. pymammotion/homeassistant/__init__.py +3 -0
  40. pymammotion/homeassistant/mower_api.py +484 -0
  41. pymammotion/homeassistant/rtk_api.py +54 -0
  42. pymammotion/http/__init__.py +0 -0
  43. pymammotion/http/encryption.py +220 -0
  44. pymammotion/http/http.py +652 -44
  45. pymammotion/http/model/__init__.py +0 -0
  46. pymammotion/{aliyun/model/stream_subscription_response.py → http/model/camera_stream.py} +14 -2
  47. pymammotion/http/model/http.py +160 -9
  48. pymammotion/http/model/response_factory.py +61 -0
  49. pymammotion/http/model/rtk.py +16 -0
  50. pymammotion/mammotion/commands/abstract_message.py +7 -5
  51. pymammotion/mammotion/commands/mammotion_command.py +32 -3
  52. pymammotion/mammotion/commands/messages/basestation.py +43 -0
  53. pymammotion/mammotion/commands/messages/driver.py +61 -29
  54. pymammotion/mammotion/commands/messages/media.py +68 -15
  55. pymammotion/mammotion/commands/messages/navigation.py +61 -25
  56. pymammotion/mammotion/commands/messages/network.py +93 -100
  57. pymammotion/mammotion/commands/messages/ota.py +18 -18
  58. pymammotion/mammotion/commands/messages/system.py +97 -72
  59. pymammotion/mammotion/commands/messages/video.py +17 -12
  60. pymammotion/mammotion/devices/__init__.py +27 -3
  61. pymammotion/mammotion/devices/base.py +50 -127
  62. pymammotion/mammotion/devices/mammotion.py +447 -212
  63. pymammotion/mammotion/devices/mammotion_bluetooth.py +105 -60
  64. pymammotion/mammotion/devices/mammotion_cloud.py +157 -105
  65. pymammotion/mammotion/devices/mammotion_mower_ble.py +49 -0
  66. pymammotion/mammotion/devices/mammotion_mower_cloud.py +39 -0
  67. pymammotion/mammotion/devices/managers/managers.py +81 -0
  68. pymammotion/mammotion/devices/mower_device.py +124 -0
  69. pymammotion/mammotion/devices/mower_manager.py +107 -0
  70. pymammotion/mammotion/devices/rtk_ble.py +89 -0
  71. pymammotion/mammotion/devices/rtk_cloud.py +113 -0
  72. pymammotion/mammotion/devices/rtk_device.py +50 -0
  73. pymammotion/mammotion/devices/rtk_manager.py +122 -0
  74. pymammotion/mqtt/__init__.py +2 -1
  75. pymammotion/mqtt/aliyun_mqtt.py +232 -0
  76. pymammotion/mqtt/linkkit/__init__.py +5 -0
  77. pymammotion/mqtt/linkkit/h2client.py +585 -0
  78. pymammotion/mqtt/linkkit/linkkit.py +3023 -0
  79. pymammotion/mqtt/mammotion_mqtt.py +176 -169
  80. pymammotion/mqtt/mqtt_models.py +66 -0
  81. pymammotion/proto/__init__.py +4839 -4
  82. pymammotion/proto/basestation.proto +8 -0
  83. pymammotion/proto/basestation_pb2.py +11 -9
  84. pymammotion/proto/basestation_pb2.pyi +16 -2
  85. pymammotion/proto/dev_net.proto +79 -55
  86. pymammotion/proto/dev_net_pb2.py +60 -56
  87. pymammotion/proto/dev_net_pb2.pyi +49 -6
  88. pymammotion/proto/luba_msg.proto +2 -1
  89. pymammotion/proto/luba_msg_pb2.py +6 -6
  90. pymammotion/proto/luba_msg_pb2.pyi +1 -0
  91. pymammotion/proto/luba_mul.proto +62 -1
  92. pymammotion/proto/luba_mul_pb2.py +38 -22
  93. pymammotion/proto/luba_mul_pb2.pyi +94 -7
  94. pymammotion/proto/mctrl_driver.proto +44 -4
  95. pymammotion/proto/mctrl_driver_pb2.py +26 -14
  96. pymammotion/proto/mctrl_driver_pb2.pyi +66 -11
  97. pymammotion/proto/mctrl_nav.proto +97 -51
  98. pymammotion/proto/mctrl_nav_pb2.py +75 -67
  99. pymammotion/proto/mctrl_nav_pb2.pyi +142 -56
  100. pymammotion/proto/mctrl_ota.proto +40 -2
  101. pymammotion/proto/mctrl_ota_pb2.py +23 -13
  102. pymammotion/proto/mctrl_ota_pb2.pyi +67 -4
  103. pymammotion/proto/mctrl_pept.proto +8 -3
  104. pymammotion/proto/mctrl_pept_pb2.py +8 -6
  105. pymammotion/proto/mctrl_pept_pb2.pyi +14 -6
  106. pymammotion/proto/mctrl_sys.proto +325 -86
  107. pymammotion/proto/mctrl_sys_pb2.py +162 -98
  108. pymammotion/proto/mctrl_sys_pb2.pyi +451 -25
  109. pymammotion/proto/message_pool.py +3 -0
  110. pymammotion/proto/py.typed +0 -0
  111. pymammotion/utility/constant/device_constant.py +65 -21
  112. pymammotion/utility/datatype_converter.py +13 -12
  113. pymammotion/utility/device_config.py +755 -0
  114. pymammotion/utility/device_type.py +218 -21
  115. pymammotion/utility/map.py +238 -51
  116. pymammotion/utility/mur_mur_hash.py +159 -0
  117. {pymammotion-0.2.62.dist-info → pymammotion-0.5.51.dist-info}/METADATA +27 -31
  118. pymammotion-0.5.51.dist-info/RECORD +152 -0
  119. {pymammotion-0.2.62.dist-info → pymammotion-0.5.51.dist-info}/WHEEL +1 -1
  120. pymammotion/aliyun/cloud_service.py +0 -65
  121. pymammotion/data/model/plan.py +0 -58
  122. pymammotion/data/state_manager.py +0 -130
  123. pymammotion/proto/basestation.py +0 -59
  124. pymammotion/proto/common.py +0 -12
  125. pymammotion/proto/dev_net.py +0 -381
  126. pymammotion/proto/luba_msg.py +0 -81
  127. pymammotion/proto/luba_mul.py +0 -76
  128. pymammotion/proto/mctrl_driver.py +0 -100
  129. pymammotion/proto/mctrl_nav.py +0 -660
  130. pymammotion/proto/mctrl_ota.py +0 -48
  131. pymammotion/proto/mctrl_pept.py +0 -41
  132. pymammotion/proto/mctrl_sys.py +0 -574
  133. pymammotion-0.2.62.dist-info/RECORD +0 -125
  134. /pymammotion/{http/_init_.py → bluetooth/model/__init__.py} +0 -0
  135. {pymammotion-0.2.62.dist-info → pymammotion-0.5.51.dist-info/licenses}/LICENSE +0 -0
@@ -2,33 +2,86 @@
2
2
  from abc import ABC
3
3
 
4
4
  from pymammotion.mammotion.commands.abstract_message import AbstractMessage
5
- from pymammotion.proto import luba_msg_pb2, luba_mul_pb2
6
- from pymammotion.proto.luba_msg import MsgCmdType, MsgDevice
7
- from pymammotion.proto.luba_mul import MUL_LANGUAGE
5
+ from pymammotion.proto import (
6
+ GetHeadlamp,
7
+ LampCtrlSta,
8
+ LampManualCtrlSta,
9
+ LubaMsg,
10
+ MsgAttr,
11
+ MsgCmdType,
12
+ MsgDevice,
13
+ MulLanguage,
14
+ MulSetAudio,
15
+ MulSetWiper,
16
+ MulSex,
17
+ SetHeadlamp,
18
+ SocMul,
19
+ )
8
20
 
9
21
 
10
22
  class MessageMedia(AbstractMessage, ABC):
11
23
  def send_order_msg_media(self, mul):
12
- luba_msg = luba_msg_pb2.LubaMsg(
13
- msgtype=luba_msg_pb2.MSG_CMD_TYPE_MUL,
14
- sender=luba_msg_pb2.DEV_MOBILEAPP,
15
- rcver=self.get_msg_device(MsgCmdType.MSG_CMD_TYPE_MUL, MsgDevice.SOC_MODULE_MULTIMEDIA),
16
- msgattr=luba_msg_pb2.MSG_ATTR_REQ,
17
- seqs=1,
24
+ luba_msg = LubaMsg(
25
+ msgtype=MsgCmdType.MUL,
26
+ sender=MsgDevice.DEV_MOBILEAPP,
27
+ rcver=self.get_msg_device(MsgCmdType.MUL, MsgDevice.SOC_MODULE_MULTIMEDIA),
28
+ msgattr=MsgAttr.REQ,
29
+ seqs=self.seqs.increment_and_get() & 255,
18
30
  version=1,
19
- subtype=1,
31
+ subtype=self.user_account,
20
32
  mul=mul,
21
33
  )
22
34
 
23
35
  return luba_msg.SerializeToString()
24
36
 
25
37
  def set_car_volume(self, volume: int):
26
- return self.send_order_msg_media(luba_mul_pb2.SocMul(set_audio=luba_mul_pb2.MulSetAudio(at_switch=volume)))
38
+ """Set the car volume. 0 - 100"""
39
+ return self.send_order_msg_media(SocMul(set_audio=MulSetAudio(at_switch=volume)))
27
40
 
28
- def set_car_voice_language(self, language_type: MUL_LANGUAGE | str | None):
41
+ def set_car_voice_language(self, language_type: MulLanguage | str | None):
42
+ return self.send_order_msg_media(SocMul(set_audio=MulSetAudio(au_language=language_type)))
43
+
44
+ def set_car_volume_sex(self, sex: MulSex):
45
+ return self.send_order_msg_media(SocMul(set_audio=MulSetAudio(sex=sex)))
46
+
47
+ def set_car_wiper(self, round_num: int):
48
+ """Set mower wiper."""
49
+ # 2
50
+ return self.send_order_msg_media(SocMul(set_wiper=MulSetWiper(round=round_num)))
51
+
52
+ def get_car_light(self, ids: int):
53
+ """Get mower light settings.
54
+ 1126 for manual
55
+ 1123 for night time settings
56
+ """
57
+ return self.send_order_msg_media(SocMul(get_lamp=GetHeadlamp(get_ids=ids)))
58
+
59
+ def set_car_light(self, on_off: bool = False):
60
+ """Set mower light.
61
+
62
+ set whether light is on during the night during mowing
63
+ auto night on true, id=1121, power_ctrl=1
64
+ auto night off false, id=1121, power_ctrl=1
65
+ """
66
+
67
+ ctrl_state = LampCtrlSta.power_ctrl_on if on_off else LampCtrlSta.power_off
29
68
  return self.send_order_msg_media(
30
- luba_mul_pb2.SocMul(set_audio=luba_mul_pb2.MulSetAudio(au_language=language_type))
69
+ SocMul(
70
+ set_lamp=SetHeadlamp(
71
+ set_ids=1121, lamp_power_ctrl=1, lamp_ctrl=ctrl_state, ctrl_lamp_bright=False, lamp_bright=0
72
+ )
73
+ )
31
74
  )
32
75
 
33
- def set_car_wiper(self, round_num: int):
34
- return self.send_order_msg_media(luba_mul_pb2.SocMul(set_wiper=luba_mul_pb2.MulSetWiper(round=round_num)))
76
+ def set_car_manual_light(self, manual_ctrl: bool = False):
77
+ """Set mower light.
78
+
79
+ set whether light is on manually
80
+ manual on: true, id=1125, power_ctrl=2
81
+ manual off: false, id=1127, power_ctrl=2
82
+ """
83
+ ids = 1125 if manual_ctrl else 1127
84
+ manual_light_ctrl = LampManualCtrlSta.manual_power_on if manual_ctrl else LampManualCtrlSta.manual_power_off
85
+ return self.send_order_msg_media(
86
+ SocMul(set_lamp=SetHeadlamp(set_ids=ids, lamp_power_ctrl=2, lamp_manual_ctrl=manual_light_ctrl))
87
+ )
@@ -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,60 +1,81 @@
1
1
  # === sendOrderMsg_Net ===
2
- from pymammotion import logger
3
- from pymammotion.mammotion.commands.messages.navigation import MessageNavigation
4
- from pymammotion.proto import dev_net_pb2, luba_msg_pb2
5
-
6
-
7
- class MessageNetwork:
8
- messageNavigation: MessageNavigation = MessageNavigation()
2
+ from abc import ABC
3
+ import time
9
4
 
10
- @staticmethod
11
- def send_order_msg_net(build) -> bytes:
12
- luba_msg = luba_msg_pb2.LubaMsg(
13
- msgtype=luba_msg_pb2.MSG_CMD_TYPE_ESP,
14
- sender=luba_msg_pb2.DEV_MOBILEAPP,
15
- rcver=luba_msg_pb2.DEV_COMM_ESP,
16
- msgattr=luba_msg_pb2.MSG_ATTR_REQ,
17
- seqs=1,
5
+ from pymammotion import logger
6
+ from pymammotion.mammotion.commands.abstract_message import AbstractMessage
7
+ from pymammotion.proto import (
8
+ DevNet,
9
+ DrvDebugDdsZmq,
10
+ DrvDevInfoReq,
11
+ DrvDevInfoReqId,
12
+ DrvUploadFileCancel,
13
+ DrvUploadFileReq,
14
+ DrvUploadFileToAppReq,
15
+ DrvWifiList,
16
+ DrvWifiSet,
17
+ DrvWifiUpload,
18
+ GetNetworkInfoReq,
19
+ IotConctrlType,
20
+ LubaMsg,
21
+ MnetCfg,
22
+ MsgAttr,
23
+ MsgCmdType,
24
+ MsgDevice,
25
+ NetType,
26
+ SetMnetCfgReq,
27
+ )
28
+
29
+
30
+ class MessageNetwork(AbstractMessage, ABC):
31
+ def send_order_msg_net(self, build: DevNet) -> bytes:
32
+ luba_msg = LubaMsg(
33
+ msgtype=MsgCmdType.ESP,
34
+ sender=MsgDevice.DEV_MOBILEAPP,
35
+ rcver=MsgDevice.DEV_COMM_ESP,
36
+ msgattr=MsgAttr.REQ,
37
+ seqs=self.seqs.increment_and_get() & 255,
18
38
  version=1,
19
- subtype=1,
39
+ subtype=self.user_account,
20
40
  net=build,
41
+ timestamp=round(time.time() * 1000),
21
42
  )
22
43
 
23
44
  return luba_msg.SerializeToString()
24
45
 
25
46
  def send_todev_ble_sync(self, sync_type: int) -> bytes:
26
- comm_esp = dev_net_pb2.DevNet(todev_ble_sync=sync_type)
47
+ comm_esp = DevNet(todev_ble_sync=sync_type)
27
48
  return self.send_order_msg_net(comm_esp)
28
49
 
29
- def get_device_base_info(self) -> bytes:
30
- net = dev_net_pb2.DevNet(todev_devinfo_req=dev_net_pb2.DrvDevInfoReq())
31
- net.todev_devinfo_req.req_ids.add(id=1, type=6)
50
+ def get_device_version_main(self) -> bytes:
51
+ net = DevNet(todev_devinfo_req=DrvDevInfoReq())
52
+ net.todev_devinfo_req.req_ids.append(DrvDevInfoReqId(id=1, type=6))
32
53
 
33
54
  return self.send_order_msg_net(net)
34
55
 
35
- def get_device_version_main(self) -> bytes:
36
- net = dev_net_pb2.DevNet(todev_devinfo_req=dev_net_pb2.DrvDevInfoReq())
56
+ def get_device_base_info(self) -> bytes:
57
+ net = DevNet(todev_devinfo_req=DrvDevInfoReq())
37
58
 
38
59
  for i in range(1, 8):
39
60
  if i == 1:
40
- net.todev_devinfo_req.req_ids.add(id=i, type=6)
41
- net.todev_devinfo_req.req_ids.add(id=i, type=3)
61
+ net.todev_devinfo_req.req_ids.append(DrvDevInfoReqId(id=i, type=6))
62
+ net.todev_devinfo_req.req_ids.append(DrvDevInfoReqId(id=i, type=3))
42
63
 
43
64
  return self.send_order_msg_net(net)
44
65
 
45
66
  def get_4g_module_info(self) -> bytes:
46
- build = dev_net_pb2.DevNet(todev_get_mnet_cfg_req=dev_net_pb2.DevNet().todev_get_mnet_cfg_req)
67
+ build = DevNet(todev_get_mnet_cfg_req=DevNet().todev_get_mnet_cfg_req)
47
68
  logger.debug("Send command -- Get device 4G network module information")
48
69
  return self.send_order_msg_net(build)
49
70
 
50
71
  def get_4g_info(self) -> bytes:
51
- build = dev_net_pb2.DevNet(todev_mnet_info_req=dev_net_pb2.DevNet().todev_mnet_info_req)
72
+ build = DevNet(todev_mnet_info_req=DevNet().todev_mnet_info_req)
52
73
  logger.debug("Send command -- Get device 4G network information")
53
74
  return self.send_order_msg_net(build)
54
75
 
55
76
  def set_zmq_enable(self) -> bytes:
56
- build = dev_net_pb2.DevNet(
57
- todev_set_dds2zmq=dev_net_pb2.DrvDebugDdsZmq(
77
+ build = DevNet(
78
+ todev_set_dds2_zmq=DrvDebugDdsZmq(
58
79
  is_enable=True,
59
80
  rx_topic_name="perception_post_result",
60
81
  tx_zmq_url="tcp://0.0.0.0:5555",
@@ -63,8 +84,8 @@ class MessageNetwork:
63
84
  logger.debug("Send command -- Set vision ZMQ to enable")
64
85
  return self.send_order_msg_net(build)
65
86
 
66
- def set_iot_setting(self, iot_control_type: dev_net_pb2.iot_conctrl_type) -> bytes:
67
- build = dev_net_pb2.DevNet(todev_set_iot_offline_req=iot_control_type)
87
+ def set_iot_setting(self, iot_control_type: IotConctrlType) -> bytes:
88
+ build = DevNet(todev_set_iot_offline_req=iot_control_type)
68
89
  logger.debug("Send command -- Device re-online")
69
90
  return self.send_order_msg_net(build)
70
91
 
@@ -77,18 +98,18 @@ class MessageNetwork:
77
98
  number: int,
78
99
  type: int,
79
100
  ) -> bytes:
80
- build = dev_net_pb2.DrvUploadFileToAppReq(
81
- bizId=request_id,
101
+ build = DrvUploadFileToAppReq(
102
+ biz_id=request_id,
82
103
  operation=operation,
83
- serverIp=server_ip,
84
- serverPort=server_port,
104
+ server_ip=server_ip,
105
+ server_port=server_port,
85
106
  num=number,
86
107
  type=type,
87
108
  )
88
109
  logger.debug(
89
110
  f"Send log====Feedback====Command======requestID:{request_id} operation:{operation} serverIp:{server_ip} type:{type}"
90
111
  )
91
- return self.send_order_msg_net(dev_net_pb2.DevNet(todev_ble_sync=1, todev_uploadfile_req=build))
112
+ return self.send_order_msg_net(DevNet(todev_ble_sync=1, todev_uploadfile_req=build))
92
113
 
93
114
  def set_device_socket_request(
94
115
  self,
@@ -100,51 +121,49 @@ class MessageNetwork:
100
121
  type: int,
101
122
  ) -> bytes:
102
123
  """Set device socket request (bluetooth only)."""
103
- build = dev_net_pb2.DrvUploadFileToAppReq(
104
- bizId=request_id,
124
+ build = DrvUploadFileToAppReq(
125
+ biz_id=request_id,
105
126
  operation=operation,
106
- serverIp=server_ip,
107
- serverPort=server_port,
127
+ server_ip=server_ip,
128
+ server_port=server_port,
108
129
  num=number,
109
130
  type=type,
110
131
  )
111
132
  logger.debug(
112
133
  f"Send log====Feedback====Command======requestID:{request_id} operation:{operation} serverIp:{server_ip} type:{type}"
113
134
  )
114
- return self.send_order_msg_net(dev_net_pb2.DevNet(todev_ble_sync=1, todev_uploadfile_req=build))
135
+ return self.send_order_msg_net(DevNet(todev_ble_sync=1, todev_uploadfile_req=build))
115
136
 
116
137
  def get_device_log_info(self, biz_id: str, type: int, log_url: str) -> bytes:
117
138
  """Get device log info (bluetooth only)."""
118
139
  return self.send_order_msg_net(
119
- dev_net_pb2.DevNet(
140
+ DevNet(
120
141
  todev_ble_sync=1,
121
- todev_req_log_info=dev_net_pb2.DrvUploadFileReq(
122
- bizId=biz_id,
142
+ todev_req_log_info=DrvUploadFileReq(
143
+ biz_id=biz_id,
123
144
  type=type,
124
145
  url=log_url,
125
146
  num=0,
126
- userId="", # TODO supply user id
147
+ user_id="", # TODO supply user id
127
148
  ),
128
149
  )
129
150
  )
130
151
 
131
152
  def cancel_log_update(self, biz_id: str) -> bytes:
132
153
  """Cancel log update (bluetooth only)."""
133
- return self.send_order_msg_net(
134
- dev_net_pb2.DevNet(todev_log_data_cancel=dev_net_pb2.DrvUploadFileCancel(bizId=biz_id))
135
- )
154
+ return self.send_order_msg_net(DevNet(todev_log_data_cancel=DrvUploadFileCancel(biz_id=biz_id)))
136
155
 
137
156
  def get_device_network_info(self) -> bytes:
138
- build = dev_net_pb2.DevNet(todev_networkinfo_req=dev_net_pb2.GetNetworkInfoReq(req_ids=1))
157
+ build = DevNet(todev_networkinfo_req=GetNetworkInfoReq(req_ids=1))
139
158
  logger.debug("Send command - get device network information")
140
159
  return self.send_order_msg_net(build)
141
160
 
142
161
  def set_device_4g_enable_status(self, new_4g_status: bool) -> bytes:
143
- build = dev_net_pb2.DevNet(
162
+ build = DevNet(
144
163
  todev_ble_sync=1,
145
- todev_set_mnet_cfg_req=dev_net_pb2.SetMnetCfgReq(
146
- cfg=dev_net_pb2.MnetCfg(
147
- type=dev_net_pb2.NET_TYPE_WIFI,
164
+ todev_set_mnet_cfg_req=SetMnetCfgReq(
165
+ cfg=MnetCfg(
166
+ type=NetType.WIFI,
148
167
  inet_enable=new_4g_status,
149
168
  mnet_enable=new_4g_status,
150
169
  )
@@ -155,58 +174,32 @@ class MessageNetwork:
155
174
  return self.send_order_msg_net(build)
156
175
 
157
176
  def set_device_wifi_enable_status(self, new_wifi_status: bool) -> bytes:
158
- build = dev_net_pb2.DevNet(
177
+ build = DevNet(
159
178
  todev_ble_sync=1,
160
- todev_Wifi_Configuration=dev_net_pb2.DrvWifiSet(configParam=4, wifi_enable=new_wifi_status),
179
+ todev_wifi_configuration=DrvWifiSet(config_param=4, wifi_enable=new_wifi_status),
161
180
  )
162
181
  logger.debug(f"szNetwork: Send command - set network (on/off status). newWifiStatus={new_wifi_status}")
163
182
  return self.send_order_msg_net(build)
164
183
 
165
- def wifi_connectinfo_update(self, device_name: str, is_binary: bool) -> bytes:
184
+ def wifi_connectinfo_update(self) -> bytes:
185
+ build = DevNet(
186
+ todev_ble_sync=1,
187
+ todev_wifi_msg_upload=DrvWifiUpload(wifi_msg_upload=1),
188
+ )
189
+ logger.debug("Send command - get Wifi connection information")
190
+ return self.send_order_msg_net(build)
191
+
192
+ def get_record_wifi_list(self) -> bytes:
193
+ build = DevNet(todev_ble_sync=1, todev_wifi_list_upload=DrvWifiList())
194
+ logger.debug("Send command - get memorized WiFi list upload command")
195
+ return self.send_order_msg_net(build)
196
+
197
+ def close_clear_connect_current_wifi(self, ssid: str, status: int) -> bytes:
198
+ build = DevNet(
199
+ todev_ble_sync=1,
200
+ todev_wifi_configuration=DrvWifiSet(config_param=status, confssid=ssid),
201
+ )
166
202
  logger.debug(
167
- f"Send command - get Wifi connection information.wifiConnectinfoUpdate().deviceName={device_name}.isBinary={is_binary}"
203
+ f"Send command - set network (disconnect, direct connect, forget, no operation reconnect) operation command (downlink ssid={ssid}, status={status})"
168
204
  )
169
- if is_binary:
170
- build = dev_net_pb2.DevNet(
171
- todev_ble_sync=1,
172
- todev_WifiMsgUpload=dev_net_pb2.DrvWifiUpload(wifi_msg_upload=1),
173
- )
174
- logger.debug("Send command - get Wifi connection information")
175
- return self.send_order_msg_net(build)
176
- self.wifi_connectinfo_update2()
177
-
178
- def wifi_connectinfo_update2(self) -> None:
179
- hash_map = {"getMsgCmd": 1}
180
- # self.post_custom_data(self.get_json_string(
181
- # 68, hash_map)) # ToDo: Fix this
182
-
183
- def get_record_wifi_list(self, is_binary: bool) -> bytes:
184
- logger.debug(f"getRecordWifiList().isBinary={is_binary}")
185
- if is_binary:
186
- build = dev_net_pb2.DevNet(todev_ble_sync=1, todev_WifiListUpload=dev_net_pb2.DrvWifiList())
187
- logger.debug("Send command - get memorized WiFi list upload command")
188
- return self.send_order_msg_net(build)
189
- self.get_record_wifi_list2()
190
-
191
- def get_record_wifi_list2(self) -> None:
192
- pass
193
- # self.messageNavigation.post_custom_data(
194
- # self.get_json_string(69)) # ToDo: Fix this
195
-
196
- def close_clear_connect_current_wifi(self, ssid: str, status: int, is_binary: bool) -> bytes:
197
- if is_binary:
198
- build = dev_net_pb2.DevNet(
199
- todev_ble_sync=1,
200
- todev_Wifi_Configuration=dev_net_pb2.DrvWifiSet(configParam=status, Confssid=ssid),
201
- )
202
- logger.debug(
203
- f"Send command - set network (disconnect, direct connect, forget, no operation reconnect) operation command (downlink ssid={ssid}, status={status})"
204
- )
205
- return self.send_order_msg_net(build)
206
- self.close_clear_connect_current_wifi2(ssid, status)
207
-
208
- def close_clear_connect_current_wifi2(self, ssid: str, get_msg_cmd: int) -> None:
209
- data = {"ssid": ssid, "getMsgCmd": get_msg_cmd}
210
- # self.messageNavigation.post_custom_data(
211
- # ToDo: Fix this
212
- # self.get_json_string(bleOrderCmd.close_clear_connect_current_wifi, data).encode())
205
+ return self.send_order_msg_net(build)
@@ -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)