@@ -146,7 +146,6 @@ class Commander{
146
146
// / be visible.
147
147
void execute ( const char *cmd );
148
148
149
-
150
149
#ifdef COMMANDER_USE_SERIAL_RESPONSE
151
150
// / Execution function for Serial response.
152
151
// /
@@ -165,6 +164,13 @@ class Commander{
165
164
// / will be passed to the selected Serial
166
165
// / object.
167
166
void execute ( const char *cmd, Serial *resp );
167
+
168
+ // / Debug channel for Serial.
169
+ // /
170
+ // / This function attaches a Serial channel
171
+ // / for debug messages. It also enables
172
+ // / the debug functionality.
173
+ void attachDebugChannel ( Serial *resp );
168
174
#endif
169
175
170
176
#ifdef COMMANDER_USE_ARDUINO_SERIAL_RESPONSE
@@ -185,6 +191,13 @@ class Commander{
185
191
// / will be passed to the selected Serial
186
192
// / object.
187
193
void execute ( const char *cmd, HardwareSerial *resp );
194
+
195
+ // / Debug channel for Arduino Serial.
196
+ // /
197
+ // / This function attaches a HardwareSerial channel
198
+ // / for debug messages. It also enables
199
+ // / the debug functionality.
200
+ void attachDebugChannel ( HardwareSerial *resp );
188
201
#endif
189
202
190
203
#ifdef COMMANDER_USE_WIFI_CLIENT_RESPONSE
@@ -195,6 +208,7 @@ class Commander{
195
208
// / the messages from the command handler
196
209
// / will be passed to the selected Serial
197
210
// / object.
211
+
198
212
void execute ( char *cmd, WiFiClient *resp );
199
213
// / Execution function for WiFi Client response.
200
214
// /
@@ -204,8 +218,21 @@ class Commander{
204
218
// / will be passed to the selected Serial
205
219
// / object.
206
220
void execute ( const char *cmd, WiFiClient *resp );
221
+
222
+ // / Debug channel for WiFiClient.
223
+ // /
224
+ // / This function attaches a WiFiClient channel
225
+ // / for debug messages. It also enables
226
+ // / the debug functionality.
227
+ void attachDebugChannel ( WiFiClient *resp );
207
228
#endif
208
229
230
+ // / Enables debug messages.
231
+ void enableDebug ();
232
+
233
+ // / Disables debug messages.
234
+ void disableDebug ();
235
+
209
236
private:
210
237
211
238
// / Starting address of the API-tree.
@@ -245,6 +272,31 @@ class Commander{
245
272
// / points to the default response handler.
246
273
commandResponse *response = &defaultResponse;
247
274
275
+ // / Flag to enable or disable debug messages.
276
+ bool debugEnabled = false ;
277
+
278
+ // / Default response handler for debug messages.
279
+ commandResponse defaultDebugResponse;
280
+
281
+ #ifdef COMMANDER_USE_SERIAL_RESPONSE
282
+ // / Serial response handler class.
283
+ commandResponseSerial serialDebugResponse;
284
+ #endif
285
+
286
+ #ifdef COMMANDER_USE_ARDUINO_SERIAL_RESPONSE
287
+ // / Serial response handler class.
288
+ commandResponseArduinoSerial arduinoSerialDebugResponse;
289
+ #endif
290
+
291
+ #ifdef COMMANDER_USE_WIFI_CLIENT_RESPONSE
292
+ // / WiFi Client response handler class.
293
+ commandResponseWiFiClient WiFiClientDebugResponse;
294
+ #endif
295
+
296
+ // / Pointer to response class. By default it
297
+ // / points to the default debug response handler.
298
+ commandResponse *dbgResponse = &defaultDebugResponse;
299
+
248
300
// / Find an API element in the tree by alphabetical place.
249
301
uint16_t find_api_index_by_place ( uint16_t place );
250
302
0 commit comments