mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-28 18:47:40 +00:00
Merge branch 'meshtastic:master' into master
This commit is contained in:
commit
53e8a40ffa
11
.github/workflows/main_matrix.yml
vendored
11
.github/workflows/main_matrix.yml
vendored
@ -22,7 +22,6 @@ jobs:
|
|||||||
check:
|
check:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
max-parallel: 2
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- board: rak11200
|
- board: rak11200
|
||||||
@ -271,6 +270,16 @@ jobs:
|
|||||||
release/device-*.bat
|
release/device-*.bat
|
||||||
retention-days: 90
|
retention-days: 90
|
||||||
|
|
||||||
|
after-checks:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [check]
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: ${{github.event.pull_request.head.ref}}
|
||||||
|
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||||
|
|
||||||
gather-artifacts:
|
gather-artifacts:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build-esp32, build-nrf52, build-native]
|
needs: [build-esp32, build-nrf52, build-native]
|
||||||
|
@ -10,7 +10,7 @@ RUN cd Meshtastic-device; git submodule update --init --recursive
|
|||||||
# only build the simulator
|
# only build the simulator
|
||||||
RUN sed -i 's/^BOARDS_ESP32.*/BOARDS_ESP32=""/' Meshtastic-device/bin/build-all.sh
|
RUN sed -i 's/^BOARDS_ESP32.*/BOARDS_ESP32=""/' Meshtastic-device/bin/build-all.sh
|
||||||
RUN sed -i 's/^BOARDS_NRF52.*/BOARDS_NRF52=""/' Meshtastic-device/bin/build-all.sh
|
RUN sed -i 's/^BOARDS_NRF52.*/BOARDS_NRF52=""/' Meshtastic-device/bin/build-all.sh
|
||||||
RUN sed -i 's/echo "Building SPIFFS.*/exit/' Meshtastic-device/bin/build-all.sh
|
RUN sed -i 's/echo "Building Filesystem.*/exit/' Meshtastic-device/bin/build-all.sh
|
||||||
RUN . ~/.platformio/penv/bin/activate; cd Meshtastic-device; ./bin/build-all.sh
|
RUN . ~/.platformio/penv/bin/activate; cd Meshtastic-device; ./bin/build-all.sh
|
||||||
|
|
||||||
CMD ["/Meshtastic-device/release/latest/bins/universal/meshtasticd_linux_amd64"]
|
CMD ["/Meshtastic-device/release/latest/bins/universal/meshtasticd_linux_amd64"]
|
||||||
|
@ -76,12 +76,12 @@ do_boards "$BOARDS_NRF52" "true"
|
|||||||
pio run --environment native
|
pio run --environment native
|
||||||
cp .pio/build/native/program $OUTDIR/bins/universal/meshtasticd_linux_amd64
|
cp .pio/build/native/program $OUTDIR/bins/universal/meshtasticd_linux_amd64
|
||||||
|
|
||||||
echo "Building SPIFFS for ESP32 targets"
|
echo "Building Filesystem for ESP32 targets"
|
||||||
pio run --environment tbeam -t buildfs
|
pio run --environment tbeam -t buildfs
|
||||||
cp .pio/build/tbeam/spiffs.bin $OUTDIR/bins/universal/spiffs-$VERSION.bin
|
cp .pio/build/tbeam/spiffs.bin $OUTDIR/bins/universal/littlefs-$VERSION.bin
|
||||||
|
|
||||||
# keep the bins in archive also
|
# keep the bins in archive also
|
||||||
cp $OUTDIR/bins/universal/spiffs* $OUTDIR/bins/universal/firmware* $OUTDIR/elfs/universal/firmware* $ARCHIVEDIR
|
cp $OUTDIR/bins/universal/littlefs* $OUTDIR/bins/universal/firmware* $OUTDIR/elfs/universal/firmware* $ARCHIVEDIR
|
||||||
|
|
||||||
echo Updating android bins $OUTDIR/forandroid
|
echo Updating android bins $OUTDIR/forandroid
|
||||||
rm -rf $OUTDIR/forandroid
|
rm -rf $OUTDIR/forandroid
|
||||||
@ -103,7 +103,7 @@ XML
|
|||||||
|
|
||||||
echo Generating $ARCHIVEDIR/firmware-$VERSION.zip
|
echo Generating $ARCHIVEDIR/firmware-$VERSION.zip
|
||||||
rm -f $ARCHIVEDIR/firmware-$VERSION.zip
|
rm -f $ARCHIVEDIR/firmware-$VERSION.zip
|
||||||
zip --junk-paths $ARCHIVEDIR/firmware-$VERSION.zip $ARCHIVEDIR/spiffs-$VERSION.bin $OUTDIR/bins/universal/firmware-*-$VERSION.* $OUTDIR/bins/universal/meshtasticd* images/system-info.bin bin/device-install.* bin/device-update.*
|
zip --junk-paths $ARCHIVEDIR/firmware-$VERSION.zip $ARCHIVEDIR/littlefs-$VERSION.bin $OUTDIR/bins/universal/firmware-*-$VERSION.* $OUTDIR/bins/universal/meshtasticd* images/system-info.bin bin/device-install.* bin/device-update.*
|
||||||
echo Generating $ARCHIVEDIR/elfs-$VERSION.zip
|
echo Generating $ARCHIVEDIR/elfs-$VERSION.zip
|
||||||
rm -f $ARCHIVEDIR/elfs-$VERSION.zip
|
rm -f $ARCHIVEDIR/elfs-$VERSION.zip
|
||||||
zip --junk-paths $ARCHIVEDIR/elfs-$VERSION.zip $OUTDIR/elfs/universal/firmware-*-$VERSION.*
|
zip --junk-paths $ARCHIVEDIR/elfs-$VERSION.zip $OUTDIR/elfs/universal/firmware-*-$VERSION.*
|
||||||
|
@ -34,9 +34,9 @@ echo "Copying ESP32 bin file"
|
|||||||
SRCBIN=.pio/build/$1/firmware.bin
|
SRCBIN=.pio/build/$1/firmware.bin
|
||||||
cp $SRCBIN $OUTDIR/$basename.bin
|
cp $SRCBIN $OUTDIR/$basename.bin
|
||||||
|
|
||||||
echo "Building SPIFFS for ESP32 targets"
|
echo "Building Filesystem for ESP32 targets"
|
||||||
pio run --environment tbeam -t buildfs
|
pio run --environment tbeam -t buildfs
|
||||||
cp .pio/build/tbeam/spiffs.bin $OUTDIR/spiffs-$VERSION.bin
|
cp .pio/build/tbeam/spiffs.bin $OUTDIR/littlefs-$VERSION.bin
|
||||||
cp images/system-info.bin $OUTDIR/system-info.bin
|
cp images/system-info.bin $OUTDIR/system-info.bin
|
||||||
|
|
||||||
cp bin/device-install.* $OUTDIR
|
cp bin/device-install.* $OUTDIR
|
||||||
|
@ -30,7 +30,7 @@ IF EXIST %FILENAME% (
|
|||||||
echo Trying to flash update %FILENAME%, but first erasing and writing system information"
|
echo Trying to flash update %FILENAME%, but first erasing and writing system information"
|
||||||
%PYTHON% -m esptool --baud 921600 erase_flash
|
%PYTHON% -m esptool --baud 921600 erase_flash
|
||||||
%PYTHON% -m esptool --baud 921600 write_flash 0x1000 system-info.bin
|
%PYTHON% -m esptool --baud 921600 write_flash 0x1000 system-info.bin
|
||||||
for %%f in (spiffs-*.bin) do (
|
for %%f in (littlefs-*.bin) do (
|
||||||
%PYTHON% -m esptool --baud 921600 write_flash 0x00390000 %%f
|
%PYTHON% -m esptool --baud 921600 write_flash 0x00390000 %%f
|
||||||
)
|
)
|
||||||
%PYTHON% -m esptool --baud 921600 write_flash 0x10000 %FILENAME%
|
%PYTHON% -m esptool --baud 921600 write_flash 0x10000 %FILENAME%
|
||||||
|
@ -48,7 +48,7 @@ if [ -f "${FILENAME}" ]; then
|
|||||||
echo "Trying to flash ${FILENAME}, but first erasing and writing system information"
|
echo "Trying to flash ${FILENAME}, but first erasing and writing system information"
|
||||||
"$PYTHON" -m esptool erase_flash
|
"$PYTHON" -m esptool erase_flash
|
||||||
"$PYTHON" -m esptool write_flash 0x1000 system-info.bin
|
"$PYTHON" -m esptool write_flash 0x1000 system-info.bin
|
||||||
"$PYTHON" -m esptool write_flash 0x00390000 spiffs-*.bin
|
"$PYTHON" -m esptool write_flash 0x00390000 littlefs-*.bin
|
||||||
"$PYTHON" -m esptool write_flash 0x10000 ${FILENAME}
|
"$PYTHON" -m esptool write_flash 0x10000 ${FILENAME}
|
||||||
else
|
else
|
||||||
echo "Invalid file: ${FILENAME}"
|
echo "Invalid file: ${FILENAME}"
|
||||||
|
51
bin/mklittlefs.py
Executable file
51
bin/mklittlefs.py
Executable file
@ -0,0 +1,51 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import getopt
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
from littlefs import LittleFS
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
print( "Building LittleFS image..." )
|
||||||
|
|
||||||
|
argList = sys.argv[1:]
|
||||||
|
arxx = { argList[i]: argList[i+1] for i in range(0, len(argList)-1, 2) }
|
||||||
|
|
||||||
|
dataPath = arxx["-c"]
|
||||||
|
blockSize = int(arxx["-b"])
|
||||||
|
blockCount = int(arxx["-s"]) / blockSize
|
||||||
|
|
||||||
|
cwd = os.getcwd()
|
||||||
|
|
||||||
|
os.chdir(dataPath)
|
||||||
|
|
||||||
|
fileList = []
|
||||||
|
dirList = []
|
||||||
|
|
||||||
|
for (dirpath, dirnames, filenames) in os.walk('.'):
|
||||||
|
for f in filenames:
|
||||||
|
if (f[:1] != '.'):
|
||||||
|
fileList.append( os.path.join(dirpath, f) )
|
||||||
|
for d in dirnames:
|
||||||
|
if (d[:1] != '.'):
|
||||||
|
dirList.append( os.path.join(dirpath, d) )
|
||||||
|
|
||||||
|
fs = LittleFS(block_size=blockSize, block_count=blockCount) # create a 448kB partition
|
||||||
|
|
||||||
|
for curDir in dirList:
|
||||||
|
print( "Creating dir " + curDir )
|
||||||
|
fs.mkdir( curDir )
|
||||||
|
|
||||||
|
for curFile in fileList:
|
||||||
|
print( "Adding file " + curFile )
|
||||||
|
with open( curFile, 'rb' ) as f:
|
||||||
|
data = f.read()
|
||||||
|
|
||||||
|
with fs.open( curFile, 'wb') as fh:
|
||||||
|
fh.write( data )
|
||||||
|
|
||||||
|
outName = argList[-1]
|
||||||
|
|
||||||
|
os.chdir(cwd)
|
||||||
|
|
||||||
|
with open(outName, 'wb') as fh:
|
||||||
|
fh.write(fs.context.buffer)
|
@ -6,6 +6,9 @@ import traceback
|
|||||||
import sys
|
import sys
|
||||||
from readprops import readProps
|
from readprops import readProps
|
||||||
|
|
||||||
|
Import("env")
|
||||||
|
env.Replace( MKSPIFFSTOOL=env.get("PROJECT_DIR") + '/bin/mklittlefs.py' )
|
||||||
|
|
||||||
Import("projenv")
|
Import("projenv")
|
||||||
|
|
||||||
prefsLoc = projenv["PROJECT_DIR"] + "/version.properties"
|
prefsLoc = projenv["PROJECT_DIR"] + "/version.properties"
|
||||||
|
@ -141,6 +141,7 @@ lib_deps =
|
|||||||
h2zero/NimBLE-Arduino@1.3.6
|
h2zero/NimBLE-Arduino@1.3.6
|
||||||
tobozo/ESP32-targz@^1.1.4
|
tobozo/ESP32-targz@^1.1.4
|
||||||
arduino-libraries/NTPClient#531eff39d9fbc831f3d03f706a161739203fbe2a
|
arduino-libraries/NTPClient#531eff39d9fbc831f3d03f706a161739203fbe2a
|
||||||
|
lorol/LittleFS_esp32@^1.0.6
|
||||||
|
|
||||||
# Hmm - this doesn't work yet
|
# Hmm - this doesn't work yet
|
||||||
# board_build.ldscript = linker/esp32.extram.bss.ld
|
# board_build.ldscript = linker/esp32.extram.bss.ld
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
void fsInit()
|
void fsInit()
|
||||||
{
|
{
|
||||||
#ifdef FS
|
#ifdef FSCom
|
||||||
if (!FSBegin())
|
if (!FSBegin())
|
||||||
{
|
{
|
||||||
DEBUG_MSG("ERROR filesystem mount Failed\n");
|
DEBUG_MSG("ERROR filesystem mount Failed\n");
|
||||||
@ -11,7 +11,7 @@ void fsInit()
|
|||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_MSG("Filesystem files:\n");
|
DEBUG_MSG("Filesystem files:\n");
|
||||||
File dir = FS.open("/");
|
File dir = FSCom.open("/");
|
||||||
File f = dir.openNextFile();
|
File f = dir.openNextFile();
|
||||||
while (f) {
|
while (f) {
|
||||||
DEBUG_MSG(" %s\n", f.name());
|
DEBUG_MSG(" %s\n", f.name());
|
||||||
|
@ -7,22 +7,22 @@
|
|||||||
#ifdef PORTDUINO
|
#ifdef PORTDUINO
|
||||||
// Portduino version
|
// Portduino version
|
||||||
#include "PortduinoFS.h"
|
#include "PortduinoFS.h"
|
||||||
#define FS PortduinoFS
|
#define FSCom PortduinoFS
|
||||||
#define FSBegin() true
|
#define FSBegin() true
|
||||||
#define FILE_O_WRITE "w"
|
#define FILE_O_WRITE "w"
|
||||||
#define FILE_O_READ "r"
|
#define FILE_O_READ "r"
|
||||||
#elif !defined(NO_ESP32)
|
#elif !defined(NO_ESP32)
|
||||||
// ESP32 version
|
// ESP32 version
|
||||||
#include "SPIFFS.h"
|
#include "LITTLEFS.h"
|
||||||
#define FS SPIFFS
|
#define FSCom LITTLEFS
|
||||||
#define FSBegin() FS.begin(true)
|
#define FSBegin() FSCom.begin(true)
|
||||||
#define FILE_O_WRITE "w"
|
#define FILE_O_WRITE "w"
|
||||||
#define FILE_O_READ "r"
|
#define FILE_O_READ "r"
|
||||||
#else
|
#else
|
||||||
// NRF52 version
|
// NRF52 version
|
||||||
#include "InternalFileSystem.h"
|
#include "InternalFileSystem.h"
|
||||||
#define FS InternalFS
|
#define FSCom InternalFS
|
||||||
#define FSBegin() FS.begin()
|
#define FSBegin() FSCom.begin()
|
||||||
using namespace Adafruit_LittleFS_Namespace;
|
using namespace Adafruit_LittleFS_Namespace;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -106,8 +106,8 @@ int update_crc32_callback(uint16_t conn_handle, uint16_t attr_handle, struct ble
|
|||||||
} else {
|
} else {
|
||||||
if (Update.end()) {
|
if (Update.end()) {
|
||||||
if (update_region == U_SPIFFS) {
|
if (update_region == U_SPIFFS) {
|
||||||
DEBUG_MSG("SPIFFS updated!\n");
|
DEBUG_MSG("Filesystem updated!\n");
|
||||||
nodeDB.saveToDisk(); // Since we just wiped spiffs, we need to save our current state
|
nodeDB.saveToDisk(); // Since we just wiped the filesystem, we need to save our current state
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Appload updated, rebooting in 5 seconds!\n");
|
DEBUG_MSG("Appload updated, rebooting in 5 seconds!\n");
|
||||||
rebootAtMsec = millis() + 5000;
|
rebootAtMsec = millis() + 5000;
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "FS.h"
|
|
||||||
|
|
||||||
#include "Channels.h"
|
#include "Channels.h"
|
||||||
#include "CryptoEngine.h"
|
#include "CryptoEngine.h"
|
||||||
#include "FSCommon.h"
|
#include "FSCommon.h"
|
||||||
@ -312,16 +310,16 @@ static const char *channelfile = "/prefs/channels.proto";
|
|||||||
/** Load a protobuf from a file, return true for success */
|
/** Load a protobuf from a file, return true for success */
|
||||||
bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct)
|
bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct)
|
||||||
{
|
{
|
||||||
#ifdef FS
|
#ifdef FSCom
|
||||||
// static DeviceState scratch; We no longer read into a tempbuf because this structure is 15KB of valuable RAM
|
// static DeviceState scratch; We no longer read into a tempbuf because this structure is 15KB of valuable RAM
|
||||||
|
|
||||||
auto f = FS.open(filename);
|
auto f = FSCom.open(filename);
|
||||||
|
|
||||||
// FIXME, temporary hack until every node in the universe is 1.2 or later - look for prefs in the old location (so we can
|
// FIXME, temporary hack until every node in the universe is 1.2 or later - look for prefs in the old location (so we can
|
||||||
// preserve region)
|
// preserve region)
|
||||||
if (!f && filename == preffile) {
|
if (!f && filename == preffile) {
|
||||||
filename = preffileOld;
|
filename = preffileOld;
|
||||||
f = FS.open(filename);
|
f = FSCom.open(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool okay = false;
|
bool okay = false;
|
||||||
@ -374,11 +372,11 @@ void NodeDB::loadFromDisk()
|
|||||||
/** Save a protobuf from a file, return true for success */
|
/** Save a protobuf from a file, return true for success */
|
||||||
bool saveProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, const void *dest_struct)
|
bool saveProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, const void *dest_struct)
|
||||||
{
|
{
|
||||||
#ifdef FS
|
#ifdef FSCom
|
||||||
// static DeviceState scratch; We no longer read into a tempbuf because this structure is 15KB of valuable RAM
|
// static DeviceState scratch; We no longer read into a tempbuf because this structure is 15KB of valuable RAM
|
||||||
String filenameTmp = filename;
|
String filenameTmp = filename;
|
||||||
filenameTmp += ".tmp";
|
filenameTmp += ".tmp";
|
||||||
auto f = FS.open(filenameTmp.c_str(), FILE_O_WRITE);
|
auto f = FSCom.open(filenameTmp.c_str(), FILE_O_WRITE);
|
||||||
bool okay = false;
|
bool okay = false;
|
||||||
if (f) {
|
if (f) {
|
||||||
DEBUG_MSG("Saving %s\n", filename);
|
DEBUG_MSG("Saving %s\n", filename);
|
||||||
@ -393,9 +391,9 @@ bool saveProto(const char *filename, size_t protoSize, size_t objSize, const pb_
|
|||||||
f.close();
|
f.close();
|
||||||
|
|
||||||
// brief window of risk here ;-)
|
// brief window of risk here ;-)
|
||||||
if (!FS.remove(filename))
|
if (!FSCom.remove(filename))
|
||||||
DEBUG_MSG("Warning: Can't remove old pref file\n");
|
DEBUG_MSG("Warning: Can't remove old pref file\n");
|
||||||
if (!FS.rename(filenameTmp.c_str(), filename))
|
if (!FSCom.rename(filenameTmp.c_str(), filename))
|
||||||
DEBUG_MSG("Error: can't rename new pref file\n");
|
DEBUG_MSG("Error: can't rename new pref file\n");
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Can't write prefs\n");
|
DEBUG_MSG("Can't write prefs\n");
|
||||||
@ -409,8 +407,8 @@ bool saveProto(const char *filename, size_t protoSize, size_t objSize, const pb_
|
|||||||
void NodeDB::saveChannelsToDisk()
|
void NodeDB::saveChannelsToDisk()
|
||||||
{
|
{
|
||||||
if (!devicestate.no_save) {
|
if (!devicestate.no_save) {
|
||||||
#ifdef FS
|
#ifdef FSCom
|
||||||
FS.mkdir("/prefs");
|
FSCom.mkdir("/prefs");
|
||||||
#endif
|
#endif
|
||||||
saveProto(channelfile, ChannelFile_size, sizeof(ChannelFile), ChannelFile_fields, &channelFile);
|
saveProto(channelfile, ChannelFile_size, sizeof(ChannelFile), ChannelFile_fields, &channelFile);
|
||||||
}
|
}
|
||||||
@ -419,15 +417,15 @@ void NodeDB::saveChannelsToDisk()
|
|||||||
void NodeDB::saveToDisk()
|
void NodeDB::saveToDisk()
|
||||||
{
|
{
|
||||||
if (!devicestate.no_save) {
|
if (!devicestate.no_save) {
|
||||||
#ifdef FS
|
#ifdef FSCom
|
||||||
FS.mkdir("/prefs");
|
FSCom.mkdir("/prefs");
|
||||||
#endif
|
#endif
|
||||||
saveProto(preffile, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate);
|
saveProto(preffile, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate);
|
||||||
saveProto(radiofile, RadioConfig_size, sizeof(RadioConfig), RadioConfig_fields, &radioConfig);
|
saveProto(radiofile, RadioConfig_size, sizeof(RadioConfig), RadioConfig_fields, &radioConfig);
|
||||||
saveChannelsToDisk();
|
saveChannelsToDisk();
|
||||||
|
|
||||||
// remove any pre 1.2 pref files, turn on after 1.2 is in beta
|
// remove any pre 1.2 pref files, turn on after 1.2 is in beta
|
||||||
// if(okay) FS.remove(preffileOld);
|
// if(okay) FSCom.remove(preffileOld);
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("***** DEVELOPMENT MODE - DO NOT RELEASE - not saving to flash *****\n");
|
DEBUG_MSG("***** DEVELOPMENT MODE - DO NOT RELEASE - not saving to flash *****\n");
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <HTTPBodyParser.hpp>
|
#include <HTTPBodyParser.hpp>
|
||||||
#include <HTTPMultipartBodyParser.hpp>
|
#include <HTTPMultipartBodyParser.hpp>
|
||||||
#include <HTTPURLEncodedBodyParser.hpp>
|
#include <HTTPURLEncodedBodyParser.hpp>
|
||||||
#include <SPIFFS.h>
|
#include <FSCommon.h>
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifndef NO_ESP32
|
||||||
#include "esp_task_wdt.h"
|
#include "esp_task_wdt.h"
|
||||||
@ -46,7 +46,10 @@ using namespace httpsserver;
|
|||||||
#include <WiFiClientSecure.h>
|
#include <WiFiClientSecure.h>
|
||||||
HTTPClient httpClient;
|
HTTPClient httpClient;
|
||||||
|
|
||||||
#define DEST_FS_USES_SPIFFS
|
// needed for ESP32-targz
|
||||||
|
#define DEST_FS_USES_LITTLEFS
|
||||||
|
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) ((major << 16) | (minor << 8) | (patch))
|
||||||
|
#define ESP_ARDUINO_VERSION ESP_ARDUINO_VERSION_VAL(1, 0, 4)
|
||||||
#include <ESP32-targz.h>
|
#include <ESP32-targz.h>
|
||||||
|
|
||||||
// We need to specify some content-type mapping, so the resources get delivered with the
|
// We need to specify some content-type mapping, so the resources get delivered with the
|
||||||
@ -127,9 +130,9 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer)
|
|||||||
ResourceNode *nodeAdmin = new ResourceNode("/admin", "GET", &handleAdmin);
|
ResourceNode *nodeAdmin = new ResourceNode("/admin", "GET", &handleAdmin);
|
||||||
ResourceNode *nodeAdminSettings = new ResourceNode("/admin/settings", "GET", &handleAdminSettings);
|
ResourceNode *nodeAdminSettings = new ResourceNode("/admin/settings", "GET", &handleAdminSettings);
|
||||||
ResourceNode *nodeAdminSettingsApply = new ResourceNode("/admin/settings/apply", "POST", &handleAdminSettingsApply);
|
ResourceNode *nodeAdminSettingsApply = new ResourceNode("/admin/settings/apply", "POST", &handleAdminSettingsApply);
|
||||||
ResourceNode *nodeAdminSPIFFS = new ResourceNode("/admin/spiffs", "GET", &handleSPIFFS);
|
ResourceNode *nodeAdminFs = new ResourceNode("/admin/fs", "GET", &handleFs);
|
||||||
ResourceNode *nodeUpdateSPIFFS = new ResourceNode("/admin/spiffs/update", "POST", &handleUpdateSPIFFS);
|
ResourceNode *nodeUpdateFs = new ResourceNode("/admin/fs/update", "POST", &handleUpdateFs);
|
||||||
ResourceNode *nodeDeleteSPIFFS = new ResourceNode("/admin/spiffs/delete", "GET", &handleDeleteSPIFFSContent);
|
ResourceNode *nodeDeleteFs = new ResourceNode("/admin/fs/delete", "GET", &handleDeleteFsContent);
|
||||||
|
|
||||||
ResourceNode *nodeRestart = new ResourceNode("/restart", "POST", &handleRestart);
|
ResourceNode *nodeRestart = new ResourceNode("/restart", "POST", &handleRestart);
|
||||||
ResourceNode *nodeFormUpload = new ResourceNode("/upload", "POST", &handleFormUpload);
|
ResourceNode *nodeFormUpload = new ResourceNode("/upload", "POST", &handleFormUpload);
|
||||||
@ -137,8 +140,8 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer)
|
|||||||
ResourceNode *nodeJsonScanNetworks = new ResourceNode("/json/scanNetworks", "GET", &handleScanNetworks);
|
ResourceNode *nodeJsonScanNetworks = new ResourceNode("/json/scanNetworks", "GET", &handleScanNetworks);
|
||||||
ResourceNode *nodeJsonBlinkLED = new ResourceNode("/json/blink", "POST", &handleBlinkLED);
|
ResourceNode *nodeJsonBlinkLED = new ResourceNode("/json/blink", "POST", &handleBlinkLED);
|
||||||
ResourceNode *nodeJsonReport = new ResourceNode("/json/report", "GET", &handleReport);
|
ResourceNode *nodeJsonReport = new ResourceNode("/json/report", "GET", &handleReport);
|
||||||
ResourceNode *nodeJsonSpiffsBrowseStatic = new ResourceNode("/json/spiffs/browse/static", "GET", &handleSpiffsBrowseStatic);
|
ResourceNode *nodeJsonFsBrowseStatic = new ResourceNode("/json/fs/browse/static", "GET", &handleFsBrowseStatic);
|
||||||
ResourceNode *nodeJsonDelete = new ResourceNode("/json/spiffs/delete/static", "DELETE", &handleSpiffsDeleteStatic);
|
ResourceNode *nodeJsonDelete = new ResourceNode("/json/fs/delete/static", "DELETE", &handleFsDeleteStatic);
|
||||||
|
|
||||||
|
|
||||||
ResourceNode *nodeRoot = new ResourceNode("/*", "GET", &handleStatic);
|
ResourceNode *nodeRoot = new ResourceNode("/*", "GET", &handleStatic);
|
||||||
@ -153,13 +156,13 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer)
|
|||||||
secureServer->registerNode(nodeFormUpload);
|
secureServer->registerNode(nodeFormUpload);
|
||||||
secureServer->registerNode(nodeJsonScanNetworks);
|
secureServer->registerNode(nodeJsonScanNetworks);
|
||||||
secureServer->registerNode(nodeJsonBlinkLED);
|
secureServer->registerNode(nodeJsonBlinkLED);
|
||||||
secureServer->registerNode(nodeJsonSpiffsBrowseStatic);
|
secureServer->registerNode(nodeJsonFsBrowseStatic);
|
||||||
secureServer->registerNode(nodeJsonDelete);
|
secureServer->registerNode(nodeJsonDelete);
|
||||||
secureServer->registerNode(nodeJsonReport);
|
secureServer->registerNode(nodeJsonReport);
|
||||||
secureServer->registerNode(nodeUpdateSPIFFS);
|
secureServer->registerNode(nodeUpdateFs);
|
||||||
secureServer->registerNode(nodeDeleteSPIFFS);
|
secureServer->registerNode(nodeDeleteFs);
|
||||||
secureServer->registerNode(nodeAdmin);
|
secureServer->registerNode(nodeAdmin);
|
||||||
secureServer->registerNode(nodeAdminSPIFFS);
|
secureServer->registerNode(nodeAdminFs);
|
||||||
secureServer->registerNode(nodeAdminSettings);
|
secureServer->registerNode(nodeAdminSettings);
|
||||||
secureServer->registerNode(nodeAdminSettingsApply);
|
secureServer->registerNode(nodeAdminSettingsApply);
|
||||||
secureServer->registerNode(nodeRoot); // This has to be last
|
secureServer->registerNode(nodeRoot); // This has to be last
|
||||||
@ -174,13 +177,13 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer)
|
|||||||
insecureServer->registerNode(nodeFormUpload);
|
insecureServer->registerNode(nodeFormUpload);
|
||||||
insecureServer->registerNode(nodeJsonScanNetworks);
|
insecureServer->registerNode(nodeJsonScanNetworks);
|
||||||
insecureServer->registerNode(nodeJsonBlinkLED);
|
insecureServer->registerNode(nodeJsonBlinkLED);
|
||||||
insecureServer->registerNode(nodeJsonSpiffsBrowseStatic);
|
insecureServer->registerNode(nodeJsonFsBrowseStatic);
|
||||||
insecureServer->registerNode(nodeJsonDelete);
|
insecureServer->registerNode(nodeJsonDelete);
|
||||||
insecureServer->registerNode(nodeJsonReport);
|
insecureServer->registerNode(nodeJsonReport);
|
||||||
insecureServer->registerNode(nodeUpdateSPIFFS);
|
insecureServer->registerNode(nodeUpdateFs);
|
||||||
insecureServer->registerNode(nodeDeleteSPIFFS);
|
insecureServer->registerNode(nodeDeleteFs);
|
||||||
insecureServer->registerNode(nodeAdmin);
|
insecureServer->registerNode(nodeAdmin);
|
||||||
insecureServer->registerNode(nodeAdminSPIFFS);
|
insecureServer->registerNode(nodeAdminFs);
|
||||||
insecureServer->registerNode(nodeAdminSettings);
|
insecureServer->registerNode(nodeAdminSettings);
|
||||||
insecureServer->registerNode(nodeAdminSettingsApply);
|
insecureServer->registerNode(nodeAdminSettingsApply);
|
||||||
insecureServer->registerNode(nodeRoot); // This has to be last
|
insecureServer->registerNode(nodeRoot); // This has to be last
|
||||||
@ -269,14 +272,14 @@ void handleAPIv1ToRadio(HTTPRequest *req, HTTPResponse *res)
|
|||||||
DEBUG_MSG("webAPI handleAPIv1ToRadio\n");
|
DEBUG_MSG("webAPI handleAPIv1ToRadio\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleSpiffsBrowseStatic(HTTPRequest *req, HTTPResponse *res)
|
void handleFsBrowseStatic(HTTPRequest *req, HTTPResponse *res)
|
||||||
{
|
{
|
||||||
|
|
||||||
res->setHeader("Content-Type", "application/json");
|
res->setHeader("Content-Type", "application/json");
|
||||||
res->setHeader("Access-Control-Allow-Origin", "*");
|
res->setHeader("Access-Control-Allow-Origin", "*");
|
||||||
res->setHeader("Access-Control-Allow-Methods", "GET");
|
res->setHeader("Access-Control-Allow-Methods", "GET");
|
||||||
|
|
||||||
File root = SPIFFS.open("/");
|
File root = FSCom.open("/");
|
||||||
|
|
||||||
if (root.isDirectory()) {
|
if (root.isDirectory()) {
|
||||||
res->println("{");
|
res->println("{");
|
||||||
@ -313,9 +316,9 @@ void handleSpiffsBrowseStatic(HTTPRequest *req, HTTPResponse *res)
|
|||||||
}
|
}
|
||||||
res->print("],");
|
res->print("],");
|
||||||
res->print("\"filesystem\" : {");
|
res->print("\"filesystem\" : {");
|
||||||
res->print("\"total\" : " + String(SPIFFS.totalBytes()) + ",");
|
res->print("\"total\" : " + String(FSCom.totalBytes()) + ",");
|
||||||
res->print("\"used\" : " + String(SPIFFS.usedBytes()) + ",");
|
res->print("\"used\" : " + String(FSCom.usedBytes()) + ",");
|
||||||
res->print("\"free\" : " + String(SPIFFS.totalBytes() - SPIFFS.usedBytes()));
|
res->print("\"free\" : " + String(FSCom.totalBytes() - FSCom.usedBytes()));
|
||||||
res->println("}");
|
res->println("}");
|
||||||
res->println("},");
|
res->println("},");
|
||||||
res->println("\"status\": \"ok\"");
|
res->println("\"status\": \"ok\"");
|
||||||
@ -323,7 +326,7 @@ void handleSpiffsBrowseStatic(HTTPRequest *req, HTTPResponse *res)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleSpiffsDeleteStatic(HTTPRequest *req, HTTPResponse *res)
|
void handleFsDeleteStatic(HTTPRequest *req, HTTPResponse *res)
|
||||||
{
|
{
|
||||||
ResourceParameters *params = req->getParams();
|
ResourceParameters *params = req->getParams();
|
||||||
std::string paramValDelete;
|
std::string paramValDelete;
|
||||||
@ -333,7 +336,7 @@ void handleSpiffsDeleteStatic(HTTPRequest *req, HTTPResponse *res)
|
|||||||
res->setHeader("Access-Control-Allow-Methods", "DELETE");
|
res->setHeader("Access-Control-Allow-Methods", "DELETE");
|
||||||
if (params->getQueryParameter("delete", paramValDelete)) {
|
if (params->getQueryParameter("delete", paramValDelete)) {
|
||||||
std::string pathDelete = "/" + paramValDelete;
|
std::string pathDelete = "/" + paramValDelete;
|
||||||
if (SPIFFS.remove(pathDelete.c_str())) {
|
if (FSCom.remove(pathDelete.c_str())) {
|
||||||
Serial.println(pathDelete.c_str());
|
Serial.println(pathDelete.c_str());
|
||||||
res->println("{");
|
res->println("{");
|
||||||
res->println("\"status\": \"ok\"");
|
res->println("\"status\": \"ok\"");
|
||||||
@ -361,18 +364,18 @@ void handleStatic(HTTPRequest *req, HTTPResponse *res)
|
|||||||
std::string filename = "/static/" + parameter1;
|
std::string filename = "/static/" + parameter1;
|
||||||
std::string filenameGzip = "/static/" + parameter1 + ".gz";
|
std::string filenameGzip = "/static/" + parameter1 + ".gz";
|
||||||
|
|
||||||
// Try to open the file from SPIFFS
|
// Try to open the file
|
||||||
File file;
|
File file;
|
||||||
|
|
||||||
bool has_set_content_type = false;
|
bool has_set_content_type = false;
|
||||||
|
|
||||||
if (SPIFFS.exists(filename.c_str())) {
|
if (FSCom.exists(filename.c_str())) {
|
||||||
file = SPIFFS.open(filename.c_str());
|
file = FSCom.open(filename.c_str());
|
||||||
if (!file.available()) {
|
if (!file.available()) {
|
||||||
DEBUG_MSG("File not available - %s\n", filename.c_str());
|
DEBUG_MSG("File not available - %s\n", filename.c_str());
|
||||||
}
|
}
|
||||||
} else if (SPIFFS.exists(filenameGzip.c_str())) {
|
} else if (FSCom.exists(filenameGzip.c_str())) {
|
||||||
file = SPIFFS.open(filenameGzip.c_str());
|
file = FSCom.open(filenameGzip.c_str());
|
||||||
res->setHeader("Content-Encoding", "gzip");
|
res->setHeader("Content-Encoding", "gzip");
|
||||||
if (!file.available()) {
|
if (!file.available()) {
|
||||||
DEBUG_MSG("File not available - %s\n", filenameGzip.c_str());
|
DEBUG_MSG("File not available - %s\n", filenameGzip.c_str());
|
||||||
@ -380,7 +383,7 @@ void handleStatic(HTTPRequest *req, HTTPResponse *res)
|
|||||||
} else {
|
} else {
|
||||||
has_set_content_type = true;
|
has_set_content_type = true;
|
||||||
filenameGzip = "/static/index.html.gz";
|
filenameGzip = "/static/index.html.gz";
|
||||||
file = SPIFFS.open(filenameGzip.c_str());
|
file = FSCom.open(filenameGzip.c_str());
|
||||||
res->setHeader("Content-Type", "text/html");
|
res->setHeader("Content-Type", "text/html");
|
||||||
if (!file.available()) {
|
if (!file.available()) {
|
||||||
DEBUG_MSG("File not available - %s\n", filenameGzip.c_str());
|
DEBUG_MSG("File not available - %s\n", filenameGzip.c_str());
|
||||||
@ -410,7 +413,7 @@ void handleStatic(HTTPRequest *req, HTTPResponse *res)
|
|||||||
res->setHeader("Content-Type", "application/octet-stream");
|
res->setHeader("Content-Type", "application/octet-stream");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the file from SPIFFS and write it to the HTTP response body
|
// Read the file and write it to the HTTP response body
|
||||||
size_t length = 0;
|
size_t length = 0;
|
||||||
do {
|
do {
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
@ -502,20 +505,12 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SPIFFS limits the total lenth of a path + file to 31 characters.
|
|
||||||
if (filename.length() + 8 > 31) {
|
|
||||||
DEBUG_MSG("Uploaded filename too long!\n");
|
|
||||||
res->println("<p>Uploaded filename too long! Limit of 23 characters.</p>");
|
|
||||||
delete parser;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// You should check file name validity and all that, but we skip that to make the core
|
// You should check file name validity and all that, but we skip that to make the core
|
||||||
// concepts of the body parser functionality easier to understand.
|
// concepts of the body parser functionality easier to understand.
|
||||||
std::string pathname = "/static/" + filename;
|
std::string pathname = "/static/" + filename;
|
||||||
|
|
||||||
// Create a new file on spiffs to stream the data into
|
// Create a new file to stream the data into
|
||||||
File file = SPIFFS.open(pathname.c_str(), "w");
|
File file = FSCom.open(pathname.c_str(), "w");
|
||||||
size_t fileLength = 0;
|
size_t fileLength = 0;
|
||||||
didwrite = true;
|
didwrite = true;
|
||||||
|
|
||||||
@ -529,7 +524,7 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
|
|||||||
// DEBUG_MSG("\n\nreadLength - %i\n", readLength);
|
// DEBUG_MSG("\n\nreadLength - %i\n", readLength);
|
||||||
|
|
||||||
// Abort the transfer if there is less than 50k space left on the filesystem.
|
// Abort the transfer if there is less than 50k space left on the filesystem.
|
||||||
if (SPIFFS.totalBytes() - SPIFFS.usedBytes() < 51200) {
|
if (FSCom.totalBytes() - FSCom.usedBytes() < 51200) {
|
||||||
file.close();
|
file.close();
|
||||||
res->println("<p>Write aborted! Reserving 50k on filesystem.</p>");
|
res->println("<p>Write aborted! Reserving 50k on filesystem.</p>");
|
||||||
|
|
||||||
@ -649,9 +644,9 @@ void handleReport(HTTPRequest *req, HTTPResponse *res)
|
|||||||
res->printf("\"heap_free\": %d,\n", ESP.getFreeHeap());
|
res->printf("\"heap_free\": %d,\n", ESP.getFreeHeap());
|
||||||
res->printf("\"psram_total\": %d,\n", ESP.getPsramSize());
|
res->printf("\"psram_total\": %d,\n", ESP.getPsramSize());
|
||||||
res->printf("\"psram_free\": %d,\n", ESP.getFreePsram());
|
res->printf("\"psram_free\": %d,\n", ESP.getFreePsram());
|
||||||
res->println("\"spiffs_total\" : " + String(SPIFFS.totalBytes()) + ",");
|
res->println("\"fs_total\" : " + String(FSCom.totalBytes()) + ",");
|
||||||
res->println("\"spiffs_used\" : " + String(SPIFFS.usedBytes()) + ",");
|
res->println("\"fs_used\" : " + String(FSCom.usedBytes()) + ",");
|
||||||
res->println("\"spiffs_free\" : " + String(SPIFFS.totalBytes() - SPIFFS.usedBytes()));
|
res->println("\"fs_free\" : " + String(FSCom.totalBytes() - FSCom.usedBytes()));
|
||||||
res->println("},");
|
res->println("},");
|
||||||
|
|
||||||
res->println("\"power\": {");
|
res->println("\"power\": {");
|
||||||
@ -699,7 +694,7 @@ void handleHotspot(HTTPRequest *req, HTTPResponse *res)
|
|||||||
res->println("<meta http-equiv=\"refresh\" content=\"0;url=/\" />\n");
|
res->println("<meta http-equiv=\"refresh\" content=\"0;url=/\" />\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res)
|
void handleUpdateFs(HTTPRequest *req, HTTPResponse *res)
|
||||||
{
|
{
|
||||||
res->setHeader("Content-Type", "text/html");
|
res->setHeader("Content-Type", "text/html");
|
||||||
res->setHeader("Access-Control-Allow-Origin", "*");
|
res->setHeader("Access-Control-Allow-Origin", "*");
|
||||||
@ -716,7 +711,7 @@ void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res)
|
|||||||
if (streamptr != nullptr) {
|
if (streamptr != nullptr) {
|
||||||
DEBUG_MSG("Connection to content server ... success!\n");
|
DEBUG_MSG("Connection to content server ... success!\n");
|
||||||
|
|
||||||
File root = SPIFFS.open("/");
|
File root = FSCom.open("/");
|
||||||
File file = root.openNextFile();
|
File file = root.openNextFile();
|
||||||
|
|
||||||
DEBUG_MSG("Deleting files from /static : \n");
|
DEBUG_MSG("Deleting files from /static : \n");
|
||||||
@ -725,7 +720,7 @@ void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res)
|
|||||||
String filePath = String(file.name());
|
String filePath = String(file.name());
|
||||||
if (filePath.indexOf("/static") == 0) {
|
if (filePath.indexOf("/static") == 0) {
|
||||||
DEBUG_MSG(" %s\n", file.name());
|
DEBUG_MSG(" %s\n", file.name());
|
||||||
SPIFFS.remove(file.name());
|
FSCom.remove(file.name());
|
||||||
}
|
}
|
||||||
file = root.openNextFile();
|
file = root.openNextFile();
|
||||||
}
|
}
|
||||||
@ -752,7 +747,7 @@ void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res)
|
|||||||
res->printf("Stream size %d<br><br>\n", streamSize);
|
res->printf("Stream size %d<br><br>\n", streamSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TARUnpacker->tarStreamExpander(streamptr, streamSize, SPIFFS, "/static")) {
|
if (!TARUnpacker->tarStreamExpander(streamptr, streamSize, FSCom, "/static")) {
|
||||||
res->printf("tarStreamExpander failed with return code #%d\n", TARUnpacker->tarGzGetError());
|
res->printf("tarStreamExpander failed with return code #%d\n", TARUnpacker->tarGzGetError());
|
||||||
Serial.printf("tarStreamExpander failed with return code #%d\n", TARUnpacker->tarGzGetError());
|
Serial.printf("tarStreamExpander failed with return code #%d\n", TARUnpacker->tarGzGetError());
|
||||||
|
|
||||||
@ -786,16 +781,16 @@ void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res)
|
|||||||
webServerThread->requestRestart = (millis() / 1000) + 5;
|
webServerThread->requestRestart = (millis() / 1000) + 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleDeleteSPIFFSContent(HTTPRequest *req, HTTPResponse *res)
|
void handleDeleteFsContent(HTTPRequest *req, HTTPResponse *res)
|
||||||
{
|
{
|
||||||
res->setHeader("Content-Type", "text/html");
|
res->setHeader("Content-Type", "text/html");
|
||||||
res->setHeader("Access-Control-Allow-Origin", "*");
|
res->setHeader("Access-Control-Allow-Origin", "*");
|
||||||
res->setHeader("Access-Control-Allow-Methods", "GET");
|
res->setHeader("Access-Control-Allow-Methods", "GET");
|
||||||
|
|
||||||
res->println("<h1>Meshtastic</h1>\n");
|
res->println("<h1>Meshtastic</h1>\n");
|
||||||
res->println("Deleting SPIFFS Content in /static/*");
|
res->println("Deleting Content in /static/*");
|
||||||
|
|
||||||
File root = SPIFFS.open("/");
|
File root = FSCom.open("/");
|
||||||
File file = root.openNextFile();
|
File file = root.openNextFile();
|
||||||
|
|
||||||
DEBUG_MSG("Deleting files from /static : \n");
|
DEBUG_MSG("Deleting files from /static : \n");
|
||||||
@ -804,7 +799,7 @@ void handleDeleteSPIFFSContent(HTTPRequest *req, HTTPResponse *res)
|
|||||||
String filePath = String(file.name());
|
String filePath = String(file.name());
|
||||||
if (filePath.indexOf("/static") == 0) {
|
if (filePath.indexOf("/static") == 0) {
|
||||||
DEBUG_MSG(" %s\n", file.name());
|
DEBUG_MSG(" %s\n", file.name());
|
||||||
SPIFFS.remove(file.name());
|
FSCom.remove(file.name());
|
||||||
}
|
}
|
||||||
file = root.openNextFile();
|
file = root.openNextFile();
|
||||||
}
|
}
|
||||||
@ -819,7 +814,7 @@ void handleAdmin(HTTPRequest *req, HTTPResponse *res)
|
|||||||
|
|
||||||
res->println("<h1>Meshtastic</h1>\n");
|
res->println("<h1>Meshtastic</h1>\n");
|
||||||
res->println("<a href=/admin/settings>Settings</a><br>\n");
|
res->println("<a href=/admin/settings>Settings</a><br>\n");
|
||||||
res->println("<a href=/admin/spiffs>Manage Web Content</a><br>\n");
|
res->println("<a href=/admin/fs>Manage Web Content</a><br>\n");
|
||||||
res->println("<a href=/json/report>Device Report</a><br>\n");
|
res->println("<a href=/json/report>Device Report</a><br>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -859,14 +854,14 @@ void handleAdminSettingsApply(HTTPRequest *req, HTTPResponse *res)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void handleSPIFFS(HTTPRequest *req, HTTPResponse *res)
|
void handleFs(HTTPRequest *req, HTTPResponse *res)
|
||||||
{
|
{
|
||||||
res->setHeader("Content-Type", "text/html");
|
res->setHeader("Content-Type", "text/html");
|
||||||
res->setHeader("Access-Control-Allow-Origin", "*");
|
res->setHeader("Access-Control-Allow-Origin", "*");
|
||||||
res->setHeader("Access-Control-Allow-Methods", "GET");
|
res->setHeader("Access-Control-Allow-Methods", "GET");
|
||||||
|
|
||||||
res->println("<h1>Meshtastic</h1>\n");
|
res->println("<h1>Meshtastic</h1>\n");
|
||||||
res->println("<a href=/admin/spiffs/delete>Delete Web Content</a><p><form action=/admin/spiffs/update "
|
res->println("<a href=/admin/fs/delete>Delete Web Content</a><p><form action=/admin/fs/update "
|
||||||
"method=post><input type=submit value=UPDATE_WEB_CONTENT></form>Be patient!");
|
"method=post><input type=submit value=UPDATE_WEB_CONTENT></form>Be patient!");
|
||||||
res->println("<p><hr><p><a href=/admin>Back to admin</a>\n");
|
res->println("<p><hr><p><a href=/admin>Back to admin</a>\n");
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,13 @@ void handleStatic(HTTPRequest *req, HTTPResponse *res);
|
|||||||
void handleRestart(HTTPRequest *req, HTTPResponse *res);
|
void handleRestart(HTTPRequest *req, HTTPResponse *res);
|
||||||
void handleFormUpload(HTTPRequest *req, HTTPResponse *res);
|
void handleFormUpload(HTTPRequest *req, HTTPResponse *res);
|
||||||
void handleScanNetworks(HTTPRequest *req, HTTPResponse *res);
|
void handleScanNetworks(HTTPRequest *req, HTTPResponse *res);
|
||||||
void handleSpiffsBrowseStatic(HTTPRequest *req, HTTPResponse *res);
|
void handleFsBrowseStatic(HTTPRequest *req, HTTPResponse *res);
|
||||||
void handleSpiffsDeleteStatic(HTTPRequest *req, HTTPResponse *res);
|
void handleFsDeleteStatic(HTTPRequest *req, HTTPResponse *res);
|
||||||
void handleBlinkLED(HTTPRequest *req, HTTPResponse *res);
|
void handleBlinkLED(HTTPRequest *req, HTTPResponse *res);
|
||||||
void handleReport(HTTPRequest *req, HTTPResponse *res);
|
void handleReport(HTTPRequest *req, HTTPResponse *res);
|
||||||
void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res);
|
void handleUpdateFs(HTTPRequest *req, HTTPResponse *res);
|
||||||
void handleDeleteSPIFFSContent(HTTPRequest *req, HTTPResponse *res);
|
void handleDeleteFsContent(HTTPRequest *req, HTTPResponse *res);
|
||||||
void handleSPIFFS(HTTPRequest *req, HTTPResponse *res);
|
void handleFs(HTTPRequest *req, HTTPResponse *res);
|
||||||
void handleAdmin(HTTPRequest *req, HTTPResponse *res);
|
void handleAdmin(HTTPRequest *req, HTTPResponse *res);
|
||||||
void handleAdminSettings(HTTPRequest *req, HTTPResponse *res);
|
void handleAdminSettings(HTTPRequest *req, HTTPResponse *res);
|
||||||
void handleAdminSettingsApply(HTTPRequest *req, HTTPResponse *res);
|
void handleAdminSettingsApply(HTTPRequest *req, HTTPResponse *res);
|
||||||
@ -38,5 +38,3 @@ class HttpAPI : public PhoneAPI
|
|||||||
/// Check the current underlying physical link to see if the client is currently connected
|
/// Check the current underlying physical link to see if the client is currently connected
|
||||||
virtual bool checkIsConnected() override { return true; } // FIXME, be smarter about this
|
virtual bool checkIsConnected() override { return true; } // FIXME, be smarter about this
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
#include "mesh-pb-constants.h"
|
#include "mesh-pb-constants.h"
|
||||||
#include "FS.h"
|
#include "FSCommon.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <pb_decode.h>
|
#include <pb_decode.h>
|
||||||
#include <pb_encode.h>
|
#include <pb_encode.h>
|
||||||
|
|
||||||
#ifdef ARDUINO_ARCH_NRF52
|
|
||||||
#include "Adafruit_LittleFS.h"
|
|
||||||
using namespace Adafruit_LittleFS_Namespace; // To get File type
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// helper function for encoding a record as a protobuf, any failures to encode are fatal and we will panic
|
/// helper function for encoding a record as a protobuf, any failures to encode are fatal and we will panic
|
||||||
/// returns the encoded packet size
|
/// returns the encoded packet size
|
||||||
size_t pb_encode_to_bytes(uint8_t *destbuf, size_t destbufsize, const pb_msgdesc_t *fields, const void *src_struct)
|
size_t pb_encode_to_bytes(uint8_t *destbuf, size_t destbufsize, const pb_msgdesc_t *fields, const void *src_struct)
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
// FIXME - make a FS abstraction for NRF52
|
|
@ -8,13 +8,12 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "gps/GeoCoord.h"
|
#include "gps/GeoCoord.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <SPIFFS.h>
|
#include <FSCommon.h>
|
||||||
//#include <assert.h>
|
//#include <assert.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
As a sender, I can send packets every n-seonds. These packets include an incramented PacketID.
|
As a sender, I can send packets every n-seonds. These packets include an incramented PacketID.
|
||||||
|
As a receiver, I can receive packets from multiple senders. These packets can be saved to the Filesystem.
|
||||||
As a receiver, I can receive packets from multiple senders. These packets can be saved to the spiffs.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RangeTestPlugin *rangeTestPlugin;
|
RangeTestPlugin *rangeTestPlugin;
|
||||||
@ -214,20 +213,20 @@ bool RangeTestPluginRadio::appendFile(const MeshPacket &mp)
|
|||||||
DEBUG_MSG("gpsStatus->getDOP() %d\n", gpsStatus->getDOP());
|
DEBUG_MSG("gpsStatus->getDOP() %d\n", gpsStatus->getDOP());
|
||||||
DEBUG_MSG("-----------------------------------------\n");
|
DEBUG_MSG("-----------------------------------------\n");
|
||||||
*/
|
*/
|
||||||
if (!SPIFFS.begin(true)) {
|
if (!FSBegin()) {
|
||||||
DEBUG_MSG("An Error has occurred while mounting SPIFFS\n");
|
DEBUG_MSG("An Error has occurred while mounting the filesystem\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SPIFFS.totalBytes() - SPIFFS.usedBytes() < 51200) {
|
if (FSCom.totalBytes() - FSCom.usedBytes() < 51200) {
|
||||||
DEBUG_MSG("SPIFFS doesn't have enough free space. Abourting write.\n");
|
DEBUG_MSG("Filesystem doesn't have enough free space. Aborting write.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the file doesn't exist, write the header.
|
// If the file doesn't exist, write the header.
|
||||||
if (!SPIFFS.exists("/static/rangetest.csv")) {
|
if (!FSCom.exists("/static/rangetest.csv")) {
|
||||||
//--------- Write to file
|
//--------- Write to file
|
||||||
File fileToWrite = SPIFFS.open("/static/rangetest.csv", FILE_WRITE);
|
File fileToWrite = FSCom.open("/static/rangetest.csv", FILE_WRITE);
|
||||||
|
|
||||||
if (!fileToWrite) {
|
if (!fileToWrite) {
|
||||||
DEBUG_MSG("There was an error opening the file for writing\n");
|
DEBUG_MSG("There was an error opening the file for writing\n");
|
||||||
@ -245,8 +244,8 @@ bool RangeTestPluginRadio::appendFile(const MeshPacket &mp)
|
|||||||
fileToWrite.close();
|
fileToWrite.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------- Apend content to file
|
//--------- Append content to file
|
||||||
File fileToAppend = SPIFFS.open("/static/rangetest.csv", FILE_APPEND);
|
File fileToAppend = FSCom.open("/static/rangetest.csv", FILE_APPEND);
|
||||||
|
|
||||||
if (!fileToAppend) {
|
if (!fileToAppend) {
|
||||||
DEBUG_MSG("There was an error opening the file for appending\n");
|
DEBUG_MSG("There was an error opening the file for appending\n");
|
||||||
|
@ -36,7 +36,7 @@ class RangeTestPluginRadio : public SinglePortPlugin
|
|||||||
void sendPayload(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false);
|
void sendPayload(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append range test data to the file on the spiffs
|
* Append range test data to the file on the Filesystem
|
||||||
*/
|
*/
|
||||||
bool appendFile(const MeshPacket &mp);
|
bool appendFile(const MeshPacket &mp);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user