fix compile error when globvars not used (#23535)

This commit is contained in:
gemu 2025-06-11 09:16:15 +02:00 committed by GitHub
parent 742b7338fd
commit 004f1ec36a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -292,6 +292,7 @@ void Script_ticker4_end(void) {
#define SCRIPT_UDP_BUFFER_SIZE 128 #define SCRIPT_UDP_BUFFER_SIZE 128
#endif #endif
#define SCRIPT_UDP_PORT 1999 #define SCRIPT_UDP_PORT 1999
#endif
// EEPROM MACROS // EEPROM MACROS
// i2c eeprom // i2c eeprom
@ -1529,6 +1530,7 @@ char *script;
} }
#ifdef USE_SCRIPT_GLOBVARS
int32_t udp_call(char *url, uint32_t port, char *sbuf) { int32_t udp_call(char *url, uint32_t port, char *sbuf) {
WiFiUDP udp; WiFiUDP udp;
IPAddress adr; IPAddress adr;
@ -1597,20 +1599,22 @@ void Script_PollUdp(void) {
if (glob_script_mem.udp_flags.udp_connected ) { if (glob_script_mem.udp_flags.udp_connected ) {
uint32_t timeout = millis(); uint32_t timeout = millis();
while (1) { while (1) {
char *packet_buffer = glob_script_mem.packet_buffer;
uint16_t plen = glob_script_mem.Script_PortUdp.parsePacket(); uint16_t plen = glob_script_mem.Script_PortUdp.parsePacket();
if (!plen || plen > glob_script_mem.pb_size) { if (!plen || plen > glob_script_mem.pb_size) {
glob_script_mem.Script_PortUdp.flush(); if (plen > 0) {
glob_script_mem.Script_PortUdp.read(packet_buffer, glob_script_mem.pb_size - 1);
glob_script_mem.Script_PortUdp.flush();
}
break; break;
} }
// not more then 500 ms // not more then 500 ms
if (millis() - timeout > 500) { break;} if (millis() - timeout > 500) { break;}
char *packet_buffer = glob_script_mem.packet_buffer; int32_t len = glob_script_mem.Script_PortUdp.read(packet_buffer, glob_script_mem.pb_size - 1);
int32_t len = glob_script_mem.Script_PortUdp.read(packet_buffer, glob_script_mem.pb_size);
packet_buffer[len] = 0; packet_buffer[len] = 0;
glob_script_mem.script_udp_remote_ip = glob_script_mem.Script_PortUdp.remoteIP(); glob_script_mem.script_udp_remote_ip = glob_script_mem.Script_PortUdp.remoteIP();
#ifdef SCRIPT_DEBUG_UDP #ifdef SCRIPT_DEBUG_UDP
//AddLog(LOG_LEVEL_DEBUG, PSTR("UDP: Packet %s - %d - %s"), packet_buffer, len, script_udp_remote_ip.toString().c_str());
AddLog(LOG_LEVEL_DEBUG, PSTR("UDP: received Packet %s - %d - %_I"), packet_buffer, len, (uint32_t)glob_script_mem.script_udp_remote_ip); AddLog(LOG_LEVEL_DEBUG, PSTR("UDP: received Packet %s - %d - %_I"), packet_buffer, len, (uint32_t)glob_script_mem.script_udp_remote_ip);
#endif #endif
char *lp = packet_buffer; char *lp = packet_buffer;
@ -1706,7 +1710,12 @@ void script_udp_sendvar(char *vname, TS_FLOAT *fp, char *sp, uint16_t alen) {
if (!glob_script_mem.udp_flags.udp_used) return; if (!glob_script_mem.udp_flags.udp_used) return;
if (!glob_script_mem.udp_flags.udp_connected) return; if (!glob_script_mem.udp_flags.udp_connected) return;
char sbuf[SCRIPT_MAX_SBSIZE + 4]; uint16_t ubsiz = SCRIPT_MAX_SBSIZE + 16;
if (ubsiz < 32) {
ubsiz = 32;
}
char sbuf[ubsiz];
strcpy(sbuf, "=>"); strcpy(sbuf, "=>");
strcat(sbuf, vname); strcat(sbuf, vname);
if (glob_script_mem.udp_flags.udp_binary_payload == 0 || !fp) { if (glob_script_mem.udp_flags.udp_binary_payload == 0 || !fp) {
@ -8218,10 +8227,14 @@ startline:
and_or = 0; and_or = 0;
if (if_exe[ifstck - 1] == 0) { if (if_exe[ifstck - 1] == 0) {
// not enabled // not enabled
#if 0
glob_script_mem.FLAGS.ignore_line = 1; glob_script_mem.FLAGS.ignore_line = 1;
/* // AddLog(LOG_LEVEL_INFO, PSTR(">>> %d"),ifstck);
#else
// AddLog(LOG_LEVEL_INFO, PSTR(">>> %d"),ifstck);
while (*lp) { while (*lp) {
if (*lp == SCRIPT_EOL) { if (*lp == SCRIPT_EOL) {
lp--;
break; break;
} }
if (*lp == '{') { if (*lp == '{') {
@ -8232,7 +8245,7 @@ startline:
lp++; lp++;
} }
goto next_line; goto next_line;
*/ #endif
} }
} else if (!strncmp(lp, "then", 4) && if_state[ifstck] == 1) { } else if (!strncmp(lp, "then", 4) && if_state[ifstck] == 1) {
lp += 4; lp += 4;