Skip to content

Commit

Permalink
Optionally specify protocol, pulselength in mqtt message
Browse files Browse the repository at this point in the history
  • Loading branch information
rickybrent committed Jan 22, 2017
1 parent 5e8fca9 commit dfa0e84
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion _433toMQTTto433nFan_ESP8266.ino
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,26 @@ void receivingMQTT(String topicNameRec, String callbackstring) {
topicNameRec.toCharArray(topicOri,26);
char DataAck[26] = "OK";
client.publish("home/ack", DataAck);
callbackstring.toCharArray(datacallback,32);
int commaPos = callbackstring.indexOf(',');
int protocol = 1; // default
int pulseLength = 350; // default
if (commaPos > 0) {
int lastCommaPos = callbackstring.lastIndexOf(',');
protocol = callbackstring.substring(commaPos + 1, lastCommaPos).toInt();
pulseLength = callbackstring.substring(lastCommaPos + 1).toInt();
callbackstring.substring(0, commaPos).toCharArray(datacallback,32);
} else {
callbackstring.toCharArray(datacallback,32);
}
trc(datacallback);
unsigned long data = strtoul(datacallback, NULL, 10); // we will not be able to pass value > 4294967295
trc(String(data));

if (topicNameRec == subjectMQTTto433){
trc("Send received data by RF 433");
//send received MQTT value by RF signal (example of signal sent data = 5264660)
mySwitch.setProtocol(protocol);
mySwitch.setPulseLength(pulseLength);
mySwitch.send(data, 24);
}
/*TODO: Disabled IR]
Expand Down

0 comments on commit dfa0e84

Please sign in to comment.