Skip to main content

Python module to communicate over the CoAP protocol

Project description

libcoapy

libcoapy project enables communication over the CoAP protocol (RFC 7252). The llapi module provides ctypes-based wrappers for the libcoap C library. The libcoapy module uses llapi to provide a high-level class interface to the libcoap functions.

Dependencies:

  • libcoap

Status

This project is still in early development. Several functions of the libcoap library are not yet available and existing high-level libcoapy APIs might change in the future.

Example

from libcoapy import *

if len(sys.argv) < 2:
	uri_str = "coaps://localhost/.well-known/core"
else:
	uri_str = sys.argv[1]

ctx = CoapContext()

session = ctx.newSession(uri_str, hint="user", key="password")

def rx_cb(session, tx_msg, rx_msg, mid):
	print(rx_msg.bytes)
	if not tx_msg.observe:
		session.ctx.stop_loop()

session.sendMessage(payload="example data", observe=False, response_callback=rx_cb)

ctx.loop()

For an example with the low-level API, see examples/ll-client.py.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

libcoapy-2024.6.17.tar.gz (12.4 kB view hashes)

Uploaded Source

Built Distribution

libcoapy-2024.6.17-py3-none-any.whl (12.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page