callbacks...()
Thanks to izanette you can now configure callback functions that do something or give feedback to the user about the current state of the application. We have added a few of our own and hope you like it!
onFirstBoot( THandlerFunction )
Called on the first boot of this app. Will only run once. After serial or ota upload.
onModeButtonNoPress( THandlerFunction )
Called when state is changed to idle. (mode button is not pressed)
onModeButtonShortPress( THandlerFunction )
Called when state is changed to short press.
onModeButtonLongPress( THandlerFunction )
Called when state is changed to long press.
onModeButtonVeryLongPress( THandlerFunction )
Called when state is changed to very long press.
onFirmwareUpdateCheck( THandlerFunction )
Called when the app is about to check for firmware updates.
onFirmwareUpdateDownload( THandlerFunction )
Called when the app starts to download updates.
onFirmwareUpdateError( THandlerFunction )
Called when downloading firmware updates end in error.
onFirmwareUpdateSuccess( THandlerFunction ) *NEW (>=2.0.1)
Called when the downloaded firmware is successfully installed.
onConfigMode( THandlerFunction )
Called when the app enters configuration mode.
WiFi.onEvent( WiFiEvent )
This is not an IAS callback but worthwhile pointing out.
As our library does most of the Wifi connecting etc. you might forget that you can actually use all the underlying Wifi functions. There are multiple ways to register wifi events. For more info check the examples that come with your esp core: ESP8266 & ESP32
In this example we use serial print to demonstrate the call backs. But you could use leds etc:
...
setup () {
...
IAS.onModeButtonShortPress([]() {
Serial.println(F(" If mode button is released, I will enter in firmware update mode."));
Serial.println(F("*-------------------------------------------------------------------------*"));
});
IAS.onModeButtonLongPress([]() {
Serial.println(F(" If mode button is released, I will enter in configuration mode."));
Serial.println(F("*-------------------------------------------------------------------------*"));
});
IAS.begin();
}