Skip to content
Merged
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
1 change: 0 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,4 @@ jobs:

- name: Build and deploy documentation
run: |
uv run --group doc python docs/_generate_requests_docstrings.py
uv run --group doc mike deploy --push --update-aliases ${GIT_TAG} latest
1 change: 0 additions & 1 deletion .github/workflows/test-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ jobs:

- name: Build docs
run: |
uv run --group doc python docs/_generate_requests_docstrings.py
uv run --group doc mkdocs build
177 changes: 0 additions & 177 deletions docs/_generate_requests_docstrings.py

This file was deleted.

6 changes: 0 additions & 6 deletions docs/file_management.md

This file was deleted.

6 changes: 0 additions & 6 deletions docs/image_management.md

This file was deleted.

6 changes: 0 additions & 6 deletions docs/os_management.md

This file was deleted.

47 changes: 43 additions & 4 deletions docs/requests.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,45 @@
# Requests Helpers
# Requests and Responses

Refer to the [smp documentation](https://jphutchins.github.io/smp/latest/) for a
complete description of each SMP Request and Response.
Every SMP Request and Response is defined by
[smp](https://jphutchins.github.io/smp/latest/), and each Request carries the
`Response`, `ErrorV1`, and `ErrorV2` it may provoke. `SMPClient.request()` therefore
returns a union that narrows exhaustively:

::: smpclient.generics
```python
response = await client.request(EchoWriteRequest(d="Hello, World!"))

if success(response):
print(response.r)
elif error_v1(response):
print(response.rc)
elif error_v2(response):
print(response.err.rc)
else:
assert_never(response)
```

## Groups

Construct requests directly from `smp`:

| Group | Reference |
| --- | --- |
| Enumeration Management | [smp.enumeration_management](https://jphutchins.github.io/smp/latest/enumeration_management/) |
| File Management | [smp.file_management](https://jphutchins.github.io/smp/latest/file_management/) |
| Image Management | [smp.image_management](https://jphutchins.github.io/smp/latest/image_management/) |
| OS Management | [smp.os_management](https://jphutchins.github.io/smp/latest/os_management/) |
| Settings Management | [smp.settings_management](https://jphutchins.github.io/smp/latest/settings_management/) |
| Shell Management | [smp.shell_management](https://jphutchins.github.io/smp/latest/shell_management/) |
| Statistics Management | [smp.statistics_management](https://jphutchins.github.io/smp/latest/statistics_management/) |
| Zephyr Management | [smp.zephyr_management](https://jphutchins.github.io/smp/latest/zephyr_management/) |
| Intercreate (user) | [smp.user.intercreate](https://jphutchins.github.io/smp/latest/user/intercreate/) |

## Narrowing helpers

::: smpclient.success

::: smpclient.error

::: smpclient.error_v1

::: smpclient.error_v2
6 changes: 0 additions & 6 deletions docs/settings_management.md

This file was deleted.

6 changes: 0 additions & 6 deletions docs/shell_management.md

This file was deleted.

6 changes: 0 additions & 6 deletions docs/statistics_management.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/user/intercreate.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
Refer to the [smp Intercreate documentation](https://jphutchins.github.io/smp/latest/user/intercreate)
for a complete description of each Request and Response.

::: smpclient.requests.user.intercreate
::: smpclient.extensions.intercreate
6 changes: 0 additions & 6 deletions docs/zephyr_management.md

This file was deleted.

8 changes: 4 additions & 4 deletions examples/ble/helloworld.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import asyncio
from typing import Final

from smpclient import SMPClient
from smpclient.generics import error, success
from smpclient.requests.os_management import EchoWrite
from smp.os_management import EchoWriteRequest

from smpclient import SMPClient, error, success
from smpclient.transport.ble import SMPBLETransport


Expand All @@ -20,7 +20,7 @@ async def main() -> None:
print("OK")

print("Sending request...", end="", flush=True)
response: Final = await client.request(EchoWrite(d="Hello, World!"))
response: Final = await client.request(EchoWriteRequest(d="Hello, World!"))
print("OK")

if success(response):
Expand Down
8 changes: 4 additions & 4 deletions examples/ble/imagestate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import asyncio
from typing import Final

from smpclient import SMPClient
from smpclient.generics import error, success
from smpclient.requests.image_management import ImageStatesRead
from smp.image_management import ImageStatesReadRequest

from smpclient import SMPClient, error, success
from smpclient.transport.ble import SMPBLETransport


Expand All @@ -20,7 +20,7 @@ async def main() -> None:
print("OK")

print("Sending request...", end="", flush=True)
response: Final = await client.request(ImageStatesRead())
response: Final = await client.request(ImageStatesReadRequest())
print("OK")

if success(response):
Expand Down
8 changes: 4 additions & 4 deletions examples/ble/mcumgrparameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import asyncio
from typing import Final

from smpclient import SMPClient
from smpclient.generics import error, success
from smpclient.requests.os_management import MCUMgrParametersRead
from smp.os_management import MCUMgrParametersReadRequest

from smpclient import SMPClient, error, success
from smpclient.transport.ble import SMPBLETransport


Expand All @@ -22,7 +22,7 @@ async def main() -> None:
print(f"Client max unencoded size is {client._transport.max_unencoded_size}B")

print("Sending request...", end="", flush=True)
response: Final = await client.request(MCUMgrParametersRead())
response: Final = await client.request(MCUMgrParametersReadRequest())
print("OK")

if success(response):
Expand Down
Loading