Skip to content

Commit 3d7925e

Browse files
authored
Merge pull request #135 from StephenCatsamas/master
fixed issue in slave example where some commands sent slave into unresponsive state
2 parents 5937307 + 4412e37 commit 3d7925e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

examples/h_SDI-12_slave_implementation/h_SDI-12_slave_implementation.ino

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ int state = 0;
3939
#define WAIT 0
4040
#define INITIATE_CONCURRENT 1
4141
#define INITIATE_MEASUREMENT 2
42+
#define PROCESS_COMMAND 3
4243

4344
// Create object by which to communicate with the SDI-12 bus on SDIPIN
4445
SDI12 slaveSDI12(DATA_PIN);
@@ -196,6 +197,7 @@ void loop() {
196197
// Character '!' indicates the end of an SDI-12 command; if the current
197198
// character is '!', stop listening and respond to the command
198199
if (charReceived == '!') {
200+
state = PROCESS_COMMAND;
199201
// Command string is completed; do something with it
200202
parseSdi12Cmd(commandReceived, dValues);
201203
// Clear command string to reset for next command
@@ -246,5 +248,9 @@ void loop() {
246248
slaveSDI12.forceListen(); // sets SDI-12 pin as input to prepare for incoming
247249
// message AGAIN
248250
break;
251+
case PROCESS_COMMAND:
252+
state = WAIT;
253+
slaveSDI12.forceListen();
254+
break;
249255
}
250256
}

0 commit comments

Comments
 (0)