arduino/src/main.cpp
void ota()
{
    bHandlingOTA = true;
    timerWrite(timer, 0); //reset timer (feed watchdog)
     //Initialise OTA in case there is a software upgrade
    ArduinoOTA.setHostname("Container");
    ArduinoOTA.onStart([]() {
      Serial.println("Start");
    });
    ArduinoOTA.onEnd([]() {
      Serial.println("\nEnd");
    });
    ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
      Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
      timerWrite(timer, 0); //reset timer (feed watchdog)
    });
    ArduinoOTA.onError([](ota_error_t error) {
      Serial.printf("Error[%u]: ", error);
      if (error == OTA_AUTH_ERROR) {Serial.println("Auth Failed");}
      else if (error == OTA_BEGIN_ERROR) {Serial.println("Begin Failed");}
      else if (error == OTA_CONNECT_ERROR) {Serial.println("Connect Failed");}
      else if (error == OTA_RECEIVE_ERROR) {Serial.println("Receive Failed");}
      else if (error == OTA_END_ERROR) {Serial.println("End Failed");}
    });
      
    ArduinoOTA.begin();

    Serial.println("Waiting for any OTA updates");

    while (1) {
      Serial.print (".");
      timerWrite(timer, 0); //reset timer (feed watchdog)
      ArduinoOTA.handle();
        delay(500);
      }
}
// NOTE : To go into OTA you must sent a command over mqtt cmnd/scale {"ota":1 }
// But the scale must also connect to wifi - if you use it to send a reading,
// it will connect to wifi and proceed with OTA mode.
NOTE : To go into OTA you must sent a command over mqtt cmnd/scale {"ota":1 }
But the scale must also connect to wifi - if you use it to send a reading,
it will connect to wifi and proceed with OTA mode.
NOTE : To go into OTA you must sent a command over mqtt cmnd / scale { " ota " : 1 } But the scale must also connect to wifi - if you use it to send a reading it will connect to wifi and proceed with OTA mode .
void ota()
{
    bHandlingOTA = true;
    timerWrite(timer, 0); 
    ArduinoOTA.setHostname("Container");
    ArduinoOTA.onStart([]() {
      Serial.println("Start");
    });
    ArduinoOTA.onEnd([]() {
      Serial.println("\nEnd");
    });
    ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
      Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
      timerWrite(timer, 0); 
    });
    ArduinoOTA.onError([](ota_error_t error) {
      Serial.printf("Error[%u]: ", error);
      if (error == OTA_AUTH_ERROR) {Serial.println("Auth Failed");}
      else if (error == OTA_BEGIN_ERROR) {Serial.println("Begin Failed");}
      else if (error == OTA_CONNECT_ERROR) {Serial.println("Connect Failed");}
      else if (error == OTA_RECEIVE_ERROR) {Serial.println("Receive Failed");}
      else if (error == OTA_END_ERROR) {Serial.println("End Failed");}
    });
    ArduinoOTA.begin();
    Serial.println("Waiting for any OTA updates");
    while (1) {
      Serial.print (".");
      timerWrite(timer, 0); 
      ArduinoOTA.handle();
        delay(500);
      }
}
void ota ( ) { bHandlingOTA = true ; timerWrite ( timer , 0 ) ; ArduinoOTA . setHostname ( " " ) ; ArduinoOTA . onStart ( [ ] ( ) { Serial . println ( " " ) ; } ) ; ArduinoOTA . onEnd ( [ ] ( ) { Serial . println ( " \n " ) ; } ) ; ArduinoOTA . onProgress ( [ ] ( unsigned int progress , unsigned int total ) { Serial . printf ( " \r " , ( progress / ( total / 100 ) ) ) ; timerWrite ( timer , 0 ) ; } ) ; ArduinoOTA . onError ( [ ] ( ota_error_t error ) { Serial . printf ( " " , error ) ; if ( error == OTA_AUTH_ERROR ) { Serial . println ( " " ) ; } else if ( error == OTA_BEGIN_ERROR ) { Serial . println ( " " ) ; } else if ( error == OTA_CONNECT_ERROR ) { Serial . println ( " " ) ; } else if ( error == OTA_RECEIVE_ERROR ) { Serial . println ( " " ) ; } else if ( error == OTA_END_ERROR ) { Serial . println ( " " ) ; } } ) ; ArduinoOTA . begin ( ) ; Serial . println ( " " ) ; while ( 1 ) { Serial . print ( " " ) ; timerWrite ( timer , 0 ) ; ArduinoOTA . handle ( ) ; delay ( 500 ) ; } }
NOTE : To go into OTA you must sent a command over mqtt cmnd/scale {"ota":1 }
But the scale must also connect to wifi - if you use it to send a reading,
it will connect to wifi and proceed with OTA mode.
NOTE : To go into OTA you must sent a command over mqtt cmnd / scale { " ota " : 1 } But the scale must also connect to wifi - if you use it to send a reading it will connect to wifi and proceed with OTA mode .
//reset timer (feed watchdog) //Initialise OTA in case there is a software upgrade //reset timer (feed watchdog) //reset timer (feed watchdog)