pymammotion 0.2.67__py3-none-any.whl → 0.2.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.
- pymammotion/bluetooth/ble.py +1 -0
- pymammotion/bluetooth/ble_message.py +78 -80
- pymammotion/mammotion/commands/messages/network.py +15 -28
- pymammotion/mammotion/devices/mammotion_bluetooth.py +0 -1
- pymammotion/mammotion/devices/mammotion_cloud.py +2 -1
- {pymammotion-0.2.67.dist-info → pymammotion-0.2.69.dist-info}/METADATA +2 -2
- {pymammotion-0.2.67.dist-info → pymammotion-0.2.69.dist-info}/RECORD +9 -9
- {pymammotion-0.2.67.dist-info → pymammotion-0.2.69.dist-info}/LICENSE +0 -0
- {pymammotion-0.2.67.dist-info → pymammotion-0.2.69.dist-info}/WHEEL +0 -0
pymammotion/bluetooth/ble.py
CHANGED
@@ -33,6 +33,7 @@ class MammotionBLE:
|
|
33
33
|
device = await scanner.find_device_by_filter(scanCallback)
|
34
34
|
if device is not None:
|
35
35
|
return await self.create_client(device)
|
36
|
+
return False
|
36
37
|
|
37
38
|
async def create_client(self, device: BLEDevice):
|
38
39
|
self.client = BleakClient(device.address)
|
@@ -12,14 +12,13 @@ from jsonic.serializable import serialize
|
|
12
12
|
|
13
13
|
from pymammotion.aliyun.tmp_constant import tmp_constant
|
14
14
|
from pymammotion.bluetooth.const import UUID_WRITE_CHARACTERISTIC
|
15
|
-
from pymammotion.bluetooth.data.convert import parse_custom_data
|
16
15
|
from pymammotion.bluetooth.data.framectrldata import FrameCtrlData
|
17
16
|
from pymammotion.bluetooth.data.notifydata import BlufiNotifyData
|
18
17
|
from pymammotion.data.model.execute_boarder import ExecuteBorder
|
19
18
|
from pymammotion.proto import (
|
20
19
|
dev_net_pb2,
|
21
|
-
luba_msg_pb2,
|
22
20
|
)
|
21
|
+
from pymammotion.proto.luba_msg import LubaMsg, MsgAttr, MsgCmdType, MsgDevice
|
23
22
|
from pymammotion.utility.constant.device_constant import bleOrderCmd
|
24
23
|
|
25
24
|
_LOGGER = logging.getLogger(__name__)
|
@@ -51,8 +50,8 @@ class BleMessage:
|
|
51
50
|
|
52
51
|
def __init__(self, client: BleakClient) -> None:
|
53
52
|
self.client = client
|
54
|
-
self.mSendSequence = itertools.count()
|
55
|
-
self.mReadSequence = itertools.count()
|
53
|
+
self.mSendSequence = itertools.count(start=0)
|
54
|
+
self.mReadSequence = itertools.count(start=0)
|
56
55
|
self.mAck = queue.Queue()
|
57
56
|
self.notification = BlufiNotifyData()
|
58
57
|
|
@@ -87,11 +86,11 @@ class BleMessage:
|
|
87
86
|
|
88
87
|
async def send_device_info(self) -> None:
|
89
88
|
"""Currently not called"""
|
90
|
-
luba_msg =
|
91
|
-
msgtype=
|
92
|
-
sender=
|
93
|
-
rcver=
|
94
|
-
msgattr=
|
89
|
+
luba_msg = LubaMsg(
|
90
|
+
msgtype=MsgCmdType.MSG_CMD_TYPE_ESP,
|
91
|
+
sender=MsgDevice.DEV_MOBILEAPP,
|
92
|
+
rcver=MsgDevice.DEV_COMM_ESP,
|
93
|
+
msgattr=MsgAttr.MSG_ATTR_REQ,
|
95
94
|
seqs=1,
|
96
95
|
version=1,
|
97
96
|
subtype=1,
|
@@ -140,69 +139,73 @@ class BleMessage:
|
|
140
139
|
# if (this.mPrintDebug):
|
141
140
|
# Log.d(TAG, "parseNotification Notification= " + Arrays.toString(response));
|
142
141
|
# }
|
143
|
-
if len(response)
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
142
|
+
if len(response) < 4:
|
143
|
+
_LOGGER.debug("parseNotification data length less than 4")
|
144
|
+
return -2
|
145
|
+
|
146
|
+
sequence = int(response[2]) # toInt
|
147
|
+
|
148
|
+
# Compare with the second counter, mod 255
|
149
|
+
if sequence != (next(self.mReadSequence) & 255):
|
150
|
+
_LOGGER.debug(
|
151
|
+
"parseNotification read sequence wrong %s %s",
|
152
|
+
sequence,
|
153
|
+
self.mReadSequence,
|
154
|
+
)
|
155
|
+
|
156
|
+
# Set the value for mReadSequence manually
|
157
|
+
self.mReadSequence = itertools.count(start=sequence - 1)
|
158
|
+
|
159
|
+
# LogUtil.m7773e(self.mGatt.getDevice().getName() + "打印丢包率", self.mReadSequence_2 + "/" + self.mReadSequence_1);
|
160
|
+
pkt_type = int(response[0]) # toInt
|
161
|
+
pkgType = self._getPackageType(pkt_type)
|
162
|
+
subType = self._getSubType(pkt_type)
|
163
|
+
self.notification.setType(pkt_type)
|
164
|
+
self.notification.setPkgType(pkgType)
|
165
|
+
self.notification.setSubType(subType)
|
166
|
+
frameCtrl = int(response[1]) # toInt
|
167
|
+
# _LOGGER.debug("frame ctrl")
|
168
|
+
# _LOGGER.debug(frameCtrl)
|
169
|
+
# _LOGGER.debug(response)
|
170
|
+
# _LOGGER.debug(f"pktType {pkt_type} pkgType {pkgType} subType {subType}")
|
171
|
+
self.notification.setFrameCtrl(frameCtrl)
|
172
|
+
frameCtrlData = FrameCtrlData(frameCtrl)
|
173
|
+
dataLen = int(response[3]) # toInt specifies length of data
|
174
|
+
|
175
|
+
try:
|
176
|
+
dataBytes = response[4 : 4 + dataLen]
|
177
|
+
if frameCtrlData.isEncrypted():
|
178
|
+
_LOGGER.debug("is encrypted")
|
179
|
+
# BlufiAES aes = new BlufiAES(self.mAESKey, AES_TRANSFORMATION, generateAESIV(sequence));
|
180
|
+
# dataBytes = aes.decrypt(dataBytes);
|
181
|
+
# }
|
182
|
+
if frameCtrlData.isChecksum():
|
183
|
+
_LOGGER.debug("checksum")
|
184
|
+
# int respChecksum1 = toInt(response[response.length - 1]);
|
185
|
+
# int respChecksum2 = toInt(response[response.length - 2]);
|
186
|
+
# int crc = BlufiCRC.calcCRC(BlufiCRC.calcCRC(0, new byte[]{(byte) sequence, (byte) dataLen}), dataBytes);
|
187
|
+
# int calcChecksum1 = (crc >> 8) & 255;
|
188
|
+
# int calcChecksum2 = crc & 255;
|
189
|
+
# if (respChecksum1 != calcChecksum1 || respChecksum2 != calcChecksum2) {
|
190
|
+
# Log.w(TAG, "parseNotification: read invalid checksum");
|
191
|
+
# if (self.mPrintDebug) {
|
192
|
+
# Log.d(TAG, "expect checksum: " + respChecksum1 + ", " + respChecksum2);
|
193
|
+
# Log.d(TAG, "received checksum: " + calcChecksum1 + ", " + calcChecksum2);
|
194
|
+
# return -4;
|
195
|
+
# }
|
196
|
+
# return -4;
|
197
|
+
# }
|
198
|
+
# }
|
199
|
+
if frameCtrlData.hasFrag():
|
200
|
+
dataOffset = 2
|
201
|
+
else:
|
202
|
+
dataOffset = 0
|
203
|
+
|
204
|
+
self.notification.addData(dataBytes, dataOffset)
|
205
|
+
return 1 if frameCtrlData.hasFrag() else 0
|
206
|
+
except Exception as e:
|
207
|
+
_LOGGER.debug(e)
|
208
|
+
return -100
|
206
209
|
|
207
210
|
# Log.w(TAG, "parseNotification data length less than 4");
|
208
211
|
return -2
|
@@ -245,14 +248,8 @@ class BleMessage:
|
|
245
248
|
# return;
|
246
249
|
case 19:
|
247
250
|
# # com/agilexrobotics/utils/EspBleUtil$BlufiCallbackMain.smali
|
248
|
-
luba_msg = parse_custom_data(data) # parse to protobuf message
|
249
|
-
|
250
|
-
if luba_msg.HasField("net"):
|
251
|
-
if luba_msg.net.HasField("toapp_wifi_iot_status"):
|
252
|
-
# await sleep(1.5)
|
253
|
-
_LOGGER.debug("sending ble sync")
|
254
|
-
# await self.send_todev_ble_sync(2)
|
255
|
-
return luba_msg
|
251
|
+
# luba_msg = parse_custom_data(data) # parse to protobuf message
|
252
|
+
return data
|
256
253
|
|
257
254
|
# private void parseCtrlData(int i, byte[] bArr) {
|
258
255
|
# if (i == 0) {
|
@@ -306,6 +303,7 @@ class BleMessage:
|
|
306
303
|
# onPostCustomDataResult(status, data)
|
307
304
|
# _LOGGER.debug(suc)
|
308
305
|
except Exception as err:
|
306
|
+
await self.client.disconnect()
|
309
307
|
_LOGGER.debug(err)
|
310
308
|
|
311
309
|
async def post_custom_data(self, data_str: str) -> None:
|
@@ -162,36 +162,23 @@ class MessageNetwork:
|
|
162
162
|
logger.debug(f"szNetwork: Send command - set network (on/off status). newWifiStatus={new_wifi_status}")
|
163
163
|
return self.send_order_msg_net(build)
|
164
164
|
|
165
|
-
def wifi_connectinfo_update(self
|
166
|
-
|
167
|
-
|
165
|
+
def wifi_connectinfo_update(self) -> bytes:
|
166
|
+
build = dev_net_pb2.DevNet(
|
167
|
+
todev_ble_sync=1,
|
168
|
+
todev_WifiMsgUpload=dev_net_pb2.DrvWifiUpload(wifi_msg_upload=1),
|
168
169
|
)
|
169
|
-
|
170
|
-
|
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()
|
170
|
+
logger.debug("Send command - get Wifi connection information")
|
171
|
+
return self.send_order_msg_net(build)
|
177
172
|
|
178
173
|
def wifi_connectinfo_update2(self) -> None:
|
179
174
|
hash_map = {"getMsgCmd": 1}
|
180
175
|
# self.post_custom_data(self.get_json_string(
|
181
176
|
# 68, hash_map)) # ToDo: Fix this
|
182
177
|
|
183
|
-
def get_record_wifi_list(self
|
184
|
-
|
185
|
-
|
186
|
-
|
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
|
178
|
+
def get_record_wifi_list(self) -> bytes:
|
179
|
+
build = dev_net_pb2.DevNet(todev_ble_sync=1, todev_WifiListUpload=dev_net_pb2.DrvWifiList())
|
180
|
+
logger.debug("Send command - get memorized WiFi list upload command")
|
181
|
+
return self.send_order_msg_net(build)
|
195
182
|
|
196
183
|
def close_clear_connect_current_wifi(self, ssid: str, status: int, is_binary: bool) -> bytes:
|
197
184
|
if is_binary:
|
@@ -205,8 +192,8 @@ class MessageNetwork:
|
|
205
192
|
return self.send_order_msg_net(build)
|
206
193
|
self.close_clear_connect_current_wifi2(ssid, status)
|
207
194
|
|
208
|
-
def close_clear_connect_current_wifi2(self, ssid: str, get_msg_cmd: int) -> None:
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
195
|
+
# def close_clear_connect_current_wifi2(self, ssid: str, get_msg_cmd: int) -> None:
|
196
|
+
# data = {"ssid": ssid, "getMsgCmd": get_msg_cmd}
|
197
|
+
# self.messageNavigation.post_custom_data(
|
198
|
+
# ToDo: Fix this
|
199
|
+
# self.get_json_string(bleOrderCmd.close_clear_connect_current_wifi, data).encode())
|
@@ -405,7 +405,6 @@ class MammotionBaseBLEDevice(MammotionBaseDevice):
|
|
405
405
|
self._cancel_disconnect_timer()
|
406
406
|
self._client = None
|
407
407
|
|
408
|
-
|
409
408
|
def _disconnect_from_timer(self) -> None:
|
410
409
|
"""Disconnect from device."""
|
411
410
|
if self._operation_lock.locked() and self._client.is_connected:
|
@@ -200,6 +200,7 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
|
|
200
200
|
if self._ble_sync_task is None or self._ble_sync_task.cancelled():
|
201
201
|
await self.run_periodic_sync_task()
|
202
202
|
self.stopped = False
|
203
|
+
self._mqtt.on_ready_event.add_subscribers(self.on_ready)
|
203
204
|
self.mqtt.connect_async()
|
204
205
|
|
205
206
|
async def _ble_sync(self) -> None:
|
@@ -286,7 +287,7 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
|
|
286
287
|
if fut is None:
|
287
288
|
return
|
288
289
|
while fut.fut.cancelled() and len(self._mqtt.waiting_queue) > 0:
|
289
|
-
fut
|
290
|
+
fut = self.dequeue_by_iot_id(self._mqtt.waiting_queue, self.iot_id)
|
290
291
|
if not fut.fut.cancelled():
|
291
292
|
fut.resolve(cast(bytes, binary_data))
|
292
293
|
await self._state_manager.notification(new_msg)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pymammotion
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.69
|
4
4
|
Summary:
|
5
5
|
License: GNU-3.0
|
6
6
|
Author: Michael Arthur
|
@@ -68,7 +68,7 @@ pip install pymammotion
|
|
68
68
|
PyMammotion uses `betterproto` and `protoc` for generating protobuf models. To set up the development environment:
|
69
69
|
|
70
70
|
1. Clone the repository
|
71
|
-
2.
|
71
|
+
2. poetry install --with=dev
|
72
72
|
3. Profit
|
73
73
|
|
74
74
|
## Contributing 🤝
|
@@ -11,8 +11,8 @@ pymammotion/aliyun/model/session_by_authcode_response.py,sha256=qW0pnnRXfyEuMbb9
|
|
11
11
|
pymammotion/aliyun/model/stream_subscription_response.py,sha256=po765WASQDboVCosbPEfDHNlanBf-3WMrA6iV3ezooY,357
|
12
12
|
pymammotion/aliyun/tmp_constant.py,sha256=M4Hq_lrGB3LZdX6R2XohRPFoK1NDnNV-pTJwJcJ9838,6650
|
13
13
|
pymammotion/bluetooth/__init__.py,sha256=LAl8jqZ1fPh-3mLmViNQsP3s814C1vsocYUa6oSaXt0,36
|
14
|
-
pymammotion/bluetooth/ble.py,sha256=
|
15
|
-
pymammotion/bluetooth/ble_message.py,sha256=
|
14
|
+
pymammotion/bluetooth/ble.py,sha256=C7H7j71fhsvBfI8QEa9PlY3Ugm2CK1CXI7CXqranM48,2470
|
15
|
+
pymammotion/bluetooth/ble_message.py,sha256=toPhMOgmHEdHzvaOsgCUfrkjdI38oeS4Av0E-I8X0_s,14952
|
16
16
|
pymammotion/bluetooth/const.py,sha256=CCqyHsYbB0BAYjwdhXt_n6eWWxmhlUrAFjvVv57mbvE,1749
|
17
17
|
pymammotion/bluetooth/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
18
18
|
pymammotion/bluetooth/data/convert.py,sha256=6DMwvzVr9FWCoQFIKSI2poFXjISc_m6X59g8FlVO0-o,800
|
@@ -54,7 +54,7 @@ pymammotion/mammotion/commands/messages/__init__.py,sha256=47DEQpj8HBSa-_TImW-5J
|
|
54
54
|
pymammotion/mammotion/commands/messages/driver.py,sha256=DlOAC_yi1ycO5hKr5rfCpLmrqao6Mb6Fv1JWwMISnKE,3766
|
55
55
|
pymammotion/mammotion/commands/messages/media.py,sha256=l-m4l2Vp1ZOHPHyJTceuLaLvdgHOEfmykkbDncCDUI4,1359
|
56
56
|
pymammotion/mammotion/commands/messages/navigation.py,sha256=Z6RQK-pMh8o7_K_1yTENx3lkNBFQTU_ojunolSre0oM,23241
|
57
|
-
pymammotion/mammotion/commands/messages/network.py,sha256=
|
57
|
+
pymammotion/mammotion/commands/messages/network.py,sha256=HjB6oz4_g_vgYybuTuzCxIXmy83mgTAl9A0CBNuLTfI,7901
|
58
58
|
pymammotion/mammotion/commands/messages/ota.py,sha256=g937HT_-OQXV6A3zUiZ53b45cOX6y-rzs5m-4b0IcTk,1473
|
59
59
|
pymammotion/mammotion/commands/messages/system.py,sha256=pUdV8z-pnoXvDM29DQbfAi2mG6uK7EHQzJL2sWZLHrc,12843
|
60
60
|
pymammotion/mammotion/commands/messages/video.py,sha256=ne1YSuQChaDFfmHgMO5Jc9_O_7vkt5yV1EXVEh3LTbg,1141
|
@@ -63,8 +63,8 @@ pymammotion/mammotion/control/joystick.py,sha256=QfBVxM_gxpWsZAGO90whtgxCI2tIZ3T
|
|
63
63
|
pymammotion/mammotion/devices/__init__.py,sha256=f2qQFPgLGmV85W2hSlMUh5BYuht9o_Ar_JEAAMD4fsE,102
|
64
64
|
pymammotion/mammotion/devices/base.py,sha256=F_L5aDtY6rgRkk7Q4CwilLenTANW6cBe9zIU3a9HRmA,10020
|
65
65
|
pymammotion/mammotion/devices/mammotion.py,sha256=hSO184o1q4ftfLPx9froFPIXk428wGg8Ayw160W3z7c,12482
|
66
|
-
pymammotion/mammotion/devices/mammotion_bluetooth.py,sha256=
|
67
|
-
pymammotion/mammotion/devices/mammotion_cloud.py,sha256=
|
66
|
+
pymammotion/mammotion/devices/mammotion_bluetooth.py,sha256=P4cJEfntCPcaGlrGGZSWEApM5D5cwCk4MbukfStSP3Q,18889
|
67
|
+
pymammotion/mammotion/devices/mammotion_cloud.py,sha256=7xbSZmC1PUG6ZfF5LtiELkQE61lybHoJcBUzz76VvLg,12074
|
68
68
|
pymammotion/mqtt/__init__.py,sha256=Ocs5e-HLJvTuDpVXyECEsWIvwsUaxzj7lZ9mSYutNDY,105
|
69
69
|
pymammotion/mqtt/mammotion_future.py,sha256=_OWqKOlUGl2yT1xOsXFQYpGd-1zQ63OxqXgy7KRQgYc,710
|
70
70
|
pymammotion/mqtt/mammotion_mqtt.py,sha256=LaySave_hf0gU3crUTLqzpdQtxIwK8vu5DM8F8fbU2Y,8748
|
@@ -119,7 +119,7 @@ pymammotion/utility/map.py,sha256=GYscVMg2cX3IPlNpCBNHDW0S55yS1WGRf1iHnNZ7TfQ,22
|
|
119
119
|
pymammotion/utility/movement.py,sha256=N75oAoAgFydqoaOedYIxGUHmuTCtPzAOtb-d_29tpfI,615
|
120
120
|
pymammotion/utility/periodic.py,sha256=MbeSb9cfhxzYmdT_RiE0dZe3H9IfbQW_zSqhmSX2RUc,3321
|
121
121
|
pymammotion/utility/rocker_util.py,sha256=6tX7sS87qoQC_tsxbx3NLL-HgS08wtzXiZkhDiz7uo0,7179
|
122
|
-
pymammotion-0.2.
|
123
|
-
pymammotion-0.2.
|
124
|
-
pymammotion-0.2.
|
125
|
-
pymammotion-0.2.
|
122
|
+
pymammotion-0.2.69.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
123
|
+
pymammotion-0.2.69.dist-info/METADATA,sha256=WB0DIDd6a9UIsShP0cBubzGQVOZJjvXNHNkOeMpfQnc,3896
|
124
|
+
pymammotion-0.2.69.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
125
|
+
pymammotion-0.2.69.dist-info/RECORD,,
|
File without changes
|
File without changes
|