Skip to content

Add option to use external receive tasks#58

Open
mzella-ll wants to merge 1 commit into
CiscoDevNet:mainfrom
mzella-ll:feature/optional-recv-tasks
Open

Add option to use external receive tasks#58
mzella-ll wants to merge 1 commit into
CiscoDevNet:mainfrom
mzella-ll:feature/optional-recv-tasks

Conversation

@mzella-ll
Copy link
Copy Markdown

Summary

This PR adds a compile-time option to disable the internal CoAP receive tasks.

When USE_EXTERNAL_RECV_TASKS is defined, the CoAP client and server no longer create, cancel, declare, or compile their internal receive tasks. This allows applications or platform integrations to operate the receive handling outside of the library.

Changes

  • Guard the CoAP client receive task declaration with USE_EXTERNAL_RECV_TASKS.
  • Guard the CoAP client receive task creation in coapclient_open().
  • Guard the CoAP client receive task cancellation in coapclient_stop().
  • Guard the CoAP client receive task implementation.
  • Guard the CoAP server receive task declaration with USE_EXTERNAL_RECV_TASKS.
  • Guard the CoAP server receive task creation in coapserver_listen().
  • Guard the CoAP server receive task cancellation in coapserver_stop().
  • Guard the CoAP server receive task implementation.

Motivation

In some deployments, incoming CoAP packets are received by code outside of the library, for example by an application-specific task, event loop, scheduler, or platform integration layer.

In these cases, the library should not create its own receive tasks. The new compile-time macro makes the internal receive task handling optional while preserving the existing behavior by default.

Expected behavior

When USE_EXTERNAL_RECV_TASKS is not defined, the existing behavior remains unchanged:

  • the CoAP client creates its internal receive task,
  • the CoAP server creates its internal receive task,
  • both tasks are cancelled when the client/server is stopped.

When USE_EXTERNAL_RECV_TASKS is defined:

  • no internal CoAP receive task is created,
  • no internal CoAP receive task is cancelled,
  • the internal receive task functions are not compiled,
  • receive handling must be provided externally.

Related issue

Fixes #57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow external receive tasks for CoAP client and server

1 participant