File tree Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change 9
9
#include " Update.h"
10
10
11
11
12
- // #define OTA_DEBUG Serial
12
+ // #define OTA_DEBUG Serial
13
13
14
14
ArduinoOTAClass::ArduinoOTAClass ()
15
15
: _port(0 )
@@ -20,6 +20,7 @@ ArduinoOTAClass::ArduinoOTAClass()
20
20
, _size(0 )
21
21
, _cmd(0 )
22
22
, _ota_port(0 )
23
+ , _ota_timeout(1000 )
23
24
, _start_callback(NULL )
24
25
, _end_callback(NULL )
25
26
, _error_callback(NULL )
@@ -260,8 +261,9 @@ void ArduinoOTAClass::_runUpdate() {
260
261
}
261
262
262
263
uint32_t written = 0 , total = 0 , tried = 0 ;
264
+
263
265
while (!Update.isFinished () && client.connected ()) {
264
- size_t waited = OTA_TIMEOUT_DURATION_MS ;
266
+ size_t waited = _ota_timeout ;
265
267
size_t available = client.available ();
266
268
while (!available && waited){
267
269
delay (1 );
@@ -387,6 +389,10 @@ int ArduinoOTAClass::getCommand() {
387
389
return _cmd;
388
390
}
389
391
392
+ void ArduinoOTAClass::setTimeout (int timeoutInMillis) {
393
+ _ota_timeout = timeoutInMillis;
394
+ }
395
+
390
396
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_ARDUINOOTA)
391
397
ArduinoOTAClass ArduinoOTA;
392
- #endif
398
+ #endif
Original file line number Diff line number Diff line change 7
7
8
8
#define INT_BUFFER_SIZE 16
9
9
10
- #ifndef OTA_TIMEOUT_DURATION_MS
11
- #define OTA_TIMEOUT_DURATION_MS 1000
12
- #endif
13
-
14
10
typedef enum {
15
11
OTA_IDLE,
16
12
OTA_WAITAUTH,
@@ -28,9 +24,9 @@ typedef enum {
28
24
class ArduinoOTAClass
29
25
{
30
26
public:
31
- typedef std::function<void (void )> THandlerFunction;
32
- typedef std::function<void (ota_error_t )> THandlerFunction_Error;
33
- typedef std::function<void (unsigned int , unsigned int )> THandlerFunction_Progress;
27
+ typedef std::function<void (void )> THandlerFunction;
28
+ typedef std::function<void (ota_error_t )> THandlerFunction_Error;
29
+ typedef std::function<void (unsigned int , unsigned int )> THandlerFunction_Progress;
34
30
35
31
ArduinoOTAClass ();
36
32
~ArduinoOTAClass ();
@@ -78,6 +74,8 @@ class ArduinoOTAClass
78
74
// Gets update command type after OTA has started. Either U_FLASH or U_SPIFFS
79
75
int getCommand ();
80
76
77
+ void setTimeout (int timeoutInMillis);
78
+
81
79
private:
82
80
int _port;
83
81
String _password;
@@ -91,6 +89,7 @@ class ArduinoOTAClass
91
89
int _size;
92
90
int _cmd;
93
91
int _ota_port;
92
+ int _ota_timeout;
94
93
IPAddress _ota_ip;
95
94
String _md5;
96
95
@@ -109,4 +108,4 @@ class ArduinoOTAClass
109
108
extern ArduinoOTAClass ArduinoOTA;
110
109
#endif
111
110
112
- #endif /* __ARDUINO_OTA_H */
111
+ #endif /* __ARDUINO_OTA_H */
You can’t perform that action at this time.
0 commit comments