diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 6d564277..e8cf8644 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -85,7 +85,7 @@ jobs: run: sudo apt-get update && sudo apt install -y graphviz - name: Set up Python 3.11.4 - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: 3.11.4 diff --git a/.github/workflows/python_sdk_test.yml b/.github/workflows/python_sdk_test.yml index e3892b10..f359f8b2 100644 --- a/.github/workflows/python_sdk_test.yml +++ b/.github/workflows/python_sdk_test.yml @@ -16,12 +16,12 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [windows-latest, macos-latest, ubuntu-latest] + os: [windows-latest, macos-12, ubuntu-latest] python-version: ['3.9', '3.10', '3.11'] include: - os: ubuntu-latest path: ~/.cache/pip - - os: macos-latest + - os: macos-12 path: ~/Library/Caches/pip - os: windows-latest path: ~\AppData\Local\pip\Cache @@ -30,7 +30,7 @@ jobs: uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} diff --git a/demos/python/sdk_wireless_camera_control/docs/changelog.rst b/demos/python/sdk_wireless_camera_control/docs/changelog.rst index 06f2b7f7..111caecf 100644 --- a/demos/python/sdk_wireless_camera_control/docs/changelog.rst +++ b/demos/python/sdk_wireless_camera_control/docs/changelog.rst @@ -9,9 +9,10 @@ All notable changes to this project will be documented in this file. The format is based on `Keep a Changelog `_, and this project adheres to `Semantic Versioning `_. -Unreleased ----------- +0.16.1 (April-23-2024) +---------------------- +* Always use extended headers * Add Delete Media HTTP API's * Add port argument to Preview Stream HTTP API * Only ask for sudo password when required diff --git a/demos/python/sdk_wireless_camera_control/open_gopro/ble/adapters/bleak_wrapper.py b/demos/python/sdk_wireless_camera_control/open_gopro/ble/adapters/bleak_wrapper.py index fefd5158..cbfe3b3a 100644 --- a/demos/python/sdk_wireless_camera_control/open_gopro/ble/adapters/bleak_wrapper.py +++ b/demos/python/sdk_wireless_camera_control/open_gopro/ble/adapters/bleak_wrapper.py @@ -89,13 +89,13 @@ async def read(self, handle: bleak.BleakClient, uuid: BleUUID) -> bytearray: logger.debug(f'Received response on BleUUID [{uuid}]: {response.hex( ":")}') return response - async def write(self, handle: bleak.BleakClient, uuid: BleUUID, data: bytearray) -> None: + async def write(self, handle: bleak.BleakClient, uuid: BleUUID, data: bytes) -> None: """Write data to a BleUUID. Args: handle (bleak.BleakClient): Device to write to uuid (BleUUID): characteristic BleUUID to write to - data (bytearray): data to write + data (bytes): data to write """ logger.debug(f"Writing to {uuid}: {uuid.hex}") await handle.write_gatt_char(uuid2bleak_string(uuid), data, response=True) diff --git a/demos/python/sdk_wireless_camera_control/open_gopro/ble/client.py b/demos/python/sdk_wireless_camera_control/open_gopro/ble/client.py index f1615560..32ea82b8 100644 --- a/demos/python/sdk_wireless_camera_control/open_gopro/ble/client.py +++ b/demos/python/sdk_wireless_camera_control/open_gopro/ble/client.py @@ -133,23 +133,23 @@ async def close(self) -> None: else: logger.debug("BLE already disconnected") - async def read(self, uuid: BleUUID) -> bytearray: + async def read(self, uuid: BleUUID) -> bytes: """Read byte data from a characteristic (identified by BleUUID) Args: uuid (BleUUID): characteristic to read Returns: - bytearray: byte data that was read + bytes: byte data that was read """ return await self._controller.read(self._handle, uuid) - async def write(self, uuid: BleUUID, data: bytearray) -> None: + async def write(self, uuid: BleUUID, data: bytes) -> None: """Write byte data to a characteristic (identified by BleUUID) Args: uuid (BleUUID): characteristic to write to - data (bytearray): byte data to write + data (bytes): byte data to write """ await self._controller.write(self._handle, uuid, data) diff --git a/demos/python/sdk_wireless_camera_control/open_gopro/ble/controller.py b/demos/python/sdk_wireless_camera_control/open_gopro/ble/controller.py index c356a798..328ae4b5 100644 --- a/demos/python/sdk_wireless_camera_control/open_gopro/ble/controller.py +++ b/demos/python/sdk_wireless_camera_control/open_gopro/ble/controller.py @@ -24,7 +24,7 @@ def __init__(self, exception_handler: Optional[Callable] = None) -> None: self._exception_handler = exception_handler @abstractmethod - async def read(self, handle: BleHandle, uuid: BleUUID) -> bytearray: + async def read(self, handle: BleHandle, uuid: BleUUID) -> bytes: """Read a bytestream response from a BleUUID. Args: @@ -32,21 +32,21 @@ async def read(self, handle: BleHandle, uuid: BleUUID) -> bytearray: uuid (BleUUID): BleUUID to read from Returns: - bytearray: response + bytes: response """ raise NotImplementedError @abstractmethod - async def write(self, handle: BleHandle, uuid: BleUUID, data: bytearray) -> None: + async def write(self, handle: BleHandle, uuid: BleUUID, data: bytes) -> None: """Write a bytestream to a BleUUID. Args: handle (BleHandle): handle to pair to uuid (BleUUID): BleUUID to write to - data (bytearray): bytestream to write + data (bytes): bytestream to write Returns: - bytearray: response + bytes: response """ raise NotImplementedError diff --git a/demos/python/sdk_wireless_camera_control/open_gopro/communicator_interface.py b/demos/python/sdk_wireless_camera_control/open_gopro/communicator_interface.py index 4379d1de..1daff778 100644 --- a/demos/python/sdk_wireless_camera_control/open_gopro/communicator_interface.py +++ b/demos/python/sdk_wireless_camera_control/open_gopro/communicator_interface.py @@ -262,24 +262,19 @@ async def _read_ble_characteristic( # TODO this should be somewhere else @classmethod - def _fragment(cls, data: bytearray) -> Generator[bytearray, None, None]: + def _fragment(cls, data: bytes) -> Generator[bytes, None, None]: """Fragment data in to MAX_BLE_PKT_LEN length packets Args: - data (bytearray): data to fragment + data (bytes): data to fragment Raises: ValueError: data is too long Yields: - Generator[bytearray, None, None]: Generator of packets as bytearrays + Generator[bytes, None, None]: Generator of packets as bytes """ MAX_BLE_PKT_LEN = 20 - general_header = BitStruct( - "continuation" / Const(0, Bit), - "header" / Const(Header.GENERAL.value, BitsInteger(2)), - "length" / BitsInteger(5), - ) extended_13_header = BitStruct( "continuation" / Const(0, Bit), @@ -300,9 +295,7 @@ def _fragment(cls, data: bytearray) -> Generator[bytearray, None, None]: ) header: Construct - if (data_len := len(data)) < (2**5 - 1): - header = general_header - elif data_len < (2**13 - 1): + if (data_len := len(data)) < (2**13 - 1): header = extended_13_header elif data_len < (2**16 - 1): header = extended_16_header diff --git a/demos/python/sdk_wireless_camera_control/pyproject.toml b/demos/python/sdk_wireless_camera_control/pyproject.toml index e4f9616e..ca471f84 100644 --- a/demos/python/sdk_wireless_camera_control/pyproject.toml +++ b/demos/python/sdk_wireless_camera_control/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "open_gopro" -version = "0.16.0" +version = "0.16.1" description = "Open GoPro API and Examples" authors = ["Tim Camise "] readme = "README.md"