OpenThread_app
Loading...
Searching...
No Matches
CoAP Resource Handlers

Callback functions handling incoming CoAP requests for specific URI paths. More...

Functions

void otapp_coap_uri_testHandle (void *aContext, otMessage *request, const otMessageInfo *aMessageInfo)
 Handler for a generic test resource.
void otapp_coap_uri_ledControlHandle (void *aContext, otMessage *request, const otMessageInfo *aMessageInfo)
 Handler for LED control resource (e.g., "light/on_off").
void otapp_coap_uri_paringServicesHandle (void *aContext, otMessage *request, const otMessageInfo *aMessageInfo)
 Handler for Pairing and Discovery services (e.g., "pairing/service").
void otapp_coap_uri_subscribedHandle (void *aContext, otMessage *request, const otMessageInfo *aMessageInfo)
 Client-side Handler for incoming Observe notifications.
void ad_temp_uri_well_knownCoreHandle (void *aContext, otMessage *request, const otMessageInfo *aMessageInfo)

Detailed Description

Callback functions handling incoming CoAP requests for specific URI paths.

This module defines the "Business Logic" of the CoAP server. Each function corresponds to a specific resource (URI) exposed by the device. These handlers are registered in the main CoAP module and invoked automatically by the OpenThread stack when a matching request arrives. Key Handlers:

  • LED Control: Handles requests to switch lights/LEDs on or off.
  • Pairing Services: Handles device discovery and exchange of capabilities (TLV).
  • Subscription Notify: Client-side handler for processing incoming Observe notifications.
Version
0.1
Date
24-07-2025
Author
Jan Łukaszewicz (plhar.nosp@m.eo@g.nosp@m.mail..nosp@m.com)

Function Documentation

◆ ad_temp_uri_well_knownCoreHandle()

void ad_temp_uri_well_knownCoreHandle ( void * aContext,
otMessage * request,
const otMessageInfo * aMessageInfo )

◆ otapp_coap_uri_ledControlHandle()

void otapp_coap_uri_ledControlHandle ( void * aContext,
otMessage * request,
const otMessageInfo * aMessageInfo )

Handler for LED control resource (e.g., "light/on_off").

Processes PUT/POST requests to change the state of the device's LED or relay. Parses the payload (e.g., "1" or "0") and calls the hardware driver to execute the action.

Parameters
[in]aContextUser context pointer.
[in]requestPointer to the incoming CoAP request message.
[in]aMessageInfoPointer to message metadata.

◆ otapp_coap_uri_paringServicesHandle()

void otapp_coap_uri_paringServicesHandle ( void * aContext,
otMessage * request,
const otMessageInfo * aMessageInfo )

Handler for Pairing and Discovery services (e.g., "pairing/service").

This is the core endpoint for the pairing process.

  • GET: Returns the device's capabilities and supported URIs encoded in TLV format.
  • POST: May be used to initiate a handshake or confirm pairing using otapp_pair_uriParseMessage.
    Parameters
    [in]aContextUser context pointer.
    [in]requestPointer to the incoming CoAP request message.
    [in]aMessageInfoPointer to message metadata.

◆ otapp_coap_uri_subscribedHandle()

void otapp_coap_uri_subscribedHandle ( void * aContext,
otMessage * request,
const otMessageInfo * aMessageInfo )

Client-side Handler for incoming Observe notifications.

This function is NOT a server resource (URI) handler in the traditional sense. It is the callback registered when this device subscribes to a remote resource. It is called when a remote device sends a notification (e.g., "Light status changed"). Logic:

  1. Extracts the CoAP Token from the message.
  2. Matches the Token using oac_uri_obs to identify the sender device.
  3. Updates the internal state mirroring the remote device via oac_uri_obs_parseMessageFromNotify.
    Parameters
    [in]aContextUser context pointer.
    [in]requestPointer to the incoming notification message.
    [in]aMessageInfoPointer to message metadata.

◆ otapp_coap_uri_testHandle()

void otapp_coap_uri_testHandle ( void * aContext,
otMessage * request,
const otMessageInfo * aMessageInfo )

Handler for a generic test resource.

Used for verifying connectivity and basic CoAP functionality (Ping/Pong). Typically responds with a simple ACK or status payload.

Parameters
[in]aContextUser context pointer (unused).
[in]requestPointer to the incoming CoAP request message.
[in]aMessageInfoPointer to message metadata (source IP, port, etc.).