Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
MessageBuilder Class Reference
[Nfc]
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:
-
buffer The 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:
-
type The type of the record to insert. payload The payload of the record (optional). is_last_record true 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:
-
type The type of the record to insert. builder The builder of the payload. is_last_record true 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:
-
record The record to insert. builder The 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:
-
record The record used to compute the size. builder The 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.
Generated on Tue Jul 12 2022 13:55:44 by
