Skip to content

Commit 4261233

Browse files
committed
Serial protocol changed to allowing controller to know if an incoming message is a ack. Outgoing and incoming serial messages now also have the same parameter count.
radioId;childId;messageType;ack;subType;payload\n Where ack parameter means the following: outgoing: 0 = unacknoledged message, 1 = request ack from destination node Incoming: 0= normal message, 1=This is an ack message
1 parent 1150c44 commit 4261233

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

libraries/MySensors/MyGateway.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void MyGateway::begin(rf24_pa_dbm_e paLevel, uint8_t channel, rf24_datarate_e da
7474
RF24::startListening();
7575

7676
// Send startup log message on serial
77-
serial(PSTR("0;0;%d;%d;Arduino startup complete.\n"), C_INTERNAL, I_LOG_MESSAGE);
77+
serial(PSTR("0;0;%d;0;%d;Arduino startup complete.\n"), C_INTERNAL, I_LOG_MESSAGE);
7878

7979
}
8080

@@ -92,7 +92,7 @@ void MyGateway::checkButtonTriggeredInclusion() {
9292
if (buttonTriggeredInclusion) {
9393
// Ok, someone pressed the inclusion button on the gateway
9494
// start inclusion mode for 1 munute.
95-
serial(PSTR("0;0;%d;%d;Inclusion started by button.\n"), C_INTERNAL, I_LOG_MESSAGE);
95+
serial(PSTR("0;0;%d;0;%d;Inclusion started by button.\n"), C_INTERNAL, I_LOG_MESSAGE);
9696
buttonTriggeredInclusion = false;
9797
setInclusionMode(true);
9898
}
@@ -171,7 +171,7 @@ void MyGateway::parseAndSend(char *commandBuffer) {
171171
// Handle messages directed to gateway
172172
if (type == I_VERSION) {
173173
// Request for version
174-
serial(PSTR("0;0;%d;%d;%s\n"),C_INTERNAL, I_VERSION, LIBRARY_VERSION);
174+
serial(PSTR("0;0;%d;0;%d;%s\n"),C_INTERNAL, I_VERSION, LIBRARY_VERSION);
175175
} else if (type == I_INCLUSION_MODE) {
176176
// Request to change inclusion mode
177177
setInclusionMode(atoi(value) == 1);
@@ -202,7 +202,7 @@ void MyGateway::setInclusionMode(boolean newMode) {
202202
if (newMode != inclusionMode)
203203
inclusionMode = newMode;
204204
// Send back mode change on serial line to ack command
205-
serial(PSTR("0;0;%d;%d;%d\n"), C_INTERNAL, I_INCLUSION_MODE, inclusionMode?1:0);
205+
serial(PSTR("0;0;%d;0;%d;%d\n"), C_INTERNAL, I_INCLUSION_MODE, inclusionMode?1:0);
206206

207207
if (inclusionMode) {
208208
inclusionStartTime = millis();
@@ -239,7 +239,7 @@ void MyGateway::serial(const char *fmt, ... ) {
239239
}
240240

241241
void MyGateway::serial(MyMessage &msg) {
242-
serial(PSTR("%d;%d;%d;%d;%s\n"),msg.sender, msg.sensor, mGetCommand(msg), msg.type, msg.getString(convBuf));
242+
serial(PSTR("%d;%d;%d;%d;%d;%s\n"),msg.sender, msg.sensor, mGetCommand(msg), mGetAck(msg), msg.type, msg.getString(convBuf));
243243
}
244244

245245

0 commit comments

Comments
 (0)