Mbed OS Reference
Loading...
Searching...
No Matches
MessageParser Class Reference

Event driven NDEF Message parser. More...

#include <MessageParser.h>

Data Structures

struct  Delegate
 Report parsing event to the application. More...
 

Public Types

enum  error_t {
  INVALID_MESSAGE_START , INSUFICIENT_DATA , INVALID_TYPE_NAME_FORMAT , INVALID_EMPTY_RECORD ,
  INVALID_UNKNOWN_TYPE_LENGTH , INVALID_UNCHANGED_TYPE , CHUNK_RECORD_NOT_SUPPORTED , MISSING_MESSAGE_END ,
  MISSING_TYPE_VALUE
}
 Error that can be reported by the parsing operation. More...
 

Public Member Functions

 MessageParser ()
 Construct a message parser. More...
 
void set_delegate (Delegate *delegate)
 Set the handler that processes parsing events. More...
 
void parse (const Span< const uint8_t > &data_buffer)
 Parse an NDEF Message. More...
 

Detailed Description

Event driven NDEF Message parser.

Definition at line 38 of file MessageParser.h.

Member Enumeration Documentation

◆ error_t

enum error_t

Error that can be reported by the parsing operation.

Enumerator
INVALID_MESSAGE_START 

The message doesn't start with a message start tag.

INSUFICIENT_DATA 

There is not enough data left to pursue parsing of the message.

INVALID_TYPE_NAME_FORMAT 

The type name of a record is invalid.

INVALID_EMPTY_RECORD 

An empty record is malformed.

INVALID_UNKNOWN_TYPE_LENGTH 

Record of unknown type embed a type length different than 0.

INVALID_UNCHANGED_TYPE 

Record of unchanged type contains a type.

CHUNK_RECORD_NOT_SUPPORTED 

Chunk record encountered.

MISSING_MESSAGE_END 

Message is not properly closed.

MISSING_TYPE_VALUE 

Type is missing in a record expecting a type (well known type, media type, absolute uri or external type).

Definition at line 43 of file MessageParser.h.

Constructor & Destructor Documentation

◆ MessageParser()

Construct a message parser.

Member Function Documentation

◆ set_delegate()

void set_delegate ( Delegate delegate)

Set the handler that processes parsing events.

Parameters
delegateThe parsing event handler.

◆ parse()

void parse ( const Span< const uint8_t > &  data_buffer)

Parse an NDEF Message.

Records and errors are reported to the handler registered with set_event_handler.

Parameters
data_bufferThe data buffer that contains the NDEF message.