Skip to content

Commit

Permalink
fix issue with jobId and set bytes to empty if there is an exception …
Browse files Browse the repository at this point in the history
…in ble
  • Loading branch information
mikey0000 committed Oct 21, 2024
1 parent 776824f commit 48c2732
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
9 changes: 3 additions & 6 deletions pymammotion/bluetooth/ble.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
10 changes: 5 additions & 5 deletions pymammotion/mammotion/devices/mammotion_bluetooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions pymammotion/proto/mctrl_nav.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 48c2732

Please sign in to comment.