MySensors Library & Examples  2.3.2-62-ge298769
Classes | Macros | Enumerations | Functions
+ Collaboration diagram for MyMessage:

Detailed Description

Here you can find all message types used by the MySensors protocol as well as macros for parsing and manipulating messages.

Classes

class  MyMessage
 MyMessage is used to create, manipulate, send and read MySensors messages. More...
 

Macros

#define V2_MYS_HEADER_PROTOCOL_VERSION   (2u)
 Protocol version.
 
#define V2_MYS_HEADER_SIZE   (7u)
 Header size.
 
#define V2_MYS_HEADER_MAX_MESSAGE_SIZE   (32u)
 Max payload size.
 
#define V2_MYS_HEADER_VSL_VERSION_POS   (0)
 bitfield position version
 
#define V2_MYS_HEADER_VSL_VERSION_SIZE   (2u)
 size version field
 
#define V2_MYS_HEADER_VSL_SIGNED_POS   (2u)
 bitfield position signed field
 
#define V2_MYS_HEADER_VSL_SIGNED_SIZE   (1u)
 size signed field
 
#define V2_MYS_HEADER_VSL_LENGTH_POS   (3u)
 bitfield position length field
 
#define V2_MYS_HEADER_VSL_LENGTH_SIZE   (5u)
 size length field
 
#define V2_MYS_HEADER_CEP_COMMAND_POS   (0)
 bitfield position command field
 
#define V2_MYS_HEADER_CEP_COMMAND_SIZE   (3u)
 size command field
 
#define V2_MYS_HEADER_CEP_ECHOREQUEST_POS   (3u)
 bitfield position echo request field
 
#define V2_MYS_HEADER_CEP_ECHOREQUEST_SIZE   (1u)
 size echo request field
 
#define V2_MYS_HEADER_CEP_ECHO_POS   (4u)
 bitfield position echo field
 
#define V2_MYS_HEADER_CEP_ECHO_SIZE   (1u)
 size echo field
 
#define V2_MYS_HEADER_CEP_PAYLOADTYPE_POS   (5u)
 bitfield position payload type field
 
#define V2_MYS_HEADER_CEP_PAYLOADTYPE_SIZE   (3u)
 size payload type field
 
#define MAX_MESSAGE_SIZE   V2_MYS_HEADER_MAX_MESSAGE_SIZE
 The maximum size of a message (including header)
 
#define HEADER_SIZE   V2_MYS_HEADER_SIZE
 The size of the header.
 
#define MAX_PAYLOAD_SIZE   (MAX_MESSAGE_SIZE - HEADER_SIZE)
 The maximum size of a payload depends on MAX_MESSAGE_SIZE and HEADER_SIZE.
 
#define MAX_PAYLOAD   MAX_PAYLOAD_SIZE
 
#define BIT(n)   ( 1<<(n) )
 Bit indexing macro.
 
#define BIT_MASK(len)   ( BIT(len)-1 )
 Create a bitmask of length 'len'.
 
#define BF_MASK(start, len)   ( BIT_MASK(len)<<(start) )
 Create a bitfield mask of length starting at bit 'start'.
 
#define BF_PREP(x, start, len)   ( ((x)&BIT_MASK(len)) << (start) )
 Prepare a bitmask for insertion or combining.
 
#define BF_GET(y, start, len)   ( ((y)>>(start)) & BIT_MASK(len) )
 Extract a bitfield of length 'len' starting at bit 'start' from 'y'.
 
#define BF_SET(y, x, start, len)   ( y= ((y) &~ BF_MASK(start, len)) | BF_PREP(x, start, len) )
 Insert a new bitfield value 'x' into 'y'.
 
#define mSetVersion(_message, _version)   _message.setVersion(_version)
 
#define mGetVersion(_message)   _message.getVersion()
 
#define mSetSigned(_message, _signed)   _message.setSigned(_signed)
 
#define mGetSigned(_message)   _message.getSigned()
 
#define mSetLength(_message, _length)   _message.setLength(_length)
 
#define mGetLength(_message)   _message.getLength()
 
#define mSetCommand(_message, _command)   _message.setCommand(_command)
 
#define mGetCommand(_message)   _message.getCommand()
 
#define mSetRequestEcho(_message, _requestEcho)   _message.setRequestEcho(_requestEcho)
 
#define mGetRequestEcho(_message)   _message.getRequestEcho()
 
#define mSetEcho(_message, _echo)   _message.setEcho(_echo)
 
#define mGetEcho(_message)   _message.getEcho()
 
#define mSetPayloadType(_message, _payloadType)   _message.setPayloadType(_payloadType)
 
#define mGetPayloadType(_message)   _message.getPayloadType()
 

Enumerations

enum  mysensors_command_t {
  C_PRESENTATION = 0, C_SET = 1, C_REQ = 2, C_INTERNAL = 3,
  C_STREAM = 4, C_RESERVED_5 = 5, C_RESERVED_6 = 6, C_INVALID_7 = 7
}
 The command field (message-type) defines the overall properties of a message. More...
 
enum  mysensors_internal_t {
  I_BATTERY_LEVEL = 0, I_TIME = 1, I_VERSION = 2, I_ID_REQUEST = 3,
  I_ID_RESPONSE = 4, I_INCLUSION_MODE = 5, I_CONFIG = 6, I_FIND_PARENT_REQUEST = 7,
  I_FIND_PARENT_RESPONSE = 8, I_LOG_MESSAGE = 9, I_CHILDREN = 10, I_SKETCH_NAME = 11,
  I_SKETCH_VERSION = 12, I_REBOOT = 13, I_GATEWAY_READY = 14, I_SIGNING_PRESENTATION = 15,
  I_NONCE_REQUEST = 16, I_NONCE_RESPONSE = 17, I_HEARTBEAT_REQUEST = 18, I_PRESENTATION = 19,
  I_DISCOVER_REQUEST = 20, I_DISCOVER_RESPONSE = 21, I_HEARTBEAT_RESPONSE = 22, I_LOCKED = 23,
  I_PING = 24, I_PONG = 25, I_REGISTRATION_REQUEST = 26, I_REGISTRATION_RESPONSE = 27,
  I_DEBUG = 28, I_SIGNAL_REPORT_REQUEST = 29, I_SIGNAL_REPORT_REVERSE = 30, I_SIGNAL_REPORT_RESPONSE = 31,
  I_PRE_SLEEP_NOTIFICATION = 32, I_POST_SLEEP_NOTIFICATION = 33
}
 Type of internal messages (for internal messages) More...
 
enum  mysensors_stream_t {
  ST_FIRMWARE_CONFIG_REQUEST = 0, ST_FIRMWARE_CONFIG_RESPONSE = 1, ST_FIRMWARE_REQUEST = 2, ST_FIRMWARE_RESPONSE = 3,
  ST_SOUND = 4, ST_IMAGE = 5, ST_FIRMWARE_CONFIRM = 6, ST_FIRMWARE_RESPONSE_RLE = 7
}
 Type of data stream (for streamed message) More...
 
enum  mysensors_payload_t {
  P_STRING = 0, P_BYTE = 1, P_INT16 = 2, P_UINT16 = 3,
  P_LONG32 = 4, P_ULONG32 = 5, P_CUSTOM = 6, P_FLOAT32 = 7
}
 Type of payload. More...
 

Functions

class MyMessage __attribute__ ((packed))
 Doxygen will complain without this comment.
 

Macro Definition Documentation

◆ MAX_PAYLOAD

#define MAX_PAYLOAD   MAX_PAYLOAD_SIZE
Deprecated:
in 3.0.0 The maximum size of a payload depends on MAX_MESSAGE_SIZE and HEADER_SIZE

Definition at line 64 of file MyMessage.h.

◆ mGetCommand

#define mGetCommand (   _message)    _message.getCommand()
Deprecated:
Get command field

Definition at line 275 of file MyMessage.h.

◆ mGetEcho

#define mGetEcho (   _message)    _message.getEcho()
Deprecated:
Get echo field

Definition at line 281 of file MyMessage.h.

◆ mGetLength

#define mGetLength (   _message)    _message.getLength()
Deprecated:
Get length field

Definition at line 272 of file MyMessage.h.

◆ mGetPayloadType

#define mGetPayloadType (   _message)    _message.getPayloadType()
Deprecated:
Get payload type field

Definition at line 284 of file MyMessage.h.

◆ mGetRequestEcho

#define mGetRequestEcho (   _message)    _message.getRequestEcho()
Deprecated:
Get echo request field

Definition at line 278 of file MyMessage.h.

◆ mGetSigned

#define mGetSigned (   _message)    _message.getSigned()
Deprecated:
Get signed field

Definition at line 269 of file MyMessage.h.

◆ mGetVersion

#define mGetVersion (   _message)    _message.getVersion()
Deprecated:
Get version field

Definition at line 266 of file MyMessage.h.

◆ mSetCommand

#define mSetCommand (   _message,
  _command 
)    _message.setCommand(_command)
Deprecated:
Set command field

Definition at line 274 of file MyMessage.h.

◆ mSetEcho

#define mSetEcho (   _message,
  _echo 
)    _message.setEcho(_echo)
Deprecated:
Set echo field

Definition at line 280 of file MyMessage.h.

◆ mSetLength

#define mSetLength (   _message,
  _length 
)    _message.setLength(_length)
Deprecated:
Set length field

Definition at line 271 of file MyMessage.h.

◆ mSetPayloadType

#define mSetPayloadType (   _message,
  _payloadType 
)    _message.setPayloadType(_payloadType)
Deprecated:
Set payload type field

Definition at line 283 of file MyMessage.h.

◆ mSetRequestEcho

#define mSetRequestEcho (   _message,
  _requestEcho 
)    _message.setRequestEcho(_requestEcho)
Deprecated:
Set echo request field

Definition at line 277 of file MyMessage.h.

◆ mSetSigned

#define mSetSigned (   _message,
  _signed 
)    _message.setSigned(_signed)
Deprecated:
Set signed field

Definition at line 268 of file MyMessage.h.

◆ mSetVersion

#define mSetVersion (   _message,
  _version 
)    _message.setVersion(_version)
Deprecated:
Set version field

Definition at line 265 of file MyMessage.h.

Enumeration Type Documentation

◆ mysensors_command_t

The command field (message-type) defines the overall properties of a message.

Enumerator
C_PRESENTATION 

Sent by a node when they present attached sensors. This is usually done in presentation() at startup.

C_SET 

This message is sent from or to a sensor when a sensor value should be updated.

C_REQ 

Requests a variable value (usually from an actuator destined for controller).

C_INTERNAL 

Internal MySensors messages (also include common messages provided/generated by the library).

C_STREAM 

For firmware and other larger chunks of data that need to be divided into pieces.

C_RESERVED_5 

C_RESERVED_5.

C_RESERVED_6 

C_RESERVED_6.

C_INVALID_7 

C_INVALID_7.

Definition at line 67 of file MyMessage.h.

◆ mysensors_internal_t

Type of internal messages (for internal messages)

Enumerator
I_BATTERY_LEVEL 

Battery level.

I_TIME 

Time (request/response)

I_VERSION 

Version.

I_ID_REQUEST 

ID request.

I_ID_RESPONSE 

ID response.

I_INCLUSION_MODE 

Inclusion mode.

I_CONFIG 

Config (request/response)

I_FIND_PARENT_REQUEST 

Find parent.

I_FIND_PARENT_RESPONSE 

Find parent response.

I_LOG_MESSAGE 

Log message.

I_CHILDREN 

Children.

I_SKETCH_NAME 

Sketch name.

I_SKETCH_VERSION 

Sketch version.

I_REBOOT 

Reboot request.

I_GATEWAY_READY 

Gateway ready.

I_SIGNING_PRESENTATION 

Provides signing related preferences (first byte is preference version)

I_NONCE_REQUEST 

Request for a nonce.

I_NONCE_RESPONSE 

Payload is nonce data.

I_HEARTBEAT_REQUEST 

Heartbeat request.

I_PRESENTATION 

Presentation message.

I_DISCOVER_REQUEST 

Discover request.

I_DISCOVER_RESPONSE 

Discover response.

I_HEARTBEAT_RESPONSE 

Heartbeat response.

I_LOCKED 

Node is locked (reason in string-payload)

I_PING 

Ping sent to node, payload incremental hop counter.

I_PONG 

In return to ping, sent back to sender, payload incremental hop counter.

I_REGISTRATION_REQUEST 

Register request to GW.

I_REGISTRATION_RESPONSE 

Register response from GW.

I_DEBUG 

Debug message.

I_SIGNAL_REPORT_REQUEST 

Device signal strength request.

I_SIGNAL_REPORT_REVERSE 

Internal.

I_SIGNAL_REPORT_RESPONSE 

Device signal strength response (RSSI)

I_PRE_SLEEP_NOTIFICATION 

Message sent before node is going to sleep.

I_POST_SLEEP_NOTIFICATION 

Message sent after node woke up (if enabled)

Definition at line 191 of file MyMessage.h.

◆ mysensors_payload_t

Type of payload.

Enumerator
P_STRING 

Payload type is string.

P_BYTE 

Payload type is byte.

P_INT16 

Payload type is INT16.

P_UINT16 

Payload type is UINT16.

P_LONG32 

Payload type is INT32.

P_ULONG32 

Payload type is UINT32.

P_CUSTOM 

Payload type is binary.

P_FLOAT32 

Payload type is float32.

Definition at line 241 of file MyMessage.h.

◆ mysensors_stream_t

Type of data stream (for streamed message)

Enumerator
ST_FIRMWARE_CONFIG_REQUEST 

Request new FW, payload contains current FW details.

ST_FIRMWARE_CONFIG_RESPONSE 

New FW details to initiate OTA FW update.

ST_FIRMWARE_REQUEST 

Request FW block.

ST_FIRMWARE_RESPONSE 

Response FW block.

ST_SOUND 

Sound.

ST_IMAGE 

Image.

ST_FIRMWARE_CONFIRM 

Mark running firmware as valid (MyOTAFirmwareUpdateNVM + mcuboot)

ST_FIRMWARE_RESPONSE_RLE 

Response FW block with run length encoded data.

Definition at line 229 of file MyMessage.h.