Merge pull request #540 from Yveaux/development

Correctly initialize MyMessage
This commit is contained in:
Thomas Mørch
2016-08-05 13:29:16 +02:00
committed by GitHub
2 changed files with 24 additions and 5 deletions
+19 -5
View File
@@ -23,14 +23,28 @@
#include <stdlib.h>
MyMessage::MyMessage() {
destination = 0; // Gateway is default destination
MyMessage::MyMessage()
{
clear();
}
MyMessage::MyMessage(uint8_t _sensor, uint8_t _type) {
destination = 0; // Gateway is default destination
MyMessage::MyMessage(uint8_t _sensor, uint8_t _type)
{
clear();
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 {
+5
View File
@@ -282,6 +282,11 @@ public:
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
* into string representation by supplying a buffer with the minimum size of