pamoja-coap
A CoAP client over UDP with confirmable delivery and observe. One capability of pamoja, one memory-safe Rust core with bindings for TypeScript, Python, and C#.
Install
pip install pamoja-coap
from pamoja import coap
This pulls in pamoja-native, the compiled engine. pip install pamoja is the whole framework in one package.
Example
The script the test suite runs, spliced here as it ran.
From bindings/python/guides/coap.py:
import asyncio
from pamoja.coap import CoapClient, Reliability
from pamoja.core import PamojaError
async def main() -> None:
# CoAP runs over UDP and opens no session, so connecting only binds a local socket.
# Nothing is listening on the far side here, and for a non-confirmable send nothing
# needs to be.
reporter = CoapClient(
host="127.0.0.1", port=5683, reliability=Reliability.NON_CONFIRMABLE
)
await reporter.connect()
print(f"reporter connected: {await reporter.is_connected()}")
# Non-confirmable delivery is at most once: the datagram leaves unacknowledged, which
# is what a battery-powered node sends when one missed reading costs nothing.
await reporter.send("sensors/1/temperature", b"21.5")
print("reporter sent 21.5 and did not wait for an answer")
# A command is different: it has to arrive. Confirmable delivery retransmits until an
# acknowledgement comes back. RFC 7252 fixes the defaults at a two-second wait and
# four retransmissions; both are cut short here so the guide does not sit waiting.
commander = CoapClient(
host="127.0.0.1",
port=5683,
reliability=Reliability.CONFIRMABLE,
ack_timeout_ms=20,
max_retransmits=1,
)
await commander.connect()
try:
await commander.send("actuators/valve", b"open")
print("commander the valve acknowledged the command")
except PamojaError as error:
print(f"commander gave up unacknowledged: {error}")
await reporter.disconnect()
print(f"reporter disconnected: {not await reporter.is_connected()}")
asyncio.run(main())
The same capability in every language
| Language | Package | Reference |
|---|---|---|
| Rust | pamoja-coap |
reference, docs.rs, install |
| TypeScript | @pamoja/coap |
reference, install |
| Python | pamoja-coap |
reference, install |
| C# | Pamoja.Coap |
reference, install |
Documentation
pamoja.coapreference, every class and function in this module.- The CoAP guide, with the same example in Rust, TypeScript, and C#.
- Every capability, and the install page.
License
MIT
Release files for pamoja-coap 0.1.17
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pamoja_coap-0.1.17.tar.gz | 3.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pamoja_coap-0.1.17-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.5 kB
Release files / pamoja_coap-0.1.17.tar.gz
| Download URL | pamoja_coap-0.1.17.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eda58e9fb5c653cec7282c11364bdb2642db5688ccd8da3ea37bf24f69273a6e
|
|
BLAKE2b-256 checksum How to use checksums |
000153e50d489d798e096e2b415f43bed1a8f4b26a251f3d7f078aa1a602799b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / pamoja_coap-0.1.17-py3-none-any.whl
| Download URL | pamoja_coap-0.1.17-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0565271ccb899f1eb16bbfd2d2e3e00b8d2f45b74e0962f66c57fd861dd4e943
|
|
BLAKE2b-256 checksum How to use checksums |
ebe3c0eb0eac6df80d03bef62dc6e0f54c0e8d73665d1cca9141489ec915b2c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|