smpclient 3.2.0__tar.gz → 3.2.1__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smpclient
3
- Version: 3.2.0
3
+ Version: 3.2.1
4
4
  Summary: Simple Management Protocol (SMP) Client for remotely managing MCU firmware
5
5
  License: Apache-2.0
6
6
  Author: J.P. Hutchins
@@ -16,7 +16,7 @@ Requires-Dist: async-timeout (>=4.0.3,<5.0.0) ; python_version < "3.11"
16
16
  Requires-Dist: bleak (>=0.22.1,<0.23.0)
17
17
  Requires-Dist: intelhex (>=2.3.0,<3.0.0)
18
18
  Requires-Dist: pyserial (>=3.5,<4.0)
19
- Requires-Dist: smp (>=1.0.3,<2.0.0)
19
+ Requires-Dist: smp (>=2.0.0,<3.0.0)
20
20
  Description-Content-Type: text/markdown
21
21
 
22
22
  # Simple Management Protocol (SMP) Client
@@ -21,7 +21,7 @@ source = "git-tag"
21
21
  [tool.poetry.dependencies]
22
22
  python = ">=3.8.1, <3.13"
23
23
  pyserial = "^3.5"
24
- smp = "^1.0.3"
24
+ smp = "^2.0.0"
25
25
  intelhex = "^2.3.0"
26
26
  bleak = "^0.22.1"
27
27
  async-timeout = { version = "^4.0.3", python = "<3.11" }
@@ -145,6 +145,15 @@ class SMPClient:
145
145
  else: # pragma: no cover
146
146
  raise Exception("Unreachable")
147
147
 
148
+ logger.info("Upload complete")
149
+
150
+ if response.match is not None:
151
+ logger.info(f"Server reports {response.match=}")
152
+ if response.match is not True:
153
+ message: Final = f"Upload failed, server reported mismatched SHA256: {response}"
154
+ logger.error(message)
155
+ raise SMPUploadError(message)
156
+
148
157
  @property
149
158
  def address(self) -> str:
150
159
  return self._address
@@ -15,7 +15,7 @@ class ImageStatesWrite(smpimg.ImageStatesWriteRequest, _ImageGroupBase):
15
15
 
16
16
 
17
17
  class ImageUploadWrite(smpimg.ImageUploadWriteRequest, _ImageGroupBase):
18
- _Response = smpimg.ImageUploadProgressWriteResponse
18
+ _Response = smpimg.ImageUploadWriteResponse
19
19
 
20
20
 
21
21
  class ImageErase(smpimg.ImageEraseRequest, _ImageGroupBase):
@@ -4,10 +4,9 @@ from __future__ import annotations
4
4
 
5
5
  import asyncio
6
6
  import logging
7
- import platform
8
7
  import re
9
8
  import sys
10
- from typing import Final, List
9
+ from typing import Final, List, Protocol
11
10
  from uuid import UUID
12
11
 
13
12
  from bleak import BleakClient, BleakGATTCharacteristic, BleakScanner
@@ -23,11 +22,24 @@ if sys.platform == "linux":
23
22
  from bleak.backends.bluezdbus.client import BleakClientBlueZDBus
24
23
  else: # stub for mypy
25
24
 
26
- class BleakClientBlueZDBus:
25
+ class BleakClientBlueZDBus(Protocol):
27
26
  async def _acquire_mtu(self) -> None:
28
27
  ...
29
28
 
30
29
 
30
+ if sys.platform == "win32":
31
+ from bleak.backends.winrt.client import BleakClientWinRT
32
+ else: # stub for mypy
33
+
34
+ class GattSession(Protocol):
35
+ max_pdu_size: int
36
+
37
+ class BleakClientWinRT(Protocol):
38
+ @property
39
+ def _session(self) -> GattSession:
40
+ ...
41
+
42
+
31
43
  SMP_SERVICE_UUID: Final = UUID("8D53DC1D-1DB7-4CD3-868B-8A527460AA84")
32
44
  SMP_CHARACTERISTIC_UUID: Final = UUID("DA2E7828-FBCE-4E01-AE9E-261174997C48")
33
45
 
@@ -95,7 +107,10 @@ class SMPBLETransport(SMPTransport):
95
107
  logger.debug(f"Found SMP characteristic: {smp_characteristic=}")
96
108
  logger.info(f"{smp_characteristic.max_write_without_response_size=}")
97
109
  self._max_write_without_response_size = smp_characteristic.max_write_without_response_size
98
- if platform.system() == "Windows" and self._max_write_without_response_size == 20:
110
+ if (
111
+ self._winrt_backend(self._client._backend)
112
+ and self._max_write_without_response_size == 20
113
+ ):
99
114
  # https://github.com/hbldh/bleak/pull/1552#issuecomment-2105573291
100
115
  logger.warning(
101
116
  "The SMP characteristic MTU is 20 bytes, possibly a Windows bug, checking again"
@@ -201,6 +216,10 @@ class SMPBLETransport(SMPTransport):
201
216
  def _bluez_backend(client_backend: BaseBleakClient) -> TypeGuard[BleakClientBlueZDBus]:
202
217
  return client_backend.__class__.__name__ == "BleakClientBlueZDBus"
203
218
 
219
+ @staticmethod
220
+ def _winrt_backend(client_backend: BaseBleakClient) -> TypeGuard[BleakClientWinRT]:
221
+ return client_backend.__class__.__name__ == "BleakClientWinRT"
222
+
204
223
  def _set_disconnected_event(self, client: BleakClient) -> None:
205
224
  if client is not self._client:
206
225
  raise SMPBLETransportException(
File without changes
File without changes
File without changes