pymammotion 0.0.37__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 (106) hide show
  1. pymammotion/__init__.py +43 -0
  2. pymammotion/aliyun/cloud_gateway.py +549 -0
  3. pymammotion/aliyun/cloud_service.py +65 -0
  4. pymammotion/aliyun/dataclass/aep_response.py +18 -0
  5. pymammotion/aliyun/dataclass/connect_response.py +51 -0
  6. pymammotion/aliyun/dataclass/dev_by_account_response.py +43 -0
  7. pymammotion/aliyun/dataclass/login_by_oauth_response.py +65 -0
  8. pymammotion/aliyun/dataclass/regions_response.py +26 -0
  9. pymammotion/aliyun/dataclass/session_by_authcode_response.py +18 -0
  10. pymammotion/aliyun/tmp_constant.py +175 -0
  11. pymammotion/bluetooth/__init__.py +1 -0
  12. pymammotion/bluetooth/ble.py +74 -0
  13. pymammotion/bluetooth/ble_message.py +430 -0
  14. pymammotion/bluetooth/const.py +27 -0
  15. pymammotion/bluetooth/data/__init__.py +0 -0
  16. pymammotion/bluetooth/data/convert.py +26 -0
  17. pymammotion/bluetooth/data/framectrldata.py +40 -0
  18. pymammotion/bluetooth/data/notifydata.py +63 -0
  19. pymammotion/const.py +9 -0
  20. pymammotion/data/__init__.py +0 -0
  21. pymammotion/data/model/__init__.py +8 -0
  22. pymammotion/data/model/device.py +157 -0
  23. pymammotion/data/model/enums.py +67 -0
  24. pymammotion/data/model/excute_boarder_params.py +48 -0
  25. pymammotion/data/model/execute_boarder.py +36 -0
  26. pymammotion/data/model/generate_route_information.py +133 -0
  27. pymammotion/data/model/hash_list.py +17 -0
  28. pymammotion/data/model/mowing_modes.py +37 -0
  29. pymammotion/data/model/plan.py +58 -0
  30. pymammotion/data/model/rapid_state.py +45 -0
  31. pymammotion/data/model/region_data.py +99 -0
  32. pymammotion/data/mqtt/__init__.py +1 -0
  33. pymammotion/data/mqtt/event.py +90 -0
  34. pymammotion/data/mqtt/properties.py +140 -0
  35. pymammotion/data/mqtt/status.py +52 -0
  36. pymammotion/event/__init__.py +6 -0
  37. pymammotion/event/event.py +50 -0
  38. pymammotion/http/_init_.py +0 -0
  39. pymammotion/http/http.py +76 -0
  40. pymammotion/luba/_init_.py +0 -0
  41. pymammotion/luba/base.py +52 -0
  42. pymammotion/mammotion/__init__.py +0 -0
  43. pymammotion/mammotion/commands/__init__.py +0 -0
  44. pymammotion/mammotion/commands/abstract_message.py +7 -0
  45. pymammotion/mammotion/commands/mammotion_command.py +34 -0
  46. pymammotion/mammotion/commands/messages/__init__.py +0 -0
  47. pymammotion/mammotion/commands/messages/driver.py +108 -0
  48. pymammotion/mammotion/commands/messages/media.py +36 -0
  49. pymammotion/mammotion/commands/messages/navigation.py +535 -0
  50. pymammotion/mammotion/commands/messages/network.py +236 -0
  51. pymammotion/mammotion/commands/messages/ota.py +34 -0
  52. pymammotion/mammotion/commands/messages/system.py +266 -0
  53. pymammotion/mammotion/commands/messages/video.py +27 -0
  54. pymammotion/mammotion/control/__init__.py +0 -0
  55. pymammotion/mammotion/control/joystick.py +184 -0
  56. pymammotion/mammotion/devices/__init__.py +1 -0
  57. pymammotion/mammotion/devices/luba.py +564 -0
  58. pymammotion/mqtt/mqtt.py +230 -0
  59. pymammotion/proto/__init__.py +0 -0
  60. pymammotion/proto/common.proto +7 -0
  61. pymammotion/proto/common.py +12 -0
  62. pymammotion/proto/common_pb2.py +25 -0
  63. pymammotion/proto/common_pb2.pyi +13 -0
  64. pymammotion/proto/dev_net.proto +297 -0
  65. pymammotion/proto/dev_net.py +381 -0
  66. pymammotion/proto/dev_net_pb2.py +107 -0
  67. pymammotion/proto/dev_net_pb2.pyi +472 -0
  68. pymammotion/proto/luba_msg.proto +73 -0
  69. pymammotion/proto/luba_msg.py +80 -0
  70. pymammotion/proto/luba_msg_pb2.py +40 -0
  71. pymammotion/proto/luba_msg_pb2.pyi +93 -0
  72. pymammotion/proto/luba_mul.proto +68 -0
  73. pymammotion/proto/luba_mul.py +76 -0
  74. pymammotion/proto/luba_mul_pb2.py +45 -0
  75. pymammotion/proto/luba_mul_pb2.pyi +91 -0
  76. pymammotion/proto/mctrl_driver.proto +67 -0
  77. pymammotion/proto/mctrl_driver.py +100 -0
  78. pymammotion/proto/mctrl_driver_pb2.py +45 -0
  79. pymammotion/proto/mctrl_driver_pb2.pyi +112 -0
  80. pymammotion/proto/mctrl_nav.proto +485 -0
  81. pymammotion/proto/mctrl_nav.py +589 -0
  82. pymammotion/proto/mctrl_nav_pb2.py +116 -0
  83. pymammotion/proto/mctrl_nav_pb2.pyi +875 -0
  84. pymammotion/proto/mctrl_ota.proto +42 -0
  85. pymammotion/proto/mctrl_ota.py +48 -0
  86. pymammotion/proto/mctrl_ota_pb2.py +35 -0
  87. pymammotion/proto/mctrl_ota_pb2.pyi +65 -0
  88. pymammotion/proto/mctrl_pept.proto +29 -0
  89. pymammotion/proto/mctrl_pept.py +41 -0
  90. pymammotion/proto/mctrl_pept_pb2.py +31 -0
  91. pymammotion/proto/mctrl_pept_pb2.pyi +50 -0
  92. pymammotion/proto/mctrl_sys.proto +487 -0
  93. pymammotion/proto/mctrl_sys.py +574 -0
  94. pymammotion/proto/mctrl_sys_pb2.py +142 -0
  95. pymammotion/proto/mctrl_sys_pb2.pyi +787 -0
  96. pymammotion/py.typed +0 -0
  97. pymammotion/utility/constant/__init__.py +1 -0
  98. pymammotion/utility/constant/device_constant.py +238 -0
  99. pymammotion/utility/datatype_converter.py +80 -0
  100. pymammotion/utility/device_type.py +152 -0
  101. pymammotion/utility/periodic.py +41 -0
  102. pymammotion/utility/rocker_util.py +135 -0
  103. pymammotion-0.0.37.dist-info/LICENSE +674 -0
  104. pymammotion-0.0.37.dist-info/METADATA +92 -0
  105. pymammotion-0.0.37.dist-info/RECORD +106 -0
  106. pymammotion-0.0.37.dist-info/WHEEL +4 -0
@@ -0,0 +1,236 @@
1
+ # === sendOrderMsg_Net ===
2
+ import json
3
+ import time
4
+ from typing import Dict
5
+
6
+ from pyluba.aliyun.tmp_constant import tmp_constant
7
+ from pyluba.mammotion.commands.messages.navigation import MessageNavigation
8
+ from pyluba.proto import dev_net_pb2, luba_msg_pb2
9
+
10
+
11
+ class MessageNetwork:
12
+ messageNavigation: MessageNavigation = MessageNavigation()
13
+
14
+ @staticmethod
15
+ def send_order_msg_net(build):
16
+ luba_msg = luba_msg_pb2.LubaMsg(
17
+ msgtype=luba_msg_pb2.MSG_CMD_TYPE_ESP,
18
+ sender=luba_msg_pb2.DEV_MOBILEAPP,
19
+ rcver=luba_msg_pb2.DEV_COMM_ESP,
20
+ msgattr=luba_msg_pb2.MSG_ATTR_REQ,
21
+ seqs=1,
22
+ version=1,
23
+ subtype=1,
24
+ net=build,
25
+ )
26
+
27
+ return luba_msg.SerializeToString()
28
+
29
+ def get_device_base_info(self):
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)
32
+
33
+ return self.send_order_msg_net(net)
34
+
35
+ def get_4g_module_info(self):
36
+ build = dev_net_pb2.DevNet(
37
+ todev_get_mnet_cfg_req=dev_net_pb2.DevNet().todev_get_mnet_cfg_req
38
+ )
39
+ print("Send command -- Get device 4G network module information")
40
+ return self.send_order_msg_net(build)
41
+
42
+ def get_4g_info(self):
43
+ build = dev_net_pb2.DevNet(
44
+ todev_mnet_info_req=dev_net_pb2.DevNet().todev_mnet_info_req
45
+ )
46
+ print("Send command -- Get device 4G network information")
47
+ return self.send_order_msg_net(build)
48
+
49
+ def set_zmq_enable(self):
50
+ build = dev_net_pb2.DevNet(
51
+ todev_set_dds2zmq=dev_net_pb2.DrvDebugDdsZmq(
52
+ is_enable=True,
53
+ rx_topic_name="perception_post_result",
54
+ tx_zmq_url="tcp://0.0.0.0:5555",
55
+ )
56
+ )
57
+ print("Send command -- Set vision ZMQ to enable")
58
+ return self.send_order_msg_net(build)
59
+
60
+ def set_iot_setting(self, iot_control_type: dev_net_pb2.iot_conctrl_type):
61
+ build = dev_net_pb2.DevNet(todev_set_iot_offline_req=iot_control_type)
62
+ print("Send command -- Device re-online")
63
+ return self.send_order_msg_net(build)
64
+
65
+ def set_device_log_upload(
66
+ self,
67
+ request_id: str,
68
+ operation: int,
69
+ server_ip: int,
70
+ server_port: int,
71
+ number: int,
72
+ type: int,
73
+ ):
74
+ build = dev_net_pb2.DrvUploadFileToAppReq(
75
+ bizId=request_id,
76
+ operation=operation,
77
+ serverIp=server_ip,
78
+ serverPort=server_port,
79
+ num=number,
80
+ type=type,
81
+ )
82
+ print(
83
+ f"Send log====Feedback====Command======requestID:{request_id} operation:{operation} serverIp:{server_ip} type:{type}"
84
+ )
85
+ return self.send_order_msg_net(
86
+ dev_net_pb2.DevNet(todev_ble_sync=1, todev_uploadfile_req=build)
87
+ )
88
+
89
+ def set_device_socket_request(
90
+ self,
91
+ request_id: str,
92
+ operation: int,
93
+ server_ip: int,
94
+ server_port: int,
95
+ number: int,
96
+ type: int,
97
+ ) -> bytes:
98
+ """Set device socket request (bluetooth only)."""
99
+ build = dev_net_pb2.DrvUploadFileToAppReq(
100
+ bizId=request_id,
101
+ operation=operation,
102
+ serverIp=server_ip,
103
+ serverPort=server_port,
104
+ num=number,
105
+ type=type,
106
+ )
107
+ print(
108
+ f"Send log====Feedback====Command======requestID:{request_id} operation:{operation} serverIp:{server_ip} type:{type}"
109
+ )
110
+ return self.send_order_msg_net(
111
+ dev_net_pb2.DevNet(todev_ble_sync=1, todev_uploadfile_req=build)
112
+ )
113
+
114
+ def get_device_log_info(self, biz_id: str, type: int, log_url: str) -> bytes:
115
+ """Get device log info (bluetooth only)."""
116
+ return self.send_order_msg_net(
117
+ dev_net_pb2.DevNet(
118
+ todev_ble_sync=1,
119
+ todev_req_log_info=dev_net_pb2.DrvUploadFileReq(
120
+ bizId=biz_id,
121
+ type=type,
122
+ url=log_url,
123
+ num=0,
124
+ userId="", # TODO supply user id
125
+ ),
126
+ )
127
+ )
128
+
129
+ def cancel_log_update(self, biz_id: str):
130
+ """Cancel log update (bluetooth only)."""
131
+ return self.send_order_msg_net(
132
+ dev_net_pb2.DevNet(
133
+ todev_log_data_cancel=dev_net_pb2.DrvUploadFileCancel(bizId=biz_id)
134
+ )
135
+ )
136
+
137
+ def get_device_network_info(self):
138
+ build = dev_net_pb2.DevNet(
139
+ todev_networkinfo_req=dev_net_pb2.GetNetworkInfoReq(req_ids=1)
140
+ )
141
+ print("Send command - get device network information")
142
+ return self.send_order_msg_net(build)
143
+
144
+ def set_device_4g_enable_status(self, new_4g_status: bool):
145
+ build = dev_net_pb2.DevNet(
146
+ todev_ble_sync=1,
147
+ todev_set_mnet_cfg_req=dev_net_pb2.SetMnetCfgReq(
148
+ cfg=dev_net_pb2.MnetCfg(
149
+ type=dev_net_pb2.NET_TYPE_WIFI,
150
+ inet_enable=new_4g_status,
151
+ mnet_enable=new_4g_status,
152
+ )
153
+ ),
154
+ )
155
+
156
+ print(f"Send command - set 4G (on/off status). newWifiStatus={new_4g_status}")
157
+ return self.send_order_msg_net(build)
158
+
159
+ def set_device_wifi_enable_status(self, new_wifi_status: bool):
160
+ build = dev_net_pb2.DevNet(
161
+ todev_ble_sync=1,
162
+ todev_Wifi_Configuration=dev_net_pb2.DrvWifiSet(
163
+ configParam=4, wifi_enable=new_wifi_status
164
+ ),
165
+ )
166
+ print(
167
+ f"szNetwork: Send command - set network (on/off status). newWifiStatus={new_wifi_status}"
168
+ )
169
+ return self.send_order_msg_net(build)
170
+
171
+ def wifi_connectinfo_update(self, device_name: str, is_binary: bool):
172
+ print(
173
+ f"Send command - get Wifi connection information.wifiConnectinfoUpdate().deviceName={device_name}.isBinary={is_binary}"
174
+ )
175
+ if is_binary:
176
+ build = dev_net_pb2.DevNet(
177
+ todev_ble_sync=1,
178
+ todev_WifiMsgUpload=dev_net_pb2.DrvWifiUpload(Wifi_Msg_Upload=1),
179
+ )
180
+ print("Send command - get Wifi connection information")
181
+ return self.send_order_msg_net(build)
182
+ self.wifi_connectinfo_update2()
183
+
184
+ def wifi_connectinfo_update2(self):
185
+ hash_map = {"getMsgCmd": 1}
186
+ # self.post_custom_data(self.get_json_string(
187
+ # 68, hash_map)) # ToDo: Fix this
188
+
189
+ def get_record_wifi_list(self, is_binary: bool):
190
+ print(f"getRecordWifiList().isBinary={is_binary}")
191
+ if is_binary:
192
+ build = dev_net_pb2.DevNet(
193
+ todev_ble_sync=1, todev_WifiListUpload=dev_net_pb2.DrvWifiList()
194
+ )
195
+ print("Send command - get memorized WiFi list upload command")
196
+ return self.send_order_msg_net(build)
197
+ self.get_record_wifi_list2()
198
+
199
+ def get_record_wifi_list2(self):
200
+ pass
201
+ # self.messageNavigation.post_custom_data(
202
+ # self.get_json_string(69)) # ToDo: Fix this
203
+
204
+ def close_clear_connect_current_wifi(self, ssid: str, status: int, is_binary: bool):
205
+ if is_binary:
206
+ build = dev_net_pb2.DevNet(
207
+ todev_ble_sync=1,
208
+ todev_Wifi_Configuration=dev_net_pb2.DrvWifiSet(
209
+ configParam=status, Confssid=ssid
210
+ ),
211
+ )
212
+ print(
213
+ f"Send command - set network (disconnect, direct connect, forget, no operation reconnect) operation command (downlink ssid={ssid}, status={status})"
214
+ )
215
+ return self.send_order_msg_net(build)
216
+ self.close_clear_connect_current_wifi2(ssid, status)
217
+
218
+ def close_clear_connect_current_wifi2(self, ssid: str, get_msg_cmd: int):
219
+ data = {"ssid": ssid, "getMsgCmd": get_msg_cmd}
220
+ # self.messageNavigation.post_custom_data(
221
+ # ToDo: Fix this
222
+ # self.get_json_string(bleOrderCmd.close_clear_connect_current_wifi, data).encode())
223
+
224
+ def get_json_string(self, cmd: int, hash_map: Dict[str, object]) -> str:
225
+ jSONObject = {}
226
+ try:
227
+ jSONObject["cmd"] = cmd
228
+ jSONObject[tmp_constant.REQUEST_ID] = int(time.time())
229
+ jSONObject2 = {}
230
+ for key, value in hash_map.items():
231
+ jSONObject2[key] = value
232
+ jSONObject["params"] = jSONObject2
233
+ return json.dumps(jSONObject)
234
+ except Exception as e:
235
+ print(e)
236
+ return ""
@@ -0,0 +1,34 @@
1
+ # === sendOrderMsg_Ota ===
2
+ from pyluba.proto import luba_msg_pb2, mctrl_ota_pb2
3
+
4
+
5
+ class MessageOta:
6
+ def send_order_msg_ota(self, ota):
7
+ luba_msg = luba_msg_pb2.LubaMsg(
8
+ msgtype=luba_msg_pb2.MSG_CMD_TYPE_EMBED_OTA,
9
+ sender=luba_msg_pb2.DEV_MOBILEAPP,
10
+ rcver=luba_msg_pb2.DEV_MAINCTL,
11
+ msgattr=luba_msg_pb2.MSG_ATTR_REQ,
12
+ seqs=1,
13
+ version=1,
14
+ subtype=1,
15
+ ota=ota,
16
+ )
17
+
18
+ return luba_msg.SerializeToString()
19
+
20
+ def get_device_ota_info(self, log_type: int):
21
+ todev_get_info_req = mctrl_ota_pb2.MctlOta(
22
+ todev_get_info_req=mctrl_ota_pb2.getInfoReq(type=mctrl_ota_pb2.IT_OTA)
23
+ )
24
+
25
+ print("===Send command to get upgrade details===logType:" + str(log_type))
26
+ return self.send_order_msg_ota(todev_get_info_req)
27
+
28
+ def get_device_info_new(self):
29
+ """New device call for OTA upgrade information."""
30
+ todev_get_info_req = mctrl_ota_pb2.MctlOta(
31
+ todev_get_info_req=mctrl_ota_pb2.getInfoReq(type=mctrl_ota_pb2.IT_BASE)
32
+ )
33
+ print("Send to get OTA upgrade information", "Get device information")
34
+ return self.send_order_msg_ota(todev_get_info_req)
@@ -0,0 +1,266 @@
1
+ # === sendOrderMsg_Sys ===
2
+ import datetime
3
+ from typing import List
4
+
5
+ from pyluba.mammotion.commands.abstract_message import AbstractMessage
6
+ from pyluba.mammotion.commands.messages.navigation import MessageNavigation
7
+ from pyluba.proto import luba_msg_pb2, mctrl_sys_pb2
8
+ from pyluba.proto.mctrl_sys import RptInfoType
9
+ from pyluba.utility.device_type import DeviceType
10
+
11
+
12
+ class MessageSystem(AbstractMessage):
13
+ messageNavigation: MessageNavigation = MessageNavigation()
14
+
15
+ def send_order_msg_sys(self, sys):
16
+ luba_msg = luba_msg_pb2.LubaMsg(
17
+ msgtype=luba_msg_pb2.MSG_CMD_TYPE_EMBED_SYS,
18
+ sender=luba_msg_pb2.DEV_MOBILEAPP,
19
+ rcver=luba_msg_pb2.DEV_MAINCTL,
20
+ sys=sys,
21
+ )
22
+
23
+ return luba_msg.SerializeToString()
24
+
25
+ def reset_system(self):
26
+ build = mctrl_sys_pb2.MctlSys(todev_reset_system=1)
27
+ print("Send command - send factory reset")
28
+ return self.send_order_msg_sys(build)
29
+
30
+ async def set_blade_control(self, on_off: int):
31
+ mctlsys = mctrl_sys_pb2.MctlSys()
32
+ sysKnifeControl = mctrl_sys_pb2.SysKnifeControl()
33
+ sysKnifeControl.knife_status = on_off
34
+ mctlsys.todev_knife_ctrl.CopyFrom(sysKnifeControl)
35
+
36
+ return self.send_order_msg_sys(mctlsys)
37
+
38
+ def get_device_product_model(self):
39
+ return self.send_order_msg_sys(
40
+ mctrl_sys_pb2.MctlSys(
41
+ device_product_type_info=mctrl_sys_pb2.device_product_type_info_t()
42
+ ),
43
+ 12,
44
+ True,
45
+ )
46
+
47
+ def read_and_set_sidelight(self, is_sidelight: bool, operate: int):
48
+ if is_sidelight:
49
+ build = mctrl_sys_pb2.TimeCtrlLight(
50
+ operate=operate,
51
+ enable=0,
52
+ action=0,
53
+ start_hour=0,
54
+ start_min=0,
55
+ end_hour=0,
56
+ end_min=0,
57
+ )
58
+ else:
59
+ build = mctrl_sys_pb2.TimeCtrlLight(
60
+ operate=operate,
61
+ enable=1,
62
+ action=0,
63
+ start_hour=0,
64
+ start_min=0,
65
+ end_hour=0,
66
+ end_min=0,
67
+ )
68
+ print(f"Send read and write sidelight command is_sidelight:{
69
+ is_sidelight}, operate:{operate}")
70
+ build2 = mctrl_sys_pb2.MctlSys(todev_time_ctrl_light=build)
71
+ print(f"Send command - send read and write sidelight command is_sidelight:{
72
+ is_sidelight}, operate:{operate}, timeCtrlLight:{build}")
73
+ return self.send_order_msg_sys(build2)
74
+
75
+ def test_tool_order_to_sys(
76
+ self, sub_cmd: int, param_id: int, param_value: List[int]
77
+ ):
78
+ build = mctrl_sys_pb2.mCtrlSimulationCmdData(
79
+ sub_cmd=sub_cmd, param_id=param_id, param_value=param_value
80
+ )
81
+ print(f"Send tool test command: subCmd={sub_cmd}, param_id:{
82
+ param_id}, param_value={param_value}")
83
+ build2 = mctrl_sys_pb2.MctlSys(simulation_cmd=build)
84
+ print(f"Send tool test command: subCmd={sub_cmd}, param_id:{
85
+ param_id}, param_value={param_value}")
86
+ return self.send_order_msg_sys(build2)
87
+
88
+ def read_and_set_rt_k_paring_code(self, op: int, cgf: str):
89
+ print(f"Send read and write base station configuration quality op:{
90
+ op}, cgf:{cgf}")
91
+ return self.send_order_msg_sys(
92
+ mctrl_sys_pb2.MctlSys(
93
+ todev_lora_cfg_req=mctrl_sys_pb2.LoraCfgReq(op=op, cfg=cgf)
94
+ )
95
+ )
96
+
97
+ def allpowerfull_rw(self, id: int, context: int, rw: int):
98
+ if (id == 6 or id == 3 or id == 7) and DeviceType.is_luba_2(
99
+ self.get_device_name()
100
+ ):
101
+ self.messageNavigation.allpowerfull_rw_adapter_x3(id, context, rw)
102
+ return
103
+ build = mctrl_sys_pb2.MctlSys(
104
+ bidire_comm_cmd=mctrl_sys_pb2.SysCommCmd(id=id, context=context, rw=rw)
105
+ )
106
+ print(
107
+ f"Send command - 9 general read and write command id={id}, context={context}, rw={rw}"
108
+ )
109
+ if id == 5:
110
+ # This logic doesnt make snese, but its what they had so..
111
+ return self.send_order_msg_sys(build)
112
+ return self.send_order_msg_sys(build)
113
+
114
+ # Commented out as not needed and too many refs to try fix up
115
+ # def factory_test_order(self, test_id: int, test_duration: int, expect: str):
116
+ # new_builder = mctrl_sys_pb2.mow_to_app_qctools_info_t.Builder()
117
+ # print(f"Factory tool print, expect={expect}")
118
+ # if not expect:
119
+ # build = new_builder.set_type_value(
120
+ # test_id).set_time_of_duration(test_duration).build()
121
+ # else:
122
+ # try:
123
+ # json_array = json.loads(expect)
124
+ # z2 = True
125
+ # for i in range(len(json_array)):
126
+ # new_builder2 = mctrl_sys_pb2.QCAppTestExcept.Builder()
127
+ # json_object = json_array[i]
128
+ # if "except_type" in json_object:
129
+ # string = json_object["except_type"]
130
+ # if "conditions" in json_object:
131
+ # json_array2 = json_object["conditions"]
132
+ # for i2 in range(len(json_array2)):
133
+ # json_object2 = json_array2[i2]
134
+ # new_builder3 = mctrl_sys_pb2.QCAppTestConditions.Builder()
135
+ # if "cond_type" in json_object2:
136
+ # new_builder3.set_cond_type(
137
+ # json_object2["cond_type"])
138
+ # else:
139
+ # z2 = False
140
+ # if "value" in json_object2:
141
+ # obj = json_object2["value"]
142
+ # if string == "int":
143
+ # new_builder3.set_int_val(int(obj))
144
+ # elif string == "float":
145
+ # new_builder3.set_float_val(float(obj))
146
+ # elif string == "double":
147
+ # new_builder3.set_double_val(float(obj))
148
+ # elif string == "string":
149
+ # new_builder3.set_string_val(str(obj))
150
+ # else:
151
+ # z2 = False
152
+ # new_builder2.add_conditions(new_builder3)
153
+ # else:
154
+ # z2 = False
155
+ # new_builder2.set_except_type(string)
156
+ # new_builder.add_except(new_builder2)
157
+ # new_builder2.clear()
158
+ # z = z2
159
+ # except json.JSONDecodeError:
160
+ # z = False
161
+ # if z:
162
+ # build = new_builder.set_type_value(
163
+ # test_id).set_time_of_duration(test_duration).build()
164
+ # else:
165
+ # build = new_builder.set_type_value(
166
+ # test_id).set_time_of_duration(test_duration).build()
167
+ # print(f"Factory tool print, mow_to_app_qctools_info_t={
168
+ # build.except_count}, mow_to_app_qctools_info_t22={build.except_list}")
169
+ # build2 = mctrl_sys_pb2.MctlSys(mow_to_app_qctools_info=build)
170
+ # print(f"Send command - factory tool test command testId={
171
+ # test_id}, testDuration={test_duration}", "Factory tool print222", True)
172
+ # return self.send_order_msg_sys(build2)
173
+
174
+ def send_sys_set_date_time(self):
175
+ calendar = datetime.now()
176
+ i = calendar.year
177
+ i2 = calendar.month
178
+ i3 = calendar.day
179
+ i4 = calendar.isoweekday()
180
+ i5 = calendar.hour
181
+ i6 = calendar.minute
182
+ i7 = calendar.second
183
+ i8 = calendar.utcoffset().total_seconds() // 60 if calendar.utcoffset() else 0
184
+ i9 = 1 if calendar.dst() else 0
185
+ print(f"Print time zone, time zone={
186
+ i8}, daylight saving time={i9} week={i4}")
187
+ build = mctrl_sys_pb2.MctlSys(
188
+ todev_data_time=mctrl_sys_pb2.SysSetDateTime(
189
+ year=i,
190
+ month=i2,
191
+ date=i3,
192
+ week=i4,
193
+ hours=i5,
194
+ minutes=i6,
195
+ seconds=i7,
196
+ time_zone=i8,
197
+ daylight=i9,
198
+ )
199
+ )
200
+ print(
201
+ f"Send command - synchronize time zone={i8}, daylight saving time={i9} week={i4}, day:{
202
+ i3}, month:{i2}, hours:{i5}, minutes:{i6}, seconds:{i7}, year={i}",
203
+ "Time synchronization",
204
+ True,
205
+ )
206
+ return self.send_order_msg_sys(build)
207
+
208
+ def get_device_version_info(self):
209
+ return self.send_order_msg_sys(mctrl_sys_pb2.MctlSys(todev_get_dev_fw_info=1))
210
+
211
+ # === sendOrderMsg_Sys2 ===
212
+
213
+ def request_iot_sys(
214
+ self,
215
+ rpt_act: mctrl_sys_pb2.rpt_act,
216
+ rpt_info_type: List[RptInfoType | str] | None,
217
+ timeout: int,
218
+ period: int,
219
+ no_change_period: int,
220
+ count: int,
221
+ ) -> None:
222
+ build = mctrl_sys_pb2.MctlSys(
223
+ todev_report_cfg=mctrl_sys_pb2.report_info_cfg(
224
+ act=rpt_act,
225
+ sub=rpt_info_type,
226
+ timeout=timeout,
227
+ period=period,
228
+ no_change_period=no_change_period,
229
+ count=count,
230
+ )
231
+ )
232
+ print(f"Send command==== IOT slim data Act {
233
+ build.todev_report_cfg.act} {build}")
234
+ return self.send_order_msg_sys(build)
235
+
236
+ def get_report_cfg(
237
+ self, timeout: int = 10000, period: int = 1000, no_change_period: int = 2000
238
+ ):
239
+ mctlsys = mctrl_sys_pb2.MctlSys(
240
+ todev_report_cfg=mctrl_sys_pb2.report_info_cfg(
241
+ timeout=timeout,
242
+ period=period,
243
+ no_change_period=no_change_period,
244
+ count=1,
245
+ )
246
+ )
247
+
248
+ mctlsys.todev_report_cfg.sub.append(RptInfoType.RIT_CONNECT.value)
249
+ mctlsys.todev_report_cfg.sub.append(RptInfoType.RIT_RTK.value)
250
+ mctlsys.todev_report_cfg.sub.append(RptInfoType.RIT_DEV_LOCAL.value)
251
+ mctlsys.todev_report_cfg.sub.append(RptInfoType.RIT_WORK.value)
252
+ mctlsys.todev_report_cfg.sub.append(RptInfoType.RIT_DEV_STA.value)
253
+ mctlsys.todev_report_cfg.sub.append(RptInfoType.RIT_VISION_POINT.value)
254
+ mctlsys.todev_report_cfg.sub.append(RptInfoType.RIT_VIO.value)
255
+ mctlsys.todev_report_cfg.sub.append(RptInfoType.RIT_VISION_STATISTIC.value)
256
+
257
+ lubaMsg = luba_msg_pb2.LubaMsg()
258
+ lubaMsg.msgtype = luba_msg_pb2.MSG_CMD_TYPE_EMBED_SYS
259
+ lubaMsg.sender = luba_msg_pb2.DEV_MOBILEAPP
260
+ lubaMsg.rcver = luba_msg_pb2.DEV_MAINCTL
261
+ lubaMsg.msgattr = luba_msg_pb2.MSG_ATTR_REQ
262
+ lubaMsg.seqs = 1
263
+ lubaMsg.version = 1
264
+ lubaMsg.subtype = 1
265
+ lubaMsg.sys.CopyFrom(mctlsys)
266
+ return lubaMsg.SerializeToString()
@@ -0,0 +1,27 @@
1
+ # === sendOrderMsg_Video ===
2
+ from pyluba.mammotion.commands.abstract_message import AbstractMessage
3
+ from pyluba.proto import luba_msg_pb2, luba_mul_pb2
4
+ from pyluba.utility.device_type import DeviceType
5
+
6
+
7
+ class MessageVideo(AbstractMessage):
8
+ async def send_order_msg_video(self, mul):
9
+ luba_msg = luba_msg_pb2.LubaMsg(
10
+ msgtype=luba_msg_pb2.MSG_CMD_TYPE_MUL,
11
+ sender=luba_msg_pb2.DEV_MOBILEAPP,
12
+ rcver=luba_msg_pb2.SOC_MODULE_MULTIMEDIA,
13
+ mul=mul,
14
+ )
15
+
16
+ return luba_msg.SerializeToString()
17
+
18
+ def device_agora_join_channel_with_position(self, enter_state: int):
19
+ position = (
20
+ luba_mul_pb2.MUL_CAMERA_POSITION.ALL
21
+ if DeviceType.is_yuka(self.get_device_name())
22
+ else luba_mul_pb2.MUL_CAMERA_POSITION.LEFT
23
+ )
24
+ mctl_sys = luba_mul_pb2.SocMul(
25
+ set_video=luba_mul_pb2.MulSetVideo(position=position, vi_switch=enter_state)
26
+ )
27
+ return self.send_order_msg_video(mctl_sys)
File without changes