commit
ef7a5ece3b
12
README.md
12
README.md
@ -128,7 +128,7 @@ The original Pycom firmware is not needed, so there is no need to update it befo
|
||||
After the ESP32 board is initially flashed and has joined a LoRaWAN network, the firmware can update itself by OTA. This process is kicked off by sending a remote control command (see below) via LoRaWAN to the board. The board then tries to connect via WiFi to a cloud service (JFrog Bintray), checks for update, and if available downloads the binary and reboots with it. If something goes wrong during this process, the board reboots back to the current version. Prerequisites for OTA are: 1. You own a Bintray repository, 2. you pushed the update binary to the Bintray repository, 3. internet access via encrypted (WPA2) WiFi is present at the board's site, 4. WiFi credentials were set in ota.conf and initially flashed to the board. Step 2 runs automated, just enter the credentials in ota.conf and set `upload_protocol = custom` in platformio.ini. Then press build and lean back watching platformio doing build and upload.
|
||||
|
||||
- **over the air (OTA), upload via WiFi:**
|
||||
If option *BOOTMENU* is defined in `paxcounter.conf`, the ESP32 board will try to connect to a known WiFi access point each time cold starting (after a power cycle or a reset), using the WiFi credentials given in `ota.conf`. Once connected to the WiFi it will fire up a simple webserver, providing a bootstrap menu waiting for a user interaction (pressing "START" button in menu). This process will be aborted by ESP32 hardware watchdog after *BOOTDELAY* seconds, ensuring booting the device to runmode. Once a user interaction in bootstrap menu was detected, the watchdog time will be extended to *BOOTTIMEOUT* seconds. During this time a firmware upload can be performed manually by user, e.g. using a smartphone in tethering mode providing the firmware upload file.
|
||||
If option *BOOTMENU* is defined in `paxcounter.conf`, the ESP32 board will try to connect to a known WiFi access point each time cold starting (after a power cycle or a reset), using the WiFi credentials given in `ota.conf`. Once connected to the WiFi it will fire up a simple webserver, providing a bootstrap menu waiting for a user interaction (pressing "START" button in menu). This process will time out after *BOOTDELAY* seconds, ensuring booting the device to runmode. Once a user interaction in bootstrap menu was detected, the timeout will be extended to *BOOTTIMEOUT* seconds. During this time a firmware upload can be performed manually by user, e.g. using a smartphone in tethering mode providing the firmware upload file.
|
||||
|
||||
# Legal note
|
||||
|
||||
@ -532,14 +532,14 @@ Send for example `8386` as Downlink on Port 2 to get battery status and time/dat
|
||||
0 ... 255 device sleep cycle in seconds/2
|
||||
e.g. 120 -> device sleeps 240 seconds after each send cycle [default = 0]
|
||||
|
||||
0x20 store device configuration
|
||||
|
||||
Current device runtime configuration is stored in NVRAM, will be reloaded after restart
|
||||
|
||||
0x21 load device configuration
|
||||
0x20 load device configuration
|
||||
|
||||
Current device runtime configuration will be loaded from NVRAM, replacing current settings immediately (use with care!)
|
||||
|
||||
0x21 store device configuration
|
||||
|
||||
Current device runtime configuration is stored in NVRAM, will be reloaded after restart
|
||||
|
||||
0x80 get device configuration
|
||||
|
||||
Device answers with it's current configuration on Port 3.
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "globals.h"
|
||||
#include "hash.h"
|
||||
#include "reset.h"
|
||||
|
||||
#include <Update.h>
|
||||
#include <WiFi.h>
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "sds011read.h"
|
||||
#include "sdcard.h"
|
||||
#include "macsniff.h"
|
||||
#include "reset.h"
|
||||
|
||||
extern Ticker cyclicTimer;
|
||||
|
||||
|
@ -148,6 +148,5 @@ extern SemaphoreHandle_t I2Caccess;
|
||||
extern TaskHandle_t irqHandlerTask, ClockTask, macProcessTask;
|
||||
extern TimerHandle_t WifiChanTimer;
|
||||
extern Timezone myTZ;
|
||||
extern RTC_NOINIT_ATTR runmode_t RTC_runmode;
|
||||
|
||||
#endif
|
||||
|
@ -15,4 +15,6 @@ void enter_deepsleep(const uint64_t wakeup_sec = 60,
|
||||
const gpio_num_t wakeup_gpio = GPIO_NUM_MAX);
|
||||
unsigned long long uptime(void);
|
||||
|
||||
extern RTC_NOINIT_ATTR runmode_t RTC_runmode;
|
||||
|
||||
#endif // _RESET_H
|
@ -57,8 +57,7 @@ extra_scripts = pre:build.py
|
||||
otakeyfile = ota.conf
|
||||
lorakeyfile = loraconf.h
|
||||
lmicconfigfile = lmic_config.h
|
||||
;platform_espressif32 = espressif32@3.0.0
|
||||
platform_espressif32 = https://github.com/platformio/platform-espressif32.git#abc2bb9
|
||||
platform_espressif32 = espressif32@3.1.1
|
||||
monitor_speed = 115200
|
||||
upload_speed = 115200 ; set by build.py and taken from hal file
|
||||
display_library = ; set by build.py and taken from hal file
|
||||
|
@ -126,7 +126,7 @@
|
||||
#define CAYENNE_SENSORENABLE 14 // sensor enable configuration
|
||||
|
||||
// MQTT settings, only needed if MQTT is used (#define HAS_MQTT in board hal file)
|
||||
#define MQTT_ETHERNET 0 // select PHY: set 0 for Wifi, 1 for ethernet
|
||||
#define MQTT_ETHERNET 1 // select PHY: set 0 for Wifi, 1 for ethernet (Wifi not yet implemented!)
|
||||
#define MQTT_INTOPIC "paxin"
|
||||
#define MQTT_OUTTOPIC "paxout"
|
||||
#define MQTT_PORT 1883
|
||||
|
@ -8,10 +8,13 @@ static const char TAG[] = __FILE__;
|
||||
// Conversion factor for micro seconds to seconds
|
||||
#define uS_TO_S_FACTOR 1000000ULL
|
||||
|
||||
// variables keep its values after a wakeup from sleep
|
||||
RTC_NOINIT_ATTR runmode_t RTC_runmode = RUNMODE_POWERCYCLE;
|
||||
// RTC_NOINIT_ATTR -> keep value after a software restart or system crash
|
||||
RTC_NOINIT_ATTR runmode_t RTC_runmode;
|
||||
|
||||
// RTC_DATA_ATTR -> keep values after a wakeup from sleep
|
||||
RTC_DATA_ATTR struct timeval RTC_sleep_start_time;
|
||||
RTC_DATA_ATTR unsigned long long RTC_millis = 0;
|
||||
|
||||
timeval sleep_stop_time;
|
||||
|
||||
const char *runmode[6] = {"powercycle", "normal", "wakeup",
|
||||
@ -46,8 +49,10 @@ void do_after_reset(void) {
|
||||
break;
|
||||
|
||||
case SW_CPU_RESET: // 0x0c Software reset CPU
|
||||
// keep previous runmode
|
||||
// (i.e. RUNMODE_UPDATE or RUNMODE_MAINTENANCE)
|
||||
// keep previous runmode, if RTC_runmode has valid value
|
||||
// sets runmode, if RTC_runmode is invalid (i.e. not initialized)
|
||||
if ((RTC_runmode != RUNMODE_UPDATE) && (RTC_runmode != RUNMODE_NORMAL))
|
||||
RTC_runmode = RUNMODE_POWERCYCLE;
|
||||
break;
|
||||
|
||||
case DEEPSLEEP_RESET: // 0x05 Deep Sleep reset digital core
|
||||
|
Loading…
Reference in New Issue
Block a user