Fix Arduino OTA
This commit is contained in:
parent
626877d4ee
commit
d46b07399f
4 changed files with 71 additions and 46 deletions
6
.github/workflows/tagging.yml
vendored
6
.github/workflows/tagging.yml
vendored
|
@ -23,7 +23,7 @@ jobs:
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
name: build-outputs
|
name: prepared-outputs
|
||||||
path: .pio/**/*.bin
|
path: .pio/**/*.bin
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
@ -44,7 +44,7 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: build-outputs
|
name: prepared-outputs
|
||||||
path: .pio
|
path: .pio
|
||||||
- name: Install esptools.py
|
- name: Install esptools.py
|
||||||
run: pip install --upgrade esptool
|
run: pip install --upgrade esptool
|
||||||
|
@ -85,7 +85,7 @@ jobs:
|
||||||
- name: Create release
|
- name: Create release
|
||||||
uses: ncipollo/release-action@v1
|
uses: ncipollo/release-action@v1
|
||||||
with:
|
with:
|
||||||
artifacts: "*/*.bin,*/*.sha256"
|
artifacts: "**/*.bin,**/*.sha256"
|
||||||
allowUpdates: true
|
allowUpdates: true
|
||||||
removeArtifacts: true
|
removeArtifacts: true
|
||||||
makeLatest: true
|
makeLatest: true
|
|
@ -5,6 +5,7 @@ Preferences preferences;
|
||||||
const char *ntpServer = "pool.ntp.org";
|
const char *ntpServer = "pool.ntp.org";
|
||||||
const long gmtOffset_sec = 0;
|
const long gmtOffset_sec = 0;
|
||||||
const int daylightOffset_sec = 3600;
|
const int daylightOffset_sec = 3600;
|
||||||
|
TaskHandle_t OTAHandle = NULL;
|
||||||
|
|
||||||
#define STA_SSID ""
|
#define STA_SSID ""
|
||||||
#define STA_PASS ""
|
#define STA_PASS ""
|
||||||
|
@ -201,4 +202,22 @@ void setupOTA()
|
||||||
else if (error == OTA_END_ERROR) Serial.println("End Failed"); });
|
else if (error == OTA_END_ERROR) Serial.println("End Failed"); });
|
||||||
|
|
||||||
ArduinoOTA.begin();
|
ArduinoOTA.begin();
|
||||||
}
|
|
||||||
|
xTaskCreatePinnedToCore(
|
||||||
|
OTAUpdateTask, // Task function
|
||||||
|
"OTAUpdateTask", // Task name
|
||||||
|
4096, // Stack size
|
||||||
|
NULL, // Task parameters
|
||||||
|
1, // Priority (higher value means higher priority)
|
||||||
|
&OTAHandle, // Task handle
|
||||||
|
0 // Core to run the task (0 or 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void OTAUpdateTask(void *pvParameters) {
|
||||||
|
for (;;) {
|
||||||
|
ArduinoOTA.handle(); // Handle OTA updates
|
||||||
|
vTaskDelay(1000 / portTICK_PERIOD_MS); // Delay to avoid high CPU usage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -15,6 +15,8 @@ void setupTime();
|
||||||
void setupPreferences();
|
void setupPreferences();
|
||||||
void setupWifi();
|
void setupWifi();
|
||||||
void setupOTA();
|
void setupOTA();
|
||||||
|
void OTAUpdateTask(void *pvParameters);
|
||||||
|
|
||||||
void wakeModemSleep();
|
void wakeModemSleep();
|
||||||
void setModemSleep();
|
void setModemSleep();
|
||||||
|
|
||||||
|
|
88
src/main.cpp
88
src/main.cpp
|
@ -23,7 +23,7 @@ GxEPD2_BW<EPD_CLASS, EPD_CLASS::HEIGHT> display = EPD_CLASS(5, 3, 2, 1);
|
||||||
|
|
||||||
typedef void (*MethodPtr)(String);
|
typedef void (*MethodPtr)(String);
|
||||||
|
|
||||||
MethodPtr methods[] = { nullptr, updateRow1, updateRow2, updateRow3 };
|
MethodPtr methods[] = {nullptr, updateRow1, updateRow2, updateRow3};
|
||||||
|
|
||||||
WiFiClientSecure client;
|
WiFiClientSecure client;
|
||||||
uint currentPrice = 0;
|
uint currentPrice = 0;
|
||||||
|
@ -45,7 +45,7 @@ void setup()
|
||||||
setupWifi();
|
setupWifi();
|
||||||
setupTime();
|
setupTime();
|
||||||
|
|
||||||
if (!inPowerSaveMode())
|
if (!inPowerSaveMode())
|
||||||
{
|
{
|
||||||
setupWebserver();
|
setupWebserver();
|
||||||
setupOTA();
|
setupOTA();
|
||||||
|
@ -57,8 +57,8 @@ void setup()
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
ArduinoOTA.handle();
|
if (isUpdating)
|
||||||
if (isUpdating) {
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,47 +93,48 @@ void loop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (uint i = 1; i <= 3; i++)
|
||||||
|
{
|
||||||
for (uint i = 1; i <= 3; i++) {
|
|
||||||
String rowContent = "";
|
String rowContent = "";
|
||||||
char keyName[5];
|
char keyName[5];
|
||||||
snprintf(keyName, sizeof(keyName), "row%d", i);
|
snprintf(keyName, sizeof(keyName), "row%d", i);
|
||||||
Serial.print(keyName);
|
Serial.print(keyName);
|
||||||
Serial.print(" ");
|
Serial.print(" ");
|
||||||
Serial.println(preferences.getUInt(keyName));
|
Serial.println(preferences.getUInt(keyName));
|
||||||
switch (preferences.getUInt(keyName)) {
|
switch (preferences.getUInt(keyName))
|
||||||
case LINE_BLOCKHEIGHT:
|
{
|
||||||
rowContent = getBlock();
|
case LINE_BLOCKHEIGHT:
|
||||||
break;
|
rowContent = getBlock();
|
||||||
case LINE_MEMPOOL_FEES:
|
break;
|
||||||
rowContent = getMempoolFees();
|
case LINE_MEMPOOL_FEES:
|
||||||
break;
|
rowContent = getMempoolFees();
|
||||||
case LINE_MEMPOOL_FEES_MEDIAN:
|
break;
|
||||||
rowContent = "NOT IMPL";
|
case LINE_MEMPOOL_FEES_MEDIAN:
|
||||||
break;
|
rowContent = "NOT IMPL";
|
||||||
case LINE_HALVING_COUNTDOWN:
|
break;
|
||||||
rowContent = "NOT IMPL";
|
case LINE_HALVING_COUNTDOWN:
|
||||||
break;
|
rowContent = "NOT IMPL";
|
||||||
case LINE_SATSPERUNIT: {
|
break;
|
||||||
uint satsPerDollar = int(round(1 / float(getPrice()) * 10e7));
|
case LINE_SATSPERUNIT:
|
||||||
rowContent = satsPerDollar;
|
{
|
||||||
break;
|
uint satsPerDollar = int(round(1 / float(getPrice()) * 10e7));
|
||||||
}
|
rowContent = satsPerDollar;
|
||||||
case LINE_FIATPRICE:
|
break;
|
||||||
rowContent = getPrice();
|
}
|
||||||
break;
|
case LINE_FIATPRICE:
|
||||||
case LINE_MARKETCAP:
|
rowContent = getPrice();
|
||||||
rowContent = "NOT IMPL";
|
break;
|
||||||
break;
|
case LINE_MARKETCAP:
|
||||||
case LINE_TIME:
|
rowContent = "NOT IMPL";
|
||||||
rowContent = "NOT IMPL";
|
break;
|
||||||
break;
|
case LINE_TIME:
|
||||||
case LINE_DATE:
|
rowContent = "NOT IMPL";
|
||||||
rowContent = "NOT IMPL";
|
break;
|
||||||
break;
|
case LINE_DATE:
|
||||||
default:
|
rowContent = "NOT IMPL";
|
||||||
rowContent = "DEFAULT";
|
break;
|
||||||
|
default:
|
||||||
|
rowContent = "DEFAULT";
|
||||||
}
|
}
|
||||||
|
|
||||||
methods[i](rowContent);
|
methods[i](rowContent);
|
||||||
|
@ -231,17 +232,20 @@ void loop()
|
||||||
|
|
||||||
delay(2 * 1000);
|
delay(2 * 1000);
|
||||||
|
|
||||||
if (inPowerSaveMode()) {
|
if (inPowerSaveMode())
|
||||||
|
{
|
||||||
display.hibernate();
|
display.hibernate();
|
||||||
setModemSleep();
|
setModemSleep();
|
||||||
esp_sleep_enable_timer_wakeup(50 * 1000000);
|
esp_sleep_enable_timer_wakeup(50 * 1000000);
|
||||||
esp_light_sleep_start();
|
esp_light_sleep_start();
|
||||||
display.init(0, false);
|
display.init(0, false);
|
||||||
wakeModemSleep();
|
wakeModemSleep();
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Serial.println(F("Sleeping"));
|
Serial.println(F("Sleeping"));
|
||||||
sleep(50);
|
sleep(50);
|
||||||
// delay(50 * 1000);
|
// delay(50 * 1000);
|
||||||
Serial.println(F("Waking up"));
|
Serial.println(F("Waking up"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue