Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
795 B

Terminal: change command-line parser (#2247) Change the underlying command line handling: - switch to a custom parser, inspired by redis / sds - update terminalRegisterCommand signature, pass only bare minimum - clean-up `help` & `commands`. update settings `set`, `get` and `del` - allow our custom test suite to run command-line tests - clean-up Stream IO to allow us to print large things into debug stream (for example, `eeprom.dump`) - send parsing errors to the debug log As a proof of concept, introduce `TERMINAL_MQTT_SUPPORT` and `TERMINAL_WEB_API_SUPPORT` - MQTT subscribes to the `<root>/cmd/set` and sends response to the `<root>/cmd`. We can't output too much, as we don't have any large-send API. - Web API listens to the `/api/cmd?apikey=...&line=...` (or PUT, params inside the body). This one is intended as a possible replacement of the `API_SUPPORT`. Internals introduce a 'task' around the AsyncWebServerRequest object that will simulate what WiFiClient does and push data into it continuously, switching between CONT and SYS. Both are experimental. We only accept a single command and not every command is updated to use Print `ctx.output` object. We are also somewhat limited by the Print / Stream overall, perhaps I am overestimating the usefulness of Arduino compatibility to such an extent :) Web API handler can also sometimes show only part of the result, whenever the command tries to yield() by itself waiting for something. Perhaps we would need to create a custom request handler for that specific use-case.
4 years ago
Terminal: change command-line parser (#2247) Change the underlying command line handling: - switch to a custom parser, inspired by redis / sds - update terminalRegisterCommand signature, pass only bare minimum - clean-up `help` & `commands`. update settings `set`, `get` and `del` - allow our custom test suite to run command-line tests - clean-up Stream IO to allow us to print large things into debug stream (for example, `eeprom.dump`) - send parsing errors to the debug log As a proof of concept, introduce `TERMINAL_MQTT_SUPPORT` and `TERMINAL_WEB_API_SUPPORT` - MQTT subscribes to the `<root>/cmd/set` and sends response to the `<root>/cmd`. We can't output too much, as we don't have any large-send API. - Web API listens to the `/api/cmd?apikey=...&line=...` (or PUT, params inside the body). This one is intended as a possible replacement of the `API_SUPPORT`. Internals introduce a 'task' around the AsyncWebServerRequest object that will simulate what WiFiClient does and push data into it continuously, switching between CONT and SYS. Both are experimental. We only accept a single command and not every command is updated to use Print `ctx.output` object. We are also somewhat limited by the Print / Stream overall, perhaps I am overestimating the usefulness of Arduino compatibility to such an extent :) Web API handler can also sometimes show only part of the result, whenever the command tries to yield() by itself waiting for something. Perhaps we would need to create a custom request handler for that specific use-case.
4 years ago
  1. /*
  2. DEBUG MODULE
  3. */
  4. #pragma once
  5. #include "espurna.h"
  6. #if DEBUG_WEB_SUPPORT
  7. #include <ArduinoJson.h>
  8. #endif
  9. extern "C" {
  10. void custom_crash_callback(struct rst_info*, uint32_t, uint32_t);
  11. }
  12. class PrintRaw;
  13. class PrintHex;
  14. enum class DebugLogMode : int {
  15. Disabled = 0,
  16. Enabled = 1,
  17. SkipBoot = 2
  18. };
  19. bool debugLogBuffer();
  20. void debugWebSetup();
  21. void debugConfigure();
  22. void debugConfigureBoot();
  23. void debugSetup();
  24. void debugSendRaw(const char* line, bool timestamp = false);
  25. void debugSend(const char* format, ...);
  26. void debugSend_P(const char* format, ...);
  27. #if DEBUG_SUPPORT
  28. #define DEBUG_MSG(...) debugSend(__VA_ARGS__)
  29. #define DEBUG_MSG_P(...) debugSend_P(__VA_ARGS__)
  30. #endif
  31. #ifndef DEBUG_MSG
  32. #define DEBUG_MSG(...)
  33. #define DEBUG_MSG_P(...)
  34. #endif