Skip to content

Commit 7150f48

Browse files
authored
Update to espressif32 5.1 // esp-idf 4.4.1 // Arduino 2.0.4 (#312)
* refresh use some new or before not known api
1 parent 80f4a13 commit 7150f48

6 files changed

Lines changed: 22 additions & 55 deletions

File tree

platformio.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ src_dir = src
3838
extra_configs = custom_config.ini
3939

4040
[env:esp32dev]
41-
platform = espressif32 @ ^3
41+
platform = espressif32 @ ^5.1
4242
board = esp32dev
4343
framework = arduino
4444
monitor_speed = 115200
@@ -47,7 +47,7 @@ monitor_speed = 115200
4747
upload_speed = 921600
4848
board_build.partitions = src/sd-partition-table.csv
4949
lib_deps =
50-
adafruit/Adafruit BusIO @ ^1.12.0
50+
adafruit/Adafruit BusIO @ ^1.13.1
5151
; https://arduinojson.org/v6/api/
5252
bblanchon/ArduinoJson @ ^6.19.4
5353
rlogiacco/CircularBuffer @ ^1.3.3

src/Firmware.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ bool Firmware::downloadToFlash(String url,
7272
size_t size = http.getSize();
7373
log_i("http size: %d. ", size);
7474
log_i("Will access Stream:, free heap %dkb", ESP.getFreeHeap() / 1024);
75-
if (status == 200) {
75+
if (status == HTTP_CODE_OK) {
7676
Update.begin();
7777
Update.onProgress([progress, size](size_t pos, size_t all) {
7878
progress(pos, size);
@@ -87,6 +87,10 @@ bool Firmware::downloadToFlash(String url,
8787
written += read;
8888
}
8989
log_i("Got %d bytes", written);
90+
} else {
91+
log_e("Got http status: %d", status);
92+
http.end();
93+
return false;
9094
}
9195
}
9296
http.end();

src/OpenBikeSensorFirmware.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include <utils/obsutils.h>
2525
#include <utils/button.h>
26+
#include <utils/timeutils.h>
2627
#include "OpenBikeSensorFirmware.h"
2728

2829
#include "SPIFFS.h"

src/configServer.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -913,9 +913,7 @@ static void handleAbout(HTTPRequest *req, HTTPResponse * res) {
913913
res->print(page);
914914
page.clear();
915915

916-
esp_chip_info_t ci;
917-
esp_chip_info(&ci);
918-
page += keyValue("Cores", String(ci.cores));
916+
page += keyValue("Cores", ESP.getChipCores());
919917
page += keyValue("CPU frequency", ESP.getCpuFreqMHz(), "MHz");
920918

921919
page += keyValue("SPIFFS size", ObsUtils::toScaledByteString(SPIFFS.totalBytes()));
@@ -1601,7 +1599,7 @@ static void handleFlashFileUpdateAction(HTTPRequest *req, HTTPResponse *res) {
16011599
static void handleDeleteFiles(HTTPRequest *req, HTTPResponse * res) {
16021600
const auto params = extractParameters(req);
16031601
String path = getParameter(params, "path");
1604-
if (path != "trash") {
1602+
if (path != "/trash") {
16051603
SD.mkdir("/trash");
16061604
}
16071605
bool moveToRoot = !getParameter(params, "move").isEmpty();
@@ -1617,7 +1615,7 @@ static void handleDeleteFiles(HTTPRequest *req, HTTPResponse * res) {
16171615
if (param.first == "delete") {
16181616
String file = param.second;
16191617

1620-
String fullName = path + (path.length() > 1 ? "/" : "") + file;
1618+
String fullName = path + (path.endsWith("/") ? "" : "/") + file;
16211619

16221620
html += ObsUtils::encodeForXmlText(file) + " &#10140; ";
16231621
if (moveToRoot) {
@@ -1679,6 +1677,10 @@ static void handleSd(HTTPRequest *req, HTTPResponse *res) {
16791677
displayTest->showTextOnGrid(0, 3, "Path:");
16801678
displayTest->showTextOnGrid(1, 3, path);
16811679

1680+
if (!path.endsWith("/")) {
1681+
path += "/";
1682+
}
1683+
16821684
// Iterate over directories
16831685
File child = file.openNextFile();
16841686
uint16_t counter = 0;
@@ -1690,7 +1692,6 @@ static void handleSd(HTTPRequest *req, HTTPResponse *res) {
16901692
TimeUtils::dateTimeToString(child.getLastWrite())
16911693
+ " - " + ObsUtils::toScaledByteString(child.size()));
16921694

1693-
fileName = fileName.substring(int(fileName.lastIndexOf("/") + 1));
16941695
fileName = ObsUtils::encodeForXmlAttribute(fileName);
16951696
bool isDirectory = child.isDirectory();
16961697
html +=
@@ -1700,7 +1701,7 @@ static void handleSd(HTTPRequest *req, HTTPResponse *res) {
17001701
+ "<input class='small' type='checkbox' value='" + fileName + "' name='delete'"
17011702
+ String(isDirectory ? "disabled" : "")
17021703
+ "><a href=\"/sd?path="
1703-
+ String(child.name())
1704+
+ path + String(child.name())
17041705
+ "\">"
17051706
+ String(isDirectory ? "&#x1F4C1;" : "&#x1F4C4;")
17061707
+ fileName
@@ -1726,7 +1727,8 @@ static void handleSd(HTTPRequest *req, HTTPResponse *res) {
17261727
html += "</ul>";
17271728

17281729
if (path != "/") {
1729-
String back = path.substring(0, path.lastIndexOf('/'));
1730+
String back = path.substring(
1731+
0, path.lastIndexOf('/', path.length() - 2));
17301732
if (back.isEmpty()) {
17311733
back = "/";
17321734
}
@@ -1738,12 +1740,12 @@ static void handleSd(HTTPRequest *req, HTTPResponse *res) {
17381740
}
17391741

17401742
if (counter > 0) {
1741-
if (path == "/uploaded") {
1743+
if (path == "/uploaded/") {
17421744
html += "<hr /><p>Move for new upload will move selected files to the root directory, where "
17431745
"they will be considered as new tracks and uploaded to the portal with the next "
17441746
"Track upload.</p><input type='submit' class='btn' name='move' value='Move for new upload' />";
17451747
}
1746-
if (path == "/trash") {
1748+
if (path == "/trash/") {
17471749
html += "<hr /><input type='submit' class='btn' value='Delete Selected' />";
17481750
} else {
17491751
html += "<hr /><input type='submit' class='btn' value='Move to Trash' />";

src/utils/median.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#ifndef OPENBIKESENSORFIRMWARE_MEDIAN_H
2525
#define OPENBIKESENSORFIRMWARE_MEDIAN_H
2626

27+
#include <algorithm>
28+
2729
template<typename T> class Median {
2830

2931
public:

test/native/median.cpp

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)