pymammotion 0.2.68__py3-none-any.whl → 0.2.70__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.
@@ -7,9 +7,6 @@ from pymammotion.bluetooth.const import (
7
7
  )
8
8
  from pymammotion.event.event import BleNotificationEvent
9
9
 
10
- # TODO setup for each Luba
11
- address = "90:38:0C:6E:EE:9E"
12
-
13
10
 
14
11
  class MammotionBLE:
15
12
  client: BleakClient
@@ -24,9 +21,7 @@ class MammotionBLE:
24
21
  # TODO: do something with incoming data
25
22
  print(device)
26
23
  print(advertising_data)
27
- if device.address == "90:38:0C:6E:EE:9E":
28
- return True
29
- if advertising_data.local_name and "Luba-" in advertising_data.local_name:
24
+ if advertising_data.local_name and ("Luba-" in advertising_data.local_name or "Yuka-" in advertising_data.local_name):
30
25
  return True
31
26
  return False
32
27
 
@@ -12,15 +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
  )
23
- from pymammotion.proto.luba_msg import MsgCmdType, LubaMsg, MsgDevice, MsgAttr
21
+ from pymammotion.proto.luba_msg import LubaMsg, MsgAttr, MsgCmdType, MsgDevice
24
22
  from pymammotion.utility.constant.device_constant import bleOrderCmd
25
23
 
26
24
  _LOGGER = logging.getLogger(__name__)
@@ -56,6 +54,7 @@ class BleMessage:
56
54
  self.mReadSequence = itertools.count(start=0)
57
55
  self.mAck = queue.Queue()
58
56
  self.notification = BlufiNotifyData()
57
+ self._write_char = client.services.get_characteristic(UUID_WRITE_CHARACTERISTIC)
59
58
 
60
59
  async def get_task(self) -> None:
61
60
  hash_map = {"pver": 1, "subCmd": 2, "result": 0}
@@ -130,7 +129,7 @@ class BleMessage:
130
129
  await self.post_custom_data(serialize(executeBorder))
131
130
 
132
131
  async def gatt_write(self, data: bytes) -> None:
133
- await self.client.write_gatt_char(UUID_WRITE_CHARACTERISTIC, data, True)
132
+ await self.client.write_gatt_char(self._write_char, data, True)
134
133
 
135
134
  def parseNotification(self, response: bytearray):
136
135
  dataOffset = None
@@ -145,7 +144,6 @@ class BleMessage:
145
144
  _LOGGER.debug("parseNotification data length less than 4")
146
145
  return -2
147
146
 
148
-
149
147
  sequence = int(response[2]) # toInt
150
148
 
151
149
  # Compare with the second counter, mod 255
@@ -157,7 +155,7 @@ class BleMessage:
157
155
  )
158
156
 
159
157
  # Set the value for mReadSequence manually
160
- self.mReadSequence = itertools.count(start=sequence)
158
+ self.mReadSequence = itertools.count(start=sequence - 1)
161
159
 
162
160
  # LogUtil.m7773e(self.mGatt.getDevice().getName() + "打印丢包率", self.mReadSequence_2 + "/" + self.mReadSequence_1);
163
161
  pkt_type = int(response[0]) # toInt
@@ -251,14 +249,8 @@ class BleMessage:
251
249
  # return;
252
250
  case 19:
253
251
  # # com/agilexrobotics/utils/EspBleUtil$BlufiCallbackMain.smali
254
- luba_msg = parse_custom_data(data) # parse to protobuf message
255
- # really need some sort of callback
256
- if luba_msg.HasField("net"):
257
- if luba_msg.net.HasField("toapp_wifi_iot_status"):
258
- # await sleep(1.5)
259
- _LOGGER.debug("sending ble sync")
260
- # await self.send_todev_ble_sync(2)
261
- return luba_msg
252
+ # luba_msg = parse_custom_data(data) # parse to protobuf message
253
+ return data
262
254
 
263
255
  # private void parseCtrlData(int i, byte[] bArr) {
264
256
  # if (i == 0) {
@@ -312,6 +304,7 @@ class BleMessage:
312
304
  # onPostCustomDataResult(status, data)
313
305
  # _LOGGER.debug(suc)
314
306
  except Exception as err:
307
+ await self.client.disconnect()
315
308
  _LOGGER.debug(err)
316
309
 
317
310
  async def post_custom_data(self, data_str: str) -> None:
@@ -97,9 +97,10 @@ class MammotionBaseBLEDevice(MammotionBaseDevice):
97
97
  self._device = device
98
98
 
99
99
  async def _ble_sync(self) -> None:
100
- _LOGGER.debug("BLE SYNC")
101
- command_bytes = self._commands.send_todev_ble_sync(2)
102
- await self._message.post_custom_data_bytes(command_bytes)
100
+ if self._client is not None and self._client.is_connected:
101
+ _LOGGER.debug("BLE SYNC")
102
+ command_bytes = self._commands.send_todev_ble_sync(2)
103
+ await self._message.post_custom_data_bytes(command_bytes)
103
104
 
104
105
  async def run_periodic_sync_task(self) -> None:
105
106
  """Send ble sync to robot."""
@@ -323,6 +324,7 @@ class MammotionBaseBLEDevice(MammotionBaseDevice):
323
324
  _LOGGER.exception("Error parsing message %s", data)
324
325
  finally:
325
326
  self._message.clearNotification()
327
+ data = b''
326
328
 
327
329
  _LOGGER.debug("%s: Received notification: %s", self.name, data)
328
330
  else:
@@ -379,11 +381,9 @@ class MammotionBaseBLEDevice(MammotionBaseDevice):
379
381
  """Resolve characteristics."""
380
382
  self._read_char = services.get_characteristic(READ_CHAR_UUID)
381
383
  if not self._read_char:
382
- self._read_char = READ_CHAR_UUID
383
384
  _LOGGER.error(CharacteristicMissingError(READ_CHAR_UUID))
384
385
  self._write_char = services.get_characteristic(WRITE_CHAR_UUID)
385
386
  if not self._write_char:
386
- self._write_char = WRITE_CHAR_UUID
387
387
  _LOGGER.error(CharacteristicMissingError(WRITE_CHAR_UUID))
388
388
 
389
389
  def _reset_disconnect_timer(self) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pymammotion
3
- Version: 0.2.68
3
+ Version: 0.2.70
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=C7H7j71fhsvBfI8QEa9PlY3Ugm2CK1CXI7CXqranM48,2470
15
- pymammotion/bluetooth/ble_message.py,sha256=k9yJBfZXA352rzA3csEQgk2prMNuM-r-0NPL1s1_f2c,15320
14
+ pymammotion/bluetooth/ble.py,sha256=sIY0vtUazXDWd_YjIFk9QEbOh_NQ9y5fVrQIemDhKd8,2374
15
+ pymammotion/bluetooth/ble_message.py,sha256=bVgrSnl6882hjGfv117SpV5BFvPkKcShti-CTC8DOOU,15032
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
@@ -63,7 +63,7 @@ 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=P4cJEfntCPcaGlrGGZSWEApM5D5cwCk4MbukfStSP3Q,18889
66
+ pymammotion/mammotion/devices/mammotion_bluetooth.py,sha256=YL_865BZ_DzosiZ1I85l4ro_DTZVQWZT0SLIjAmSyCU,18903
67
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
@@ -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.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,,
122
+ pymammotion-0.2.70.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
123
+ pymammotion-0.2.70.dist-info/METADATA,sha256=Vi-ttJuh4fzMfWA11xLx0O5KGHrNO7Cf3kmGbr73Y2Y,3896
124
+ pymammotion-0.2.70.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
125
+ pymammotion-0.2.70.dist-info/RECORD,,