Skip to content

Commit 5bb8c9b

Browse files
committed
Bugfixes and cleanup
1 parent 7fa54a6 commit 5bb8c9b

File tree

8 files changed

+24
-218
lines changed

8 files changed

+24
-218
lines changed

libraries/MySensors/MyConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
/***
1919
* Enable/Disable debug logging
2020
*/
21-
#define DEBUG
21+
//#define DEBUG
2222

2323
#endif

libraries/MySensors/MySensor.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ void MySensor::begin(void (*_msgCallback)(const MyMessage &), uint8_t _nodeId, b
8181
requestNodeId();
8282
}
8383

84-
debug(PSTR("%s started, id %d\n"), repeaterMode?"repeater":"sensor", nc.nodeId);
84+
if (!isGateway) {
85+
debug(PSTR("%s started, id %d\n"), repeaterMode?"repeater":"sensor", nc.nodeId);
86+
}
8587

8688
// Open reading pipe for messages directed to this node (set write pipe to same)
8789
RF24::openReadingPipe(WRITE_PIPE, TO_ADDR(nc.nodeId));

libraries/MySensors/examples/EthernetGateway/EthernetGateway.ino

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,29 @@ void setup()
104104
{
105105
// Initialize gateway at maximum PA level, channel 70 and callback for write operations
106106
gw.begin(incomingMessage, 0, true, 0, RF24_PA_LEVEL_GW, RF24_CHANNEL, RF24_DATARATE);
107-
107+
// Setup pipes for radio library
108+
gw.openReadingPipe(WRITE_PIPE, BASE_RADIO_ID);
109+
gw.openReadingPipe(CURRENT_NODE_PIPE, BASE_RADIO_ID);
110+
gw.startListening();
111+
108112
Ethernet.begin(mac, myIp);
109113
setupGateway(RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN, INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, output);
110114

111-
112115
// Add led timer interrupt
113116
MsTimer2::set(300, ledTimersInterrupt);
114117
MsTimer2::start();
115118

116119
// Add interrupt for inclusion button to pin
117120
PCintPort::attachInterrupt(pinInclusion, startInclusionInterrupt, RISING);
118121

119-
120122
// give the Ethernet interface a second to initialize
121123
delay(1000);
122-
124+
123125
// start listening for clients
124126
server.begin();
127+
128+
//output(PSTR("0;0;%d;0;%d;Gateway startup complete.\n"), C_INTERNAL, I_GATEWAY_READY);
129+
125130
}
126131

127132

@@ -132,20 +137,21 @@ void loop()
132137

133138
checkButtonTriggeredInclusion();
134139
checkInclusionFinished();
135-
140+
136141
// if an incoming client connects, there will be
137142
// bytes available to read via the client object
138143
EthernetClient client = server.available();
139144

140145
if (client) {
141-
// if got 1 or more bytes
146+
147+
// if got 1 or more bytes
142148
if (client.available()) {
143149
// read the bytes incoming from the client
144150
char inChar = client.read();
145-
146151
if (inputPos<MAX_RECEIVE_LENGTH-1) {
147152
// if newline then command is complete
148153
if (inChar == '\n') {
154+
Serial.println("Finished");
149155
// a command was issued by the client
150156
// we will now try to send it to the actuator
151157
inputString[inputPos] = 0;
@@ -167,7 +173,7 @@ void loop()
167173
inputPos = 0;
168174
}
169175
}
170-
}
176+
}
171177
}
172178

173179

libraries/MySensors/examples/EthernetGateway/GatewayUtil.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef __GATEWAYUTIL_H__
22
#define __GATEWAYUTIL_H__
33

4-
#include <stdarg.h>
54

65
#ifdef ARDUINO
76

@@ -48,6 +47,7 @@ void setupGateway(uint8_t _rx, uint8_t _tx, uint8_t _er, uint8_t _inc, uint8_t _
4847
countTx = 0;
4948
countErr = 0;
5049

50+
5151
// Setup led pins
5252
pinMode(pinRx, OUTPUT);
5353
pinMode(pinTx, OUTPUT);
@@ -240,7 +240,6 @@ void ledTimersInterrupt() {
240240
digitalWrite(pinEr, HIGH);
241241
}
242242
if(countErr != 255) { countErr--; }
243-
244243
}
245244

246245
void rxBlink(uint8_t cnt) {

libraries/MySensors/examples/MQTTGateway/GatewayUtil.h

Lines changed: 0 additions & 120 deletions
This file was deleted.

libraries/MySensors/examples/MQTTGateway/MQTTGateway.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,11 @@ void setup()
144144
{
145145
// Initialize gateway at maximum PA level, channel 70 and callback for write operations
146146
gw.begin(incomingMessage, 0, true, 0, RF24_PA_LEVEL_GW, RF24_CHANNEL, RF24_DATARATE);
147-
147+
// Setup pipes for radio library
148+
gw.openReadingPipe(WRITE_PIPE, BASE_RADIO_ID);
149+
gw.openReadingPipe(CURRENT_NODE_PIPE, BASE_RADIO_ID);
150+
gw.startListening();
151+
148152
Ethernet.begin(TCP_MAC, TCP_IP);
149153

150154

libraries/MySensors/examples/MQTTGateway/MyMQTT.hx

Lines changed: 0 additions & 83 deletions
This file was deleted.

libraries/MySensors/examples/SerialGateway/SerialGateway.ino

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ void setup()
6363
gw.openReadingPipe(CURRENT_NODE_PIPE, BASE_RADIO_ID);
6464
gw.startListening();
6565

66-
Serial.begin(BAUD_RATE);
67-
6866
setupGateway(RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN, INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, output);
6967

7068
// Add led timer interrupt

0 commit comments

Comments
 (0)