iot_water_monitor_v2

Dependencies:   easy-connect-v16 Watchdog FP MQTTPacket RecordType-v-16 watersenor_and_temp_code

Embed: (wiki syntax)

« Back to documentation index

Message Class Reference

Class containing a list of Record. More...

#include <Message.h>

Public Member Functions

void add_record (Record *r)
 Add a ndef record to this message.
void remove_record (Record *r)
 Remove a ndef record to this message.
void add_records (const std::vector< Record * > &addList)
 Add all the records in the list to this message.
Recordoperator[] (const uint32_t index) const
 Get the specific record contained by this message, NULL if not a valid index.
uint32_t get_N_records () const
 Get the number of records in this message.
uint16_t get_byte_length () const
 Length in bytes needed to write this message.
uint16_t write (uint8_t *buffer) const
 Write message in the provided buffer.

Static Public Member Functions

static void parse_message (const uint8_t *const buffer, const uint16_t bufferLength, Message *message)
 Create a set of records from a raw buffer adding them to a message object.
static void remove_and_delete_all_record (Message &msg)
 Remove all the recrods from the mesasge and delete it.

Detailed Description

Class containing a list of Record.

Definition at line 51 of file Message.h.


Member Function Documentation

void add_record ( Record r )

Add a ndef record to this message.

Parameters:
rRecord to add

Definition at line 58 of file Message.h.

void add_records ( const std::vector< Record * > &  addList )

Add all the records in the list to this message.

Parameters:
addListList of records to add.

Definition at line 75 of file Message.h.

uint16_t get_byte_length (  ) const

Length in bytes needed to write this message.

Returns:
number of bytes needed to write this message

Definition at line 48 of file Message.cpp.

uint32_t get_N_records (  ) const

Get the number of records in this message.

Returns:
number of records in this message

Definition at line 96 of file Message.h.

Record* operator[] ( const uint32_t  index ) const

Get the specific record contained by this message, NULL if not a valid index.

Parameters:
indexRecord index.
Returns:
a Record object if present, otherwise NULL

Definition at line 84 of file Message.h.

void parse_message ( const uint8_t *const   buffer,
const uint16_t  bufferLength,
Message message 
) [static]

Create a set of records from a raw buffer adding them to a message object.

Message buffer must NOT contain the buffer length in the first two bytes.
Parameters:
bufferBuffer containing the message record.
bufferLengthBuffer length.
[in,out]Messagemessage that will contain the new records.

Definition at line 96 of file Message.cpp.

void remove_and_delete_all_record ( Message msg ) [static]

Remove all the recrods from the mesasge and delete it.

Parameters:
msgMessage with the records to delete

Definition at line 120 of file Message.cpp.

void remove_record ( Record r )

Remove a ndef record to this message.

Parameters:
rrecord to remove

Definition at line 66 of file Message.h.

uint16_t write ( uint8_t *  buffer ) const

Write message in the provided buffer.

The first 2 bytes contain the NDEF message length.
Parameters:
[out]bufferBuffer the message must be written into.
Returns:
number of bytes written

Definition at line 65 of file Message.cpp.