Correct datastring implementation going to the esp to reset if publishing value and protocol only
This commit is contained in:
1 parent
4b0d3943ce
commit
60bc75f0b6
1 file changed
+55
-51
+55
-51
@@ -276,79 +276,83 @@ void IRtoMQTT(){
|
|||||||
unsigned long data = IRdata["value"];
|
unsigned long data = IRdata["value"];
|
||||||
const char * raw = IRdata["raw"];
|
const char * raw = IRdata["raw"];
|
||||||
const char * datastring = IRdata["datastring"];
|
const char * datastring = IRdata["datastring"];
|
||||||
if (data != 0||raw||datastring) {
|
if (data != 0 || raw || datastring) {
|
||||||
trc(F("MQTTtoIR data || raw ok"));
|
trc(F("MQTTtoIR value || raw || datasring ok"));
|
||||||
bool signalSent = false;
|
bool signalSent = false;
|
||||||
trc(F("value"));
|
trc(F("value"));
|
||||||
trc(data);
|
trc(data);
|
||||||
trc(F("raw"));
|
if(datastring){
|
||||||
trc(raw);
|
trc(F("datastring"));
|
||||||
trc(F("datastring"));
|
trc(datastring);
|
||||||
trc(datastring);
|
}else{
|
||||||
|
datastring ="";
|
||||||
|
}
|
||||||
const char * protocol_name = IRdata["protocol_name"];
|
const char * protocol_name = IRdata["protocol_name"];
|
||||||
unsigned int valueBITS = IRdata["bits"];
|
unsigned int valueBITS = IRdata["bits"]|0;
|
||||||
uint16_t valueRPT = IRdata["repeat"]|repeatIRwNumber;
|
uint16_t valueRPT = IRdata["repeat"]|repeatIRwNumber;
|
||||||
|
|
||||||
if(raw){
|
if(raw){
|
||||||
unsigned int s = strlen(raw);
|
trc(F("raw"));
|
||||||
//number of "," value count
|
trc(raw);
|
||||||
int count = 0;
|
unsigned int s = strlen(raw);
|
||||||
for(int i = 0; i < s; i++)
|
//number of "," value count
|
||||||
{
|
int count = 0;
|
||||||
if (raw[i] == ',') {
|
for(int i = 0; i < s; i++)
|
||||||
count++;
|
{
|
||||||
}
|
if (raw[i] == ',') {
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
#ifdef IR_GC
|
}
|
||||||
if(strstr(protocol_name, "IR_GC") != NULL){ // sending GC data from https://irdb.globalcache.com
|
#ifdef IR_GC
|
||||||
trc(F("IR_GC"));
|
if(strstr(protocol_name, "IR_GC") != NULL){ // sending GC data from https://irdb.globalcache.com
|
||||||
//buffer allocation from char datacallback
|
trc(F("IR_GC"));
|
||||||
uint16_t GC[count+1];
|
//buffer allocation from char datacallback
|
||||||
String value = "";
|
uint16_t GC[count+1];
|
||||||
int j = 0;
|
|
||||||
for(int i = 0; i < s; i++)
|
|
||||||
{
|
|
||||||
if (raw[i] != ',') {
|
|
||||||
value = value + String(raw[i]);
|
|
||||||
}
|
|
||||||
if ((raw[i] == ',') || (i == s - 1))
|
|
||||||
{
|
|
||||||
GC[j]= value.toInt();
|
|
||||||
value = "";
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
irsend.sendGC(GC, j);
|
|
||||||
signalSent = true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef IR_Raw
|
|
||||||
if(strstr(protocol_name, "IR_Raw") != NULL){ // sending Raw data
|
|
||||||
trc(F("IR_Raw"));
|
|
||||||
//buffer allocation from char datacallback
|
|
||||||
#if defined(ESP8266) || defined(ESP32)
|
|
||||||
uint16_t Raw[count+1];
|
|
||||||
#else
|
|
||||||
unsigned int Raw[count+1];
|
|
||||||
#endif
|
|
||||||
String value = "";
|
String value = "";
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for(int i = 0; i < s; i++)
|
for(int i = 0; i < s; i++)
|
||||||
{
|
{
|
||||||
if (raw[i] != ',') {
|
if (raw[i] != ',') {
|
||||||
value = value + String(raw[i]);
|
value = value + String(raw[i]);
|
||||||
}
|
}
|
||||||
if ((raw[i] == ',') || (i == s - 1))
|
if ((raw[i] == ',') || (i == s - 1))
|
||||||
{
|
{
|
||||||
Raw[j]= value.toInt();
|
GC[j]= value.toInt();
|
||||||
value = "";
|
value = "";
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
irsend.sendRaw(Raw, j, RawFrequency);
|
irsend.sendGC(GC, j);
|
||||||
signalSent = true;
|
signalSent = true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef IR_Raw
|
||||||
|
if(strstr(protocol_name, "IR_Raw") != NULL){ // sending Raw data
|
||||||
|
trc(F("IR_Raw"));
|
||||||
|
//buffer allocation from char datacallback
|
||||||
|
#if defined(ESP8266) || defined(ESP32)
|
||||||
|
uint16_t Raw[count+1];
|
||||||
|
#else
|
||||||
|
unsigned int Raw[count+1];
|
||||||
#endif
|
#endif
|
||||||
|
String value = "";
|
||||||
|
int j = 0;
|
||||||
|
for(int i = 0; i < s; i++)
|
||||||
|
{
|
||||||
|
if (raw[i] != ',') {
|
||||||
|
value = value + String(raw[i]);
|
||||||
|
}
|
||||||
|
if ((raw[i] == ',') || (i == s - 1))
|
||||||
|
{
|
||||||
|
Raw[j]= value.toInt();
|
||||||
|
value = "";
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
irsend.sendRaw(Raw, j, RawFrequency);
|
||||||
|
signalSent = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}else if(protocol_name && (strstr(protocol_name, "IR_NEC") == NULL)){
|
}else if(protocol_name && (strstr(protocol_name, "IR_NEC") == NULL)){
|
||||||
signalSent = sendIdentifiedProtocol(protocol_name, data, datastring, valueBITS, valueRPT);
|
signalSent = sendIdentifiedProtocol(protocol_name, data, datastring, valueBITS, valueRPT);
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
Reference in new issue
Block a user