Add basic OTA updates handling (#3)

This commit is contained in:
Zdzislaw Goik 2022-03-02 22:14:00 +01:00 committed by GitHub
parent c80b665077
commit a569ac21e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 8 deletions

View File

@ -2,5 +2,5 @@
#include "pinout.h" #include "pinout.h"
namespace WiFiHandler { namespace WiFiHandler {
void setupWifi(); void setupWifi(const char* ssid, const char* password);
} }

View File

@ -1,2 +1,5 @@
const char* ssid = ""; const char* ssid = "";
const char* password = ""; const char* password = "";
const char* OTAPassword = ""; // if empty, no password will be required
uint16_t OTAServerPort = 3232;

View File

@ -15,8 +15,15 @@ framework = arduino
monitor_speed = 115200 monitor_speed = 115200
monitor_rts = 0 monitor_rts = 0
monitor_dtr = 0 monitor_dtr = 0
build_flags = -O2 build_flags =
-O2
build_unflags = -Os build_unflags = -Os
;upload_port = 192.168.1.43 ;replace this with your own ip
;upload_protocol = espota
upload_flags =
--auth=Password
board_build.partitions = min_spiffs.csv
lib_deps = lib_deps =
esp32-camera esp32-camera

View File

@ -1,9 +1,11 @@
#include <Arduino.h> #include <Arduino.h>
#include "pinout.h" #include "pinout.h"
#include "credentials.h"
#include "WifiHandler.h" #include "WifiHandler.h"
#include "cameraHandler.h" #include "cameraHandler.h"
#include "LEDManager.h" #include "LEDManager.h"
#include "httpdHandler.h" #include "httpdHandler.h"
#include "OTA.h"
void setup(){ void setup(){
Serial.begin(115200); Serial.begin(115200);
@ -14,12 +16,14 @@ void setup(){
LEDManager::setupLED(); LEDManager::setupLED();
// todo add blink handling // todo add blink handling
CameraHandler::setupCamera(); CameraHandler::setupCamera();
WiFiHandler::setupWifi(); WiFiHandler::setupWifi(ssid, password);
// todo add blink handling // todo add blink handling
HttpdHandler::startStreamServer(); HttpdHandler::startStreamServer();
LEDManager::on(); LEDManager::on();
OTA::SetupOTA(OTAPassword, OTAServerPort);
} }
void loop(){ void loop(){
delay(1); OTA::HandleOTAUpdate();
} }

View File

@ -1,9 +1,8 @@
#include "WifiHandler.h" #include "WifiHandler.h"
#include "credentials.h"
#include "LEDManager.h" #include "LEDManager.h"
namespace WiFiHandler { namespace WiFiHandler {
void setupWifi(){ void setupWifi(const char* ssid, const char* password){
Serial.println("Initializing connection to wifi"); Serial.println("Initializing connection to wifi");
WiFi.begin(ssid, password); WiFi.begin(ssid, password);