A module that utilizes MicroCoAPy library to communicate through CoAP with

from protocols import coap_config
from protocols import coap_client

protocol_config = coap_config.CoAPConfig()
protocol_config.server_ip = ""
protocol_config.server_port = 5683
protocol_config.message_channel_id = "aaaaa-bbbb-cccccc-ddddddd"
protocol_config.thing_id = "aaaaa-bbbb-cccccc-ddddddd"
protocol_config.thing_token = "aaaaa-bbbb-cccccc-ddddddd"

coap_cli = coap_client.CoAPClient(cfg.protocol_config)
connectionStatus = coap_cli.start()

coap_cli.postMessage("{test: 1}")

class constructor


Create a new instance of the CoAPClient. Requires a CoAPConfig instance with all the information filled as the configuration will be kept for future calls. Will prepare all the authentication and exchange URLs required to properly communicate with backend.

  • params:
    • coap_config: CoAPConfig instance, for data fields details please advice CoAPConfig page

class methods


Initializes socket and callbacks to be ready for data transmission.

  • returns
    • Boolean: connection status


Publish an Non-Confirmable CoAP message on topic based on message_channel_id as JSON.

  • params:
    • message: A string message to be transmitted.


A request to process messages that have already been received as Publish responses or messages from Subscriptions.


Wait for incoming message for specific period of time.

  • params:
    • timeoutMs: the timeout in (ms). If timeout is set to -1, it will wait indefinitely till a message is received.


Close transmission socket and deinitialize.