diff --git a/include/hasp_conf.h b/include/hasp_conf.h index dc6eca52..f458102b 100644 --- a/include/hasp_conf.h +++ b/include/hasp_conf.h @@ -123,7 +123,7 @@ #endif #ifndef HASP_USE_CONSOLE -#define HASP_USE_CONSOLE HASP_TARGET_ARDUINO +#define HASP_USE_CONSOLE 1 #endif /* Filesystem */ diff --git a/src/hasp_debug.cpp b/src/hasp_debug.cpp index 2adfd826..ca648c60 100644 --- a/src/hasp_debug.cpp +++ b/src/hasp_debug.cpp @@ -139,13 +139,11 @@ void debugStart(void) LOG_INFO(TAG_DEBG, F("Console started")); debug_flush(); -#else +#endif #if HASP_USE_CONSOLE > 0 consoleSetup(); #endif - -#endif } void debugStop() diff --git a/src/sys/svc/hasp_console.cpp b/src/sys/svc/hasp_console.cpp index 66312569..17612d2d 100644 --- a/src/sys/svc/hasp_console.cpp +++ b/src/sys/svc/hasp_console.cpp @@ -5,8 +5,10 @@ #if HASP_USE_CONSOLE > 0 +#if HASP_TARGET_ARDUINO #include "ConsoleInput.h" #include +#endif #include "hasp_debug.h" #include "hasp_console.h" @@ -17,15 +19,18 @@ extern hasp_http_config_t http_config; #endif +#if HASP_TARGET_ARDUINO // Create a new Stream that buffers all writes to serialClient HardwareSerial* bufferedSerialClient = (HardwareSerial*)&HASP_SERIAL; +ConsoleInput* console; +#endif uint8_t consoleLoginState = CONSOLE_UNAUTHENTICATED; uint16_t serialPort = 0; uint8_t consoleEnabled = true; // Enable serial debug output uint8_t consoleLoginAttempt = 0; // Initial attempt -ConsoleInput* console; +#if HASP_TARGET_ARDUINO void console_update_prompt() { if(console) console->update(__LINE__); @@ -101,9 +106,21 @@ static void console_process_line(const char* input) } } } +#elif HASP_TARGET_PC +static bool console_running = true; +static int console_thread(void* arg) +{ + while(console_running) { + std::string input; + std::getline(std::cin, input); + dispatch_text_line(input.c_str(), TAG_CONS); + } +} +#endif void consoleStart() { +#if HASP_TARGET_ARDUINO LOG_TRACE(TAG_MSGR, F(D_SERVICE_STARTING)); console = new ConsoleInput(bufferedSerialClient, HASP_CONSOLE_BUFFER); if(console) { @@ -126,16 +143,32 @@ void consoleStart() console_logoff(); LOG_ERROR(TAG_CONS, F(D_SERVICE_START_FAILED)); } +#elif HASP_TARGET_PC + LOG_TRACE(TAG_MSGR, F(D_SERVICE_STARTING)); +#if defined(WINDOWS) + CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)console_thread, NULL, 0, NULL); +#elif defined(POSIX) + pthread_t thread; + pthread_create(&thread, NULL, (void* (*)(void*))console_thread, NULL); +#endif +#endif } void consoleStop() { +#if HASP_TARGET_ARDUINO console_logoff(); Log.unregisterOutput(0); // serialClient HASP_SERIAL.end(); - delete console; console = NULL; +#elif HASP_TARGET_PC +#if defined(WINDOWS) + +#elif defined(POSIX) + +#endif +#endif } void consoleSetup() @@ -147,6 +180,7 @@ void consoleSetup() IRAM_ATTR void consoleLoop() { +#if HASP_TARGET_ARDUINO if(!console) return; bool update = false; @@ -175,6 +209,7 @@ IRAM_ATTR void consoleLoop() } } if(update) console_update_prompt(); +#endif } #if HASP_USE_CONFIG > 0 @@ -201,4 +236,4 @@ bool consoleSetConfig(const JsonObject& settings) } #endif // HASP_USE_CONFIG -#endif \ No newline at end of file +#endif diff --git a/src/sys/svc/hasp_console.h b/src/sys/svc/hasp_console.h index 10c17b69..18834508 100644 --- a/src/sys/svc/hasp_console.h +++ b/src/sys/svc/hasp_console.h @@ -4,10 +4,10 @@ #ifndef HASP_CONSOLE_H #define HASP_CONSOLE_H -#if HASP_USE_CONSOLE > 0 - #include "hasplib.h" +#if HASP_USE_CONSOLE > 0 + /* ===== Default Event Processors ===== */ void consoleSetup(); IRAM_ATTR void consoleLoop(void); diff --git a/src/sys/svc/hasp_http.cpp b/src/sys/svc/hasp_http.cpp index e3737309..6debc383 100644 --- a/src/sys/svc/hasp_http.cpp +++ b/src/sys/svc/hasp_http.cpp @@ -2,6 +2,9 @@ For full license information read the LICENSE file in the project folder */ #include "hasplib.h" + +#if HASP_USE_HTTP > 0 + #include "ArduinoLog.h" #define HTTP_LEGACY @@ -21,7 +24,6 @@ #include "hasp_gui.h" #include "hasp_debug.h" -#if HASP_USE_HTTP > 0 #include "sys/net/hasp_network.h" #include "sys/net/hasp_time.h" diff --git a/src/sys/svc/hasp_http_async.cpp b/src/sys/svc/hasp_http_async.cpp index 2c8ec707..683d2f50 100644 --- a/src/sys/svc/hasp_http_async.cpp +++ b/src/sys/svc/hasp_http_async.cpp @@ -3,6 +3,9 @@ //#include "webServer.h" #include "hasplib.h" + +#if HASP_USE_HTTP_ASYNC > 0 + #include "ArduinoLog.h" #if defined(ARDUINO_ARCH_ESP32) @@ -16,7 +19,6 @@ #include "hasp_gui.h" #include "hasp_debug.h" -#if HASP_USE_HTTP_ASYNC > 0 #include "sys/net/hasp_network.h" /* clang-format off */ diff --git a/user_setups/darwin_sdl/darwin_sdl_64bits.ini b/user_setups/darwin_sdl/darwin_sdl_64bits.ini index 4a1962c0..7f6b2dca 100644 --- a/user_setups/darwin_sdl/darwin_sdl_64bits.ini +++ b/user_setups/darwin_sdl/darwin_sdl_64bits.ini @@ -99,6 +99,7 @@ build_src_filter = - - + + + - + - diff --git a/user_setups/linux_sdl/linux_fbdev_64bits.ini b/user_setups/linux_sdl/linux_fbdev_64bits.ini index 4904cf69..6517de41 100644 --- a/user_setups/linux_sdl/linux_fbdev_64bits.ini +++ b/user_setups/linux_sdl/linux_fbdev_64bits.ini @@ -84,6 +84,7 @@ build_src_filter = - - + + + - + - diff --git a/user_setups/linux_sdl/linux_sdl_64bits.ini b/user_setups/linux_sdl/linux_sdl_64bits.ini index 432c9814..09976003 100644 --- a/user_setups/linux_sdl/linux_sdl_64bits.ini +++ b/user_setups/linux_sdl/linux_sdl_64bits.ini @@ -89,6 +89,7 @@ build_src_filter = - - + + + - + - diff --git a/user_setups/win32/windows_gdi_64bits.ini b/user_setups/win32/windows_gdi_64bits.ini index d2657df5..901d2f36 100644 --- a/user_setups/win32/windows_gdi_64bits.ini +++ b/user_setups/win32/windows_gdi_64bits.ini @@ -113,6 +113,7 @@ build_src_filter = - - + + + - + - diff --git a/user_setups/win32/windows_sdl_64bits.ini b/user_setups/win32/windows_sdl_64bits.ini index 3c6957bb..a9327f8a 100644 --- a/user_setups/win32/windows_sdl_64bits.ini +++ b/user_setups/win32/windows_sdl_64bits.ini @@ -119,6 +119,7 @@ build_src_filter = - - + + + - + -