/********* Pleasedontcode.com **********
Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- Terms and Conditions:
You have a non-exclusive, revocable, worldwide, royalty-free license
for personal and commercial use. Attribution is optional; modifications
are allowed, but you're responsible for code maintenance. We're not
liable for any loss or damage. For full terms,
please visit pleasedontcode.com/termsandconditions.
- Project: OTA Check
- Source Code NOT compiled for: Arduino Opta WiFi
- Source Code created on: 2025-10-05 11:46:50
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* Detect a debounced push-button event on A0 using */
/* EasyButton; the input uses INPUT_PULLUP, so a */
/* pressed state is LOW and should trigger the system */
/* logic. Integrate flash over the air. */
/****** END SYSTEM REQUIREMENTS *****/
/* START CODE */
/****** DEFINITION OF LIBRARIES *****/
#include
#include
#ifndef POTA_ENABLED
#define POTA_ENABLED 1
#endif
#if defined(POTA_ENABLED) && POTA_ENABLED
POTA ota;
#endif
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
void buttonPressed();
/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t button_PushButton_PIN_A0 = A0;
/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****
******/
EasyButton debouncedBtn(button_PushButton_PIN_A0);
void setup(void)
{
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println();
Serial.println("POTATest: Debounced button on A0 ready. Press to trigger OTA (if configured).");
pinMode(button_PushButton_PIN_A0, INPUT_PULLUP);
debouncedBtn.begin();
debouncedBtn.onPressed(buttonPressed);
}
void buttonPressed()
{
Serial.println("Debounced button pressed (LOW). Triggering OTA check if configured...");
#if defined(POTA_ENABLED) && POTA_ENABLED
POTAError err = ota.checkAndPerformOTA();
if (err == POTAError::NO_UPDATE_AVAILABLE) {
Serial.println("OTA: firmware already up to date");
} else if (err != POTAError::SUCCESS) {
Serial.print("OTA error: ");
Serial.println(ota.errorToString(err));
} else {
Serial.println("OTA check completed successfully");
}
#endif
}
void loop(void)
{
// put your main code here, to run repeatedly:
debouncedBtn.read();
}
/* END CODE */