Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
Debug.h
1 /*
2  * Debug.h
3  *
4  */
5 
6 #ifndef SMINGCORE_DEBUG_H_
7 #define SMINGCORE_DEBUG_H_
8 
9 #include "HardwareSerial.h"
10 #include "Clock.h"
11 #include "WString.h"
12 #include "../Services/CommandProcessing/CommandProcessingIncludes.h"
13 
18 
22 typedef struct
23 {
24  DebugPrintCharDelegate debugDelegate = nullptr;
25  Stream *debugStream = nullptr;
27 
31 typedef enum
32 {
35 } eDBGPrefix;
36 
47 class DebugClass : public Print
48 {
49 public:
53  DebugClass();
54  virtual ~DebugClass();
55 
58  void initCommand();
59 
62  void start();
63 
66  void stop();
67 
71  bool status();
72 
77  void setDebug(DebugPrintCharDelegate reqDelegate);
78 
83  void setDebug(Stream &reqStream);
84 
85 private:
86  bool started = false;
87  bool useDebugPrefix = true;
88  bool newDebugLine = true;
89  DebugOuputOptions debugOut;
90  void printPrefix();
91  void processDebugCommands(String commandLine, CommandOutput* commandOutput);
92 
93  size_t write(uint8_t); /* implementation of write for Print Class */
94 };
95 
104 extern DebugClass Debug;
105 
107 #endif /* SMINGCORE_DEBUG_H_ */
Delegate< void(char dbgChar)> DebugPrintCharDelegate
Delegate constructor usage: (&YourClass::method, this)
Definition: Debug.h:17
Provides debug output to stream (e.g. Serial) or delegate function handler.
Definition: Debug.h:47
void initCommand()
Enable control of debug output from CLI command handler output.
Definition: WString.h:42
Provides formatted output to stream.
Definition: Print.h:31
void setDebug(DebugPrintCharDelegate reqDelegate)
Configure debug to use delegate handler for its output.
Do not use debug prefix.
Definition: Debug.h:33
DebugClass Debug
Global instance of Debug object.
Definition: CommandOutput.h:17
eDBGPrefix
Debug prefix state.
Definition: Debug.h:31
Structure for debug options.
Definition: Debug.h:22
Use debug prefix.
Definition: Debug.h:34
bool status()
Get debug status.
void start()
Start debug output.
void stop()
Stop debug output.
DebugClass()
Instantiate a debug object.
Definition: Stream.h:30