Fix ESPiLight transmission error reporting (#762)
This commit is contained in:
1 parent
ae3253315f
commit
eef8c5048d
1 file changed
+11
-17
+11
-17
@@ -101,26 +101,21 @@ void MQTTtoPilight(char* topicOri, JsonObject& Pilightdata) {
|
||||
ELECHOUSE_cc1101.SetTx(CC1101_FREQUENCY); // set Transmit on
|
||||
rf.disableReceiver();
|
||||
# endif
|
||||
int result = 0;
|
||||
|
||||
if (cmpToMainTopic(topicOri, subjectMQTTtoPilight)) {
|
||||
Log.trace(F("MQTTtoPilight json data analysis" CR));
|
||||
const char* message = Pilightdata["message"];
|
||||
const char* protocol = Pilightdata["protocol"];
|
||||
const char* raw = Pilightdata["raw"];
|
||||
if (raw) {
|
||||
int msgLength = 0;
|
||||
uint16_t codes[MAXPULSESTREAMLENGTH];
|
||||
msgLength = rf.stringToPulseTrain(
|
||||
raw,
|
||||
codes, MAXPULSESTREAMLENGTH);
|
||||
int msgLength = rf.stringToPulseTrain(
|
||||
raw, codes, MAXPULSESTREAMLENGTH);
|
||||
if (msgLength > 0) {
|
||||
rf.sendPulseTrain(codes, msgLength);
|
||||
Log.notice(F("MQTTtoPilight raw ok" CR));
|
||||
result = msgLength;
|
||||
} else {
|
||||
Log.trace(F("MQTTtoPilight raw KO" CR));
|
||||
switch (result) {
|
||||
switch (msgLength) {
|
||||
case ESPiLight::ERROR_INVALID_PULSETRAIN_MSG_C:
|
||||
Log.trace(F("'c' not found in string, or has no data" CR));
|
||||
break;
|
||||
@@ -134,19 +129,16 @@ void MQTTtoPilight(char* topicOri, JsonObject& Pilightdata) {
|
||||
Log.trace(F("pulse type not defined" CR));
|
||||
break;
|
||||
}
|
||||
Log.error(F("Invalid JSON: raw data malformed" CR));
|
||||
}
|
||||
} else if (message && protocol) {
|
||||
Log.trace(F("MQTTtoPilight msg & protocol ok" CR));
|
||||
result = rf.send(protocol, message);
|
||||
} else {
|
||||
Log.error(F("MQTTtoPilight failed json read" CR));
|
||||
}
|
||||
|
||||
if (result > 0) {
|
||||
int msgLength = rf.send(protocol, message);
|
||||
if (msgLength > 0) {
|
||||
Log.trace(F("Adv data MQTTtoPilight push state via PilighttoMQTT" CR));
|
||||
pub(subjectGTWPilighttoMQTT, Pilightdata);
|
||||
} else {
|
||||
switch (result) {
|
||||
switch (msgLength) {
|
||||
case ESPiLight::ERROR_UNAVAILABLE_PROTOCOL:
|
||||
Log.error(F("protocol is not available" CR));
|
||||
break;
|
||||
@@ -160,10 +152,12 @@ void MQTTtoPilight(char* topicOri, JsonObject& Pilightdata) {
|
||||
Log.error(F("no transmitter pin" CR));
|
||||
break;
|
||||
default:
|
||||
Log.error(F("invalid json data, can't read raw or message/protocol" CR));
|
||||
break;
|
||||
Log.error(F("Invalid JSON: can't read message/protocol" CR));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.error(F("MQTTtoPilight failed json read" CR));
|
||||
}
|
||||
}
|
||||
# ifdef ZradioCC1101
|
||||
ELECHOUSE_cc1101.SetRx(CC1101_FREQUENCY); // set Receive on
|
||||
|
||||
Reference in new issue
Block a user