mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-25 20:26:41 +00:00
Change dispatch_exec to dispatch_run_script
This commit is contained in:
parent
560d491f71
commit
8ec8de6980
@ -365,11 +365,13 @@ void dispatch_topic_payload(const char* topic, const char* payload, bool update,
|
|||||||
// Parse one line of text and execute the command
|
// Parse one line of text and execute the command
|
||||||
void dispatch_text_line(const char* cmnd, uint8_t source)
|
void dispatch_text_line(const char* cmnd, uint8_t source)
|
||||||
{
|
{
|
||||||
if(cmnd[0] == '/' && cmnd[1] == '/') return; // comment
|
while(cmnd[0] == ' ' || cmnd[0] == '\t') cmnd++; // skip leading spaces
|
||||||
|
if(cmnd[0] == '/' && cmnd[1] == '/') return; // comment
|
||||||
|
|
||||||
switch(cmnd[0]) {
|
switch(cmnd[0]) {
|
||||||
case '#':
|
case '#': // comment
|
||||||
break; // comment
|
case '\0': // empty line
|
||||||
|
break;
|
||||||
|
|
||||||
case '{':
|
case '{':
|
||||||
dispatch_command("jsonl", cmnd, false, source);
|
dispatch_command("jsonl", cmnd, false, source);
|
||||||
@ -380,7 +382,6 @@ void dispatch_text_line(const char* cmnd, uint8_t source)
|
|||||||
break; // comment
|
break; // comment
|
||||||
|
|
||||||
case ' ':
|
case ' ':
|
||||||
while(cmnd[0] == ' ') cmnd++; // skip leading spaces
|
|
||||||
dispatch_text_line(cmnd, source);
|
dispatch_text_line(cmnd, source);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -689,7 +690,7 @@ void dispatch_parse_jsonl(const char*, const char* payload, uint8_t source)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void dispatch_exec(const char*, const char* payload, uint8_t source)
|
void dispatch_run_script(const char*, const char* payload, uint8_t source)
|
||||||
{
|
{
|
||||||
const char* filename = payload;
|
const char* filename = payload;
|
||||||
if(filename[0] == 'L' && filename[1] == ':') filename += 2; // strip littlefs drive letter
|
if(filename[0] == 'L' && filename[1] == ':') filename += 2; // strip littlefs drive letter
|
||||||
@ -1430,7 +1431,7 @@ void dispatchSetup()
|
|||||||
dispatch_add_command(PSTR("clearfont"), dispatch_clear_font);
|
dispatch_add_command(PSTR("clearfont"), dispatch_clear_font);
|
||||||
dispatch_add_command(PSTR("sensors"), dispatch_send_sensordata);
|
dispatch_add_command(PSTR("sensors"), dispatch_send_sensordata);
|
||||||
dispatch_add_command(PSTR("theme"), dispatch_theme);
|
dispatch_add_command(PSTR("theme"), dispatch_theme);
|
||||||
dispatch_add_command(PSTR("run"), dispatch_exec);
|
dispatch_add_command(PSTR("run"), dispatch_run_script);
|
||||||
dispatch_add_command(PSTR("service"), dispatch_service);
|
dispatch_add_command(PSTR("service"), dispatch_service);
|
||||||
dispatch_add_command(PSTR("antiburn"), dispatch_antiburn);
|
dispatch_add_command(PSTR("antiburn"), dispatch_antiburn);
|
||||||
dispatch_add_command(PSTR("calibrate"), dispatch_calibrate);
|
dispatch_add_command(PSTR("calibrate"), dispatch_calibrate);
|
||||||
|
@ -78,7 +78,7 @@ void dispatch_idle_state(uint8_t state);
|
|||||||
void dispatch_calibrate(const char*, const char*, uint8_t source);
|
void dispatch_calibrate(const char*, const char*, uint8_t source);
|
||||||
void dispatch_antiburn(const char*, const char* payload, uint8_t source);
|
void dispatch_antiburn(const char*, const char* payload, uint8_t source);
|
||||||
void dispatch_wakeup();
|
void dispatch_wakeup();
|
||||||
void dispatch_exec(const char*, const char* payload, uint8_t source);
|
void dispatch_run_script(const char*, const char* payload, uint8_t source);
|
||||||
void dispatch_config(const char* topic, const char* payload, uint8_t source);
|
void dispatch_config(const char* topic, const char* payload, uint8_t source);
|
||||||
|
|
||||||
void dispatch_normalized_group_values(hasp_update_value_t& value);
|
void dispatch_normalized_group_values(hasp_update_value_t& value);
|
||||||
|
@ -42,10 +42,10 @@ void network_run_scripts()
|
|||||||
{
|
{
|
||||||
if(last_network_state != current_network_state) {
|
if(last_network_state != current_network_state) {
|
||||||
if(current_network_state) {
|
if(current_network_state) {
|
||||||
dispatch_exec(NULL, "L:/online.cmd", TAG_NETW);
|
dispatch_run_script(NULL, "L:/online.cmd", TAG_HASP);
|
||||||
networkStart();
|
networkStart();
|
||||||
} else {
|
} else {
|
||||||
dispatch_exec(NULL, "L:/offline.cmd", TAG_NETW);
|
dispatch_run_script(NULL, "L:/offline.cmd", TAG_HASP);
|
||||||
networkStop();
|
networkStop();
|
||||||
}
|
}
|
||||||
last_network_state = current_network_state;
|
last_network_state = current_network_state;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user