pymammotion 0.5.69__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.
Files changed (154) hide show
  1. pymammotion/__init__.py +53 -0
  2. pymammotion/agora/__init__.py +0 -0
  3. pymammotion/agora/agora_api.py +755 -0
  4. pymammotion/agora/agora_rtc_capabilities.py +748 -0
  5. pymammotion/agora/agora_websockets.py +1175 -0
  6. pymammotion/aliyun/__init__.py +1 -0
  7. pymammotion/aliyun/client.py +235 -0
  8. pymammotion/aliyun/cloud_gateway.py +982 -0
  9. pymammotion/aliyun/model/aep_response.py +21 -0
  10. pymammotion/aliyun/model/connect_response.py +51 -0
  11. pymammotion/aliyun/model/dev_by_account_response.py +195 -0
  12. pymammotion/aliyun/model/login_by_oauth_response.py +64 -0
  13. pymammotion/aliyun/model/regions_response.py +29 -0
  14. pymammotion/aliyun/model/session_by_authcode_response.py +19 -0
  15. pymammotion/aliyun/model/thing_response.py +12 -0
  16. pymammotion/aliyun/regions.py +62 -0
  17. pymammotion/aliyun/tea/core.py +297 -0
  18. pymammotion/aliyun/tmp_constant.py +171 -0
  19. pymammotion/bluetooth/__init__.py +1 -0
  20. pymammotion/bluetooth/ble.py +62 -0
  21. pymammotion/bluetooth/ble_message.py +676 -0
  22. pymammotion/bluetooth/const.py +27 -0
  23. pymammotion/bluetooth/data/__init__.py +0 -0
  24. pymammotion/bluetooth/data/convert.py +25 -0
  25. pymammotion/bluetooth/data/framectrldata.py +40 -0
  26. pymammotion/bluetooth/data/notifydata.py +62 -0
  27. pymammotion/bluetooth/model/__init__.py +0 -0
  28. pymammotion/bluetooth/model/atomic_integer.py +54 -0
  29. pymammotion/const.py +13 -0
  30. pymammotion/data/__init__.py +0 -0
  31. pymammotion/data/model/__init__.py +8 -0
  32. pymammotion/data/model/account.py +8 -0
  33. pymammotion/data/model/device.py +192 -0
  34. pymammotion/data/model/device_config.py +72 -0
  35. pymammotion/data/model/device_info.py +60 -0
  36. pymammotion/data/model/device_limits.py +49 -0
  37. pymammotion/data/model/enums.py +77 -0
  38. pymammotion/data/model/errors.py +12 -0
  39. pymammotion/data/model/events.py +14 -0
  40. pymammotion/data/model/generate_geojson.py +565 -0
  41. pymammotion/data/model/generate_route_information.py +26 -0
  42. pymammotion/data/model/hash_list.py +475 -0
  43. pymammotion/data/model/location.py +36 -0
  44. pymammotion/data/model/mowing_modes.py +77 -0
  45. pymammotion/data/model/rapid_state.py +45 -0
  46. pymammotion/data/model/raw_data.py +215 -0
  47. pymammotion/data/model/region_data.py +102 -0
  48. pymammotion/data/model/report_info.py +182 -0
  49. pymammotion/data/model/work.py +27 -0
  50. pymammotion/data/mower_state_manager.py +369 -0
  51. pymammotion/data/mqtt/__init__.py +1 -0
  52. pymammotion/data/mqtt/event.py +227 -0
  53. pymammotion/data/mqtt/mammotion_properties.py +276 -0
  54. pymammotion/data/mqtt/properties.py +203 -0
  55. pymammotion/data/mqtt/status.py +57 -0
  56. pymammotion/event/__init__.py +6 -0
  57. pymammotion/event/event.py +96 -0
  58. pymammotion/homeassistant/__init__.py +3 -0
  59. pymammotion/homeassistant/mower_api.py +514 -0
  60. pymammotion/homeassistant/rtk_api.py +54 -0
  61. pymammotion/http/__init__.py +0 -0
  62. pymammotion/http/encryption.py +220 -0
  63. pymammotion/http/http.py +673 -0
  64. pymammotion/http/model/__init__.py +0 -0
  65. pymammotion/http/model/camera_stream.py +31 -0
  66. pymammotion/http/model/http.py +249 -0
  67. pymammotion/http/model/response_factory.py +61 -0
  68. pymammotion/http/model/rtk.py +16 -0
  69. pymammotion/mammotion/__init__.py +0 -0
  70. pymammotion/mammotion/commands/__init__.py +0 -0
  71. pymammotion/mammotion/commands/abstract_message.py +24 -0
  72. pymammotion/mammotion/commands/mammotion_command.py +81 -0
  73. pymammotion/mammotion/commands/messages/__init__.py +0 -0
  74. pymammotion/mammotion/commands/messages/basestation.py +43 -0
  75. pymammotion/mammotion/commands/messages/driver.py +122 -0
  76. pymammotion/mammotion/commands/messages/media.py +87 -0
  77. pymammotion/mammotion/commands/messages/navigation.py +564 -0
  78. pymammotion/mammotion/commands/messages/network.py +205 -0
  79. pymammotion/mammotion/commands/messages/ota.py +38 -0
  80. pymammotion/mammotion/commands/messages/system.py +330 -0
  81. pymammotion/mammotion/commands/messages/video.py +33 -0
  82. pymammotion/mammotion/control/__init__.py +0 -0
  83. pymammotion/mammotion/control/joystick.py +145 -0
  84. pymammotion/mammotion/devices/__init__.py +29 -0
  85. pymammotion/mammotion/devices/base.py +163 -0
  86. pymammotion/mammotion/devices/mammotion.py +571 -0
  87. pymammotion/mammotion/devices/mammotion_bluetooth.py +496 -0
  88. pymammotion/mammotion/devices/mammotion_cloud.py +355 -0
  89. pymammotion/mammotion/devices/mammotion_mower_ble.py +48 -0
  90. pymammotion/mammotion/devices/mammotion_mower_cloud.py +39 -0
  91. pymammotion/mammotion/devices/managers/managers.py +81 -0
  92. pymammotion/mammotion/devices/mower_device.py +120 -0
  93. pymammotion/mammotion/devices/mower_manager.py +107 -0
  94. pymammotion/mammotion/devices/rtk_ble.py +89 -0
  95. pymammotion/mammotion/devices/rtk_cloud.py +115 -0
  96. pymammotion/mammotion/devices/rtk_device.py +50 -0
  97. pymammotion/mammotion/devices/rtk_manager.py +125 -0
  98. pymammotion/mqtt/__init__.py +6 -0
  99. pymammotion/mqtt/aliyun_mqtt.py +237 -0
  100. pymammotion/mqtt/linkkit/__init__.py +5 -0
  101. pymammotion/mqtt/linkkit/h2client.py +585 -0
  102. pymammotion/mqtt/linkkit/linkkit.py +3025 -0
  103. pymammotion/mqtt/mammotion_future.py +26 -0
  104. pymammotion/mqtt/mammotion_mqtt.py +214 -0
  105. pymammotion/mqtt/mqtt_models.py +66 -0
  106. pymammotion/proto/__init__.py +4841 -0
  107. pymammotion/proto/basestation.proto +51 -0
  108. pymammotion/proto/basestation_pb2.py +35 -0
  109. pymammotion/proto/basestation_pb2.pyi +89 -0
  110. pymammotion/proto/common.proto +7 -0
  111. pymammotion/proto/common_pb2.py +25 -0
  112. pymammotion/proto/common_pb2.pyi +13 -0
  113. pymammotion/proto/dev_net.proto +321 -0
  114. pymammotion/proto/dev_net_pb2.py +111 -0
  115. pymammotion/proto/dev_net_pb2.pyi +515 -0
  116. pymammotion/proto/luba_msg.proto +76 -0
  117. pymammotion/proto/luba_msg_pb2.py +41 -0
  118. pymammotion/proto/luba_msg_pb2.pyi +97 -0
  119. pymammotion/proto/luba_mul.proto +129 -0
  120. pymammotion/proto/luba_mul_pb2.py +61 -0
  121. pymammotion/proto/luba_mul_pb2.pyi +178 -0
  122. pymammotion/proto/mctrl_driver.proto +107 -0
  123. pymammotion/proto/mctrl_driver_pb2.py +57 -0
  124. pymammotion/proto/mctrl_driver_pb2.pyi +167 -0
  125. pymammotion/proto/mctrl_nav.proto +591 -0
  126. pymammotion/proto/mctrl_nav_pb2.py +136 -0
  127. pymammotion/proto/mctrl_nav_pb2.pyi +1067 -0
  128. pymammotion/proto/mctrl_ota.proto +80 -0
  129. pymammotion/proto/mctrl_ota_pb2.py +45 -0
  130. pymammotion/proto/mctrl_ota_pb2.pyi +128 -0
  131. pymammotion/proto/mctrl_pept.proto +34 -0
  132. pymammotion/proto/mctrl_pept_pb2.py +33 -0
  133. pymammotion/proto/mctrl_pept_pb2.pyi +58 -0
  134. pymammotion/proto/mctrl_sys.proto +741 -0
  135. pymammotion/proto/mctrl_sys_pb2.py +206 -0
  136. pymammotion/proto/mctrl_sys_pb2.pyi +1213 -0
  137. pymammotion/proto/message_pool.py +3 -0
  138. pymammotion/proto/py.typed +0 -0
  139. pymammotion/py.typed +0 -0
  140. pymammotion/utility/constant/__init__.py +3 -0
  141. pymammotion/utility/constant/device_constant.py +315 -0
  142. pymammotion/utility/conversions.py +5 -0
  143. pymammotion/utility/datatype_converter.py +124 -0
  144. pymammotion/utility/device_config.py +755 -0
  145. pymammotion/utility/device_type.py +489 -0
  146. pymammotion/utility/map.py +259 -0
  147. pymammotion/utility/movement.py +18 -0
  148. pymammotion/utility/mur_mur_hash.py +159 -0
  149. pymammotion/utility/periodic.py +106 -0
  150. pymammotion/utility/rocker_util.py +194 -0
  151. pymammotion-0.5.69.dist-info/METADATA +93 -0
  152. pymammotion-0.5.69.dist-info/RECORD +154 -0
  153. pymammotion-0.5.69.dist-info/WHEEL +4 -0
  154. pymammotion-0.5.69.dist-info/licenses/LICENSE +674 -0
@@ -0,0 +1,205 @@
1
+ # === sendOrderMsg_Net ===
2
+ from abc import ABC
3
+ import time
4
+
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,
38
+ version=1,
39
+ subtype=self.user_account,
40
+ net=build,
41
+ timestamp=round(time.time() * 1000),
42
+ )
43
+
44
+ return luba_msg.SerializeToString()
45
+
46
+ def send_todev_ble_sync(self, sync_type: int) -> bytes:
47
+ comm_esp = DevNet(todev_ble_sync=sync_type)
48
+ return self.send_order_msg_net(comm_esp)
49
+
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))
53
+
54
+ return self.send_order_msg_net(net)
55
+
56
+ def get_device_base_info(self) -> bytes:
57
+ net = DevNet(todev_devinfo_req=DrvDevInfoReq())
58
+
59
+ for i in range(1, 8):
60
+ if i == 1:
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))
63
+
64
+ return self.send_order_msg_net(net)
65
+
66
+ def get_4g_module_info(self) -> bytes:
67
+ build = DevNet(todev_get_mnet_cfg_req=DevNet().todev_get_mnet_cfg_req)
68
+ logger.debug("Send command -- Get device 4G network module information")
69
+ return self.send_order_msg_net(build)
70
+
71
+ def get_4g_info(self) -> bytes:
72
+ build = DevNet(todev_mnet_info_req=DevNet().todev_mnet_info_req)
73
+ logger.debug("Send command -- Get device 4G network information")
74
+ return self.send_order_msg_net(build)
75
+
76
+ def set_zmq_enable(self) -> bytes:
77
+ build = DevNet(
78
+ todev_set_dds2_zmq=DrvDebugDdsZmq(
79
+ is_enable=True,
80
+ rx_topic_name="perception_post_result",
81
+ tx_zmq_url="tcp://0.0.0.0:5555",
82
+ )
83
+ )
84
+ logger.debug("Send command -- Set vision ZMQ to enable")
85
+ return self.send_order_msg_net(build)
86
+
87
+ def set_iot_setting(self, iot_control_type: IotConctrlType) -> bytes:
88
+ build = DevNet(todev_set_iot_offline_req=iot_control_type)
89
+ logger.debug("Send command -- Device re-online")
90
+ return self.send_order_msg_net(build)
91
+
92
+ def set_device_log_upload(
93
+ self,
94
+ request_id: str,
95
+ operation: int,
96
+ server_ip: int,
97
+ server_port: int,
98
+ number: int,
99
+ type: int,
100
+ ) -> bytes:
101
+ build = DrvUploadFileToAppReq(
102
+ biz_id=request_id,
103
+ operation=operation,
104
+ server_ip=server_ip,
105
+ server_port=server_port,
106
+ num=number,
107
+ type=type,
108
+ )
109
+ logger.debug(
110
+ f"Send log====Feedback====Command======requestID:{request_id} operation:{operation} serverIp:{server_ip} type:{type}"
111
+ )
112
+ return self.send_order_msg_net(DevNet(todev_ble_sync=1, todev_uploadfile_req=build))
113
+
114
+ def set_device_socket_request(
115
+ self,
116
+ request_id: str,
117
+ operation: int,
118
+ server_ip: int,
119
+ server_port: int,
120
+ number: int,
121
+ type: int,
122
+ ) -> bytes:
123
+ """Set device socket request (bluetooth only)."""
124
+ build = DrvUploadFileToAppReq(
125
+ biz_id=request_id,
126
+ operation=operation,
127
+ server_ip=server_ip,
128
+ server_port=server_port,
129
+ num=number,
130
+ type=type,
131
+ )
132
+ logger.debug(
133
+ f"Send log====Feedback====Command======requestID:{request_id} operation:{operation} serverIp:{server_ip} type:{type}"
134
+ )
135
+ return self.send_order_msg_net(DevNet(todev_ble_sync=1, todev_uploadfile_req=build))
136
+
137
+ def get_device_log_info(self, biz_id: str, type: int, log_url: str) -> bytes:
138
+ """Get device log info (bluetooth only)."""
139
+ return self.send_order_msg_net(
140
+ DevNet(
141
+ todev_ble_sync=1,
142
+ todev_req_log_info=DrvUploadFileReq(
143
+ biz_id=biz_id,
144
+ type=type,
145
+ url=log_url,
146
+ num=0,
147
+ user_id="", # TODO supply user id
148
+ ),
149
+ )
150
+ )
151
+
152
+ def cancel_log_update(self, biz_id: str) -> bytes:
153
+ """Cancel log update (bluetooth only)."""
154
+ return self.send_order_msg_net(DevNet(todev_log_data_cancel=DrvUploadFileCancel(biz_id=biz_id)))
155
+
156
+ def get_device_network_info(self) -> bytes:
157
+ build = DevNet(todev_networkinfo_req=GetNetworkInfoReq(req_ids=1))
158
+ logger.debug("Send command - get device network information")
159
+ return self.send_order_msg_net(build)
160
+
161
+ def set_device_4g_enable_status(self, new_4g_status: bool) -> bytes:
162
+ build = DevNet(
163
+ todev_ble_sync=1,
164
+ todev_set_mnet_cfg_req=SetMnetCfgReq(
165
+ cfg=MnetCfg(
166
+ type=NetType.WIFI,
167
+ inet_enable=new_4g_status,
168
+ mnet_enable=new_4g_status,
169
+ )
170
+ ),
171
+ )
172
+
173
+ logger.debug(f"Send command - set 4G (on/off status). newWifiStatus={new_4g_status}")
174
+ return self.send_order_msg_net(build)
175
+
176
+ def set_device_wifi_enable_status(self, new_wifi_status: bool) -> bytes:
177
+ build = DevNet(
178
+ todev_ble_sync=1,
179
+ todev_wifi_configuration=DrvWifiSet(config_param=4, wifi_enable=new_wifi_status),
180
+ )
181
+ logger.debug(f"szNetwork: Send command - set network (on/off status). newWifiStatus={new_wifi_status}")
182
+ return self.send_order_msg_net(build)
183
+
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
+ )
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)
@@ -0,0 +1,38 @@
1
+ # === sendOrderMsg_Ota ===
2
+ from abc import ABC
3
+ import logging
4
+
5
+ from pymammotion.mammotion.commands.abstract_message import AbstractMessage
6
+ from pymammotion.proto import GetInfoReq, InfoType, LubaMsg, MctlOta, MsgAttr, MsgCmdType, MsgDevice
7
+
8
+ _LOGGER = logging.getLogger(__name__)
9
+
10
+
11
+ class MessageOta(AbstractMessage, ABC):
12
+ """Message OTA class."""
13
+
14
+ def send_order_msg_ota(self, ota):
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,
21
+ version=1,
22
+ subtype=self.user_account,
23
+ ota=ota,
24
+ )
25
+
26
+ return luba_msg.SerializeToString()
27
+
28
+ def get_device_ota_info(self, log_type: int):
29
+ todev_get_info_req = MctlOta(todev_get_info_req=GetInfoReq(type=InfoType.IT_OTA))
30
+
31
+ _LOGGER.debug("===Send command to get upgrade details===logType:" + str(log_type))
32
+ return self.send_order_msg_ota(todev_get_info_req)
33
+
34
+ def get_device_info_new(self) -> bytes:
35
+ """New device call for OTA upgrade 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
+ return self.send_order_msg_ota(todev_get_info_req)
@@ -0,0 +1,330 @@
1
+ # === sendOrderMsg_Sys ===
2
+ from abc import ABC
3
+ import datetime
4
+ import time
5
+
6
+ from pymammotion import logger
7
+ from pymammotion.mammotion.commands.abstract_message import AbstractMessage
8
+ from pymammotion.proto import (
9
+ DeviceProductTypeInfoT,
10
+ LoraCfgReq,
11
+ LubaMsg,
12
+ MctlSys,
13
+ MCtrlSimulationCmdData,
14
+ MsgAttr,
15
+ MsgCmdType,
16
+ MsgDevice,
17
+ ReportInfoCfg,
18
+ RptAct,
19
+ RptInfoType,
20
+ SysCommCmd,
21
+ SysKnifeControl,
22
+ SysSetDateTime,
23
+ TimeCtrlLight,
24
+ )
25
+
26
+
27
+ class MessageSystem(AbstractMessage, ABC):
28
+ def send_order_msg_sys(self, sys) -> bytes:
29
+ luba_msg = LubaMsg(
30
+ msgtype=MsgCmdType.EMBED_SYS,
31
+ msgattr=MsgAttr.REQ,
32
+ sender=MsgDevice.DEV_MOBILEAPP,
33
+ rcver=self.get_msg_device(MsgCmdType.EMBED_SYS, MsgDevice.DEV_MAINCTL),
34
+ sys=sys,
35
+ seqs=self.seqs.increment_and_get() & 255,
36
+ version=1,
37
+ subtype=self.user_account,
38
+ timestamp=round(time.time() * 1000),
39
+ )
40
+
41
+ return luba_msg.SerializeToString()
42
+
43
+ def send_order_msg_sys_legacy(self, sys) -> bytes:
44
+ luba_msg = LubaMsg(
45
+ msgtype=MsgCmdType.EMBED_SYS,
46
+ msgattr=MsgAttr.REQ,
47
+ sender=MsgDevice.DEV_MOBILEAPP,
48
+ rcver=MsgDevice.DEV_MAINCTL,
49
+ sys=sys,
50
+ seqs=self.seqs.increment_and_get() & 255,
51
+ version=1,
52
+ subtype=self.user_account,
53
+ timestamp=round(time.time() * 1000),
54
+ )
55
+
56
+ return luba_msg.SerializeToString()
57
+
58
+ def reset_system(self) -> bytes:
59
+ build = MctlSys(todev_reset_system=1)
60
+ logger.debug("Send command - send factory reset")
61
+ return self.send_order_msg_sys(build)
62
+
63
+ def set_blade_control(self, on_off: int) -> bytes:
64
+ mctlsys = MctlSys()
65
+ sys_knife_control = SysKnifeControl()
66
+ sys_knife_control.knife_status = on_off
67
+ mctlsys.todev_knife_ctrl = sys_knife_control
68
+
69
+ return self.send_order_msg_sys(mctlsys)
70
+
71
+ def get_device_product_model(self) -> bytes:
72
+ return self.send_order_msg_sys(MctlSys(device_product_type_info=DeviceProductTypeInfoT(result=1)))
73
+
74
+ def read_and_set_sidelight(self, is_sidelight: bool, operate: int) -> bytes:
75
+ """Read state of sidelight as well as set it."""
76
+ if is_sidelight:
77
+ build = TimeCtrlLight(
78
+ operate=operate,
79
+ enable=0,
80
+ action=0,
81
+ start_hour=0,
82
+ start_min=0,
83
+ end_hour=0,
84
+ end_min=0,
85
+ )
86
+ else:
87
+ build = TimeCtrlLight(
88
+ operate=operate,
89
+ enable=1,
90
+ action=0,
91
+ start_hour=0,
92
+ start_min=0,
93
+ end_hour=0,
94
+ end_min=0,
95
+ )
96
+ logger.debug(f"Send read and write sidelight command is_sidelight:{
97
+ is_sidelight}, operate:{operate}")
98
+ build2 = MctlSys(todev_time_ctrl_light=build)
99
+ logger.debug(f"Send command - send read and write sidelight command is_sidelight:{
100
+ is_sidelight}, operate:{operate}, timeCtrlLight:{build}")
101
+ return self.send_order_msg_sys(build2)
102
+
103
+ def test_tool_order_to_sys(self, sub_cmd: int, param_id: int, param_value: list[int]) -> bytes:
104
+ build = MCtrlSimulationCmdData(sub_cmd=sub_cmd, param_id=param_id, param_value=param_value)
105
+ logger.debug(f"Send tool test command: subCmd={sub_cmd}, param_id:{
106
+ param_id}, param_value={param_value}")
107
+ build2 = MctlSys(simulation_cmd=build)
108
+ logger.debug(f"Send tool test command: subCmd={sub_cmd}, param_id:{
109
+ param_id}, param_value={param_value}")
110
+ return self.send_order_msg_sys(build2)
111
+
112
+ def read_and_set_rtk_paring_code(self, op: int, cgf: str | None = None) -> bytes:
113
+ logger.debug(f"Send read and write base station configuration quality op:{
114
+ op}, cgf:{cgf}")
115
+ return self.send_order_msg_sys(MctlSys(todev_lora_cfg_req=LoraCfgReq(op=op, cfg=cgf)))
116
+
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}")
120
+ return self.send_order_msg_sys(build)
121
+
122
+ # Commented out as not needed and too many refs to try fix up
123
+ # def factory_test_order(self, test_id: int, test_duration: int, expect: str):
124
+ # new_builder = mow_to_app_qctools_info_t.Builder()
125
+ # logger.debug(f"Factory tool logger.debug, expect={expect}")
126
+ # if not expect:
127
+ # build = new_builder.set_type_value(
128
+ # test_id).set_time_of_duration(test_duration).build()
129
+ # else:
130
+ # try:
131
+ # json_array = json.loads(expect)
132
+ # z2 = True
133
+ # for i in range(len(json_array)):
134
+ # new_builder2 = QCAppTestExcept.Builder()
135
+ # json_object = json_array[i]
136
+ # if "except_type" in json_object:
137
+ # string = json_object["except_type"]
138
+ # if "conditions" in json_object:
139
+ # json_array2 = json_object["conditions"]
140
+ # for i2 in range(len(json_array2)):
141
+ # json_object2 = json_array2[i2]
142
+ # new_builder3 = QCAppTestConditions.Builder()
143
+ # if "cond_type" in json_object2:
144
+ # new_builder3.set_cond_type(
145
+ # json_object2["cond_type"])
146
+ # else:
147
+ # z2 = False
148
+ # if "value" in json_object2:
149
+ # obj = json_object2["value"]
150
+ # if string == "int":
151
+ # new_builder3.set_int_val(int(obj))
152
+ # elif string == "float":
153
+ # new_builder3.set_float_val(float(obj))
154
+ # elif string == "double":
155
+ # new_builder3.set_double_val(float(obj))
156
+ # elif string == "string":
157
+ # new_builder3.set_string_val(str(obj))
158
+ # else:
159
+ # z2 = False
160
+ # new_builder2.add_conditions(new_builder3)
161
+ # else:
162
+ # z2 = False
163
+ # new_builder2.set_except_type(string)
164
+ # new_builder.add_except(new_builder2)
165
+ # new_builder2.clear()
166
+ # z = z2
167
+ # except json.JSONDecodeError:
168
+ # z = False
169
+ # if z:
170
+ # build = new_builder.set_type_value(
171
+ # test_id).set_time_of_duration(test_duration).build()
172
+ # else:
173
+ # build = new_builder.set_type_value(
174
+ # test_id).set_time_of_duration(test_duration).build()
175
+ # logger.debug(f"Factory tool logger.debug, mow_to_app_qctools_info_t={
176
+ # build.except_count}, mow_to_app_qctools_info_t22={build.except_list}")
177
+ # build2 = MctlSys(mow_to_app_qctools_info=build)
178
+ # logger.debug(f"Send command - factory tool test command testId={
179
+ # test_id}, testDuration={test_duration}", "Factory tool logger.debug222", True)
180
+ # return self.send_order_msg_sys(build2)
181
+
182
+ def send_sys_set_date_time(self) -> bytes:
183
+ # TODO get HA timezone
184
+ calendar = datetime.datetime.now()
185
+ i = calendar.year
186
+ i2 = calendar.month
187
+ i3 = calendar.day
188
+ i4 = calendar.isoweekday()
189
+ i5 = calendar.hour
190
+ i6 = calendar.minute
191
+ i7 = calendar.second
192
+ i8 = calendar.utcoffset().total_seconds() // 60 if calendar.utcoffset() else 0
193
+ i9 = 1 if calendar.dst() else 0
194
+ logger.debug(f"Print time zone, time zone={
195
+ i8}, daylight saving time={i9} week={i4}")
196
+ build = MctlSys(
197
+ todev_data_time=SysSetDateTime(
198
+ year=i,
199
+ month=i2,
200
+ date=i3,
201
+ week=i4,
202
+ hours=i5,
203
+ minutes=i6,
204
+ seconds=i7,
205
+ time_zone=i8,
206
+ daylight=i9,
207
+ )
208
+ )
209
+ logger.debug(
210
+ f"Send command - synchronize time zone={i8}, daylight saving time={i9} week={i4}, day:{
211
+ i3}, month:{i2}, hours:{i5}, minutes:{i6}, seconds:{i7}, year={i}",
212
+ "Time synchronization",
213
+ True,
214
+ )
215
+ return self.send_order_msg_sys(build)
216
+
217
+ def get_device_version_info(self) -> bytes:
218
+ return self.send_order_msg_sys(MctlSys(todev_get_dev_fw_info=1))
219
+
220
+ def read_and_set_rtk_pairing_code(self, op: int, cfg: str) -> bytes:
221
+ return self.send_order_msg_sys(MctlSys(todev_lora_cfg_req=LoraCfgReq(op=op, cfg=cfg)))
222
+
223
+ # === sendOrderMsg_Sys2 ===
224
+
225
+ def request_iot_sys(
226
+ self,
227
+ rpt_act: RptAct,
228
+ rpt_info_type: list[RptInfoType | str] | None,
229
+ timeout: int,
230
+ period: int,
231
+ no_change_period: int,
232
+ count: int,
233
+ ) -> bytes:
234
+ build = MctlSys(
235
+ todev_report_cfg=ReportInfoCfg(
236
+ act=rpt_act,
237
+ sub=rpt_info_type,
238
+ timeout=timeout,
239
+ period=period,
240
+ no_change_period=no_change_period,
241
+ count=count,
242
+ )
243
+ )
244
+ logger.debug(f"Send command==== IOT slim data Act {
245
+ build.todev_report_cfg.act}")
246
+ return self.send_order_msg_sys_legacy(build)
247
+
248
+ def get_maintenance(self) -> bytes:
249
+ return self.request_iot_sys(
250
+ rpt_act=RptAct.RPT_START,
251
+ rpt_info_type=[
252
+ RptInfoType.RIT_MAINTAIN,
253
+ RptInfoType.RIT_BASESTATION_INFO,
254
+ RptInfoType.RIT_FW_INFO,
255
+ ],
256
+ timeout=1000,
257
+ period=1000,
258
+ no_change_period=2000,
259
+ count=3,
260
+ )
261
+
262
+ def get_report_cfg_stop(self, timeout: int = 10000, period: int = 1000, no_change_period: int = 1000):
263
+ # TODO use send_order_msg_sys_legacy
264
+ mctl_sys = MctlSys(
265
+ todev_report_cfg=ReportInfoCfg(
266
+ act=RptAct.RPT_STOP,
267
+ timeout=timeout,
268
+ period=period,
269
+ no_change_period=no_change_period,
270
+ count=1,
271
+ )
272
+ )
273
+
274
+ mctl_sys.todev_report_cfg.sub.append(RptInfoType.RIT_CONNECT)
275
+ mctl_sys.todev_report_cfg.sub.append(RptInfoType.RIT_RTK)
276
+ mctl_sys.todev_report_cfg.sub.append(RptInfoType.RIT_DEV_LOCAL)
277
+ mctl_sys.todev_report_cfg.sub.append(RptInfoType.RIT_WORK)
278
+ mctl_sys.todev_report_cfg.sub.append(RptInfoType.RIT_DEV_STA)
279
+ mctl_sys.todev_report_cfg.sub.append(RptInfoType.RIT_VISION_POINT)
280
+ mctl_sys.todev_report_cfg.sub.append(RptInfoType.RIT_VIO)
281
+ mctl_sys.todev_report_cfg.sub.append(RptInfoType.RIT_VISION_STATISTIC)
282
+
283
+ luba_msg = LubaMsg(
284
+ msgtype=MsgCmdType.EMBED_SYS,
285
+ sender=MsgDevice.DEV_MOBILEAPP,
286
+ rcver=MsgDevice.DEV_MAINCTL,
287
+ msgattr=MsgAttr.REQ,
288
+ seqs=self.seqs.increment_and_get() & 255,
289
+ version=1,
290
+ subtype=self.user_account,
291
+ sys=mctl_sys,
292
+ timestamp=round(time.time() * 1000),
293
+ )
294
+
295
+ return luba_msg.SerializeToString()
296
+
297
+ def get_report_cfg(self, timeout: int = 10000, period: int = 1000, no_change_period: int = 2000):
298
+ # TODO use send_order_msg_sys_legacy
299
+ mctl_sys = MctlSys(
300
+ todev_report_cfg=ReportInfoCfg(
301
+ act=RptAct.RPT_START,
302
+ timeout=timeout,
303
+ period=period,
304
+ no_change_period=no_change_period,
305
+ count=1,
306
+ )
307
+ )
308
+
309
+ mctl_sys.todev_report_cfg.sub.append(RptInfoType.RIT_CONNECT)
310
+ mctl_sys.todev_report_cfg.sub.append(RptInfoType.RIT_RTK)
311
+ mctl_sys.todev_report_cfg.sub.append(RptInfoType.RIT_DEV_LOCAL)
312
+ mctl_sys.todev_report_cfg.sub.append(RptInfoType.RIT_WORK)
313
+ mctl_sys.todev_report_cfg.sub.append(RptInfoType.RIT_DEV_STA)
314
+ mctl_sys.todev_report_cfg.sub.append(RptInfoType.RIT_VISION_POINT)
315
+ mctl_sys.todev_report_cfg.sub.append(RptInfoType.RIT_VIO)
316
+ mctl_sys.todev_report_cfg.sub.append(RptInfoType.RIT_VISION_STATISTIC)
317
+ mctl_sys.todev_report_cfg.sub.append(RptInfoType.RIT_BASESTATION_INFO)
318
+
319
+ luba_msg = LubaMsg(
320
+ msgtype=MsgCmdType.EMBED_SYS,
321
+ sender=MsgDevice.DEV_MOBILEAPP,
322
+ rcver=MsgDevice.DEV_MAINCTL,
323
+ msgattr=MsgAttr.REQ,
324
+ seqs=self.seqs.increment_and_get() & 255,
325
+ version=1,
326
+ subtype=self.user_account,
327
+ sys=mctl_sys,
328
+ timestamp=round(time.time() * 1000),
329
+ )
330
+ return luba_msg.SerializeToString()
@@ -0,0 +1,33 @@
1
+ # === sendOrderMsg_Video ===
2
+ from abc import ABC
3
+ import time
4
+
5
+ from pymammotion.mammotion.commands.abstract_message import AbstractMessage
6
+ from pymammotion.proto import LubaMsg, MsgAttr, MsgCmdType, MsgDevice, MulCameraPosition, MulSetVideo, SocMul
7
+ from pymammotion.utility.device_type import DeviceType
8
+
9
+
10
+ class MessageVideo(AbstractMessage, ABC):
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),
17
+ mul=mul,
18
+ seqs=self.seqs.increment_and_get() & 255,
19
+ version=1,
20
+ subtype=self.user_account,
21
+ timestamp=round(time.time() * 1000),
22
+ )
23
+
24
+ return luba_msg.SerializeToString()
25
+
26
+ def device_agora_join_channel_with_position(self, enter_state: int):
27
+ position = (
28
+ MulCameraPosition.ALL
29
+ if DeviceType.value_of_str(self.get_device_name()).get_value() == DeviceType.LUBA_YUKA.get_value()
30
+ else MulCameraPosition.LEFT
31
+ )
32
+ soc_mul = SocMul(set_video=MulSetVideo(position=position, vi_switch=enter_state))
33
+ return self.send_order_msg_video(soc_mul)
File without changes