MySensors Library & Examples  2.3.2-62-ge298769
MyMultiMessage.h
Go to the documentation of this file.
1 /*
2  * The MySensors Arduino library handles the wireless radio link and protocol
3  * between your home built sensors/actuators and HA controller of choice.
4  * The sensors forms a self healing radio network with optional repeaters. Each
5  * repeater and gateway builds a routing tables in EEPROM which keeps track of the
6  * network topology allowing messages to be routed to nodes.
7  *
8  * Created by Henrik Ekblad <[email protected]>
9  * Copyright (C) 2013-2022 Sensnology AB
10  * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
11  *
12  * Documentation: http://www.mysensors.org
13  * Support Forum: http://forum.mysensors.org
14  *
15  * Multi message feature added by Constantin Petra <[email protected]>
16  * Copyright (C) 2022 Constantin Petra
17  *
18  * This program is free software; you can redistribute it and/or
19  * modify it under the terms of the GNU General Public License
20  * version 2 as published by the Free Software Foundation.
21  */
22 
90 #ifndef MYMULTIMESSAGE_H
91 #define MYMULTIMESSAGE_H
92 #include "MyMessage.h"
93 
98 {
99 private:
100  // A pointer to the "real" message
101  MyMessage *_msg;
102 
103  // Current offset inside the message
104  size_t _offset;
105 
106  // Common setup, returns a pointer to the next area that can be used, NULL if no more room
107  void *common(uint8_t type, uint8_t sensor, uint8_t ptype, uint8_t size, uint8_t cmd);
108 
109 public:
114  explicit MyMultiMessage(MyMessage *msg);
115 
123  bool set(uint8_t messageType, uint8_t sensorId, uint8_t value);
124 
132  bool set(uint8_t messageType, uint8_t sensorId, uint16_t value);
133 
141  bool set(uint8_t messageType, uint8_t sensorId, int16_t value);
142 
151  bool set(uint8_t messageType, uint8_t sensorId, uint32_t value);
152 
160  bool set(uint8_t messageType, uint8_t sensorId, int32_t value);
161 
170  bool set(uint8_t messageType, uint8_t sensorId, float value, uint8_t decimals);
171 
175  void reset();
176 
181  bool setBattery(uint8_t value);
182 
187  bool getNext(MyMessage &m);
188 
189  ~MyMultiMessage();
190 
191 };
192 #endif
type
uint8_t type
8 bit - Type varies depending on command
Definition: MyMessage.h:353
sensor
uint8_t sensor
8 bit - Id of sensor that this message concerns.
Definition: MyMessage.h:354
MyMultiMessage::setBattery
bool setBattery(uint8_t value)
Set battery level.
MyMultiMessage::reset
void reset()
Reset the message contents, so that in can be reused after send()
MyMultiMessage
A collection of APIs that convert a MyMessage object to a message group.
Definition: MyMultiMessage.h:97
MyMessage.h
API and type declarations for MySensors messages.
MyMultiMessage::set
bool set(uint8_t messageType, uint8_t sensorId, uint8_t value)
Set payload to unsigned 8-bit integer value.
MyMultiMessage::MyMultiMessage
MyMultiMessage(MyMessage *msg)
MyMessage
MyMessage is used to create, manipulate, send and read MySensors messages.
Definition: MyMessage.h:290
MyMultiMessage::getNext
bool getNext(MyMessage &m)
get next message from the blob