Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,29 @@ jobs:
extras: ""
expect-serial: fail
expect-ble: fail
expect-bumble: fail
- name: serial-only
extras: "[serial]"
expect-serial: pass
expect-ble: fail
expect-bumble: fail
- name: ble-only
extras: "[ble]"
expect-serial: fail
expect-ble: pass
expect-bumble: fail
- name: bumble-only
extras: "[bumble]"
# bumble depends on pyserial-asyncio, which transitively installs
# pyserial — so the serial transport import happens to succeed too.
expect-serial: pass
expect-ble: fail
expect-bumble: pass
- name: all
extras: "[all]"
expect-serial: pass
expect-ble: pass
expect-bumble: pass
name: transport-extras (${{ matrix.name }})
steps:
- uses: actions/checkout@v4
Expand All @@ -82,6 +93,14 @@ jobs:
! .venv/bin/python -c "from smpclient.transport.ble import SMPBLETransport" 2>/dev/null
fi

- name: bumble transport should ${{ matrix.expect-bumble }}
run: |
if [ "${{ matrix.expect-bumble }}" = "pass" ]; then
.venv/bin/python -c "from smpclient.transport.bumble import SMPBumbleTransport"
else
! .venv/bin/python -c "from smpclient.transport.bumble import SMPBumbleTransport" 2>/dev/null
fi

- name: udp transport should pass
run: .venv/bin/python -c "from smpclient.transport.udp import SMPUDPTransport"

Expand Down
18 changes: 10 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ classifiers = [
"Operating System :: MacOS :: MacOS X",
]
dependencies = [
"smp>=4.0.2",
"intelhex>=2.3.0",
"async-timeout>=4.0.3; python_version < '3.11'",
"smp>=4.0.2,<5",
"intelhex>=2.3,<3",
"async-timeout>=4.0.3,<5; python_version < '3.11'",
]

[project.optional-dependencies]
serial = ["pyserial>=3.5"]
ble = ["bleak>=2.0.0"]
serial = ["pyserial>=3.5,<4"]
ble = ["bleak>=2,<3"]
udp = []
all = ["smpclient[serial,ble,udp]"]
bumble = ["bumble==0.0.228", "libusb1>=3.1,<4", "platformdirs>=4,<5"]
all = ["smpclient[serial,ble,udp,bumble]"]

[project.urls]
Homepage = "https://www.intercreate.io"
Expand All @@ -40,6 +41,7 @@ Issues = "https://github.com/intercreate/smpclient/issues"

[project.scripts]
mcuimg = "smpclient.mcuboot:mcuimg"
smpbumble = "smpclient.transport.bumble.__main__:smpbumble"

[build-system]
requires = ["hatchling", "hatch-vcs"]
Expand Down Expand Up @@ -89,7 +91,7 @@ matrix = """

[tool.ruff]
line-length = 100
extend-exclude = ["dutfirmware"]
extend-exclude = ["dutfirmware", ".claude"]

[tool.ruff.lint]
extend-select = ["I", "D"]
Expand All @@ -113,7 +115,7 @@ check-return-types = false
check-yield-types = false

[tool.pytest.ini_options]
norecursedirs = "dutfirmware/*"
norecursedirs = ["dutfirmware/*", ".claude/*"]
filterwarnings = ["ignore:The --rsyncdir:DeprecationWarning"]

[tool.coverage.run]
Expand Down
13 changes: 12 additions & 1 deletion src/smpclient/transport/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
"""Simple Management Protocol (SMP) Client Transport Protocol."""

from typing import Protocol
from typing import Final, Protocol
from uuid import UUID

SMP_SERVICE_UUID: Final = UUID("8D53DC1D-1DB7-4CD3-868B-8A527460AA84")
"""The 128-bit GATT service UUID for an SMP server.

Shared by all GATT-based transports (`ble`, `bumble`) so the constant has a
single source of truth.
"""

SMP_CHARACTERISTIC_UUID: Final = UUID("DA2E7828-FBCE-4E01-AE9E-261174997C48")
"""The 128-bit GATT characteristic UUID for the SMP write+notify channel."""


class SMPTransportDisconnected(Exception):
Expand Down
10 changes: 6 additions & 4 deletions src/smpclient/transport/ble.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@
from typing_extensions import override

from smpclient.exceptions import SMPClientException
from smpclient.transport import SMPTransport, SMPTransportDisconnected
from smpclient.transport import (
SMP_CHARACTERISTIC_UUID,
SMP_SERVICE_UUID,
SMPTransport,
SMPTransportDisconnected,
)

if sys.platform == "linux":
from bleak.backends.bluezdbus.client import BleakClientBlueZDBus
Expand All @@ -42,9 +47,6 @@ class BleakClientWinRT(Protocol):
def _session(self) -> GattSession: ...


SMP_SERVICE_UUID: Final = UUID("8D53DC1D-1DB7-4CD3-868B-8A527460AA84")
SMP_CHARACTERISTIC_UUID: Final = UUID("DA2E7828-FBCE-4E01-AE9E-261174997C48")

MAC_ADDRESS_PATTERN: Final = re.compile(r"([0-9A-F]{2}[:]){5}[0-9A-F]{2}$", flags=re.IGNORECASE)
UUID_PATTERN: Final = re.compile(
r"^[a-f0-9]{8}-?[a-f0-9]{4}-?[a-f0-9]{4}-?[a-f0-9]{4}-?[a-f0-9]{12}\Z",
Expand Down
Loading