pymammotion 0.2.67__py3-none-any.whl → 0.2.68__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 +76 -70
- 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.68.dist-info}/METADATA +1 -1
- {pymammotion-0.2.67.dist-info → pymammotion-0.2.68.dist-info}/RECORD +9 -9
- {pymammotion-0.2.67.dist-info → pymammotion-0.2.68.dist-info}/LICENSE +0 -0
- {pymammotion-0.2.67.dist-info → pymammotion-0.2.68.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)
|
@@ -20,6 +20,7 @@ from pymammotion.proto import (
|
|
20
20
|
dev_net_pb2,
|
21
21
|
luba_msg_pb2,
|
22
22
|
)
|
23
|
+
from pymammotion.proto.luba_msg import MsgCmdType, LubaMsg, MsgDevice, MsgAttr
|
23
24
|
from pymammotion.utility.constant.device_constant import bleOrderCmd
|
24
25
|
|
25
26
|
_LOGGER = logging.getLogger(__name__)
|
@@ -51,8 +52,8 @@ class BleMessage:
|
|
51
52
|
|
52
53
|
def __init__(self, client: BleakClient) -> None:
|
53
54
|
self.client = client
|
54
|
-
self.mSendSequence = itertools.count()
|
55
|
-
self.mReadSequence = itertools.count()
|
55
|
+
self.mSendSequence = itertools.count(start=0)
|
56
|
+
self.mReadSequence = itertools.count(start=0)
|
56
57
|
self.mAck = queue.Queue()
|
57
58
|
self.notification = BlufiNotifyData()
|
58
59
|
|
@@ -87,11 +88,11 @@ class BleMessage:
|
|
87
88
|
|
88
89
|
async def send_device_info(self) -> None:
|
89
90
|
"""Currently not called"""
|
90
|
-
luba_msg =
|
91
|
-
msgtype=
|
92
|
-
sender=
|
93
|
-
rcver=
|
94
|
-
msgattr=
|
91
|
+
luba_msg = LubaMsg(
|
92
|
+
msgtype=MsgCmdType.MSG_CMD_TYPE_ESP,
|
93
|
+
sender=MsgDevice.DEV_MOBILEAPP,
|
94
|
+
rcver=MsgDevice.DEV_COMM_ESP,
|
95
|
+
msgattr=MsgAttr.MSG_ATTR_REQ,
|
95
96
|
seqs=1,
|
96
97
|
version=1,
|
97
98
|
subtype=1,
|
@@ -140,69 +141,74 @@ class BleMessage:
|
|
140
141
|
# if (this.mPrintDebug):
|
141
142
|
# Log.d(TAG, "parseNotification Notification= " + Arrays.toString(response));
|
142
143
|
# }
|
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
|
-
|
144
|
+
if len(response) < 4:
|
145
|
+
_LOGGER.debug("parseNotification data length less than 4")
|
146
|
+
return -2
|
147
|
+
|
148
|
+
|
149
|
+
sequence = int(response[2]) # toInt
|
150
|
+
|
151
|
+
# Compare with the second counter, mod 255
|
152
|
+
if sequence != (next(self.mReadSequence) & 255):
|
153
|
+
_LOGGER.debug(
|
154
|
+
"parseNotification read sequence wrong %s %s",
|
155
|
+
sequence,
|
156
|
+
self.mReadSequence,
|
157
|
+
)
|
158
|
+
|
159
|
+
# Set the value for mReadSequence manually
|
160
|
+
self.mReadSequence = itertools.count(start=sequence)
|
161
|
+
|
162
|
+
# LogUtil.m7773e(self.mGatt.getDevice().getName() + "打印丢包率", self.mReadSequence_2 + "/" + self.mReadSequence_1);
|
163
|
+
pkt_type = int(response[0]) # toInt
|
164
|
+
pkgType = self._getPackageType(pkt_type)
|
165
|
+
subType = self._getSubType(pkt_type)
|
166
|
+
self.notification.setType(pkt_type)
|
167
|
+
self.notification.setPkgType(pkgType)
|
168
|
+
self.notification.setSubType(subType)
|
169
|
+
frameCtrl = int(response[1]) # toInt
|
170
|
+
# _LOGGER.debug("frame ctrl")
|
171
|
+
# _LOGGER.debug(frameCtrl)
|
172
|
+
# _LOGGER.debug(response)
|
173
|
+
# _LOGGER.debug(f"pktType {pkt_type} pkgType {pkgType} subType {subType}")
|
174
|
+
self.notification.setFrameCtrl(frameCtrl)
|
175
|
+
frameCtrlData = FrameCtrlData(frameCtrl)
|
176
|
+
dataLen = int(response[3]) # toInt specifies length of data
|
177
|
+
|
178
|
+
try:
|
179
|
+
dataBytes = response[4 : 4 + dataLen]
|
180
|
+
if frameCtrlData.isEncrypted():
|
181
|
+
_LOGGER.debug("is encrypted")
|
182
|
+
# BlufiAES aes = new BlufiAES(self.mAESKey, AES_TRANSFORMATION, generateAESIV(sequence));
|
183
|
+
# dataBytes = aes.decrypt(dataBytes);
|
184
|
+
# }
|
185
|
+
if frameCtrlData.isChecksum():
|
186
|
+
_LOGGER.debug("checksum")
|
187
|
+
# int respChecksum1 = toInt(response[response.length - 1]);
|
188
|
+
# int respChecksum2 = toInt(response[response.length - 2]);
|
189
|
+
# int crc = BlufiCRC.calcCRC(BlufiCRC.calcCRC(0, new byte[]{(byte) sequence, (byte) dataLen}), dataBytes);
|
190
|
+
# int calcChecksum1 = (crc >> 8) & 255;
|
191
|
+
# int calcChecksum2 = crc & 255;
|
192
|
+
# if (respChecksum1 != calcChecksum1 || respChecksum2 != calcChecksum2) {
|
193
|
+
# Log.w(TAG, "parseNotification: read invalid checksum");
|
194
|
+
# if (self.mPrintDebug) {
|
195
|
+
# Log.d(TAG, "expect checksum: " + respChecksum1 + ", " + respChecksum2);
|
196
|
+
# Log.d(TAG, "received checksum: " + calcChecksum1 + ", " + calcChecksum2);
|
197
|
+
# return -4;
|
198
|
+
# }
|
199
|
+
# return -4;
|
200
|
+
# }
|
201
|
+
# }
|
202
|
+
if frameCtrlData.hasFrag():
|
203
|
+
dataOffset = 2
|
204
|
+
else:
|
205
|
+
dataOffset = 0
|
206
|
+
|
207
|
+
self.notification.addData(dataBytes, dataOffset)
|
208
|
+
return 1 if frameCtrlData.hasFrag() else 0
|
209
|
+
except Exception as e:
|
210
|
+
_LOGGER.debug(e)
|
211
|
+
return -100
|
206
212
|
|
207
213
|
# Log.w(TAG, "parseNotification data length less than 4");
|
208
214
|
return -2
|
@@ -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)
|
@@ -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=k9yJBfZXA352rzA3csEQgk2prMNuM-r-0NPL1s1_f2c,15320
|
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.68.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
123
|
+
pymammotion-0.2.68.dist-info/METADATA,sha256=GPRAhITGV9-PrjCNA6PGJWm32nKPm_cHw5T-PqVbJwk,3874
|
124
|
+
pymammotion-0.2.68.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
125
|
+
pymammotion-0.2.68.dist-info/RECORD,,
|
File without changes
|
File without changes
|