OpenThread_app
Loading...
Searching...
No Matches
CoAP Observe Registry

Manages the list of remote subscribers (observers) for local resources. More...

Classes

struct  oac_uri_dataPacket_t
struct  oac_uri_obs_t
struct  oac_uri_observer_t

Macros

#define OAC_URI_OBS_TOKEN_LENGTH   4
#define OAC_URI_OBS_SUBSCRIBERS_MAX_NUM   20
#define OAC_URI_OBS_DEVICENAME_FULL_SIZE   OTAPP_DNS_SRV_LABEL_SIZE
#define OAC_URI_OBS_PAIRED_URI_MAX   OTAPP_PAIRED_URI_MAX
#define OAC_URI_OBS_BUFFER_SIZE   (8 * 4)
#define OAC_URI_OBS_TX_BUFFER_SIZE   (OAC_URI_OBS_TOKEN_LENGTH + OAC_URI_OBS_BUFFER_SIZE)
#define OAC_URI_OBS_UPDATE_IP_ADDR_Msk   (0x1UL << 0U)
#define OAC_URI_OBS_UPDATE_URI_TOKEN_Msk   (0x1UL << 1U)
#define OAC_URI_OBS_ADD_NEW_URI_Msk   (0x1UL << 2U)

Typedefs

typedef int8_t oacu_result_t
typedef uint8_t oacu_uriIndex_t
typedef uint8_t oacu_token_t
typedef struct oac_uri_obs_t oac_uri_obs_t
typedef struct oac_uri_observer_t oac_uri_observer_t

Enumerations

enum  oac_obsError_t {
  OAC_URI_OBS_OK = (-1) , OAC_URI_OBS_ERROR = (-2) , OAC_URI_OBS_IS = (-3) , OAC_URI_OBS_IS_NOT = (-4) ,
  OAC_URI_OBS_TOKEN_EXIST = (-5) , OAC_URI_OBS_TOKEN_NOT_EXIST = (-6) , OAC_URI_OBS_LIST_FULL = (-7) , OAC_URI_OBS_IP_UPDATED = (-8) ,
  OAC_URI_OBS_IP_NO_NEED_UPDATE = (-9) , OAC_URI_OBS_NOT_SUB_REQUEST = (-10) , OAC_URI_OBS_ADDED_NEW_DEVICE = (-11) , OAC_URI_OBS_NO_NEED_UPDATE = (-12)
}

Functions

oac_uri_observer_toac_uri_obs_getSubListHandle (void)
 todo
oac_uri_dataPacket_toac_uri_obs_getdataPacketHandle (void)
 get ptr to oac_uri_dataPacket_t struct. it is like as a buffer. You can override it
int8_t oac_uri_obs_subscribe (oac_uri_observer_t *subListHandle, const oacu_token_t *token, oacu_uriIndex_t uriIndex, const otIp6Address *ipAddr, const char *deviceNameFull)
int8_t oac_uri_obs_subscribeFromUri (oac_uri_observer_t *subListHandle, otMessage *aMessage, const otMessageInfo *aMessageInfo, oacu_uriIndex_t uriId, char *deviceNameFull)
int8_t oac_uri_obs_unsubscribe (oac_uri_observer_t *subListHandle, char *deviceNameFull, const oacu_token_t *token)
 todo
int8_t oac_uri_obs_notify (oac_uri_observer_t *subListHandle, const otIp6Address *excludedIpAddr, oacu_uriIndex_t uriIndex, const uint8_t *dataToNotify, uint16_t dataSize)
 todo
int8_t oac_uri_obs_parseMessageFromNotify (const uint8_t *inBuffer, const uint16_t dataSize, oac_uri_dataPacket_t *out)
 parse incomming message from notify
int8_t oac_uri_obs_deleteAll (oac_uri_observer_t *subListHandle)
int8_t oac_uri_obs_sendSubscribeRequest (const otIp6Address *ipAddr, const char *aUriPath, uint8_t *tokenOut)
 todo
int8_t oac_uri_obs_sendSubscribeRequestUpdate (const otIp6Address *ipAddr, const char *aUriPath, uint8_t *tokenIn)
 todo

Detailed Description

Manages the list of remote subscribers (observers) for local resources.

This module implements the Server-side logic of the CoAP Observe extension (RFC 7641). It acts as a registry for remote devices (Clients) that have requested to be notified about changes in this device's state. Workflow:

  1. Subscription: A remote client sends a GET request with the Observe option to a local URI (e.g. "light/on_off").
  2. Registration: This module saves the Client's IP address, the Token they generated, and the URI they are interested in.
  3. Notification: When the local resource changes (e.g. light turns ON), the application iterates through this registry.
  4. Delivery: The application sends an asynchronous CoAP Response (Notification) to all registered IPs using the stored Tokens.
Author
Jan Łukaszewicz (plhar.nosp@m.eo@g.nosp@m.mail..nosp@m.com)
Version
0.1
Date
16-09-2025

Macro Definition Documentation

◆ OAC_URI_OBS_ADD_NEW_URI_Msk

#define OAC_URI_OBS_ADD_NEW_URI_Msk   (0x1UL << 2U)

◆ OAC_URI_OBS_BUFFER_SIZE

#define OAC_URI_OBS_BUFFER_SIZE   (8 * 4)

◆ OAC_URI_OBS_DEVICENAME_FULL_SIZE

#define OAC_URI_OBS_DEVICENAME_FULL_SIZE   OTAPP_DNS_SRV_LABEL_SIZE

◆ OAC_URI_OBS_PAIRED_URI_MAX

#define OAC_URI_OBS_PAIRED_URI_MAX   OTAPP_PAIRED_URI_MAX

◆ OAC_URI_OBS_SUBSCRIBERS_MAX_NUM

#define OAC_URI_OBS_SUBSCRIBERS_MAX_NUM   20

◆ OAC_URI_OBS_TOKEN_LENGTH

#define OAC_URI_OBS_TOKEN_LENGTH   4

◆ OAC_URI_OBS_TX_BUFFER_SIZE

#define OAC_URI_OBS_TX_BUFFER_SIZE   (OAC_URI_OBS_TOKEN_LENGTH + OAC_URI_OBS_BUFFER_SIZE)

◆ OAC_URI_OBS_UPDATE_IP_ADDR_Msk

#define OAC_URI_OBS_UPDATE_IP_ADDR_Msk   (0x1UL << 0U)

◆ OAC_URI_OBS_UPDATE_URI_TOKEN_Msk

#define OAC_URI_OBS_UPDATE_URI_TOKEN_Msk   (0x1UL << 1U)

Typedef Documentation

◆ oac_uri_obs_t

typedef struct oac_uri_obs_t oac_uri_obs_t

◆ oac_uri_observer_t

typedef struct oac_uri_observer_t oac_uri_observer_t

◆ oacu_result_t

typedef int8_t oacu_result_t

◆ oacu_token_t

typedef uint8_t oacu_token_t

◆ oacu_uriIndex_t

typedef uint8_t oacu_uriIndex_t

Enumeration Type Documentation

◆ oac_obsError_t

Enumerator
OAC_URI_OBS_OK 
OAC_URI_OBS_ERROR 
OAC_URI_OBS_IS 
OAC_URI_OBS_IS_NOT 
OAC_URI_OBS_TOKEN_EXIST 
OAC_URI_OBS_TOKEN_NOT_EXIST 
OAC_URI_OBS_LIST_FULL 
OAC_URI_OBS_IP_UPDATED 
OAC_URI_OBS_IP_NO_NEED_UPDATE 
OAC_URI_OBS_NOT_SUB_REQUEST 
OAC_URI_OBS_ADDED_NEW_DEVICE 
OAC_URI_OBS_NO_NEED_UPDATE 

Function Documentation

◆ oac_uri_obs_deleteAll()

int8_t oac_uri_obs_deleteAll ( oac_uri_observer_t * subListHandle)
Parameters
subListHandle
Returns
int8_t

◆ oac_uri_obs_getdataPacketHandle()

oac_uri_dataPacket_t * oac_uri_obs_getdataPacketHandle ( void )

get ptr to oac_uri_dataPacket_t struct. it is like as a buffer. You can override it

Returns
oac_uri_dataPacket_t* [out] ptr to oac_uri_dataPacket_t

◆ oac_uri_obs_getSubListHandle()

oac_uri_observer_t * oac_uri_obs_getSubListHandle ( void )

todo

Returns
oac_uri_observer_t*

◆ oac_uri_obs_notify()

int8_t oac_uri_obs_notify ( oac_uri_observer_t * subListHandle,
const otIp6Address * excludedIpAddr,
oacu_uriIndex_t uriIndex,
const uint8_t * dataToNotify,
uint16_t dataSize )

todo

Parameters
subListHandle
serverUri
dataToNotify
dataSize
Returns
int8_t

◆ oac_uri_obs_parseMessageFromNotify()

int8_t oac_uri_obs_parseMessageFromNotify ( const uint8_t * inBuffer,
const uint16_t dataSize,
oac_uri_dataPacket_t * out )

parse incomming message from notify

Parameters
inBuffer
dataSize
out
Returns
uint8_t

◆ oac_uri_obs_sendSubscribeRequest()

int8_t oac_uri_obs_sendSubscribeRequest ( const otIp6Address * ipAddr,
const char * aUriPath,
uint8_t * tokenOut )

todo

Parameters
ipAddr
aUriPath
outToken
Returns
int8_t

◆ oac_uri_obs_sendSubscribeRequestUpdate()

int8_t oac_uri_obs_sendSubscribeRequestUpdate ( const otIp6Address * ipAddr,
const char * aUriPath,
uint8_t * tokenIn )

todo

Parameters
ipAddr
aUriPath
tokenIn
Returns
int8_t

◆ oac_uri_obs_subscribe()

int8_t oac_uri_obs_subscribe ( oac_uri_observer_t * subListHandle,
const oacu_token_t * token,
oacu_uriIndex_t uriIndex,
const otIp6Address * ipAddr,
const char * deviceNameFull )
Parameters
subListHandle
token
uriIndex
ipAddr
Returns
int8_t

◆ oac_uri_obs_subscribeFromUri()

int8_t oac_uri_obs_subscribeFromUri ( oac_uri_observer_t * subListHandle,
otMessage * aMessage,
const otMessageInfo * aMessageInfo,
oacu_uriIndex_t uriId,
char * deviceNameFull )
Parameters
subListHandle
aMessage
aMessageInfo
uriId
Returns
int8_t

◆ oac_uri_obs_unsubscribe()

int8_t oac_uri_obs_unsubscribe ( oac_uri_observer_t * subListHandle,
char * deviceNameFull,
const oacu_token_t * token )

todo

Parameters
subListHandle
token
Returns
int8_t