diff --git a/src/Arduino_ESP32_OTA.cpp b/src/Arduino_ESP32_OTA.cpp index 76c1d02..dbc0fae 100644 --- a/src/Arduino_ESP32_OTA.cpp +++ b/src/Arduino_ESP32_OTA.cpp @@ -91,7 +91,6 @@ void Arduino_ESP32_OTA::setMagic(uint32_t magic) void Arduino_ESP32_OTA::write_byte_to_flash(uint8_t data) { Update.write(&data, 1); - _context->writtenBytes++; } int Arduino_ESP32_OTA::startDownload(const char * ota_url) @@ -103,7 +102,10 @@ int Arduino_ESP32_OTA::startDownload(const char * ota_url) int statusCode; int res; - _context = new Context(ota_url, std::bind(&Arduino_ESP32_OTA::write_byte_to_flash, this, std::placeholders::_1)); + _context = new Context(ota_url, [this](uint8_t data){ + _context->writtenBytes++; + write_byte_to_flash(data); + }); if(strcmp(_context->parsed_url.schema(), "http") == 0) { _client = new WiFiClient();