Skip to content

Commit

Permalink
Use new DRD, fix DRD on flash
Browse files Browse the repository at this point in the history
  • Loading branch information
lbussy committed Dec 3, 2020
1 parent 9975e1d commit 5f65290
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
8 changes: 2 additions & 6 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
# TODO List

## Open

### Firmware
- Detect first run after flash
- Normalize DRD with KC

## Other
- Update documentation

### Completed This Sprint
Expand All @@ -15,6 +9,8 @@
- ~~Add temps to last bubble~~
- ~~Add build and branch to version display on page~~
- ~~Auto-reload the About page information~~
- ~~Detect first run after flash~~
- ~~Normalize DRD with KC~~

## Complete

Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ lib_deps =
https://github.com/lbussy/AsyncWiFiManager.git
https://github.com/lbussy/ESPAsyncTCP
https://github.com/lbussy/asyncHTTPrequest.git
https://github.com/lbussy/DoubleResetDetect.git
https://github.com/lbussy/CircularBuffer.git
https://github.com/lbussy/LCBUrl.git
https://github.com/lbussy/esptelnet.git
ESP_DoubleResetDetector
ThingSpeak
monitor_filters =
esp8266_exception_decoder
Expand Down
9 changes: 6 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ SOFTWARE. */

#include "main.h"

DoubleResetDetect drd(DRD_TIMEOUT, DRD_ADDRESS);
DoubleResetDetector* drd;

void setup()
{
bool rst = drd.detect(); // Check for double-reset
drd = new DoubleResetDetector(DRD_TIMEOUT, DRD_ADDRESS);
setSerial();

if (loadConfig())
Expand All @@ -44,7 +44,7 @@ void setup()
Log.notice(F("%s low, presenting portal." CR), stringify(RESETWIFI));
doWiFi(true);
}
else if (rst == true)
else if (drd->detectDoubleReset())
{
Log.notice(F("DRD: Triggered, presenting portal." CR));
doWiFi(true);
Expand Down Expand Up @@ -95,6 +95,9 @@ void loop()

while (true)
{
// Handle DRD timeout
drd->loop();

// Handle semaphores - No radio work in a Ticker!
tickerLoop();

Expand Down
18 changes: 9 additions & 9 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ SOFTWARE. */
#ifndef _MAIN_H
#define _MAIN_H

// Use LittleFS for DRD storage
#define ESP_DRD_USE_LITTLEFS true
// #define DOUBLERESETDETECTOR_DEBUG true
// Number of seconds to consider as considered a double reset.
#define DRD_TIMEOUT 10
// RTC Memory Address for the DoubleResetDetector to use
#define DRD_ADDRESS 0

#include "serialhandler.h"
#include "config.h"
#include "execota.h"
Expand All @@ -39,18 +47,10 @@ SOFTWARE. */
#include "mdns.h"
#include "ntp.h"
#include "thatVersion.h"
#include <DoubleResetDetect.h>
#include <ESP_DoubleResetDetector.h>
#include <ArduinoLog.h>
#include <Arduino.h>

// DRD_TIMEOUT = Maximum number of seconds between resets that counts
// as a double reset
// DRD_ADDRESS = Address to the block in the RTC user memory change it
// if it collides with another usage of the address block
//
#define DRD_TIMEOUT 3.0
#define DRD_ADDRESS 0x00

extern struct Config config;
extern bool loadConfig();
extern const char *filename;
Expand Down

0 comments on commit 5f65290

Please sign in to comment.