nRF5 SDK v16.0.0
Data Structures | Macros | Functions
CoAP Observe

Public API of Nordic's CoAP Observe implementation. More...

Data Structures

struct  coap_observer_t
 Struct for CoAP Server for holding an instance of a remote observer. More...
 
struct  coap_observable_t
 Struct for CoAP Client for holding an instance of a remote observable resource. More...
 

Macros

#define COAP_OPT_OBSERVE   6
 

Functions

uint32_t coap_observe_server_register (uint32_t *p_handle, coap_observer_t *p_observer)
 Register a new observer. More...
 
uint32_t coap_observe_server_unregister (uint32_t handle)
 Unregister an observer. More...
 
uint32_t coap_observe_server_search (uint32_t *p_handle, coap_remote_t *p_observer_addr, coap_resource_t *p_resource)
 Search the observer list for an observer matching remote address and subject given. More...
 
uint32_t coap_observe_server_next_get (coap_observer_t **pp_observer, coap_observer_t *p_observer, coap_resource_t *p_resource)
 Iterate through observers subscribing to a specific resource. More...
 
uint32_t coap_observe_server_get (uint32_t handle, coap_observer_t **pp_observer)
 Retrieve the observer based on handle. More...
 
uint32_t coap_observe_client_register (uint32_t *p_handle, coap_observable_t *p_observable)
 Register a new observable resource. More...
 
uint32_t coap_observe_client_unregister (uint32_t handle)
 Unregister an observable resource. More...
 
uint32_t coap_observe_client_search (uint32_t *p_handle, uint8_t *p_token, uint16_t token_len)
 Search for a observable resource instance by token. More...
 
uint32_t coap_observe_client_get (uint32_t handle, coap_observable_t **pp_observable)
 Retrieve the observable resource based on handle. More...
 
uint32_t coap_observe_client_next_get (coap_observable_t **pp_observable, uint32_t *p_handle, coap_observable_t *p_observable)
 Iterate through observable resources. More...
 

Detailed Description

Public API of Nordic's CoAP Observe implementation.

Macro Definition Documentation

#define COAP_OPT_OBSERVE   6

Observe option number.

Function Documentation

uint32_t coap_observe_client_get ( uint32_t  handle,
coap_observable_t **  pp_observable 
)

Retrieve the observable resource based on handle.

Parameters
[in]handleHandle to the coap_observable_t instance.
[out]pp_observablePointer to an observable resource return by reference. Should not be NULL.
Return values
NRF_SUCCESSIf observable resource was found in the observable resource list.
NRF_ERROR_NULLIf pp_observable pointer is NULL.
NRF_ERROR_NOT_FOUNDIf observable resource associated with the handle was not found.
uint32_t coap_observe_client_next_get ( coap_observable_t **  pp_observable,
uint32_t *  p_handle,
coap_observable_t p_observable 
)

Iterate through observable resources.

Parameters
[out]pp_observablePointer to be filled by the search function upon finding the next observable resource starting from from the pointer provided. Should not be NULL.
[out]p_handleHandler to the observable resource found returned by reference. Should not be NULL.
[in]p_observablePointer to the observable resource where to start the search.
Return values
NRF_SUCCESSIf observer was found.
NRF_ERROR_NULLIf pp_observer or p_observer pointer is NULL.
NRF_ERROR_NOT_FOUNDIf next observer was not found.
uint32_t coap_observe_client_register ( uint32_t *  p_handle,
coap_observable_t p_observable 
)

Register a new observable resource.

Parameters
[out]p_handleHandle to the observable resource instance registered. Returned by reference. Should not be NULL.
[in]p_observablePointer to a observable resource structure to register. The structure will be copied. Should not be NULL.
Return values
NRF_SUCCESSIf the observable resource was registered successfully.
NRF_ERROR_NO_MEMIf the observable resource could not be added to the list.
NRF_ERROR_NULLIf one of the parameters is a NULL pointer.
uint32_t coap_observe_client_search ( uint32_t *  p_handle,
uint8_t *  p_token,
uint16_t  token_len 
)

Search for a observable resource instance by token.

Parameters
[out]p_handleHandle to the observable resource instance registered. Returned by reference. Should not be NULL.
[in]p_tokenPointer to the byte array holding the token id. Should not be NULL.
[in]token_lenLength of the token.
Return values
NRF_SUCCESSIf observable resource was found in the observable resource list.
NRF_ERROR_NULLIf one of the pointers are NULL.
NRF_ERROR_NOT_FOUNDIf observable resource was not found in the observable resource list.
uint32_t coap_observe_client_unregister ( uint32_t  handle)

Unregister an observable resource.

Unregister the observable resource and clear the memory used by this instance.

Parameters
[in]handleHandle to the observable resource instance registered.
Return values
NRF_SUCCESSIf the observable resource was successfully unregistered.
NRF_ERROR_NOT_FOUNDIf the given handle was not found in the observable resource list.
uint32_t coap_observe_server_get ( uint32_t  handle,
coap_observer_t **  pp_observer 
)

Retrieve the observer based on handle.

Parameters
[in]handleHandle to the coap_observer_t instance.
[out]pp_observerPointer to an observer return by reference. Should not be NULL.
Return values
NRF_SUCCESSIf observer was found in the observer list.
NRF_ERROR_NULLIf pp_observer pointer is NULL.
NRF_ERROR_NOT_FOUNDIf observer associated with the handle was not found.
uint32_t coap_observe_server_next_get ( coap_observer_t **  pp_observer,
coap_observer_t p_observer,
coap_resource_t p_resource 
)

Iterate through observers subscribing to a specific resource.

Parameters
[out]pp_observerPointer to be filled by the search function upon finding the next observer starting from from the p_observer pointer provided. Should not be NULL.
[in]p_observerPointer to the observer where to start the search.
[in]p_resourcePointer to the resource of interest. Should not be NULL.
Return values
NRF_SUCCESSIf observer was found.
NRF_ERROR_NULLIf pp_observer or p_resource pointer is NULL.
NRF_ERROR_NOT_FOUNDIf next observer was not found.
uint32_t coap_observe_server_register ( uint32_t *  p_handle,
coap_observer_t p_observer 
)

Register a new observer.

Parameters
[out]p_handleHandle to the observer instance registered. Returned by reference. Should not be NULL.
[in]p_observerPointer to the observer structure to register. The data will be copied. Should not be NULL.
Return values
NRF_SUCCESSIf the observer was registered successfully.
NRF_ERROR_NO_MEMIf the observer could not be added to the list.
NRF_ERROR_NULLIf one of the parameters is a NULL pointer.
uint32_t coap_observe_server_search ( uint32_t *  p_handle,
coap_remote_t p_observer_addr,
coap_resource_t p_resource 
)

Search the observer list for an observer matching remote address and subject given.

Parameters
[out]p_handleHandle to the observer instance registered. Returned by reference. Should not be NULL.
[in]p_observer_addrPointer to an address structure giving remote address of the observer and port number. Should not be NULL.
[in]p_resourcePointer to the resource the observer is registered to. Should not be NULL.
Return values
NRF_SUCCESSIf observer was found in the observer list.
NRF_ERROR_NULLIf one of the pointers are NULL.
NRF_ERROR_NOT_FOUNDIf observer was not found.
uint32_t coap_observe_server_unregister ( uint32_t  handle)

Unregister an observer.

Unregister the observer and clear the memory used by this instance.

Parameters
[in]handleHandle to the observer instance registered.
Return values
NRF_SUCCESSIf the observer was successfully unregistered.
NRF_ERROR_NOT_FOUNDIf the given handle was not found in the observer list.

Documentation feedback | Developer Zone | Subscribe | Updated