MySensors Library & Examples  2.3.2-62-ge298769
Classes
+ Collaboration diagram for Multi-message support:

Detailed Description

Block object that enables sending multiple sensor data in one message, including battery information.

MyMultiMessage usage example

USE_BLOB is a local define, only for emphasizing the changes needed for using the blob feature.

#define USE_BLOB
// Initialize general message
#ifdef USE_BLOB
MyMessage msgBlob(0, V_MULTI_MESSAGE);
#else
MyMessage msgTEMPERATURE(CHILD_ID_TEMPERATURE, V_TEMP);
MyMessage msgHUMIDITY(CHILD_ID_HUMIDITY, V_HUM);
#endif

The code below shows a simple humidity/temperature/battery sensor sending everything in one message:

#ifdef USE_BLOB
MyMultiMessage blob(&msgBlob);
blob.set(V_TEMP, CHILD_ID_TEMPERATURE , temperature, 1);
blob.set(V_HUM, CHILD_ID_HUMIDITY, humidity, 1);
blob.setBattery(batt_level);
send(msgBlob);
#else
send(msgTEMPERATURE.set(temperature, 1));
wait(10); // the wait() is needed at least for rfm69, otherwise it takes a long time.
send(msgHUMIDITY.set(humidity, 1));
wait(10);
#endif

Fitting more messages may become more complex, though:

Todo:
Add logic in MyMultiMessage to handle sending itself.
MyMultiMessage blob(&msgBlob);
if (!blob.set(V_TEMP, 0 , temperature, 1)) {
send(msgBlob);
wait(10);
msgBlob.reset();
blob.set(V_TEMP, 0 , temperature, 1)
}
if (!blob.setBattery(batt_level)) {
send(msgBlob);
wait(10);
msgBlob.reset();
blob.setBattery(batt_level)
}

Classes

class  MyMultiMessage
 A collection of APIs that convert a MyMessage object to a message group. More...
 
send
bool send(MyMessage &msg, const bool requestEcho=false)
MyMultiMessage
A collection of APIs that convert a MyMessage object to a message group.
Definition: MyMultiMessage.h:97
wait
void wait(const uint32_t waitingMS)
MyMessage
MyMessage is used to create, manipulate, send and read MySensors messages.
Definition: MyMessage.h:290