Skip to content

Commit

Permalink
fix: #43: send length, image, upgrade after initial upload request if…
Browse files Browse the repository at this point in the history
… offset is 0
  • Loading branch information
JPHutchins committed Sep 3, 2024
1 parent 8c5ae1b commit 2fe0a19
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion smpclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,14 @@ async def upload(
while response.off != len(image):
response = await self.request(
self._maximize_image_upload_write_packet(
ImageUploadWrite(off=response.off, data=b""), image
ImageUploadWrite(
off=response.off,
data=b"",
len=len(image) if response.off == 0 else None,
image=slot if response.off == 0 else None,
upgrade=upgrade if response.off == 0 else None,
),
image,
),
timeout_s=subsequent_timeout_s,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_smp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ async def test_upload() -> None:
@patch("tests.test_smp_client.SMPMockTransport.mtu", new_callable=PropertyMock)
@patch("tests.test_smp_client.SMPMockTransport.max_unencoded_size", new_callable=PropertyMock)
@pytest.mark.asyncio
@pytest.mark.parametrize("mtu", [23, 124, 127, 251, 498, 512, 1024, 2048, 4096, 8192])
@pytest.mark.parametrize("mtu", [124, 127, 251, 498, 512, 1024, 2048, 4096, 8192])
async def test_upload_hello_world_bin(
mock_mtu: PropertyMock, mock_max_unencoded_size: PropertyMock, mtu: int
) -> None:
Expand Down

0 comments on commit 2fe0a19

Please sign in to comment.