Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

MessageBuilder Class Reference

Construct a NDEF Message. More...

#include <MessageBuilder.h>

Data Structures

struct  PayloadBuilder
 Build a record payload. More...

Public Member Functions

 MessageBuilder (const Span< uint8_t > &buffer)
 Create a new MessageBuilder that can be used to construct valid NDEF messages.
bool append_record (const RecordType &type, const RecordPayload &payload=RecordPayload(), bool is_last_record=false)
 Append a new record to the message being built.
bool append_record (const RecordType &type, const PayloadBuilder &builder, bool is_last_record=false)
 Append a new record to the message being built.
bool append_record (const Record &record, const PayloadBuilder *builder=NULL)
 Append a new record to the message being built.
void reset ()
 Reset the builder state.
void reset (const Span< uint8_t > &buffer)
 Reset the builder state and assign a new buffer to it.
bool is_message_complete () const
 Return true if the message stored is complete and false otherwise.
Span< const uint8_t > get_message () const
 Return the buffer storing the data if the message is complete or an empty buffer if the message is not complete.

Static Public Member Functions

static size_t compute_record_size (const Record &record, const PayloadBuilder *builder=NULL)
 Compute the size of a record.

Detailed Description

Construct a NDEF Message.

Definition at line 37 of file MessageBuilder.h.


Constructor & Destructor Documentation

MessageBuilder ( const Span< uint8_t > &  buffer )

Create a new MessageBuilder that can be used to construct valid NDEF messages.

Parameters:
bufferThe data buffer that will contain the NDEF message.

Definition at line 25 of file MessageBuilder.cpp.


Member Function Documentation

bool append_record ( const RecordType type,
const RecordPayload payload = RecordPayload(),
bool  is_last_record = false 
)

Append a new record to the message being built.

Parameters:
typeThe type of the record to insert.
payloadThe payload of the record (optional).
is_last_recordtrue if the record to insert is the last record of the payload or false otherwise.
Returns:
true if the record has been successfully inserted or false otherwise.
Note:
insertion can fail if the message is already complete or if the size remaining in the message buffer is not large enough to makes the record inserted fit.

Definition at line 33 of file MessageBuilder.cpp.

bool append_record ( const RecordType type,
const PayloadBuilder builder,
bool  is_last_record = false 
)

Append a new record to the message being built.

Parameters:
typeThe type of the record to insert.
builderThe builder of the payload.
is_last_recordtrue if the record to insert is the last record of the payload or false otherwise.
Returns:
true if the record has been successfully inserted or false otherwise.
Note:
insertion can fail if the message is already complete or if the size remaining in the message buffer is not large enough to makes the record inserted fit.

Definition at line 50 of file MessageBuilder.cpp.

bool append_record ( const Record record,
const PayloadBuilder builder = NULL 
)

Append a new record to the message being built.

Parameters:
recordThe record to insert.
builderThe builder that will construct the payload.
Returns:
true if the record has been successfully inserted or false otherwise.
Note:
insertion can fail if the message is already complete or if the size remaining in the message buffer is not large enough to makes the record inserted fit.

Definition at line 68 of file MessageBuilder.cpp.

size_t compute_record_size ( const Record record,
const PayloadBuilder builder = NULL 
) [static]

Compute the size of a record.

Parameters:
recordThe record used to compute the size.
builderThe payload builder if any.
Returns:
The size of the payload for the record in input.

Definition at line 182 of file MessageBuilder.cpp.

Span< const uint8_t > get_message (  ) const

Return the buffer storing the data if the message is complete or an empty buffer if the message is not complete.

Returns:
The message built.

Definition at line 173 of file MessageBuilder.cpp.

bool is_message_complete (  ) const

Return true if the message stored is complete and false otherwise.

Returns:
true if the message is complete or false.

Definition at line 168 of file MessageBuilder.cpp.

void reset ( const Span< uint8_t > &  buffer )

Reset the builder state and assign a new buffer to it.

Definition at line 159 of file MessageBuilder.cpp.

void reset ( void   )

Reset the builder state.

Definition at line 151 of file MessageBuilder.cpp.