diff --git a/pymammotion/bluetooth/ble.py b/pymammotion/bluetooth/ble.py index 6d6a856..9e1ec0d 100644 --- a/pymammotion/bluetooth/ble.py +++ b/pymammotion/bluetooth/ble.py @@ -7,9 +7,6 @@ ) from pymammotion.event.event import BleNotificationEvent -# TODO setup for each Luba -address = "90:38:0C:6E:EE:9E" - class MammotionBLE: client: BleakClient @@ -24,9 +21,9 @@ def scanCallback(device, advertising_data) -> bool: # TODO: do something with incoming data print(device) print(advertising_data) - if device.address == "90:38:0C:6E:EE:9E": - return True - if advertising_data.local_name and "Luba-" in advertising_data.local_name: + if advertising_data.local_name and ( + "Luba-" in advertising_data.local_name or "Yuka-" in advertising_data.local_name + ): return True return False diff --git a/pymammotion/mammotion/devices/mammotion_bluetooth.py b/pymammotion/mammotion/devices/mammotion_bluetooth.py index 495bc90..75ad7aa 100644 --- a/pymammotion/mammotion/devices/mammotion_bluetooth.py +++ b/pymammotion/mammotion/devices/mammotion_bluetooth.py @@ -97,9 +97,10 @@ def update_device(self, device: BLEDevice) -> None: self._device = device async def _ble_sync(self) -> None: - _LOGGER.debug("BLE SYNC") - command_bytes = self._commands.send_todev_ble_sync(2) - await self._message.post_custom_data_bytes(command_bytes) + if self._client is not None and self._client.is_connected: + _LOGGER.debug("BLE SYNC") + command_bytes = self._commands.send_todev_ble_sync(2) + await self._message.post_custom_data_bytes(command_bytes) async def run_periodic_sync_task(self) -> None: """Send ble sync to robot.""" @@ -321,6 +322,7 @@ async def _notification_handler(self, _sender: BleakGATTCharacteristic, data: by self._update_raw_data(data) except (KeyError, ValueError, IndexError, UnicodeDecodeError): _LOGGER.exception("Error parsing message %s", data) + data = b"" finally: self._message.clearNotification() @@ -379,11 +381,9 @@ def _resolve_characteristics(self, services: BleakGATTServiceCollection) -> None """Resolve characteristics.""" self._read_char = services.get_characteristic(READ_CHAR_UUID) if not self._read_char: - self._read_char = READ_CHAR_UUID _LOGGER.error(CharacteristicMissingError(READ_CHAR_UUID)) self._write_char = services.get_characteristic(WRITE_CHAR_UUID) if not self._write_char: - self._write_char = WRITE_CHAR_UUID _LOGGER.error(CharacteristicMissingError(WRITE_CHAR_UUID)) def _reset_disconnect_timer(self) -> None: diff --git a/pymammotion/proto/mctrl_nav.proto b/pymammotion/proto/mctrl_nav.proto index 5b7f0cd..a99c86b 100644 --- a/pymammotion/proto/mctrl_nav.proto +++ b/pymammotion/proto/mctrl_nav.proto @@ -174,7 +174,7 @@ message NavGetCommDataAck { message NavReqCoverPath { int32 pver = 1; - int64 jobId = 2; + fixed64 jobId = 2; int32 jobVer = 3; int32 jobMode = 4; int32 subCmd = 5; @@ -195,7 +195,7 @@ message NavReqCoverPath { message NavUploadZigZagResult { int32 pver = 1; - int64 jobId = 2; + fixed64 jobId = 2; int32 jobVer = 3; int32 result = 4; int32 area = 5; diff --git a/pyproject.toml b/pyproject.toml index b546586..52a3574 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [project] name = "pymammotion" -version = "0.2.68" +version = "0.2.73" [tool.poetry] name = "pymammotion" -version = "0.2.68" +version = "0.2.73" license = "GNU-3.0" description = "" readme = "README.md" @@ -61,7 +61,7 @@ mypy = "^1.11.2" autotyping = "^24.3.0" [tool.bumpver] -current_version = "0.2.68" +current_version = "0.2.73" version_pattern = "MAJOR.MINOR.PATCH" commit_message = "Bump version {old_version} -> {new_version}" commit = true