Fix problems found after verification of local commits.
This commit is contained in:
@@ -160,7 +160,7 @@ void MyGateway::parseAndSend(char *commandBuffer) {
|
|||||||
msg.sensor = sensor;
|
msg.sensor = sensor;
|
||||||
msg.type = type;
|
msg.type = type;
|
||||||
mSetCommand(msg,command);
|
mSetCommand(msg,command);
|
||||||
mSetRequestAck(msg,ack==0?false:true);
|
mSetRequestAck(msg,ack?1:0);
|
||||||
mSetAck(msg,false);
|
mSetAck(msg,false);
|
||||||
msg.set(value);
|
msg.set(value);
|
||||||
ok = sendRoute(msg);
|
ok = sendRoute(msg);
|
||||||
|
|||||||
@@ -35,10 +35,9 @@ const char* MyMessage::getString() const {
|
|||||||
|
|
||||||
char* MyMessage::getString(char *buffer) const {
|
char* MyMessage::getString(char *buffer) const {
|
||||||
uint8_t payloadType = miGetPayloadType();
|
uint8_t payloadType = miGetPayloadType();
|
||||||
|
|
||||||
if (payloadType == P_STRING) {
|
if (payloadType == P_STRING) {
|
||||||
strncpy(buffer, data, miGetLength());
|
strncpy(buffer, data, miGetLength());
|
||||||
buffer[miGetLength()] = '\0';
|
buffer[miGetLength()] = 0;
|
||||||
return buffer;
|
return buffer;
|
||||||
} else if (buffer != NULL) {
|
} else if (buffer != NULL) {
|
||||||
switch(payloadType) {
|
switch(payloadType) {
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ typedef enum {
|
|||||||
#define BIT_MASK(len) ( BIT(len)-1 )
|
#define BIT_MASK(len) ( BIT(len)-1 )
|
||||||
// Create a bitfield mask of length starting at bit 'start'.
|
// Create a bitfield mask of length starting at bit 'start'.
|
||||||
#define BF_MASK(start, len) ( BIT_MASK(len)<<(start) )
|
#define BF_MASK(start, len) ( BIT_MASK(len)<<(start) )
|
||||||
|
|
||||||
// Prepare a bitmask for insertion or combining.
|
// Prepare a bitmask for insertion or combining.
|
||||||
#define BF_PREP(x, start, len) ( ((x)&BIT_MASK(len)) << (start) )
|
#define BF_PREP(x, start, len) ( ((x)&BIT_MASK(len)) << (start) )
|
||||||
// Extract a bitfield of length len starting at bit 'start' from y.
|
// Extract a bitfield of length len starting at bit 'start' from y.
|
||||||
@@ -87,7 +88,7 @@ typedef enum {
|
|||||||
#define mSetRequestAck(_msg,_rack) BF_SET(_msg.command_ack_payload, _rack, 3, 1)
|
#define mSetRequestAck(_msg,_rack) BF_SET(_msg.command_ack_payload, _rack, 3, 1)
|
||||||
#define mGetRequestAck(_msg) BF_GET(_msg.command_ack_payload, 3, 1)
|
#define mGetRequestAck(_msg) BF_GET(_msg.command_ack_payload, 3, 1)
|
||||||
|
|
||||||
#define mSetAck(_msg,_ack) BF_SET(_msg.command_ack_payload, _ack, 4, 1)
|
#define mSetAck(_msg,_ackMsg) BF_SET(_msg.command_ack_payload, _ackMsg, 4, 1)
|
||||||
#define mGetAck(_msg) BF_GET(_msg.command_ack_payload, 4, 1)
|
#define mGetAck(_msg) BF_GET(_msg.command_ack_payload, 4, 1)
|
||||||
|
|
||||||
#define mSetPayloadType(_msg, _pt) BF_SET(_msg.command_ack_payload, _pt, 5, 3)
|
#define mSetPayloadType(_msg, _pt) BF_SET(_msg.command_ack_payload, _pt, 5, 3)
|
||||||
@@ -95,9 +96,6 @@ typedef enum {
|
|||||||
|
|
||||||
|
|
||||||
// internal access for special fields
|
// internal access for special fields
|
||||||
#define miSetPayloadType(_pt) BF_SET(command_ack_payload, _pt, 4, 4)
|
|
||||||
#define miGetPayloadType() BF_GET(command_ack_payload, 4, 4)
|
|
||||||
|
|
||||||
#define miSetLength(_length) BF_SET(version_length, _length, 3, 5)
|
#define miSetLength(_length) BF_SET(version_length, _length, 3, 5)
|
||||||
#define miGetLength() BF_GET(version_length, 3, 5)
|
#define miGetLength() BF_GET(version_length, 3, 5)
|
||||||
|
|
||||||
@@ -107,6 +105,8 @@ typedef enum {
|
|||||||
#define miSetAck(_ack) BF_SET(command_ack_payload, _ack, 4, 1)
|
#define miSetAck(_ack) BF_SET(command_ack_payload, _ack, 4, 1)
|
||||||
#define miGetAck() BF_GET(command_ack_payload, 4, 1)
|
#define miGetAck() BF_GET(command_ack_payload, 4, 1)
|
||||||
|
|
||||||
|
#define miSetPayloadType(_pt) BF_SET(command_ack_payload, _pt, 5, 3)
|
||||||
|
#define miGetPayloadType() BF_GET(command_ack_payload, 5, 3)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#define BARO_CHILD 0
|
#define BARO_CHILD 0
|
||||||
#define TEMP_CHILD 1
|
#define TEMP_CHILD 1
|
||||||
|
|
||||||
#define LIGHT_SENSOR_ANALOG_PIN 0
|
|
||||||
unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in seconds)
|
unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in seconds)
|
||||||
|
|
||||||
Adafruit_BMP085 bmp = Adafruit_BMP085(); // Digital Pressure Sensor
|
Adafruit_BMP085 bmp = Adafruit_BMP085(); // Digital Pressure Sensor
|
||||||
|
|||||||
@@ -66,6 +66,10 @@ void loop()
|
|||||||
|
|
||||||
void incomingMessage(const MyMessage &message) {
|
void incomingMessage(const MyMessage &message) {
|
||||||
// We only expect one type of message from controller. But we better check anyway.
|
// We only expect one type of message from controller. But we better check anyway.
|
||||||
|
if (message.isAck()) {
|
||||||
|
Serial.println("This is an ack from gateway");
|
||||||
|
}
|
||||||
|
|
||||||
if (message.type==V_LIGHT) {
|
if (message.type==V_LIGHT) {
|
||||||
// Change relay state
|
// Change relay state
|
||||||
state = message.getBool();
|
state = message.getBool();
|
||||||
|
|||||||
Reference in New Issue
Block a user