ProsecCoAP 🥂
 
Loading...
Searching...
No Matches
Coap::Observer Class Reference

A remote CoAP observer, actively observing a resource. More...

#include <Observers.h>

Public Member Functions

 Observer ()
 Default constructor that creates an inactive observer.
 
 Observer (IPAddress ip, uint16_t port, const uint8_t *token, uint8_t tokenLength)
 Constructor that creates an active observer with the given parameters.
 
bool isActive () const
 Check if the observer is currently active.
 
void setActive (bool active)
 Set the observer as active or inactive.
 
IPAddress getIp () const
 Get the IP address of the observer.
 
uint16_t getPort () const
 Get the port of the observer.
 
const uint8_t * getToken () const
 Get the token pointer used by the observer.
 
uint8_t getTokenLength () const
 Get the token length used by the observer.
 
uint32_t getNextSequentialNumber ()
 The sequential number for notifications, as per specifications.
 

Detailed Description

A remote CoAP observer, actively observing a resource.

It tracks a remote observer registered for notifications.

Constructor & Destructor Documentation

◆ Observer() [1/2]

Coap::Observer::Observer ( )
inline

Default constructor that creates an inactive observer.

◆ Observer() [2/2]

Coap::Observer::Observer ( IPAddress ip,
uint16_t port,
const uint8_t * token,
uint8_t tokenLength )
inline

Constructor that creates an active observer with the given parameters.

Parameters
ipThe IP address of the observer.
portThe port of the observer.
tokenThe token used by the observer.
tokenLengthThe length of the token in bytes.

Member Function Documentation

◆ getIp()

IPAddress Coap::Observer::getIp ( ) const
inline

Get the IP address of the observer.

Returns
The IP address.

◆ getNextSequentialNumber()

uint32_t Coap::Observer::getNextSequentialNumber ( )
inline

The sequential number for notifications, as per specifications.

As per https://datatracker.ietf.org/doc/html/rfc7641#section-4.4, the sequence number MAY start at any value and MUST NOT increase so fast that it increases by more than 2^23 within less than 256 seconds.

As per implementation notes, using the local clock (e.g. millis()) is a simple way to meet this requirement.

Note
Only the least significant 24 bits are used.

◆ getPort()

uint16_t Coap::Observer::getPort ( ) const
inline

Get the port of the observer.

Returns
The port number.

◆ getToken()

const uint8_t * Coap::Observer::getToken ( ) const
inline

Get the token pointer used by the observer.

Returns
Pointer to the token.

◆ getTokenLength()

uint8_t Coap::Observer::getTokenLength ( ) const
inline

Get the token length used by the observer.

Returns
The token length in bytes.

◆ isActive()

bool Coap::Observer::isActive ( ) const
inline

Check if the observer is currently active.

Returns
True if the observer is active, false otherwise.

◆ setActive()

void Coap::Observer::setActive ( bool active)
inline

Set the observer as active or inactive.

Parameters
activeTrue to set the observer as active, false to set it as inactive.

The documentation for this class was generated from the following file: