@@ -18,7 +18,12 @@ extern "C" {
18
18
#include " include/UdpContext.h"
19
19
#include < ESP8266mDNS.h>
20
20
21
- // #define OTA_DEBUG 1
21
+
22
+ #ifdef DEBUG_ESP_OTA
23
+ #ifdef DEBUG_ESP_PORT
24
+ #define OTA_DEBUG DEBUG_ESP_PORT
25
+ #endif
26
+ #endif
22
27
23
28
ArduinoOTAClass::ArduinoOTAClass ()
24
29
: _port(0 )
@@ -109,8 +114,8 @@ void ArduinoOTAClass::begin() {
109
114
}
110
115
_initialized = true ;
111
116
_state = OTA_IDLE;
112
- #if OTA_DEBUG
113
- Serial .printf (" OTA server at: %s.local:%u\n " , _hostname.c_str (), _port);
117
+ #ifdef OTA_DEBUG
118
+ OTA_DEBUG .printf (" OTA server at: %s.local:%u\n " , _hostname.c_str (), _port);
114
119
#endif
115
120
}
116
121
@@ -226,8 +231,8 @@ void ArduinoOTAClass::_onRx(){
226
231
227
232
void ArduinoOTAClass::_runUpdate () {
228
233
if (!Update.begin (_size, _cmd)) {
229
- #if OTA_DEBUG
230
- Serial .println (" Update Begin Error" );
234
+ #ifdef OTA_DEBUG
235
+ OTA_DEBUG .println (" Update Begin Error" );
231
236
#endif
232
237
if (_error_callback) {
233
238
_error_callback (OTA_BEGIN_ERROR);
@@ -249,8 +254,8 @@ void ArduinoOTAClass::_runUpdate() {
249
254
250
255
WiFiClient client;
251
256
if (!client.connect (_ota_ip, _ota_port)) {
252
- #if OTA_DEBUG
253
- Serial .printf (" Connect Failed\n " );
257
+ #ifdef OTA_DEBUG
258
+ OTA_DEBUG .printf (" Connect Failed\n " );
254
259
#endif
255
260
_udp_ota->listen (*IP_ADDR_ANY, _port);
256
261
if (_error_callback) {
@@ -265,8 +270,8 @@ void ArduinoOTAClass::_runUpdate() {
265
270
while (!client.available () && waited--)
266
271
delay (1 );
267
272
if (!waited){
268
- #if OTA_DEBUG
269
- Serial .printf (" Receive Failed\n " );
273
+ #ifdef OTA_DEBUG
274
+ OTA_DEBUG .printf (" Receive Failed\n " );
270
275
#endif
271
276
_udp_ota->listen (*IP_ADDR_ANY, _port);
272
277
if (_error_callback) {
@@ -288,8 +293,8 @@ void ArduinoOTAClass::_runUpdate() {
288
293
client.print (" OK" );
289
294
client.stop ();
290
295
delay (10 );
291
- #if OTA_DEBUG
292
- Serial .printf (" Update Success\n Rebooting...\n " );
296
+ #ifdef OTA_DEBUG
297
+ OTA_DEBUG .printf (" Update Success\n Rebooting...\n " );
293
298
#endif
294
299
if (_end_callback) {
295
300
_end_callback ();
@@ -301,8 +306,8 @@ void ArduinoOTAClass::_runUpdate() {
301
306
_error_callback (OTA_END_ERROR);
302
307
}
303
308
Update.printError (client);
304
- #if OTA_DEBUG
305
- Update.printError (Serial );
309
+ #ifdef OTA_DEBUG
310
+ Update.printError (OTA_DEBUG );
306
311
#endif
307
312
_state = OTA_IDLE;
308
313
}
0 commit comments