![]() |
MySensors Library & Examples
2.3.2-62-ge298769
|
MyMessage is used to create, manipulate, send and read MySensors messages.
Definition at line 290 of file MyMessage.h.
#include <MyMessage.h>
Collaboration diagram for MyMessage:Public Member Functions | |
| MyMessage (void) | |
| MyMessage (const uint8_t sensorId, const mysensors_data_t dataType) | |
| void | clear (void) |
| Clear message contents. | |
| char * | getStream (char *buffer) const |
| char * | getString (char *buffer) const |
| Copy the payload into the supplied buffer. | |
| const char * | getString (void) const |
| Get payload as string. More... | |
| void * | getCustom (void) const |
| Get custom payload. More... | |
| bool | getBool (void) const |
| Get bool payload. More... | |
| uint8_t | getByte (void) const |
| Get unsigned 8-bit integer payload. More... | |
| float | getFloat (void) const |
| Get float payload. More... | |
| int16_t | getInt (void) const |
| Get signed 16-bit integer payload. More... | |
| uint16_t | getUInt (void) const |
| Get unsigned 16-bit integer payload. More... | |
| int32_t | getLong (void) const |
| Get signed 32-bit integer payload. More... | |
| uint32_t | getULong (void) const |
| Get unsigned 32-bit integer payload. More... | |
| uint8_t | getHeaderSize (void) const |
| getHeaderSize More... | |
| uint8_t | getMaxPayloadSize (void) const |
| getMaxPayloadSize More... | |
| uint8_t | getExpectedMessageSize (void) const |
| getExpectedMessageSize More... | |
| bool | isProtocolVersionValid (void) const |
| isProtocolVersionValid More... | |
| bool | getRequestEcho (void) const |
| Getter for echo request. More... | |
| MyMessage & | setRequestEcho (const bool requestEcho) |
| Setter for echo request. More... | |
| uint8_t | getVersion (void) const |
| Getter for version. More... | |
| MyMessage & | setVersion (void) |
| Setter for version. | |
| uint8_t | getLength (void) const |
| Getter for length. More... | |
| MyMessage & | setLength (const uint8_t length) |
| Setter for length. More... | |
| mysensors_command_t | getCommand (void) const |
| Getter for command type. More... | |
| MyMessage & | setCommand (const mysensors_command_t command) |
| Setter for command type. More... | |
| mysensors_payload_t | getPayloadType (void) const |
| Getter for payload type. More... | |
| MyMessage & | setPayloadType (const mysensors_payload_t payloadType) |
| Setter for payload type. More... | |
| bool | getSigned (void) const |
| Getter for sign field. More... | |
| MyMessage & | setSigned (const bool signedFlag) |
| Setter for sign field. More... | |
| bool | isAck (void) const |
| Getter for echo-flag. More... | |
| bool | isEcho (void) const |
| Getter for echo-flag. More... | |
| MyMessage & | setEcho (const bool echo) |
| Setter for echo-flag. More... | |
| uint8_t | getType (void) const |
| Get message type. More... | |
| MyMessage & | setType (const uint8_t messageType) |
| Set message type. More... | |
| uint8_t | getLast (void) const |
| Get last ID. More... | |
| MyMessage & | setLast (const uint8_t lastId) |
| Set last ID. More... | |
| uint8_t | getSender (void) const |
| Get sender ID. More... | |
| MyMessage & | setSender (const uint8_t senderId) |
| Set sender ID. More... | |
| uint8_t | getSensor (void) const |
| Get sensor ID of message. More... | |
| MyMessage & | setSensor (const uint8_t sensorId) |
| Set which child sensor this message belongs to. More... | |
| uint8_t | getDestination (void) const |
| Get destination. More... | |
| MyMessage & | setDestination (const uint8_t destinationId) |
| Set final destination node id for this message. More... | |
| MyMessage & | set (const void *payload, const size_t length) |
| Set entire payload. More... | |
| MyMessage & | set (const char *value) |
| Set payload to character array. More... | |
| MyMessage & | set (const __FlashStringHelper *value) |
| Set payload to character array from flash. More... | |
| MyMessage & | set (const float value, const uint8_t decimals) |
| Set payload to decimal number. More... | |
| MyMessage & | set (const bool value) |
| Set payload to bool value. More... | |
| MyMessage & | set (const uint8_t value) |
| Set payload to unsigned 8-bit integer value. More... | |
| MyMessage & | set (const uint32_t value) |
| Set payload to unsigned 32-bit integer value. More... | |
| MyMessage & | set (const int32_t value) |
| Set payload to signed 32-bit integer value. More... | |
| MyMessage & | set (const uint16_t value) |
| Set payload to unsigned 16-bit integer value. More... | |
| MyMessage & | set (const int16_t value) |
| Set payload to signed 16-bit integer value. More... | |
| union { | |
| uint8_t bValue | |
| unsigned byte value (8-bit) | |
| uint16_t uiValue | |
| unsigned integer value (16-bit) | |
| int16_t iValue | |
| signed integer value (16-bit) | |
| uint32_t ulValue | |
| unsigned long value (32-bit) | |
| int32_t lValue | |
| signed long value (32-bit) | |
| struct { | |
| float fValue | |
| < Float messages | |
| uint8_t fPrecision | |
| Number of decimals when serializing. | |
| } __attribute__ | |
| char data [MAX_PAYLOAD_SIZE+1] | |
| Buffer for raw payload data. | |
| } | __attribute__ ((packed)) |
| Doxygen will complain without this comment. | |
Public Attributes | |
| uint8_t | last |
| 8 bit - Id of last node this message passed | |
| uint8_t | sender |
| 8 bit - Id of sender node (origin) | |
| uint8_t | destination |
| 8 bit - Id of destination node | |
| uint8_t | version_length |
| uint8_t | command_echo_payload |
| uint8_t | type |
| 8 bit - Type varies depending on command | |
| uint8_t | sensor |
| 8 bit - Id of sensor that this message concerns. | |
| MyMessage::MyMessage | ( | void | ) |
Default constructor
| MyMessage::MyMessage | ( | const uint8_t | sensorId, |
| const mysensors_data_t | dataType | ||
| ) |
Constructor
| sensorId | id of the child sensor for this message |
| dataType |
| bool MyMessage::getBool | ( | void | ) | const |
Get bool payload.
| uint8_t MyMessage::getByte | ( | void | ) | const |
Get unsigned 8-bit integer payload.
| mysensors_command_t MyMessage::getCommand | ( | void | ) | const |
Getter for command type.
| void* MyMessage::getCustom | ( | void | ) | const |
Get custom payload.
| uint8_t MyMessage::getDestination | ( | void | ) | const |
Get destination.
| uint8_t MyMessage::getExpectedMessageSize | ( | void | ) | const |
getExpectedMessageSize
| float MyMessage::getFloat | ( | void | ) | const |
Get float payload.
| uint8_t MyMessage::getHeaderSize | ( | void | ) | const |
getHeaderSize
| int16_t MyMessage::getInt | ( | void | ) | const |
Get signed 16-bit integer payload.
| uint8_t MyMessage::getLast | ( | void | ) | const |
Get last ID.
| uint8_t MyMessage::getLength | ( | void | ) | const |
Getter for length.
| int32_t MyMessage::getLong | ( | void | ) | const |
Get signed 32-bit integer payload.
| uint8_t MyMessage::getMaxPayloadSize | ( | void | ) | const |
getMaxPayloadSize
| mysensors_payload_t MyMessage::getPayloadType | ( | void | ) | const |
Getter for payload type.
| bool MyMessage::getRequestEcho | ( | void | ) | const |
Getter for echo request.
| uint8_t MyMessage::getSender | ( | void | ) | const |
Get sender ID.
| uint8_t MyMessage::getSensor | ( | void | ) | const |
| bool MyMessage::getSigned | ( | void | ) | const |
Getter for sign field.
| char* MyMessage::getStream | ( | char * | buffer | ) | const |
If payload is something else than P_STRING you can have the payload value converted into string representation by supplying a buffer with the minimum size of 2 * MAX_PAYLOAD_SIZE + 1. This is to be able to fit hex-conversion of a full binary payload.
| buffer | pointer to a buffer that's at least 2 * MAX_PAYLOAD_SIZE + 1 bytes large |
| const char* MyMessage::getString | ( | void | ) | const |
Get payload as string.
| uint8_t MyMessage::getType | ( | void | ) | const |
| uint16_t MyMessage::getUInt | ( | void | ) | const |
Get unsigned 16-bit integer payload.
| uint32_t MyMessage::getULong | ( | void | ) | const |
Get unsigned 32-bit integer payload.
| uint8_t MyMessage::getVersion | ( | void | ) | const |
Getter for version.
| bool MyMessage::isAck | ( | void | ) | const |
| bool MyMessage::isEcho | ( | void | ) | const |
| bool MyMessage::isProtocolVersionValid | ( | void | ) | const |
isProtocolVersionValid
| MyMessage& MyMessage::set | ( | const __FlashStringHelper * | value | ) |
Set payload to character array from flash.
| value | pointer to the character array. The array must be null-terminated. |
| MyMessage& MyMessage::set | ( | const bool | value | ) |
Set payload to bool value.
| value | true or false |
| MyMessage& MyMessage::set | ( | const char * | value | ) |
Set payload to character array.
| value | pointer to the character array. The array must be null-terminated. |
| MyMessage& MyMessage::set | ( | const float | value, |
| const uint8_t | decimals | ||
| ) |
Set payload to decimal number.
| value | float |
| decimals | number of decimals to include |
| MyMessage& MyMessage::set | ( | const int16_t | value | ) |
Set payload to signed 16-bit integer value.
| value | (–32768 to 32767) |
| MyMessage& MyMessage::set | ( | const int32_t | value | ) |
Set payload to signed 32-bit integer value.
| value | (–2147483648 to 2147483647) |
| MyMessage& MyMessage::set | ( | const uint16_t | value | ) |
Set payload to unsigned 16-bit integer value.
| value | (0 to 65535) |
| MyMessage& MyMessage::set | ( | const uint32_t | value | ) |
Set payload to unsigned 32-bit integer value.
| value | (0 to 4294967295) |
| MyMessage& MyMessage::set | ( | const uint8_t | value | ) |
Set payload to unsigned 8-bit integer value.
| value | (0 to 255) |
| MyMessage& MyMessage::set | ( | const void * | payload, |
| const size_t | length | ||
| ) |
Set entire payload.
| payload | pointer to the buffer where the payload is stored |
| length | of the payload |
| MyMessage& MyMessage::setCommand | ( | const mysensors_command_t | command | ) |
Setter for command type.
| command |
| MyMessage& MyMessage::setDestination | ( | const uint8_t | destinationId | ) |
Set final destination node id for this message.
| destinationId |
| MyMessage& MyMessage::setEcho | ( | const bool | echo | ) |
Setter for echo-flag.
| echo | true if this an echo message |
| MyMessage& MyMessage::setLast | ( | const uint8_t | lastId | ) |
Set last ID.
| lastId |
| MyMessage& MyMessage::setLength | ( | const uint8_t | length | ) |
Setter for length.
| length |
| MyMessage& MyMessage::setPayloadType | ( | const mysensors_payload_t | payloadType | ) |
Setter for payload type.
| payloadType |
| MyMessage& MyMessage::setRequestEcho | ( | const bool | requestEcho | ) |
Setter for echo request.
| requestEcho |
| MyMessage& MyMessage::setSender | ( | const uint8_t | senderId | ) |
Set sender ID.
| senderId |
| MyMessage& MyMessage::setSensor | ( | const uint8_t | sensorId | ) |
Set which child sensor this message belongs to.
| sensorId |
| MyMessage& MyMessage::setSigned | ( | const bool | signedFlag | ) |
Setter for sign field.
| signedFlag |
| MyMessage& MyMessage::setType | ( | const uint8_t | messageType | ) |
Set message type.
| messageType |
| uint8_t MyMessage::command_echo_payload |
3 bit - Command type
1 bit - Request an echo - Indicator that receiver should echo the message back to the sender
1 bit - Is echo message - Indicator that this is the echoed message
3 bit - Payload data type
Definition at line 641 of file MyMessage.h.
| uint8_t MyMessage::version_length |
2 bit - Protocol version
1 bit - Signed flag
5 bit - Length of payload
Definition at line 633 of file MyMessage.h.