mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-22 02:06:31 +00:00
Move heap to stack
This commit is contained in:
parent
a52c059cdc
commit
a6dcf46771
@ -345,7 +345,7 @@
|
|||||||
#define USE_SONOFF_IFAN // Add support for Sonoff iFan02 and iFan03 (+2k code)
|
#define USE_SONOFF_IFAN // Add support for Sonoff iFan02 and iFan03 (+2k code)
|
||||||
#define USE_BUZZER // Add support for a buzzer (+0k6 code)
|
#define USE_BUZZER // Add support for a buzzer (+0k6 code)
|
||||||
#define USE_ARILUX_RF // Add support for Arilux RF remote controller (+0k8 code, 252 iram (non 2.3.0))
|
#define USE_ARILUX_RF // Add support for Arilux RF remote controller (+0k8 code, 252 iram (non 2.3.0))
|
||||||
//#define USE_SHUTTER // Add Shutter support for up to 4 shutter with different motortypes (+6k code)
|
//#define USE_SHUTTER // Add Shutter support for up to 4 shutter with different motortypes (+11k code)
|
||||||
#define USE_DEEPSLEEP // Add support for deepsleep (+1k code)
|
#define USE_DEEPSLEEP // Add support for deepsleep (+1k code)
|
||||||
//#define USE_EXS_DIMMER // Add support for ES-Store WiFi Dimmer (+1k5 code)
|
//#define USE_EXS_DIMMER // Add support for ES-Store WiFi Dimmer (+1k5 code)
|
||||||
// #define EXS_MCU_CMNDS // Add command to send MCU commands (+0k8 code)
|
// #define EXS_MCU_CMNDS // Add command to send MCU commands (+0k8 code)
|
||||||
|
@ -499,17 +499,14 @@ bool NewerVersion(char* version_str)
|
|||||||
uint32_t version = 0;
|
uint32_t version = 0;
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
char *str_ptr;
|
char *str_ptr;
|
||||||
char* version_dup = strdup(version_str); // Duplicate the version_str as strtok_r will modify it.
|
|
||||||
|
|
||||||
if (!version_dup) {
|
char version_dup[strlen(version_str) +1];
|
||||||
return false; // Bail if we can't duplicate. Assume bad.
|
strncpy(version_dup, version_str, sizeof(version_dup)); // Duplicate the version_str as strtok_r will modify it.
|
||||||
}
|
|
||||||
// Loop through the version string, splitting on '.' seperators.
|
// Loop through the version string, splitting on '.' seperators.
|
||||||
for (char *str = strtok_r(version_dup, ".", &str_ptr); str && i < sizeof(VERSION); str = strtok_r(nullptr, ".", &str_ptr), i++) {
|
for (char *str = strtok_r(version_dup, ".", &str_ptr); str && i < sizeof(VERSION); str = strtok_r(nullptr, ".", &str_ptr), i++) {
|
||||||
int field = atoi(str);
|
int field = atoi(str);
|
||||||
// The fields in a version string can only range from 0-255.
|
// The fields in a version string can only range from 0-255.
|
||||||
if ((field < 0) || (field > 255)) {
|
if ((field < 0) || (field > 255)) {
|
||||||
free(version_dup);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Shuffle the accumulated bytes across, and add the new byte.
|
// Shuffle the accumulated bytes across, and add the new byte.
|
||||||
@ -521,7 +518,6 @@ bool NewerVersion(char* version_str)
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(version_dup); // We no longer need this.
|
|
||||||
// A version string should have 2-4 fields. e.g. 1.2, 1.2.3, or 1.2.3a (= 1.2.3.1).
|
// A version string should have 2-4 fields. e.g. 1.2, 1.2.3, or 1.2.3a (= 1.2.3.1).
|
||||||
// If not, then don't consider it a valid version string.
|
// If not, then don't consider it a valid version string.
|
||||||
if ((i < 2) || (i > sizeof(VERSION))) {
|
if ((i < 2) || (i > sizeof(VERSION))) {
|
||||||
|
@ -808,18 +808,22 @@ void CmndShutterButton(void)
|
|||||||
// (setting>> 2)&(0x3f) : shutter_position single press 0 disabled, 1..101 == 0..100%
|
// (setting>> 2)&(0x3f) : shutter_position single press 0 disabled, 1..101 == 0..100%
|
||||||
// (setting>> 0)&(0x03) : shutter_index
|
// (setting>> 0)&(0x03) : shutter_index
|
||||||
if (XdrvMailbox.data_len > 0) {
|
if (XdrvMailbox.data_len > 0) {
|
||||||
uint32_t i = 0, button_index = 0;
|
uint32_t i = 0;
|
||||||
bool done = false, isShortCommand = false;
|
uint32_t button_index = 0;
|
||||||
|
bool done = false;
|
||||||
|
bool isShortCommand = false;
|
||||||
char *str_ptr;
|
char *str_ptr;
|
||||||
char* version_dup = strdup(XdrvMailbox.data); // Duplicate the version_str as strtok_r will modify it.
|
|
||||||
// Loop through the version string, splitting on ' ' seperators.
|
|
||||||
for (char *str = strtok_r(version_dup, " ", &str_ptr); str && i < (1+4+4+1); str = strtok_r(nullptr, " ", &str_ptr), i++) {
|
|
||||||
int field;
|
|
||||||
if (str[0] == '-')
|
|
||||||
field = -1;
|
|
||||||
else
|
|
||||||
field = atoi(str);
|
|
||||||
|
|
||||||
|
char data_copy[strlen(XdrvMailbox.data) +1];
|
||||||
|
strncpy(data_copy, XdrvMailbox.data, sizeof(data_copy)); // Duplicate data as strtok_r will modify it.
|
||||||
|
// Loop through the data string, splitting on ' ' seperators.
|
||||||
|
for (char *str = strtok_r(data_copy, " ", &str_ptr); str && i < (1+4+4+1); str = strtok_r(nullptr, " ", &str_ptr), i++) {
|
||||||
|
int field;
|
||||||
|
if (str[0] == '-') {
|
||||||
|
field = -1;
|
||||||
|
} else {
|
||||||
|
field = atoi(str);
|
||||||
|
}
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
if ((field >= -1) && (field<=4)) {
|
if ((field >= -1) && (field<=4)) {
|
||||||
@ -866,7 +870,6 @@ void CmndShutterButton(void)
|
|||||||
}
|
}
|
||||||
if (done) break;
|
if (done) break;
|
||||||
}
|
}
|
||||||
free(version_dup);
|
|
||||||
|
|
||||||
if (button_index) {
|
if (button_index) {
|
||||||
if (button_index==-1) {
|
if (button_index==-1) {
|
||||||
@ -957,30 +960,31 @@ void CmndShutterInvert(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CmndShutterCalibration(void) // ????
|
void CmndShutterCalibration(void)
|
||||||
{
|
{
|
||||||
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= shutters_present)) {
|
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= shutters_present)) {
|
||||||
if (XdrvMailbox.data_len > 0) {
|
if (XdrvMailbox.data_len > 0) {
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
char *str_ptr;
|
char *str_ptr;
|
||||||
char* version_dup = strdup(XdrvMailbox.data); // Duplicate the version_str as strtok_r will modify it.
|
|
||||||
// Loop through the version string, splitting on '.' seperators.
|
char data_copy[strlen(XdrvMailbox.data) +1];
|
||||||
for (char *str = strtok_r(version_dup, " ", &str_ptr); str && i < 5; str = strtok_r(nullptr, " ", &str_ptr), i++) {
|
strncpy(data_copy, XdrvMailbox.data, sizeof(data_copy)); // Duplicate data as strtok_r will modify it.
|
||||||
int field = atoi(str);
|
// Loop through the data string, splitting on ' ' seperators.
|
||||||
// The fields in a version string can only range from 1-30000.
|
for (char *str = strtok_r(data_copy, " ", &str_ptr); str && i < 5; str = strtok_r(nullptr, " ", &str_ptr), i++) {
|
||||||
// and following value must be higher than previous one
|
int field = atoi(str);
|
||||||
if ((field <= 0) || (field > 30000) || ( (i>0) && (field <= messwerte[i-1]) ) ) {
|
// The fields in a data string can only range from 1-30000.
|
||||||
break;
|
// and following value must be higher than previous one
|
||||||
}
|
if ((field <= 0) || (field > 30000) || ( (i>0) && (field <= messwerte[i-1]) ) ) {
|
||||||
messwerte[i] = field;
|
break;
|
||||||
}
|
}
|
||||||
free(version_dup);
|
messwerte[i] = field;
|
||||||
for (i=0 ; i < 5 ; i++) {
|
}
|
||||||
Settings.shuttercoeff[i][XdrvMailbox.index -1] = (uint32_t)messwerte[i] * 1000 / messwerte[4];
|
for (i = 0; i < 5; i++) {
|
||||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("Settings.shuttercoeff: %d, i: %d, value: %d, messwert %d"), i,XdrvMailbox.index -1,Settings.shuttercoeff[i][XdrvMailbox.index -1], messwerte[i]);
|
Settings.shuttercoeff[i][XdrvMailbox.index -1] = (uint32_t)messwerte[i] * 1000 / messwerte[4];
|
||||||
}
|
AddLog_P2(LOG_LEVEL_INFO, PSTR("Settings.shuttercoeff: %d, i: %d, value: %d, messwert %d"), i,XdrvMailbox.index -1,Settings.shuttercoeff[i][XdrvMailbox.index -1], messwerte[i]);
|
||||||
ShutterInit();
|
}
|
||||||
ResponseCmndIdxChar(XdrvMailbox.data);
|
ShutterInit();
|
||||||
|
ResponseCmndIdxChar(XdrvMailbox.data);
|
||||||
} else {
|
} else {
|
||||||
char setting_chr[30] = "0";
|
char setting_chr[30] = "0";
|
||||||
snprintf_P(setting_chr, sizeof(setting_chr), PSTR("%d %d %d %d %d"), Settings.shuttercoeff[0][XdrvMailbox.index -1], Settings.shuttercoeff[1][XdrvMailbox.index -1], Settings.shuttercoeff[2][XdrvMailbox.index -1], Settings.shuttercoeff[3][XdrvMailbox.index -1], Settings.shuttercoeff[4][XdrvMailbox.index -1]);
|
snprintf_P(setting_chr, sizeof(setting_chr), PSTR("%d %d %d %d %d"), Settings.shuttercoeff[0][XdrvMailbox.index -1], Settings.shuttercoeff[1][XdrvMailbox.index -1], Settings.shuttercoeff[2][XdrvMailbox.index -1], Settings.shuttercoeff[3][XdrvMailbox.index -1], Settings.shuttercoeff[4][XdrvMailbox.index -1]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user