Gateway.cpp now compiles,
Ethernet gateway fits in memory with debug enabled. :)
This commit is contained in:
@@ -12,6 +12,6 @@
|
|||||||
/***
|
/***
|
||||||
* Enable/Disable debug logging
|
* Enable/Disable debug logging
|
||||||
*/
|
*/
|
||||||
//#define DEBUG
|
#define DEBUG
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include "MyGateway.h"
|
#include "MyGateway.h"
|
||||||
|
|
||||||
|
|
||||||
MyGateway::MyGateway(uint8_t _cepin, uint8_t _cspin, uint8_t _inclusion_time) : MySensor(_cepin, _cspin) {
|
MyGateway::MyGateway(uint8_t _cepin, uint8_t _cspin, uint8_t _inclusion_time) : MySensor(_cepin, _cspin) {
|
||||||
ledMode = false;
|
ledMode = false;
|
||||||
inclusionTime = _inclusion_time;
|
inclusionTime = _inclusion_time;
|
||||||
@@ -37,8 +38,8 @@ void MyGateway::begin(rf24_pa_dbm_e paLevel, uint8_t channel, rf24_datarate_e da
|
|||||||
useWriteCallback = false;
|
useWriteCallback = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
s.nodeId = 0;
|
nc.nodeId = 0;
|
||||||
s.distance = 0;
|
nc.distance = 0;
|
||||||
inclusionMode = 0;
|
inclusionMode = 0;
|
||||||
buttonTriggeredInclusion = false;
|
buttonTriggeredInclusion = false;
|
||||||
countRx = 0;
|
countRx = 0;
|
||||||
@@ -93,11 +94,6 @@ void MyGateway::checkButtonTriggeredInclusion() {
|
|||||||
serial(PSTR("0;0;%d;%d;Inclusion started by button.\n"), C_INTERNAL, I_LOG_MESSAGE);
|
serial(PSTR("0;0;%d;%d;Inclusion started by button.\n"), C_INTERNAL, I_LOG_MESSAGE);
|
||||||
buttonTriggeredInclusion = false;
|
buttonTriggeredInclusion = false;
|
||||||
setInclusionMode(true);
|
setInclusionMode(true);
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
sendChildren();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,7 +150,13 @@ void MyGateway::parseAndSend(char *commandBuffer) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
txBlink(1);
|
txBlink(1);
|
||||||
ok = sendRoute(msg.build(GATEWAY_ADDRESS, destination, sensor, command, type).set(value));
|
msg.sender = GATEWAY_ADDRESS;
|
||||||
|
msg.destination = destination;
|
||||||
|
msg.sensor = sensor;
|
||||||
|
msg.type = type;
|
||||||
|
mSetCommand(msg,command);
|
||||||
|
msg.set(value);
|
||||||
|
ok = sendRoute(msg);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
errBlink(1);
|
errBlink(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ void MySensor::findParentNode() {
|
|||||||
|
|
||||||
boolean MySensor::sendRoute(MyMessage message) {
|
boolean MySensor::sendRoute(MyMessage message) {
|
||||||
// Make sure to process any incoming messages before sending (could this end up in recursive loop?)
|
// Make sure to process any incoming messages before sending (could this end up in recursive loop?)
|
||||||
process();
|
// process();
|
||||||
|
|
||||||
// If we still don't have any node id, re-request and skip this message.
|
// If we still don't have any node id, re-request and skip this message.
|
||||||
if (nc.nodeId == AUTO && !(mGetCommand(message) == C_INTERNAL && message.type == I_REQUEST_ID)) {
|
if (nc.nodeId == AUTO && !(mGetCommand(message) == C_INTERNAL && message.type == I_REQUEST_ID)) {
|
||||||
|
|||||||
@@ -204,6 +204,8 @@ class MySensor : public RF24
|
|||||||
NodeConfig nc; // Essential settings for node to work
|
NodeConfig nc; // Essential settings for node to work
|
||||||
ControllerConfig cc; // Configuration coming from controller
|
ControllerConfig cc; // Configuration coming from controller
|
||||||
boolean relayMode;
|
boolean relayMode;
|
||||||
|
MyMessage msg; // Buffer for incoming messages.
|
||||||
|
MyMessage ack; // Buffer for ack messages.
|
||||||
|
|
||||||
void setupRelayMode();
|
void setupRelayMode();
|
||||||
void setupRadio(rf24_pa_dbm_e paLevel, uint8_t channel, rf24_datarate_e dataRate);
|
void setupRadio(rf24_pa_dbm_e paLevel, uint8_t channel, rf24_datarate_e dataRate);
|
||||||
@@ -214,8 +216,6 @@ class MySensor : public RF24
|
|||||||
private:
|
private:
|
||||||
uint8_t failedTransmissions;
|
uint8_t failedTransmissions;
|
||||||
uint8_t *childNodeTable; // In memory buffer for routing information to other nodes. also stored in EEPROM
|
uint8_t *childNodeTable; // In memory buffer for routing information to other nodes. also stored in EEPROM
|
||||||
MyMessage msg; // Buffer for incoming messages.
|
|
||||||
MyMessage ack; // Buffer for ack messages.
|
|
||||||
void (*timeCallback)(unsigned long); // Callback for requested time messages
|
void (*timeCallback)(unsigned long); // Callback for requested time messages
|
||||||
void (*msgCallback)(MyMessage); // Callback for incoming messages from other nodes and gateway.
|
void (*msgCallback)(MyMessage); // Callback for incoming messages from other nodes and gateway.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user