SatCat5
satcat5::coap::ReadHeader Class Reference

Detailed Description

Parser for CoAP message headers only.

See also
coap_reader.h, coap::Option.

Definition at line 80 of file coap_reader.h.

#include <coap_reader.h>

Inheritance diagram for satcat5::coap::ReadHeader:
[legend]
Collaboration diagram for satcat5::coap::ReadHeader:
[legend]

Public Member Functions

 ReadHeader (satcat5::io::Readable *src)
 Create this object and read the message header only.
 
 ReadHeader (const ReadHeader &)=delete
 
ReadHeaderoperator= (const ReadHeader &)=delete
 
bool next_option ()
 Consume current option and advance to the next one. More...
 
satcat5::io::Readableread_data ()
 Access the message payload. More...
 
void read_finalize ()
 Forward read_finalize() to the inner source.
 
bool error () const
 < Error during parsing?
 
Code error_code () const
 < Code for the error
 
const char * error_msg () const
 < Optional message
 
u8 version () const
 < Version (Ver)
 
u8 type () const
 < Type (T)
 
u8 tkl () const
 < Token length (TKL)
 
Code code () const
 < Response code (CODE)
 
u16 msg_id () const
 < Message ID
 
u64 token () const
 < Token value
 
bool is_request () const
 < CON or NON request?
 
bool is_response () const
 < ACK request?
 
satcat5::coap::Optionoption ()
 

Protected Types

enum class  State { OPTIONS , DATA , ERROR }
 List of possible parser states.
 

Protected Member Functions

u16 read_var_int (u8 nybb)
 Read variable-length integer from Option header.
 
void set_error (Code code, const char *msg="")
 Set error code and stop further parsing.
 

Protected Attributes

satcat5::io::Readable *const m_src
 Source buffer of CoAP message.
 
State m_state
 Parser state.
 
Code m_error_code
 Error code, or Empty to Reset.
 
const char * m_error_msg
 Diagnostic Payload for error.
 
const u8 m_type
 Version, type, TKL.
 
satcat5::coap::Code m_code
 Status code x.yy.
 
const u16 m_id
 Message ID.
 
u64 m_token
 Token (0-8 bytes)
 
satcat5::coap::Option m_opt
 Contents of the current option.
 

Member Function Documentation

◆ next_option()

bool ReadHeader::next_option ( )

Consume current option and advance to the next one.

Returns
True until all options have been read.

Definition at line 59 of file coap_reader.cc.

◆ read_data()

Readable * ReadHeader::read_data ( )

Access the message payload.

Calling this method discards any unparsed options.

Definition at line 90 of file coap_reader.cc.


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