added OTA
This commit is contained in:
@@ -18,3 +18,5 @@ lib_deps =
|
|||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
lib_ldf_mode = deep+
|
lib_ldf_mode = deep+
|
||||||
extra_scripts = ./littlefsbuilder.py
|
extra_scripts = ./littlefsbuilder.py
|
||||||
|
upload_protocol = espota
|
||||||
|
upload_port = 192.168.2.254
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ void handleGame(void)
|
|||||||
if (hall_idle_count > HALLIDLESAMPLES)
|
if (hall_idle_count > HALLIDLESAMPLES)
|
||||||
{
|
{
|
||||||
hall_is_Idle = false;
|
hall_is_Idle = false;
|
||||||
hall_idle_count = 8;
|
hall_idle_count = HALLPLAYSAMPLES;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -47,7 +47,7 @@ void handleGame(void)
|
|||||||
hall_idle_count--;
|
hall_idle_count--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debugD("HallSensor: val=%d, delta=%d, count=%d, idle=%s\n",
|
Serial.printf("HallSensor: val=%d, delta=%d, count=%d, idle=%s\n",
|
||||||
hall_sample,
|
hall_sample,
|
||||||
hall_delta,
|
hall_delta,
|
||||||
hall_idle_count,
|
hall_idle_count,
|
||||||
|
|||||||
@@ -5,8 +5,9 @@
|
|||||||
#include "SerialDebug.h"
|
#include "SerialDebug.h"
|
||||||
|
|
||||||
#define HALLINTERVAL 100
|
#define HALLINTERVAL 100
|
||||||
#define HALLIDLETHRESHOLD 3
|
#define HALLIDLETHRESHOLD 4
|
||||||
#define HALLIDLESAMPLES 3
|
#define HALLIDLESAMPLES 4
|
||||||
|
#define HALLPLAYSAMPLES 8
|
||||||
|
|
||||||
void initGame(void);
|
void initGame(void);
|
||||||
void handleGame(void);
|
void handleGame(void);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "rfid.h"
|
#include "rfid.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "ota.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -18,8 +19,9 @@ void setup()
|
|||||||
|
|
||||||
initStorage();
|
initStorage();
|
||||||
initConfig();
|
initConfig();
|
||||||
|
initOta();
|
||||||
initAudio();
|
initAudio();
|
||||||
//initRfid();
|
initRfid();
|
||||||
|
|
||||||
initGame();
|
initGame();
|
||||||
|
|
||||||
@@ -30,7 +32,8 @@ void loop()
|
|||||||
debugHandle();
|
debugHandle();
|
||||||
|
|
||||||
handleAudio();
|
handleAudio();
|
||||||
//handleRfid();
|
handleRfid();
|
||||||
handleGame();
|
//handleGame();
|
||||||
handlePower();
|
handlePower();
|
||||||
|
handleOta();
|
||||||
}
|
}
|
||||||
|
|||||||
11
FW/leo_muziekdoos_esp32/src/network.cpp
Normal file
11
FW/leo_muziekdoos_esp32/src/network.cpp
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#include "network.h"
|
||||||
|
|
||||||
|
void initNetwork(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleNetwork(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
4
FW/leo_muziekdoos_esp32/src/network.h
Normal file
4
FW/leo_muziekdoos_esp32/src/network.h
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
void initNetwork(void);
|
||||||
|
void handleNetwork(void);
|
||||||
60
FW/leo_muziekdoos_esp32/src/ota.cpp
Normal file
60
FW/leo_muziekdoos_esp32/src/ota.cpp
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
#include "ota.h"
|
||||||
|
|
||||||
|
const char *ssid = SECRET_SSID;
|
||||||
|
const char *password = SECRET_PASS;
|
||||||
|
|
||||||
|
void initOta(void)
|
||||||
|
{
|
||||||
|
// pinMode(led, OUTPUT);
|
||||||
|
// Serial.begin(115200);
|
||||||
|
// Serial.println("Booting");
|
||||||
|
WiFi.mode(WIFI_STA);
|
||||||
|
WiFi.begin(SECRET_SSID, SECRET_PASS);
|
||||||
|
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
|
||||||
|
Serial.println("Connection Failed! Retry...");
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
// Port defaults to 3232
|
||||||
|
// ArduinoOTA.setPort(3232);
|
||||||
|
// Hostname defaults to esp3232-[MAC]
|
||||||
|
ArduinoOTA.setHostname("muziekdoos");
|
||||||
|
// No authentication by default
|
||||||
|
// ArduinoOTA.setPassword("admin");
|
||||||
|
// Password can be set with it's md5 value as well
|
||||||
|
// MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
|
||||||
|
// ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");
|
||||||
|
ArduinoOTA
|
||||||
|
.onStart([]() {
|
||||||
|
String type;
|
||||||
|
if (ArduinoOTA.getCommand() == U_FLASH)
|
||||||
|
type = "sketch";
|
||||||
|
else // U_SPIFFS
|
||||||
|
type = "filesystem";
|
||||||
|
// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
|
||||||
|
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.begin();
|
||||||
|
Serial.println("Ready");
|
||||||
|
Serial.print("IP address: ");
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleOta(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
ArduinoOTA.handle();
|
||||||
|
}
|
||||||
10
FW/leo_muziekdoos_esp32/src/ota.h
Normal file
10
FW/leo_muziekdoos_esp32/src/ota.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "ArduinoOTA.h"
|
||||||
|
#include "secrets.h"
|
||||||
|
// #include <WiFi.h>
|
||||||
|
// #include <AsyncTCP.h>
|
||||||
|
// #include <ESPAsyncWebServer.h>
|
||||||
|
// #include <AsyncElegantOTA.h>
|
||||||
|
|
||||||
|
void initOta(void);
|
||||||
|
void handleOta(void);
|
||||||
@@ -12,18 +12,27 @@ void initPowerOn(void)
|
|||||||
{
|
{
|
||||||
//disable brownout
|
//disable brownout
|
||||||
//WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
|
//WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
|
||||||
|
if(digitalRead(PWR_BTN))
|
||||||
|
{
|
||||||
|
//enable LDO
|
||||||
|
pinMode(PWR_HOLD, OUTPUT);
|
||||||
|
pinMode(PWR_BTN, INPUT);
|
||||||
|
digitalWrite(PWR_HOLD, HIGH);
|
||||||
|
powerbutton_released = false;
|
||||||
|
|
||||||
|
//dac_sdMode
|
||||||
|
pinMode(DAC_SDMODE, OUTPUT);
|
||||||
|
digitalWrite(DAC_SDMODE, HIGH);
|
||||||
|
//powerstate = poweringOn;
|
||||||
|
//buttonPower.begin();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ESP.deepSleep(10000);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//enable LDO
|
|
||||||
pinMode(PWR_HOLD, OUTPUT);
|
|
||||||
pinMode(PWR_BTN, INPUT);
|
|
||||||
digitalWrite(PWR_HOLD, HIGH);
|
|
||||||
powerbutton_released = false;
|
|
||||||
|
|
||||||
//dac_sdMode
|
|
||||||
pinMode(DAC_SDMODE, OUTPUT);
|
|
||||||
digitalWrite(DAC_SDMODE, HIGH);
|
|
||||||
//powerstate = poweringOn;
|
|
||||||
//buttonPower.begin();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,6 +52,8 @@ void handlePower(void)
|
|||||||
debugHandle();
|
debugHandle();
|
||||||
while(digitalRead(PWR_BTN)) {}
|
while(digitalRead(PWR_BTN)) {}
|
||||||
digitalWrite(PWR_HOLD, LOW);
|
digitalWrite(PWR_HOLD, LOW);
|
||||||
|
delay(1000);
|
||||||
|
ESP.restart();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
powerbutton_released = true;
|
powerbutton_released = true;
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ void initRfid()
|
|||||||
void handleRfid()
|
void handleRfid()
|
||||||
{
|
{
|
||||||
uint32_t timeNow = millis();
|
uint32_t timeNow = millis();
|
||||||
//int8_t TagType = TRACK_NOTHING;
|
|
||||||
|
|
||||||
if (timeNow - last_rfid_update > RFIDINTERVAL)
|
if (timeNow - last_rfid_update > RFIDINTERVAL)
|
||||||
{
|
{
|
||||||
|
|||||||
4
FW/leo_muziekdoos_esp32/src/secrets.h
Normal file
4
FW/leo_muziekdoos_esp32/src/secrets.h
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define SECRET_SSID "poes"
|
||||||
|
#define SECRET_PASS "Rijnstraat214"
|
||||||
Reference in New Issue
Block a user