MySensors Library & Examples  2.3.1
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 PROTOCOL_VERSION   (2u)
 The version of the protocol.
 
#define MAX_MESSAGE_LENGTH   (32u)
 The maximum size of a message (including header)
 
#define HEADER_SIZE   (7u)
 The size of the header.
 
#define MAX_PAYLOAD   (MAX_MESSAGE_LENGTH - HEADER_SIZE)
 The maximum size of a payload depends on MAX_MESSAGE_LENGTH and HEADER_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)   BF_SET(_message.version_length, _version, 0, 2)
 Set version field.
 
#define mGetVersion(_message)   ((uint8_t)BF_GET(_message.version_length, 0, 2))
 Get version field.
 
#define mSetSigned(_message, _signed)   BF_SET(_message.version_length, _signed, 2, 1)
 Set signed field.
 
#define mGetSigned(_message)   ((bool)BF_GET(_message.version_length, 2, 1))
 Get signed field.
 
#define mSetLength(_message, _length)   BF_SET(_message.version_length, _length, 3, 5)
 Set length field.
 
#define mGetLength(_message)   ((uint8_t)BF_GET(_message.version_length, 3, 5))
 Get length field.
 
#define mSetCommand(_message, _command)   BF_SET(_message.command_ack_payload, _command, 0, 3)
 Set command field.
 
#define mGetCommand(_message)   ((uint8_t)BF_GET(_message.command_ack_payload, 0, 3))
 Get command field.
 
#define mSetRequestAck(_message, _rack)   BF_SET(_message.command_ack_payload, _rack, 3, 1)
 Set ack-request field.
 
#define mGetRequestAck(_message)   ((bool)BF_GET(_message.command_ack_payload, 3, 1))
 Get ack-request field.
 
#define mSetAck(_message, _ackMsg)   BF_SET(_message.command_ack_payload, _ackMsg, 4, 1)
 Set ack field.
 
#define mGetAck(_message)   ((bool)BF_GET(_message.command_ack_payload, 4, 1))
 Get ack field.
 
#define mSetPayloadType(_message, _pt)   BF_SET(_message.command_ack_payload, _pt, 5, 3)
 Set payload type field.
 
#define mGetPayloadType(_message)   ((uint8_t)BF_GET(_message.command_ack_payload, 5, 3))
 Get payload type field.
 
#define miGetCommand()   ((uint8_t)BF_GET(command_ack_payload, 0, 3))
 Internal getter for command field.
 
#define miSetLength(_length)   BF_SET(version_length, _length, 3, 5)
 Internal setter for length field.
 
#define miGetLength()   ((uint8_t)BF_GET(version_length, 3, 5))
 Internal getter for length field.
 
#define miSetVersion(_version)   BF_SET(version_length, _version, 0, 2)
 Internal setter for version field.
 
#define miGetVersion()   ((uint8_t)BF_GET(version_length, 0, 2))
 Internal getter for version field.
 
#define miSetRequestAck(_rack)   BF_SET(command_ack_payload, _rack, 3, 1)
 Internal setter for ack-request field.
 
#define miGetRequestAck()   ((bool)BF_GET(command_ack_payload, 3, 1))
 Internal getter for ack-request field.
 
#define miSetAck(_ack)   BF_SET(command_ack_payload, _ack, 4, 1)
 Internal setter for ack field.
 
#define miGetAck()   ((bool)BF_GET(command_ack_payload, 4, 1))
 Internal getter for ack field.
 
#define miSetPayloadType(_pt)   BF_SET(command_ack_payload, _pt, 5, 3)
 Internal setter for payload type field.
 
#define miGetPayloadType()   (uint8_t)BF_GET(command_ack_payload, 5, 3)
 Internal getter for payload type field.
 

Enumerations

enum  mysensors_command_t {
  C_PRESENTATION = 0, C_SET = 1, C_REQ = 2, C_INTERNAL = 3,
  C_STREAM = 4
}
 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.
 

Enumeration Type Documentation

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.

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)

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.

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.