mirror of https://github.com/arendst/Tasmota.git
dd using heap when more than 199 IRSend values need to be send. May need increase of define MQTT_MAX_PACKET_SIZE too
dd using heap when more than 199 IRSend values need to be send. May need increase of define MQTT_MAX_PACKET_SIZE too (#5950)
This commit is contained in:
parent
9d706c9864
commit
8ed16c15a0
|
@ -1,6 +1,7 @@
|
|||
/* 6.5.0.16 20190611
|
||||
* Refactored TLS based on BearSSL, warning breaking change for fingerprints validation (see doc)
|
||||
* Add checkbox to GUI password field enabling visibility during password entry only (#5934)
|
||||
* Add using heap when more than 199 IRSend values need to be send. May need increase of define MQTT_MAX_PACKET_SIZE too (#5950)
|
||||
*
|
||||
* 6.5.0.15 20190606
|
||||
* Change pubsubclient MQTT_KEEPALIVE from 10 to 30 seconds in preparation of AWS IoT support
|
||||
|
|
|
@ -639,12 +639,32 @@ bool IrSendCommand(void)
|
|||
} else { // At least two raw data values
|
||||
// IRsend 0,896,876,900,888,894,876,1790,874,872,1810,1736,948,872,880,872,936,872,1792,900,888,1734
|
||||
count++;
|
||||
uint16_t raw_array[count]; // It's safe to use stack for up to 240 packets (limited by mqtt_data length)
|
||||
for (uint16_t i = 0; i < count; i++) {
|
||||
raw_array[i] = strtol(strtok_r(nullptr, ", ", &p), nullptr, 0); // Allow decimal (20496) and hexadecimal (0x5010) input
|
||||
if (count < 200) {
|
||||
uint16_t raw_array[count]; // It's safe to use stack for up to 200 packets (limited by mqtt_data length)
|
||||
for (uint16_t i = 0; i < count; i++) {
|
||||
raw_array[i] = strtol(strtok_r(nullptr, ", ", &p), nullptr, 0); // Allow decimal (20496) and hexadecimal (0x5010) input
|
||||
}
|
||||
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DBG: stack count %d"), count);
|
||||
|
||||
irsend_active = true;
|
||||
irsend->sendRaw(raw_array, count, freq);
|
||||
} else {
|
||||
uint16_t *raw_array = reinterpret_cast<uint16_t*>(malloc(count * sizeof(uint16_t)));
|
||||
if (raw_array == nullptr) {
|
||||
error = IE_INVALID_RAWDATA;
|
||||
} else {
|
||||
for (uint16_t i = 0; i < count; i++) {
|
||||
raw_array[i] = strtol(strtok_r(nullptr, ", ", &p), nullptr, 0); // Allow decimal (20496) and hexadecimal (0x5010) input
|
||||
}
|
||||
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DBG: heap count %d"), count);
|
||||
|
||||
irsend_active = true;
|
||||
irsend->sendRaw(raw_array, count, freq);
|
||||
free(raw_array);
|
||||
}
|
||||
}
|
||||
irsend_active = true;
|
||||
irsend->sendRaw(raw_array, count, freq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue