Merge pull request #540 from Yveaux/development
Correctly initialize MyMessage
This commit is contained in:
+19
-5
@@ -23,14 +23,28 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
MyMessage::MyMessage() {
|
MyMessage::MyMessage()
|
||||||
destination = 0; // Gateway is default destination
|
{
|
||||||
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
MyMessage::MyMessage(uint8_t _sensor, uint8_t _type) {
|
MyMessage::MyMessage(uint8_t _sensor, uint8_t _type)
|
||||||
destination = 0; // Gateway is default destination
|
{
|
||||||
|
clear();
|
||||||
sensor = _sensor;
|
sensor = _sensor;
|
||||||
type = _type;
|
type = _type;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyMessage::clear()
|
||||||
|
{
|
||||||
|
last = 0u;
|
||||||
|
sender = 0u;
|
||||||
|
destination = 0u; // Gateway is default destination
|
||||||
|
version_length = 0u;
|
||||||
|
command_ack_payload = 0u;
|
||||||
|
type = 0u;
|
||||||
|
sensor = 0u;
|
||||||
|
(void)memset(data, 0u, sizeof(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MyMessage::isAck() const {
|
bool MyMessage::isAck() const {
|
||||||
|
|||||||
@@ -282,6 +282,11 @@ public:
|
|||||||
|
|
||||||
char i2h(uint8_t i) const;
|
char i2h(uint8_t i) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear message contents.
|
||||||
|
*/
|
||||||
|
void clear();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If payload is something else than P_STRING you can have the payload value converted
|
* 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
|
* into string representation by supplying a buffer with the minimum size of
|
||||||
|
|||||||
Reference in New Issue
Block a user