Advertisement
rhessellund

ESP32 - EloquentSurveillance

Feb 3rd, 2023 (edited)
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.87 KB | None | 0 0
  1. #include <ArduinoOTA.h>
  2. #include "EloquentSurveillance.h"
  3. #define VERBOSE
  4. #define WIFI_SSID "home"
  5. #define WIFI_PASS "ITs@Secr3t"
  6.  
  7. EloquentSurveillance::StreamServer streamServer(80);
  8.  
  9. // ********************************************************************* SETUP
  10.  
  11. void setup() {
  12.     Serial.begin(115200);
  13.     delay(3000);
  14.  
  15.     /**
  16.      * See CameraCaptureExample for more details
  17.      */
  18.     camera.aithinker();
  19.     camera.highQuality();
  20.     camera.svga();
  21.  
  22.     while (!camera.begin())
  23.         debug("ERROR", camera.getErrorMessage());
  24.  
  25.     while (!wifi.connect(WIFI_SSID, WIFI_PASS))
  26.         debug("ERROR", wifi.getErrorMessage());
  27.  
  28.     ArduinoOTA.onStart([]()
  29.     {
  30.       String type;
  31.       if (ArduinoOTA.getCommand() == U_FLASH)
  32.         type = "sketch";
  33.       else // U_SPIFFS
  34.         type = "filesystem";
  35.       Serial.println("Start updating " + type);
  36.     })
  37.     .onEnd([]() {
  38.       Serial.println("\nEnd");
  39.     })
  40.     .onProgress([](unsigned int progress, unsigned int total) {
  41.       Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  42.     })
  43.     .onError([](ota_error_t error) {
  44.       Serial.printf("Error[%u]: ", error);
  45.       if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
  46.       else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
  47.       else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
  48.       else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
  49.       else if (error == OTA_END_ERROR) Serial.println("End Failed");
  50.     });
  51.     ArduinoOTA.setPassword(WIFI_PASS);
  52.     ArduinoOTA.begin();
  53.  
  54.     while (!streamServer.begin())
  55.         debug("ERROR", streamServer.getErrorMessage());
  56.  
  57.     debug("SUCCESS", streamServer.getWelcomeMessage());
  58.  
  59. }
  60.  
  61. // ********************************************************************* LOOP
  62.  
  63. void loop()
  64. {
  65.      ArduinoOTA.handle();
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement