From dd44892c72d0dc59ff58d44814955b4dd7f99fb8 Mon Sep 17 00:00:00 2001 From: fvanroie Date: Tue, 12 Apr 2022 03:38:58 +0200 Subject: [PATCH] Add boot.cmd script --- src/hasp/hasp_dispatch.cpp | 12 +++++------- src/main_arduino.cpp | 1 + 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/hasp/hasp_dispatch.cpp b/src/hasp/hasp_dispatch.cpp index 8e257bcd..0781e3fa 100644 --- a/src/hasp/hasp_dispatch.cpp +++ b/src/hasp/hasp_dispatch.cpp @@ -705,27 +705,25 @@ void dispatch_exec(const char*, const char* payload, uint8_t source) // char buffer[512]; // use stack String buffer((char*)0); // use heap - buffer.reserve(256); + buffer.reserve(512); - ReadBufferingStream bufferedFile{cmdfile, 256}; + ReadBufferingStream bufferedFile{cmdfile, 512}; cmdfile.seek(0); while(bufferedFile.available()) { size_t index = 0; buffer = ""; - // while(index < sizeof(buffer) - 1) { while(index < MQTT_MAX_PACKET_SIZE) { int c = bufferedFile.read(); if(c < 0 || c == '\n' || c == '\r') { // CR or LF break; } - // buffer[index] = (char)c; buffer += (char)c; index++; } - // buffer[index] = 0; // terminate string - // if(index > 0 && buffer[0] != '#') dispatch_text_line(buffer.c_str(), TAG_FILE); // # for comments - if(index > 0 && buffer.charAt(0) != '#') dispatch_text_line(buffer.c_str(), TAG_FILE); // # for comments + if(index > 0 && buffer.charAt(0) != '#') { // Check for comments + dispatch_text_line(buffer.c_str(), TAG_FILE); + } } cmdfile.close(); diff --git a/src/main_arduino.cpp b/src/main_arduino.cpp index e7c34850..f2264136 100644 --- a/src/main_arduino.cpp +++ b/src/main_arduino.cpp @@ -121,6 +121,7 @@ void setup() mainLastLoopTime = -1000; // reset loop counter delay(20); + dispatch_exec(NULL, "/boot.cmd", TAG_HASP); // guiStart(); }