kopia lustrzana https://github.com/meshtastic/firmware
Merge branch 'meshtastic:master' into master
commit
01f1b33eec
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
arm-none-eabi-readelf -s -e .pio/build/nrf52dk/firmware.elf | head -80
|
arm-none-eabi-readelf -s -e .pio/build/nrf52dk/firmware.elf | head -80
|
||||||
|
|
||||||
nm -CSr --size-sort .pio/build/nrf52dk/firmware.elf | grep '^200'
|
nm -CSr --size-sort .pio/build/nrf52dk/firmware.elf | grep '^200'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/python2
|
#!/usr/bin/env python2
|
||||||
|
|
||||||
# This is a layout for 4MB of flash
|
# This is a layout for 4MB of flash
|
||||||
# Name, Type, SubType, Offset, Size, Flags
|
# Name, Type, SubType, Offset, Size, Flags
|
||||||
|
@ -38,4 +38,4 @@ app0, app, ota_0, , 0x{app:x},
|
||||||
app1, app, ota_1, , 0x{app:x},
|
app1, app, ota_1, , 0x{app:x},
|
||||||
spiffs, data, spiffs, , 0x{spi:x} """.format(**locals())
|
spiffs, data, spiffs, , 0x{spi:x} """.format(**locals())
|
||||||
|
|
||||||
print(table)
|
print(table)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# You probably don't want to use this script, it programs a custom bootloader build onto a nrf52 board
|
# You probably don't want to use this script, it programs a custom bootloader build onto a nrf52 board
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# You probably don't want to use this script, it programs a custom bootloader build onto a nrf52 board
|
# You probably don't want to use this script, it programs a custom bootloader build onto a nrf52 board
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
mosquitto_sub -h mqtt.meshtastic.org -v -t \$SYS/\# -t msh/+/stat/\# -t msh/+/json/\#
|
mosquitto_sub -h mqtt.meshtastic.org -v -t \$SYS/\# -t msh/+/stat/\# -t msh/+/json/\#
|
||||||
# mosquitto_sub -h test.mosquitto.org -v -t mesh/\# -F "%j"
|
# mosquitto_sub -h test.mosquitto.org -v -t mesh/\# -F "%j"
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
mosquitto_pub -h mqtt.meshtastic.org -u meshdev -P large4cats -t msh/1/stat/FakeNode -m online -d
|
mosquitto_pub -h mqtt.meshtastic.org -u meshdev -P large4cats -t msh/1/stat/FakeNode -m online -d
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
pio run --environment native
|
pio run --environment native
|
||||||
gdbserver --once localhost:2345 .pio/build/native/program "$@"
|
gdbserver --once localhost:2345 .pio/build/native/program "$@"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
pio run --environment native
|
pio run --environment native
|
||||||
.pio/build/native/program "$@"
|
.pio/build/native/program "$@"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# JLinkRTTViewer
|
# JLinkRTTViewer
|
||||||
JLinkRTTClient
|
JLinkRTTClient
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
JLinkGDBServerCLExe -if SWD -select USB -port 2331 -device NRF52832_XXAA
|
JLinkGDBServerCLExe -if SWD -select USB -port 2331 -device NRF52832_XXAA
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
JLinkGDBServerCLExe -if SWD -select USB -port 2331 -device NRF52833_XXAA
|
JLinkGDBServerCLExe -if SWD -select USB -port 2331 -device NRF52833_XXAA
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
JLinkGDBServerCLExe -if SWD -select USB -port 2331 -device NRF52840_XXAA -SuppressInfoUpdateFW -DisableAutoUpdateFW -rtos GDBServer/RTOSPlugin_FreeRTOS
|
JLinkGDBServerCLExe -if SWD -select USB -port 2331 -device NRF52840_XXAA -SuppressInfoUpdateFW -DisableAutoUpdateFW -rtos GDBServer/RTOSPlugin_FreeRTOS
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
esptool.py --baud 921600 write_flash 0x10000 release/archive/old/firmware-tbeam-EU865-1.0.0.bin
|
esptool.py --baud 921600 write_flash 0x10000 release/archive/old/firmware-tbeam-EU865-1.0.0.bin
|
||||||
echo "Erasing the otadata partition, which will turn off flash flippy-flop and force the first image to be used"
|
echo "Erasing the otadata partition, which will turn off flash flippy-flop and force the first image to be used"
|
||||||
esptool.py --baud 921600 erase_region 0xe000 0x2000
|
esptool.py --baud 921600 erase_region 0xe000 0x2000
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
esptool.py --baud 921600 write_flash 0x10000 release/archive/old/firmware-tbeam-1.1.50.bin
|
esptool.py --baud 921600 write_flash 0x10000 release/archive/old/firmware-tbeam-1.1.50.bin
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "This script is only for developers who are publishing new builds on github. Most users don't need it"
|
echo "This script is only for developers who are publishing new builds on github. Most users don't need it"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# You probably don't need this - it is a basic test of the serial flash on the TTGO eink board
|
# You probably don't need this - it is a basic test of the serial flash on the TTGO eink board
|
||||||
|
|
||||||
nrfjprog --qspiini nrf52/ttgo_eink_qpsi.ini --qspieraseall
|
nrfjprog --qspiini nrf52/ttgo_eink_qpsi.ini --qspieraseall
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
esptool.py --baud 921600 read_flash 0x1000 0xf000 system-info.img
|
esptool.py --baud 921600 read_flash 0x1000 0xf000 system-info.img
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
@ -12,4 +12,4 @@ cd proto
|
||||||
|
|
||||||
#echo "Regenerating protobuf documentation - if you see an error message"
|
#echo "Regenerating protobuf documentation - if you see an error message"
|
||||||
#echo "you can ignore it unless doing a new protobuf release to github."
|
#echo "you can ignore it unless doing a new protobuf release to github."
|
||||||
#bin/regen-docs.sh
|
#bin/regen-docs.sh
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
pio run --upload-port /dev/ttyUSB0 -t upload -t monitor
|
pio run --upload-port /dev/ttyUSB0 -t upload -t monitor
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
pio run --upload-port /dev/ttyUSB1 -t upload -t monitor
|
pio run --upload-port /dev/ttyUSB1 -t upload -t monitor
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo uploading to usb1
|
echo uploading to usb1
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
TARG=tbeam
|
TARG=tbeam
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# /home/kevinh/.platformio/packages/tool-openocd-esp32/bin/openocd -s /home/kevinh/.platformio/packages/tool-openocd-esp32 -c gdb_port pipe; tcl_port disabled; telnet_port disabled -s /home/kevinh/.platformio/packages/tool-openocd-esp32/share/openocd/scripts -f interface/jlink.cfg -f board/esp-wroom-32.cfg
|
# /home/kevinh/.platformio/packages/tool-openocd-esp32/bin/openocd -s /home/kevinh/.platformio/packages/tool-openocd-esp32 -c gdb_port pipe; tcl_port disabled; telnet_port disabled -s /home/kevinh/.platformio/packages/tool-openocd-esp32/share/openocd/scripts -f interface/jlink.cfg -f board/esp-wroom-32.cfg
|
||||||
/home/kevinh/.platformio/packages/tool-openocd-esp32/bin/openocd -s /home/kevinh/.platformio/packages/tool-openocd-esp32 -s /home/kevinh/.platformio/packages/tool-openocd-esp32/share/openocd/scripts -f interface/jlink.cfg -f ./lora32-openocd.cfg
|
/home/kevinh/.platformio/packages/tool-openocd-esp32/bin/openocd -s /home/kevinh/.platformio/packages/tool-openocd-esp32 -s /home/kevinh/.platformio/packages/tool-openocd-esp32/share/openocd/scripts -f interface/jlink.cfg -f ./lora32-openocd.cfg
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
pio device monitor -b 921600
|
pio device monitor -b 921600
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
pio device monitor -p /dev/ttyUSB1 -b 921600
|
pio device monitor -p /dev/ttyUSB1 -b 921600
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "Starting simulator"
|
echo "Starting simulator"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "building for t-echo"
|
echo "building for t-echo"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "Converting to uf2 for NRF52 Adafruit bootloader"
|
echo "Converting to uf2 for NRF52 Adafruit bootloader"
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
pio run --upload-port /dev/ttyUSB1 -t upload
|
pio run --upload-port /dev/ttyUSB1 -t upload
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
echo using amap tool to display memory map
|
echo using amap tool to display memory map
|
||||||
amap .pio/build/output.map
|
amap .pio/build/output.map
|
||||||
|
|
2
proto
2
proto
|
@ -1 +1 @@
|
||||||
Subproject commit 7b80bde4213c530ab3d85a19d1795025299d4633
|
Subproject commit 5ab590addb44f85b0590c49d09b9e0efd0e521bd
|
|
@ -84,6 +84,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define BUTTON_PIN_ALT PIN_BUTTON2
|
#define BUTTON_PIN_ALT PIN_BUTTON2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PIN_BUTTON_TOUCH
|
||||||
|
#define BUTTON_PIN_TOUCH PIN_BUTTON_TOUCH
|
||||||
|
#endif
|
||||||
|
|
||||||
// FIXME, use variant.h defs for all of this!!! (even on the ESP32 targets)
|
// FIXME, use variant.h defs for all of this!!! (even on the ESP32 targets)
|
||||||
#elif defined(CubeCell_BoardPlus)
|
#elif defined(CubeCell_BoardPlus)
|
||||||
|
|
||||||
|
|
49
src/main.cpp
49
src/main.cpp
|
@ -187,6 +187,9 @@ class ButtonThread : public OSThread
|
||||||
#endif
|
#endif
|
||||||
#ifdef BUTTON_PIN_ALT
|
#ifdef BUTTON_PIN_ALT
|
||||||
OneButton userButtonAlt;
|
OneButton userButtonAlt;
|
||||||
|
#endif
|
||||||
|
#ifdef BUTTON_PIN_TOUCH
|
||||||
|
OneButton userButtonTouch;
|
||||||
#endif
|
#endif
|
||||||
static bool shutdown_on_long_stop;
|
static bool shutdown_on_long_stop;
|
||||||
|
|
||||||
|
@ -222,6 +225,21 @@ class ButtonThread : public OSThread
|
||||||
userButtonAlt.attachLongPressStop(userButtonPressedLongStop);
|
userButtonAlt.attachLongPressStop(userButtonPressedLongStop);
|
||||||
wakeOnIrq(BUTTON_PIN_ALT, FALLING);
|
wakeOnIrq(BUTTON_PIN_ALT, FALLING);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef BUTTON_PIN_TOUCH
|
||||||
|
userButtonTouch = OneButton(BUTTON_PIN_TOUCH, true, true);
|
||||||
|
#ifdef INPUT_PULLUP_SENSE
|
||||||
|
// Some platforms (nrf52) have a SENSE variant which allows wake from sleep - override what OneButton did
|
||||||
|
pinMode(BUTTON_PIN_TOUCH, INPUT_PULLUP_SENSE);
|
||||||
|
#endif
|
||||||
|
userButtonTouch.attachClick(touchPressed);
|
||||||
|
userButtonTouch.attachDuringLongPress(touchPressedLong);
|
||||||
|
userButtonTouch.attachDoubleClick(touchDoublePressed);
|
||||||
|
userButtonTouch.attachLongPressStart(touchPressedLongStart);
|
||||||
|
userButtonTouch.attachLongPressStop(touchPressedLongStop);
|
||||||
|
wakeOnIrq(BUTTON_PIN_TOUCH, FALLING);
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -237,6 +255,10 @@ class ButtonThread : public OSThread
|
||||||
#ifdef BUTTON_PIN_ALT
|
#ifdef BUTTON_PIN_ALT
|
||||||
userButtonAlt.tick();
|
userButtonAlt.tick();
|
||||||
canSleep &= userButtonAlt.isIdle();
|
canSleep &= userButtonAlt.isIdle();
|
||||||
|
#endif
|
||||||
|
#ifdef BUTTON_PIN_TOUCH
|
||||||
|
userButtonTouch.tick();
|
||||||
|
canSleep &= userButtonTouch.isIdle();
|
||||||
#endif
|
#endif
|
||||||
// if (!canSleep) DEBUG_MSG("Supressing sleep!\n");
|
// if (!canSleep) DEBUG_MSG("Supressing sleep!\n");
|
||||||
// else DEBUG_MSG("sleep ok\n");
|
// else DEBUG_MSG("sleep ok\n");
|
||||||
|
@ -245,6 +267,33 @@ class ButtonThread : public OSThread
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static void touchPressed()
|
||||||
|
{
|
||||||
|
screen->forceDisplay();
|
||||||
|
DEBUG_MSG("touch press!\n");
|
||||||
|
}
|
||||||
|
static void touchDoublePressed()
|
||||||
|
{
|
||||||
|
DEBUG_MSG("touch double press!\n");
|
||||||
|
}
|
||||||
|
static void touchPressedLong()
|
||||||
|
{
|
||||||
|
DEBUG_MSG("touch press long!\n");
|
||||||
|
}
|
||||||
|
static void touchDoublePressedLong()
|
||||||
|
{
|
||||||
|
DEBUG_MSG("touch double pressed!\n");
|
||||||
|
}
|
||||||
|
static void touchPressedLongStart()
|
||||||
|
{
|
||||||
|
DEBUG_MSG("touch long press start!\n");
|
||||||
|
}
|
||||||
|
static void touchPressedLongStop()
|
||||||
|
{
|
||||||
|
DEBUG_MSG("touch long press stop!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void userButtonPressed()
|
static void userButtonPressed()
|
||||||
{
|
{
|
||||||
// DEBUG_MSG("press!\n");
|
// DEBUG_MSG("press!\n");
|
||||||
|
|
|
@ -93,7 +93,8 @@ bool RadioLibInterface::canSendImmediately()
|
||||||
/// bluetooth comms code. If the txmit queue is empty it might return an error
|
/// bluetooth comms code. If the txmit queue is empty it might return an error
|
||||||
ErrorCode RadioLibInterface::send(MeshPacket *p)
|
ErrorCode RadioLibInterface::send(MeshPacket *p)
|
||||||
{
|
{
|
||||||
if (disabled) {
|
if (disabled || radioConfig.preferences.is_lora_tx_disabled) {
|
||||||
|
DEBUG_MSG("send - lora_tx_disabled\n");
|
||||||
packetPool.release(p);
|
packetPool.release(p);
|
||||||
return ERRNO_DISABLED;
|
return ERRNO_DISABLED;
|
||||||
}
|
}
|
||||||
|
@ -300,7 +301,7 @@ void RadioLibInterface::handleReceiveInterrupt()
|
||||||
void RadioLibInterface::startSend(MeshPacket *txp)
|
void RadioLibInterface::startSend(MeshPacket *txp)
|
||||||
{
|
{
|
||||||
printPacket("Starting low level send", txp);
|
printPacket("Starting low level send", txp);
|
||||||
if (disabled) {
|
if (disabled || radioConfig.preferences.is_lora_tx_disabled) {
|
||||||
DEBUG_MSG("startSend is dropping tx packet because we are disabled\n");
|
DEBUG_MSG("startSend is dropping tx packet because we are disabled\n");
|
||||||
packetPool.release(txp);
|
packetPool.release(txp);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
#define PB_ADMIN_PB_H_INCLUDED
|
#define PB_ADMIN_PB_H_INCLUDED
|
||||||
#include <pb.h>
|
#include <pb.h>
|
||||||
#include "channel.pb.h"
|
#include "channel.pb.h"
|
||||||
#include "radioconfig.pb.h"
|
|
||||||
#include "mesh.pb.h"
|
#include "mesh.pb.h"
|
||||||
|
#include "radioconfig.pb.h"
|
||||||
|
|
||||||
#if PB_PROTO_HEADER_VERSION != 40
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
#error Regenerate this file with the current version of nanopb generator.
|
#error Regenerate this file with the current version of nanopb generator.
|
||||||
|
@ -86,7 +86,7 @@ extern const pb_msgdesc_t AdminMessage_msg;
|
||||||
#define AdminMessage_fields &AdminMessage_msg
|
#define AdminMessage_fields &AdminMessage_msg
|
||||||
|
|
||||||
/* Maximum encoded size of messages (where known) */
|
/* Maximum encoded size of messages (where known) */
|
||||||
#define AdminMessage_size 529
|
#define AdminMessage_size 532
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
|
|
@ -155,6 +155,7 @@ typedef struct _RadioConfig_UserPreferences {
|
||||||
uint32_t hop_limit;
|
uint32_t hop_limit;
|
||||||
char mqtt_username[32];
|
char mqtt_username[32];
|
||||||
char mqtt_password[32];
|
char mqtt_password[32];
|
||||||
|
bool is_lora_tx_disabled;
|
||||||
} RadioConfig_UserPreferences;
|
} RadioConfig_UserPreferences;
|
||||||
|
|
||||||
typedef struct _RadioConfig {
|
typedef struct _RadioConfig {
|
||||||
|
@ -199,9 +200,9 @@ extern "C" {
|
||||||
|
|
||||||
/* Initializer values for message structs */
|
/* Initializer values for message structs */
|
||||||
#define RadioConfig_init_default {false, RadioConfig_UserPreferences_init_default}
|
#define RadioConfig_init_default {false, RadioConfig_UserPreferences_init_default}
|
||||||
#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", ""}
|
#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0}
|
||||||
#define RadioConfig_init_zero {false, RadioConfig_UserPreferences_init_zero}
|
#define RadioConfig_init_zero {false, RadioConfig_UserPreferences_init_zero}
|
||||||
#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", ""}
|
#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0}
|
||||||
|
|
||||||
/* Field tags (for use in manual encoding/decoding) */
|
/* Field tags (for use in manual encoding/decoding) */
|
||||||
#define RadioConfig_UserPreferences_position_broadcast_secs_tag 1
|
#define RadioConfig_UserPreferences_position_broadcast_secs_tag 1
|
||||||
|
@ -272,6 +273,7 @@ extern "C" {
|
||||||
#define RadioConfig_UserPreferences_hop_limit_tag 154
|
#define RadioConfig_UserPreferences_hop_limit_tag 154
|
||||||
#define RadioConfig_UserPreferences_mqtt_username_tag 155
|
#define RadioConfig_UserPreferences_mqtt_username_tag 155
|
||||||
#define RadioConfig_UserPreferences_mqtt_password_tag 156
|
#define RadioConfig_UserPreferences_mqtt_password_tag 156
|
||||||
|
#define RadioConfig_UserPreferences_is_lora_tx_disabled_tag 157
|
||||||
#define RadioConfig_preferences_tag 1
|
#define RadioConfig_preferences_tag 1
|
||||||
|
|
||||||
/* Struct field encoding specification for nanopb */
|
/* Struct field encoding specification for nanopb */
|
||||||
|
@ -349,7 +351,8 @@ X(a, STATIC, SINGULAR, UINT32, auto_screen_carousel_secs, 152) \
|
||||||
X(a, STATIC, SINGULAR, UINT32, on_battery_shutdown_after_secs, 153) \
|
X(a, STATIC, SINGULAR, UINT32, on_battery_shutdown_after_secs, 153) \
|
||||||
X(a, STATIC, SINGULAR, UINT32, hop_limit, 154) \
|
X(a, STATIC, SINGULAR, UINT32, hop_limit, 154) \
|
||||||
X(a, STATIC, SINGULAR, STRING, mqtt_username, 155) \
|
X(a, STATIC, SINGULAR, STRING, mqtt_username, 155) \
|
||||||
X(a, STATIC, SINGULAR, STRING, mqtt_password, 156)
|
X(a, STATIC, SINGULAR, STRING, mqtt_password, 156) \
|
||||||
|
X(a, STATIC, SINGULAR, BOOL, is_lora_tx_disabled, 157)
|
||||||
#define RadioConfig_UserPreferences_CALLBACK NULL
|
#define RadioConfig_UserPreferences_CALLBACK NULL
|
||||||
#define RadioConfig_UserPreferences_DEFAULT NULL
|
#define RadioConfig_UserPreferences_DEFAULT NULL
|
||||||
|
|
||||||
|
@ -361,8 +364,8 @@ extern const pb_msgdesc_t RadioConfig_UserPreferences_msg;
|
||||||
#define RadioConfig_UserPreferences_fields &RadioConfig_UserPreferences_msg
|
#define RadioConfig_UserPreferences_fields &RadioConfig_UserPreferences_msg
|
||||||
|
|
||||||
/* Maximum encoded size of messages (where known) */
|
/* Maximum encoded size of messages (where known) */
|
||||||
#define RadioConfig_size 526
|
#define RadioConfig_size 529
|
||||||
#define RadioConfig_UserPreferences_size 523
|
#define RadioConfig_UserPreferences_size 526
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "airtime.h"
|
#include "airtime.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "mesh/http/ContentHelper.h"
|
#include "mesh/http/ContentHelper.h"
|
||||||
|
#include "mesh/http/WebServer.h"
|
||||||
#include "mesh/http/WiFiAPClient.h"
|
#include "mesh/http/WiFiAPClient.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
#include "sleep.h"
|
#include "sleep.h"
|
||||||
|
@ -43,7 +44,7 @@ using namespace httpsserver;
|
||||||
|
|
||||||
#include <HTTPClient.h>
|
#include <HTTPClient.h>
|
||||||
#include <WiFiClientSecure.h>
|
#include <WiFiClientSecure.h>
|
||||||
HTTPClient http;
|
HTTPClient httpClient;
|
||||||
|
|
||||||
#define DEST_FS_USES_SPIFFS
|
#define DEST_FS_USES_SPIFFS
|
||||||
#include <ESP32-targz.h>
|
#include <ESP32-targz.h>
|
||||||
|
@ -57,7 +58,7 @@ char contentTypes[][2][32] = {{".txt", "text/plain"}, {".html", "text/html"}
|
||||||
{".css", "text/css"}, {".ico", "image/vnd.microsoft.icon"},
|
{".css", "text/css"}, {".ico", "image/vnd.microsoft.icon"},
|
||||||
{".svg", "image/svg+xml"}, {"", ""}};
|
{".svg", "image/svg+xml"}, {"", ""}};
|
||||||
|
|
||||||
//const char *tarURL = "https://www.casler.org/temp/meshtastic-web.tar";
|
// const char *tarURL = "https://www.casler.org/temp/meshtastic-web.tar";
|
||||||
const char *tarURL = "https://api-production-871d.up.railway.app/mirror/webui";
|
const char *tarURL = "https://api-production-871d.up.railway.app/mirror/webui";
|
||||||
const char *certificate = NULL; // change this as needed, leave as is for no TLS check (yolo security)
|
const char *certificate = NULL; // change this as needed, leave as is for no TLS check (yolo security)
|
||||||
|
|
||||||
|
@ -73,22 +74,22 @@ WiFiClient *getTarHTTPClientPtr(WiFiClientSecure *client, const char *url, const
|
||||||
client->setCACert(cert);
|
client->setCACert(cert);
|
||||||
}
|
}
|
||||||
const char *UserAgent = "ESP32-HTTP-GzUpdater-Client";
|
const char *UserAgent = "ESP32-HTTP-GzUpdater-Client";
|
||||||
http.setReuse(true); // handle 301 redirects gracefully
|
httpClient.setReuse(true); // handle 301 redirects gracefully
|
||||||
http.setUserAgent(UserAgent);
|
httpClient.setUserAgent(UserAgent);
|
||||||
http.setConnectTimeout(10000); // 10s timeout = 10000
|
httpClient.setConnectTimeout(10000); // 10s timeout = 10000
|
||||||
if (!http.begin(*client, url)) {
|
if (!httpClient.begin(*client, url)) {
|
||||||
log_e("Can't open url %s", url);
|
log_e("Can't open url %s", url);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
const char *headerKeys[] = {"location", "redirect", "Content-Type", "Content-Length", "Content-Disposition"};
|
const char *headerKeys[] = {"location", "redirect", "Content-Type", "Content-Length", "Content-Disposition"};
|
||||||
const size_t numberOfHeaders = 5;
|
const size_t numberOfHeaders = 5;
|
||||||
http.collectHeaders(headerKeys, numberOfHeaders);
|
httpClient.collectHeaders(headerKeys, numberOfHeaders);
|
||||||
int httpCode = http.GET();
|
int httpCode = httpClient.GET();
|
||||||
// file found at server
|
// file found at server
|
||||||
if (httpCode == HTTP_CODE_FOUND || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
|
if (httpCode == HTTP_CODE_FOUND || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
|
||||||
String newlocation = "";
|
String newlocation = "";
|
||||||
String headerLocation = http.header("location");
|
String headerLocation = httpClient.header("location");
|
||||||
String headerRedirect = http.header("redirect");
|
String headerRedirect = httpClient.header("redirect");
|
||||||
if (headerLocation != "") {
|
if (headerLocation != "") {
|
||||||
newlocation = headerLocation;
|
newlocation = headerLocation;
|
||||||
Serial.printf("302 (location): %s => %s\n", url, headerLocation.c_str());
|
Serial.printf("302 (location): %s => %s\n", url, headerLocation.c_str());
|
||||||
|
@ -96,7 +97,7 @@ WiFiClient *getTarHTTPClientPtr(WiFiClientSecure *client, const char *url, const
|
||||||
Serial.printf("301 (redirect): %s => %s\n", url, headerLocation.c_str());
|
Serial.printf("301 (redirect): %s => %s\n", url, headerLocation.c_str());
|
||||||
newlocation = headerRedirect;
|
newlocation = headerRedirect;
|
||||||
}
|
}
|
||||||
http.end();
|
httpClient.end();
|
||||||
if (newlocation != "") {
|
if (newlocation != "") {
|
||||||
log_w("Found 302/301 location header: %s", newlocation.c_str());
|
log_w("Found 302/301 location header: %s", newlocation.c_str());
|
||||||
return getTarHTTPClientPtr(client, newlocation.c_str(), cert);
|
return getTarHTTPClientPtr(client, newlocation.c_str(), cert);
|
||||||
|
@ -107,7 +108,7 @@ WiFiClient *getTarHTTPClientPtr(WiFiClientSecure *client, const char *url, const
|
||||||
}
|
}
|
||||||
if (httpCode != 200)
|
if (httpCode != 200)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return http.getStreamPtr();
|
return httpClient.getStreamPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer)
|
void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer)
|
||||||
|
@ -123,7 +124,9 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer)
|
||||||
ResourceNode *nodeHotspotApple = new ResourceNode("/hotspot-detect.html", "GET", &handleHotspot);
|
ResourceNode *nodeHotspotApple = new ResourceNode("/hotspot-detect.html", "GET", &handleHotspot);
|
||||||
ResourceNode *nodeHotspotAndroid = new ResourceNode("/generate_204", "GET", &handleHotspot);
|
ResourceNode *nodeHotspotAndroid = new ResourceNode("/generate_204", "GET", &handleHotspot);
|
||||||
|
|
||||||
ResourceNode *nodeUpdateSPIFFS = new ResourceNode("/update", "GET", &handleUpdateSPIFFS);
|
ResourceNode *nodeSPIFFS = new ResourceNode("/spiffs", "GET", &handleSPIFFS);
|
||||||
|
ResourceNode *nodeUpdateSPIFFS = new ResourceNode("/spiffs/update", "POST", &handleUpdateSPIFFS);
|
||||||
|
ResourceNode *nodeDeleteSPIFFS = new ResourceNode("/spiffs/delete", "GET", &handleDeleteSPIFFSContent);
|
||||||
|
|
||||||
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);
|
||||||
|
@ -150,6 +153,8 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer)
|
||||||
secureServer->registerNode(nodeJsonDelete);
|
secureServer->registerNode(nodeJsonDelete);
|
||||||
secureServer->registerNode(nodeJsonReport);
|
secureServer->registerNode(nodeJsonReport);
|
||||||
secureServer->registerNode(nodeUpdateSPIFFS);
|
secureServer->registerNode(nodeUpdateSPIFFS);
|
||||||
|
secureServer->registerNode(nodeDeleteSPIFFS);
|
||||||
|
secureServer->registerNode(nodeSPIFFS);
|
||||||
secureServer->registerNode(nodeRoot); // This has to be last
|
secureServer->registerNode(nodeRoot); // This has to be last
|
||||||
|
|
||||||
// Insecure nodes
|
// Insecure nodes
|
||||||
|
@ -166,6 +171,8 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer)
|
||||||
insecureServer->registerNode(nodeJsonDelete);
|
insecureServer->registerNode(nodeJsonDelete);
|
||||||
insecureServer->registerNode(nodeJsonReport);
|
insecureServer->registerNode(nodeJsonReport);
|
||||||
insecureServer->registerNode(nodeUpdateSPIFFS);
|
insecureServer->registerNode(nodeUpdateSPIFFS);
|
||||||
|
insecureServer->registerNode(nodeDeleteSPIFFS);
|
||||||
|
insecureServer->registerNode(nodeSPIFFS);
|
||||||
insecureServer->registerNode(nodeRoot); // This has to be last
|
insecureServer->registerNode(nodeRoot); // This has to be last
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,9 +374,12 @@ void handleStatic(HTTPRequest *req, HTTPResponse *res)
|
||||||
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());
|
||||||
res->println("Web server is running.<br><br>The content you are looking for can't be found. Please see: <a "
|
res->println(
|
||||||
"href=https://meshtastic.org/docs/getting-started/faq#wifi--web-browser>FAQ</a>.<br><br><a "
|
"Web server is running.<br><br>The content you are looking for can't be found. Please see: <a "
|
||||||
"href=/json/report>stats</a><br><br><a href=/update>Experemntal Web Content OTA Update</a>");
|
"href=https://meshtastic.org/docs/getting-started/faq#wifi--web-browser>FAQ</a>.<br><br>Experimental "
|
||||||
|
"Web Content OTA Update</a> -- Click "
|
||||||
|
"this just once and wait. Be patient!<form action=/spiffs/update "
|
||||||
|
"method=post><input type=submit value=UPDATE></form>");
|
||||||
} else {
|
} else {
|
||||||
res->setHeader("Content-Encoding", "gzip");
|
res->setHeader("Content-Encoding", "gzip");
|
||||||
}
|
}
|
||||||
|
@ -685,30 +695,33 @@ void handleUpdateSPIFFS(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", "POST");
|
||||||
|
|
||||||
res->println("Downloading Meshtastic Web Content...");
|
res->println("Downloading Meshtastic Web Content...");
|
||||||
|
|
||||||
File root = SPIFFS.open("/");
|
|
||||||
File file = root.openNextFile();
|
|
||||||
|
|
||||||
DEBUG_MSG("Deleting files from /static\n");
|
|
||||||
|
|
||||||
while (file) {
|
|
||||||
String filePath = String(file.name());
|
|
||||||
if (filePath.indexOf("/static") == 0) {
|
|
||||||
DEBUG_MSG("%s\n", file.name());
|
|
||||||
SPIFFS.remove(file.name());
|
|
||||||
}
|
|
||||||
file = root.openNextFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
// return;
|
|
||||||
|
|
||||||
WiFiClientSecure *client = new WiFiClientSecure;
|
WiFiClientSecure *client = new WiFiClientSecure;
|
||||||
Stream *streamptr = getTarHTTPClientPtr(client, tarURL, certificate);
|
Stream *streamptr = getTarHTTPClientPtr(client, tarURL, certificate);
|
||||||
|
|
||||||
|
delay(5); // Let other network operations run
|
||||||
|
|
||||||
if (streamptr != nullptr) {
|
if (streamptr != nullptr) {
|
||||||
|
DEBUG_MSG("Connection to content server ... success!\n");
|
||||||
|
|
||||||
|
File root = SPIFFS.open("/");
|
||||||
|
File file = root.openNextFile();
|
||||||
|
|
||||||
|
DEBUG_MSG("Deleting files from /static : \n");
|
||||||
|
|
||||||
|
while (file) {
|
||||||
|
String filePath = String(file.name());
|
||||||
|
if (filePath.indexOf("/static") == 0) {
|
||||||
|
DEBUG_MSG(" %s\n", file.name());
|
||||||
|
SPIFFS.remove(file.name());
|
||||||
|
}
|
||||||
|
file = root.openNextFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(5); // Let other network operations run
|
||||||
|
|
||||||
TarUnpacker *TARUnpacker = new TarUnpacker();
|
TarUnpacker *TARUnpacker = new TarUnpacker();
|
||||||
TARUnpacker->haltOnError(false); // stop on fail (manual restart/reset required)
|
TARUnpacker->haltOnError(false); // stop on fail (manual restart/reset required)
|
||||||
|
@ -721,33 +734,80 @@ void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res)
|
||||||
BaseUnpacker::defaultTarStatusProgressCallback); // print the filenames as they're expanded
|
BaseUnpacker::defaultTarStatusProgressCallback); // print the filenames as they're expanded
|
||||||
TARUnpacker->setTarMessageCallback(BaseUnpacker::targzPrintLoggerCallback); // tar log verbosity
|
TARUnpacker->setTarMessageCallback(BaseUnpacker::targzPrintLoggerCallback); // tar log verbosity
|
||||||
|
|
||||||
String contentLengthStr = http.header("Content-Length");
|
String contentLengthStr = httpClient.header("Content-Length");
|
||||||
contentLengthStr.trim();
|
contentLengthStr.trim();
|
||||||
int64_t streamSize = -1;
|
int64_t streamSize = -1;
|
||||||
if (contentLengthStr != "") {
|
if (contentLengthStr != "") {
|
||||||
streamSize = atoi(contentLengthStr.c_str());
|
streamSize = atoi(contentLengthStr.c_str());
|
||||||
Serial.printf("Stream size %d\n", streamSize);
|
Serial.printf("Stream size %d\n", streamSize);
|
||||||
res->printf("Stream size %d\n", streamSize);
|
res->printf("Stream size %d<br><br>\n", streamSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TARUnpacker->tarStreamExpander(streamptr, streamSize, SPIFFS, "/static")) {
|
if (!TARUnpacker->tarStreamExpander(streamptr, streamSize, SPIFFS, "/static")) {
|
||||||
|
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());
|
||||||
|
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
/*
|
||||||
// print leftover bytes if any (probably zero-fill from the server)
|
// print leftover bytes if any (probably zero-fill from the server)
|
||||||
while (http.connected()) {
|
while (httpClient.connected()) {
|
||||||
size_t streamSize = streamptr->available();
|
size_t streamSize = streamptr->available();
|
||||||
if (streamSize) {
|
if (streamSize) {
|
||||||
Serial.printf("%02x ", streamptr->read());
|
Serial.printf("%02x ", streamptr->read());
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
res->printf("Failed to establish http connection\n");
|
||||||
Serial.println("Failed to establish http connection");
|
Serial.println("Failed to establish http connection");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
res->println("<a href=/>Done</a>");
|
res->println("Done! Restarting the device. <a href=/>Click this in 10 seconds</a>");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is a work around for a bug where we run out of memory.
|
||||||
|
* TODO: Fixme!
|
||||||
|
*/
|
||||||
|
// ESP.restart();
|
||||||
|
webServerThread->requestRestart = (millis() / 1000) + 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleDeleteSPIFFSContent(HTTPRequest *req, HTTPResponse *res)
|
||||||
|
{
|
||||||
|
res->setHeader("Content-Type", "text/html");
|
||||||
|
res->setHeader("Access-Control-Allow-Origin", "*");
|
||||||
|
res->setHeader("Access-Control-Allow-Methods", "GET");
|
||||||
|
|
||||||
|
res->println("Deleting SPIFFS Content in /static/*");
|
||||||
|
|
||||||
|
File root = SPIFFS.open("/");
|
||||||
|
File file = root.openNextFile();
|
||||||
|
|
||||||
|
DEBUG_MSG("Deleting files from /static : \n");
|
||||||
|
|
||||||
|
while (file) {
|
||||||
|
String filePath = String(file.name());
|
||||||
|
if (filePath.indexOf("/static") == 0) {
|
||||||
|
DEBUG_MSG(" %s\n", file.name());
|
||||||
|
SPIFFS.remove(file.name());
|
||||||
|
}
|
||||||
|
file = root.openNextFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleSPIFFS(HTTPRequest *req, HTTPResponse *res)
|
||||||
|
{
|
||||||
|
res->setHeader("Content-Type", "text/html");
|
||||||
|
res->setHeader("Access-Control-Allow-Origin", "*");
|
||||||
|
res->setHeader("Access-Control-Allow-Methods", "GET");
|
||||||
|
|
||||||
|
res->println("<a href=/spiffs/delete>Delete Web Content</a><p><form action=/spiffs/update "
|
||||||
|
"method=post><input type=submit value=UPDATE_WEB_CONTENT></form>Be patient!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleRestart(HTTPRequest *req, HTTPResponse *res)
|
void handleRestart(HTTPRequest *req, HTTPResponse *res)
|
||||||
|
@ -759,7 +819,7 @@ void handleRestart(HTTPRequest *req, HTTPResponse *res)
|
||||||
DEBUG_MSG("***** Restarted on HTTP(s) Request *****\n");
|
DEBUG_MSG("***** Restarted on HTTP(s) Request *****\n");
|
||||||
res->println("Restarting");
|
res->println("Restarting");
|
||||||
|
|
||||||
ESP.restart();
|
webServerThread->requestRestart = (millis() / 1000) + 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleBlinkLED(HTTPRequest *req, HTTPResponse *res)
|
void handleBlinkLED(HTTPRequest *req, HTTPResponse *res)
|
||||||
|
|
|
@ -16,6 +16,9 @@ void handleSpiffsDeleteStatic(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 handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res);
|
||||||
|
void handleDeleteSPIFFSContent(HTTPRequest *req, HTTPResponse *res);
|
||||||
|
void handleSPIFFS(HTTPRequest *req, HTTPResponse *res);
|
||||||
|
|
||||||
|
|
||||||
// Interface to the PhoneAPI to access the protobufs with messages
|
// Interface to the PhoneAPI to access the protobufs with messages
|
||||||
class HttpAPI : public PhoneAPI
|
class HttpAPI : public PhoneAPI
|
||||||
|
|
|
@ -175,6 +175,10 @@ int32_t WebServerThread::runOnce()
|
||||||
// DEBUG_MSG("WebServerThread::runOnce()\n");
|
// DEBUG_MSG("WebServerThread::runOnce()\n");
|
||||||
handleWebResponse();
|
handleWebResponse();
|
||||||
|
|
||||||
|
if (requestRestart && (millis() / 1000) > requestRestart) {
|
||||||
|
ESP.restart();
|
||||||
|
}
|
||||||
|
|
||||||
// Loop every 5ms.
|
// Loop every 5ms.
|
||||||
return (5);
|
return (5);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ class WebServerThread : private concurrency::OSThread
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WebServerThread();
|
WebServerThread();
|
||||||
|
uint32_t requestRestart = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int32_t runOnce();
|
virtual int32_t runOnce();
|
||||||
|
|
|
@ -120,6 +120,7 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
#define PIN_BUTTON1 (32 + 10)
|
#define PIN_BUTTON1 (32 + 10)
|
||||||
#define PIN_BUTTON2 (0 + 18) // 0.18 is labeled on the board as RESET but we configure it in the bootloader as a regular GPIO
|
#define PIN_BUTTON2 (0 + 18) // 0.18 is labeled on the board as RESET but we configure it in the bootloader as a regular GPIO
|
||||||
|
#define PIN_BUTTON_TOUCH (0 + 11) // 0.11 is the soft touch button on T-Echo
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Analog pins
|
* Analog pins
|
||||||
|
|
Ładowanie…
Reference in New Issue