Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
Debug.h
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/anakod/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  * Debug.h
8  *
9  ****/
10 
11 #ifndef _SMING_CORE_DEBUG_H_
12 #define _SMING_CORE_DEBUG_H_
13 
14 #include "HardwareSerial.h"
15 #include "Clock.h"
16 #include "WString.h"
17 #include "../Services/CommandProcessing/CommandProcessingIncludes.h"
18 
23 
27 typedef struct {
28  DebugPrintCharDelegate debugDelegate = nullptr;
29  Stream* debugStream = nullptr;
31 
35 typedef enum {
38 } eDBGPrefix;
39 
50 class DebugClass : public Print
51 {
52 public:
56  DebugClass();
57 
60  void initCommand();
61 
64  void start();
65 
68  void stop();
69 
73  bool status()
74  {
75  return started;
76  }
77 
82  void setDebug(DebugPrintCharDelegate reqDelegate);
83 
88  void setDebug(Stream& reqStream);
89 
90  /* implementation of write for Print Class */
91  size_t write(uint8_t) override;
92 
93 private:
94  bool started = false;
95  bool useDebugPrefix = true;
96  bool newDebugLine = true;
97  DebugOuputOptions debugOut;
98  void printPrefix();
99  void processDebugCommands(String commandLine, CommandOutput* commandOutput);
100 };
101 
110 extern DebugClass Debug;
111 
113 #endif /* _SMING_CORE_DEBUG_H_ */
Delegate< void(char dbgChar)> DebugPrintCharDelegate
Delegate constructor usage: (&YourClass::method, this)
Definition: Debug.h:22
Provides debug output to stream (e.g. Serial) or delegate function handler.
Definition: Debug.h:50
void initCommand()
Enable control of debug output from CLI command handler output.
The string class.
Definition: WString.h:104
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:36
DebugClass Debug
Global instance of Debug object.
Definition: CommandOutput.h:17
size_t write(uint8_t) override
Writes a single character to output stream.
eDBGPrefix
Debug prefix state.
Definition: Debug.h:35
Structure for debug options.
Definition: Debug.h:27
Use debug prefix.
Definition: Debug.h:37
bool status()
Get debug status.
Definition: Debug.h:73
void start()
Start debug output.
void stop()
Stop debug output.
DebugClass()
Instantiate a debug object.
Definition: Stream.h:30