Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ArduinoOTA.h>
- #include "EloquentSurveillance.h"
- #define VERBOSE
- #define WIFI_SSID "home"
- #define WIFI_PASS "ITs@Secr3t"
- EloquentSurveillance::StreamServer streamServer(80);
- // ********************************************************************* SETUP
- void setup() {
- Serial.begin(115200);
- delay(3000);
- /**
- * See CameraCaptureExample for more details
- */
- camera.aithinker();
- camera.highQuality();
- camera.svga();
- while (!camera.begin())
- debug("ERROR", camera.getErrorMessage());
- while (!wifi.connect(WIFI_SSID, WIFI_PASS))
- debug("ERROR", wifi.getErrorMessage());
- ArduinoOTA.onStart([]()
- {
- String type;
- if (ArduinoOTA.getCommand() == U_FLASH)
- type = "sketch";
- else // U_SPIFFS
- type = "filesystem";
- Serial.println("Start updating " + type);
- })
- .onEnd([]() {
- Serial.println("\nEnd");
- })
- .onProgress([](unsigned int progress, unsigned int total) {
- Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
- })
- .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.setPassword(WIFI_PASS);
- ArduinoOTA.begin();
- while (!streamServer.begin())
- debug("ERROR", streamServer.getErrorMessage());
- debug("SUCCESS", streamServer.getWelcomeMessage());
- }
- // ********************************************************************* LOOP
- void loop()
- {
- ArduinoOTA.handle();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement