pymammotion 0.2.25__py3-none-any.whl → 0.2.27__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.
@@ -9,9 +9,7 @@ import random
9
9
  import string
10
10
  import time
11
11
  import uuid
12
- from logging import getLogger, exception
13
- from datetime import datetime
14
- from urllib.parse import urlencode
12
+ from logging import getLogger
15
13
 
16
14
  from aiohttp import ClientSession
17
15
  from alibabacloud_iot_api_gateway.client import Client
@@ -19,6 +17,7 @@ from alibabacloud_iot_api_gateway.models import CommonParams, Config, IoTApiRequ
19
17
  from alibabacloud_tea_util.client import Client as UtilClient
20
18
  from alibabacloud_tea_util.models import RuntimeOptions
21
19
 
20
+ from pymammotion.http.http import MammotionHTTP
22
21
  from pymammotion.aliyun.dataclass.aep_response import AepResponse
23
22
  from pymammotion.aliyun.dataclass.connect_response import ConnectResponse
24
23
  from pymammotion.aliyun.dataclass.dev_by_account_response import (
@@ -79,6 +78,7 @@ class CloudIOTGateway:
79
78
 
80
79
  def __init__(self, connect_response: ConnectResponse | None = None, login_by_oauth_response: LoginByOAuthResponse | None = None, aep_response: AepResponse | None = None, session_by_authcode_response: SessionByAuthCodeResponse | None = None, region_response: RegionResponse | None = None, dev_by_account: ListingDevByAccountResponse | None = None):
81
80
  """Initialize the CloudIOTGateway."""
81
+ self.mammotion_http: MammotionHTTP | None = None
82
82
  self._app_key = APP_KEY
83
83
  self._app_secret = APP_SECRET
84
84
  self.domain = ALIYUN_DOMAIN
@@ -616,3 +616,6 @@ class CloudIOTGateway:
616
616
  @property
617
617
  def listing_dev_by_account_response(self):
618
618
  return self._devices_by_account_response
619
+
620
+ def set_http(self, mammotion_http):
621
+ self.mammotion_http = mammotion_http
@@ -112,11 +112,11 @@ class BleMessage:
112
112
  type = self.messageNavigation.getTypeValue(0, 5)
113
113
  try:
114
114
  request = await self.messageNavigation.post(BleMessage.mEncrypted, BleMessage.mChecksum, False, type, None)
115
- # print(request)
115
+ # _LOGGER.debug(request)
116
116
  except Exception as err:
117
117
  # Log.w(TAG, "post requestDeviceStatus interrupted")
118
118
  request = False
119
- print(err)
119
+ _LOGGER.error(err)
120
120
 
121
121
  # if not request:
122
122
  # onStatusResponse(BlufiCallback.CODE_WRITE_DATA_FAILED, null)
@@ -126,11 +126,11 @@ class BleMessage:
126
126
  type = self.messageNavigation.getTypeValue(0, 7)
127
127
  try:
128
128
  request = await self.messageNavigation.post(BleMessage.mEncrypted, BleMessage.mChecksum, False, type, None)
129
- # print(request)
129
+ # _LOGGER.debug(request)
130
130
  except Exception as err:
131
131
  # Log.w(TAG, "post requestDeviceStatus interrupted")
132
132
  request = False
133
- print(err)
133
+ _LOGGER.error(err)
134
134
 
135
135
  async def sendBorderPackage(self, executeBorder: ExecuteBorder):
136
136
  await self.messageNavigation.post_custom_data(serialize(executeBorder))
@@ -150,7 +150,7 @@ class BleMessage:
150
150
  if len(response) >= 4:
151
151
  sequence = int(response[2]) # toInt
152
152
  if sequence != next(self.mReadSequence):
153
- print(
153
+ _LOGGER.debug(
154
154
  "parseNotification read sequence wrong",
155
155
  sequence,
156
156
  self.mReadSequence,
@@ -168,10 +168,10 @@ class BleMessage:
168
168
  self.notification.setPkgType(pkgType)
169
169
  self.notification.setSubType(subType)
170
170
  frameCtrl = int(response[1]) # toInt
171
- # print("frame ctrl")
172
- # print(frameCtrl)
173
- # print(response)
174
- # print(f"pktType {pkt_type} pkgType {pkgType} subType {subType}")
171
+ # _LOGGER.debug("frame ctrl")
172
+ # _LOGGER.debug(frameCtrl)
173
+ # _LOGGER.debug(response)
174
+ # _LOGGER.debug(f"pktType {pkt_type} pkgType {pkgType} subType {subType}")
175
175
  self.notification.setFrameCtrl(frameCtrl)
176
176
  frameCtrlData = FrameCtrlData(frameCtrl)
177
177
  dataLen = int(response[3]) # toInt specifies length of data
@@ -179,12 +179,12 @@ class BleMessage:
179
179
  try:
180
180
  dataBytes = response[4 : 4 + dataLen]
181
181
  if frameCtrlData.isEncrypted():
182
- print("is encrypted")
182
+ _LOGGER.debug("is encrypted")
183
183
  # BlufiAES aes = new BlufiAES(self.mAESKey, AES_TRANSFORMATION, generateAESIV(sequence));
184
184
  # dataBytes = aes.decrypt(dataBytes);
185
185
  # }
186
186
  if frameCtrlData.isChecksum():
187
- print("checksum")
187
+ _LOGGER.debug("checksum")
188
188
  # int respChecksum1 = toInt(response[response.length - 1]);
189
189
  # int respChecksum2 = toInt(response[response.length - 2]);
190
190
  # int crc = BlufiCRC.calcCRC(BlufiCRC.calcCRC(0, new byte[]{(byte) sequence, (byte) dataLen}), dataBytes);
@@ -208,7 +208,7 @@ class BleMessage:
208
208
  self.notification.addData(dataBytes, dataOffset)
209
209
  return 1 if frameCtrlData.hasFrag() else 0
210
210
  except Exception as e:
211
- print(e)
211
+ _LOGGER.debug(e)
212
212
  return -100
213
213
 
214
214
  # Log.w(TAG, "parseNotification data length less than 4");
@@ -235,7 +235,7 @@ class BleMessage:
235
235
  # this.mSecurityCallback.onReceiveDevicePublicKey(data);
236
236
  # return;
237
237
  # }
238
- print(subType)
238
+ _LOGGER.debug(subType)
239
239
  match subType:
240
240
  # case 15:
241
241
  # parseWifiState(data);
@@ -257,7 +257,7 @@ class BleMessage:
257
257
  if luba_msg.HasField("net"):
258
258
  if luba_msg.net.HasField("toapp_wifi_iot_status"):
259
259
  # await sleep(1.5)
260
- print("sending ble sync")
260
+ _LOGGER.debug("sending ble sync")
261
261
  # await self.send_todev_ble_sync(2)
262
262
  return luba_msg
263
263
 
@@ -297,7 +297,7 @@ class BleMessage:
297
297
  ack = next(self.mAck)
298
298
  return ack == expectAck
299
299
  except Exception as err:
300
- print(err)
300
+ _LOGGER.debug(err)
301
301
  return False
302
302
 
303
303
  def generateSendSequence(self):
@@ -311,9 +311,9 @@ class BleMessage:
311
311
  suc = await self.post(self.mEncrypted, self.mChecksum, self.mRequireAck, type_val, data)
312
312
  # int status = suc ? 0 : BlufiCallback.CODE_WRITE_DATA_FAILED
313
313
  # onPostCustomDataResult(status, data)
314
- # print(suc)
314
+ # _LOGGER.debug(suc)
315
315
  except Exception as err:
316
- print(err)
316
+ _LOGGER.debug(err)
317
317
 
318
318
  async def post_custom_data(self, data_str: str):
319
319
  data = data_str.encode()
@@ -325,7 +325,7 @@ class BleMessage:
325
325
  # int status = suc ? 0 : BlufiCallback.CODE_WRITE_DATA_FAILED
326
326
  # onPostCustomDataResult(status, data)
327
327
  except Exception as err:
328
- print(err)
328
+ _LOGGER.debug(err)
329
329
 
330
330
  async def post(
331
331
  self,
@@ -366,8 +366,8 @@ class BleMessage:
366
366
  frag = index != len(chunks) - 1
367
367
  sequence = self.generateSendSequence()
368
368
  postBytes = self.getPostBytes(type_of, encrypt, checksum, require_ack, frag, sequence, chunk)
369
- # print("sequence")
370
- # print(sequence)
369
+ # _LOGGER.debug("sequence")
370
+ # _LOGGER.debug(sequence)
371
371
  posted = await self.gatt_write(postBytes)
372
372
  if posted != None:
373
373
  return False
@@ -378,7 +378,7 @@ class BleMessage:
378
378
  if require_ack and not self.receiveAck(sequence):
379
379
  return False
380
380
  else:
381
- print("sleeping 0.01")
381
+ _LOGGER.debug("sleeping 0.01")
382
382
  await sleep(0.01)
383
383
 
384
384
  def getPostBytes(
@@ -402,5 +402,5 @@ class BleMessage:
402
402
  if data != None:
403
403
  byteOS.write(data)
404
404
 
405
- print(byteOS.getvalue())
405
+ _LOGGER.debug(byteOS.getvalue())
406
406
  return byteOS.getvalue()
@@ -148,7 +148,7 @@ class ThingEventMessage(DataClassORJSONMixin):
148
148
  elif identifier == "device_warning_event":
149
149
  params_obj = DeviceWarningEventParams(**params_dict)
150
150
  elif identifier == "device_config_req_event":
151
- params_obj = payload.get("params", '')
151
+ params_obj = payload.get("params", {})
152
152
  elif identifier == "device_notification_event":
153
153
  params_obj = DeviceNotificationEventParams(**params_dict)
154
154
  else:
@@ -23,18 +23,3 @@ class MammotionCommand(MessageSystem, MessageNavigation, MessageNetwork, Message
23
23
 
24
24
  def set_device_product_key(self, product_key: str) -> None:
25
25
  self._product_key = product_key
26
-
27
- """BLE commands for Luba."""
28
-
29
- def send_todev_ble_sync(self, sync_type: int) -> bytes:
30
- commEsp = dev_net_pb2.DevNet(todev_ble_sync=sync_type)
31
-
32
- lubaMsg = luba_msg_pb2.LubaMsg()
33
- lubaMsg.msgtype = luba_msg_pb2.MSG_CMD_TYPE_ESP
34
- lubaMsg.sender = luba_msg_pb2.DEV_MOBILEAPP
35
- lubaMsg.msgattr = luba_msg_pb2.MSG_ATTR_REQ
36
- lubaMsg.seqs = 1
37
- lubaMsg.version = 1
38
- lubaMsg.subtype = 1
39
- lubaMsg.net.CopyFrom(commEsp)
40
- return lubaMsg.SerializeToString()
@@ -26,6 +26,10 @@ class MessageNetwork:
26
26
 
27
27
  return luba_msg.SerializeToString()
28
28
 
29
+ def send_todev_ble_sync(self, sync_type: int) -> bytes:
30
+ comm_esp = dev_net_pb2.DevNet(todev_ble_sync=sync_type)
31
+ return self.send_order_msg_net(comm_esp)
32
+
29
33
  def get_device_base_info(self):
30
34
  net = dev_net_pb2.DevNet(todev_devinfo_req=dev_net_pb2.DrvDevInfoReq())
31
35
  net.todev_devinfo_req.req_ids.add(id=1, type=6)
@@ -199,7 +199,7 @@ async def create_devices(ble_device: BLEDevice,
199
199
  preference: ConnectionPreference = ConnectionPreference.BLUETOOTH):
200
200
  mammotion = Mammotion(ble_device, preference)
201
201
 
202
- if cloud_credentials:
202
+ if cloud_credentials and preference == ConnectionPreference.EITHER or preference == ConnectionPreference.WIFI:
203
203
  cloud_client = await Mammotion.login(cloud_credentials.account_id or cloud_credentials.email,
204
204
  cloud_credentials.password)
205
205
  await mammotion.initiate_cloud_connection(cloud_client)
@@ -266,6 +266,7 @@ class Mammotion(object):
266
266
  _LOGGER.debug("CountryCode: " + country_code)
267
267
  _LOGGER.debug("AuthCode: " + mammotion_http.login_info.authorization_code)
268
268
  loop = asyncio.get_running_loop()
269
+ cloud_client.set_http(mammotion_http)
269
270
  await loop.run_in_executor(None, cloud_client.get_region, country_code, mammotion_http.login_info.authorization_code)
270
271
  await cloud_client.connect()
271
272
  await cloud_client.login_by_oauth(country_code, mammotion_http.login_info.authorization_code)
@@ -815,7 +816,6 @@ class MammotionBaseBLEDevice(MammotionBaseDevice):
815
816
  except asyncio.TimeoutError:
816
817
  timeout_expired = True
817
818
  notify_msg = b''
818
- self._notify_future.set_result(notify_msg)
819
819
  finally:
820
820
  if not timeout_expired:
821
821
  timeout_handle.cancel()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pymammotion
3
- Version: 0.2.25
3
+ Version: 0.2.27
4
4
  Summary:
5
5
  License: GNU-3.0
6
6
  Author: Michael Arthur
@@ -1,6 +1,6 @@
1
1
  pymammotion/__init__.py,sha256=kmnjdt3AEMejIz5JK7h1tTJj5ZriAgKwZBa3ScA4-Ao,1516
2
2
  pymammotion/aliyun/__init__.py,sha256=T1lkX7TRYiL4nqYanG4l4MImV-SlavSbuooC-W-uUGw,29
3
- pymammotion/aliyun/cloud_gateway.py,sha256=ra7m3CgP6mIoc0RhRFk-rySdcEWOjbZcDBwvfNvMpM8,22461
3
+ pymammotion/aliyun/cloud_gateway.py,sha256=L3efICH21kHNz2eXpReGoTBoTQU-PERX5RTyS7J6eDA,22576
4
4
  pymammotion/aliyun/cloud_service.py,sha256=YWcKuKK6iRWy5mTnBYgHxcCusiRGGzQt3spSf7dGDss,2183
5
5
  pymammotion/aliyun/dataclass/aep_response.py,sha256=8f6GIP58ve8gd6AL3HBoXxsy0n2q4ygWvjELGnoOnVc,452
6
6
  pymammotion/aliyun/dataclass/connect_response.py,sha256=Yz-fEbDzgGPTo5Of2oAjmFkSv08T7ze80pQU4k-gKIU,824
@@ -11,7 +11,7 @@ pymammotion/aliyun/dataclass/session_by_authcode_response.py,sha256=_5vsyIxocoec
11
11
  pymammotion/aliyun/tmp_constant.py,sha256=M4Hq_lrGB3LZdX6R2XohRPFoK1NDnNV-pTJwJcJ9838,6650
12
12
  pymammotion/bluetooth/__init__.py,sha256=LAl8jqZ1fPh-3mLmViNQsP3s814C1vsocYUa6oSaXt0,36
13
13
  pymammotion/bluetooth/ble.py,sha256=9fA8yw5xXNJRSbC68SdOMf2QJnHoD7RhhCjLFoF0c0I,2404
14
- pymammotion/bluetooth/ble_message.py,sha256=75jaOgUiPoCt33c9OLyCpfN9Pp1QfINTUAFZVF3zoM8,15487
14
+ pymammotion/bluetooth/ble_message.py,sha256=byibcxZ5b_hE3UzHAImyTcxdBOcya9rdswdtuLV8_hY,15663
15
15
  pymammotion/bluetooth/const.py,sha256=CCqyHsYbB0BAYjwdhXt_n6eWWxmhlUrAFjvVv57mbvE,1749
16
16
  pymammotion/bluetooth/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  pymammotion/bluetooth/data/convert.py,sha256=tlctvRODoYypy4FpMD_UBwB1bIn5hG0QdQQdNI0e1R8,792
@@ -35,7 +35,7 @@ pymammotion/data/model/rapid_state.py,sha256=BdJFD_DlhrVneg-PqEruqCoMty-CR7q_9Qn
35
35
  pymammotion/data/model/region_data.py,sha256=75xOTM1qeRbSROp53eIczw3yCmYM9DgMjMh8qE9xkKo,2880
36
36
  pymammotion/data/model/report_info.py,sha256=1Rj_yRZ9apWX296QHae5prdObDbs32bsQf9rzMz2KEQ,4458
37
37
  pymammotion/data/mqtt/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
38
- pymammotion/data/mqtt/event.py,sha256=0bxP7mt3unvoaPIJn5VDUXMuwTcakgw6bfuv64aaYAk,4522
38
+ pymammotion/data/mqtt/event.py,sha256=ec5TfIBaPZefTKTM3SBweM758hYR3ocjb7rNUMpttn0,4522
39
39
  pymammotion/data/mqtt/properties.py,sha256=HkBPghr26L9_b4QaOi1DtPgb0UoPIOGSe9wb3kgnM6Y,2815
40
40
  pymammotion/data/mqtt/status.py,sha256=zqnlo-MzejEQZszl0i0Wucoc3E76x6UtI9JLxoBnu54,1067
41
41
  pymammotion/data/state_manager.py,sha256=T6slACOpbnhWVKmJD_XrBY9vrcCFc6q2l6jEf-g89NQ,3095
@@ -46,19 +46,19 @@ pymammotion/http/http.py,sha256=XJ8_i20HwZ94BqKxCF29dRtRyP_gNOwqJ8gue4F7SOw,2491
46
46
  pymammotion/mammotion/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
47
  pymammotion/mammotion/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
48
  pymammotion/mammotion/commands/abstract_message.py,sha256=nw6r7694yzl7iJKqRqhLmAPRjd_TL_Xo_-JXq2_a_ug,222
49
- pymammotion/mammotion/commands/mammotion_command.py,sha256=LwJkBTXNjEXpJG-vjeJTsSHdvojQflpLJ_D7Q75ZKNQ,1578
49
+ pymammotion/mammotion/commands/mammotion_command.py,sha256=84XxnatnBm_5WQ_KOa2N0ltydQOhSvCme3fFqkuyEhg,1056
50
50
  pymammotion/mammotion/commands/messages/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
51
  pymammotion/mammotion/commands/messages/driver.py,sha256=IFtmp9gJ3p3U2xtTgWVpKBMbnVnUht6Ioih17po6Hr4,3783
52
52
  pymammotion/mammotion/commands/messages/media.py,sha256=ps0l06CXy5Ej--gTNCsyKttwo7yHLVrJUpn-wNJYecs,1150
53
53
  pymammotion/mammotion/commands/messages/navigation.py,sha256=-qit4SrtMpnPr0qsub_HD0pzKMlYsyzspW5uf1Ym008,23217
54
- pymammotion/mammotion/commands/messages/network.py,sha256=1a0BIhaBhBuhqYaK5EUqLbDgfzjzsIGrXS32wMKtxOU,8316
54
+ pymammotion/mammotion/commands/messages/network.py,sha256=Hv5u7omEdffpTsOKw-uIlfhRkd_X1GyvKJT-nswHJ2w,8490
55
55
  pymammotion/mammotion/commands/messages/ota.py,sha256=XkeuWBZtpYMMBze6r8UN7dJXbe2FxUNGNnjwBpXJKM0,1240
56
56
  pymammotion/mammotion/commands/messages/system.py,sha256=m4Cc1zUcLgMFCu6zp5rMupwjDnMD-1PM6hqXpXuXRtw,10984
57
57
  pymammotion/mammotion/commands/messages/video.py,sha256=_8lJsU4sLm2CGnc7RDkueA0A51Ysui6x7SqFnhX8O2g,1007
58
58
  pymammotion/mammotion/control/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
59
59
  pymammotion/mammotion/control/joystick.py,sha256=mresPubTlWCuLQBOFD9KTyYJz5BjZgqt52BaRodemhM,5557
60
60
  pymammotion/mammotion/devices/__init__.py,sha256=T72jt0ejtMjo1rPmn_FeMF3pmp0LLeRRpc9WcDKEYYY,126
61
- pymammotion/mammotion/devices/mammotion.py,sha256=PQPiPxfPGi9wNne2Rcxy7Tcf1kRdkvAvqZqM5nEu5qM,49394
61
+ pymammotion/mammotion/devices/mammotion.py,sha256=Cu6N_zq93TsOnvpd-nH7StopmkKTrzBOQsDKv_RYKEE,49478
62
62
  pymammotion/mqtt/__init__.py,sha256=Ocs5e-HLJvTuDpVXyECEsWIvwsUaxzj7lZ9mSYutNDY,105
63
63
  pymammotion/mqtt/mammotion_future.py,sha256=WKnHqeHiS2Ut-SaDBNOxqh1jDLeTiyLTsJ7PNUexrjk,687
64
64
  pymammotion/mqtt/mammotion_mqtt.py,sha256=X012f5RvmZI52FlgchLSWbngvPnkv9M_gTYvJHakYaM,8127
@@ -113,7 +113,7 @@ pymammotion/utility/map.py,sha256=aoi-Luzuph02hKynTofMoq3mnPstanx75MDAVv49CuY,22
113
113
  pymammotion/utility/movement.py,sha256=JISPBWCOe4MqHbhmkewhV5aWykr1p6f01DzJfvOF-J8,613
114
114
  pymammotion/utility/periodic.py,sha256=9wJMfwXPlx6Mbp3Fws7LLTI34ZDKphH1bva_Ggyk32g,3281
115
115
  pymammotion/utility/rocker_util.py,sha256=syPL0QN4zMzHiTIkUKS7RXBBptjdbkfNlPddwUD5V3A,7171
116
- pymammotion-0.2.25.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
117
- pymammotion-0.2.25.dist-info/METADATA,sha256=liR32EcxsTwl9FcHXPD2W2Xnt7IefPMm5GxOHUTPRMc,3969
118
- pymammotion-0.2.25.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
119
- pymammotion-0.2.25.dist-info/RECORD,,
116
+ pymammotion-0.2.27.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
117
+ pymammotion-0.2.27.dist-info/METADATA,sha256=5ks2LDgNm-FfMrx3bda29NSW3pyW1s8h50iSj9p1pQQ,3969
118
+ pymammotion-0.2.27.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
119
+ pymammotion-0.2.27.dist-info/RECORD,,