Skip to content

Commit cfbcead

Browse files
committed
Fix bug making gateway sending all payloads with newline character included. Fix bug related to receiving Mertic/Imperial setting in sensor nodes (getByte was implemented wrong).
1 parent 612ab5e commit cfbcead

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

libraries/MySensors/MyGateway.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ void MyGateway::parseAndSend(char *commandBuffer) {
169169
}
170170
} else {
171171
value = str;
172+
// Remove newline character
173+
value[strlen(value)-1] = 0;
172174
}
173175
break;
174176
}
@@ -193,7 +195,6 @@ void MyGateway::parseAndSend(char *commandBuffer) {
193195
mSetCommand(msg,command);
194196
mSetRequestAck(msg,ack?1:0);
195197
mSetAck(msg,false);
196-
msg.set(value);
197198
if (command == C_STREAM)
198199
msg.set(bvalue, blen);
199200
else

libraries/MySensors/MyMessage.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,7 @@ char* MyMessage::getString(char *buffer) const {
8787
}
8888

8989
uint8_t MyMessage::getByte() const {
90-
if (miGetPayloadType() == P_BYTE) {
91-
return data[0];
92-
} else if (miGetPayloadType() == P_STRING) {
93-
return atoi(data);
94-
} else {
95-
return 0;
96-
}
90+
return data[0];
9791
}
9892

9993
bool MyMessage::getBool() const {

0 commit comments

Comments
 (0)