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

The option iterator. More...

#include <ProsecCoAP.h>

Public Member Functions

 OptionIterator (const Message &message)
 Initialize the option iterator for the given message.
 
ErrorCode next (Option &option)
 Get the next option in the message.
 

Friends

class Message
 

Detailed Description

The option iterator.

It allows iterating through the options of a CoAP message, in order of increasing option number.

Constructor & Destructor Documentation

◆ OptionIterator()

Coap::OptionIterator::OptionIterator ( const Message & message)

Initialize the option iterator for the given message.

The first byte to be read will be the one after the header and token (if present).

Parameters
messageThe reference to the message to iterate.

Member Function Documentation

◆ next()

ErrorCode Coap::OptionIterator::next ( Option & option)

Get the next option in the message.

Note that some options may be repeated.

Parameters
[out]optionThe next option.
Returns
An error code indicating success or failure. It returns ErrorCode::OK when an option is found. When there are no more options (either end of the message or beginning of payload), it returns ErrorCode::NOT_FOUND. If the message is malformed, it returns ErrorCode::MALFORMED_MESSAGE.
Coap::OptionIterator it = message.getOptionIterator();
Coap::Option option;
while((err = optIterator.next(opt)) == Coap::ErrorCode::OK) {
// Process option...
}
The option iterator.
Definition ProsecCoAP.h:95
A CoAP option.
Definition ProsecCoAP.h:59

Friends And Related Symbol Documentation

◆ Message

friend class Message
friend

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