Compare commits
157 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
433502e7a0 | ||
|
cd1ada6744 | ||
|
22a4f40f41 | ||
|
59b95cd68b | ||
|
88c396398d | ||
|
5477ab4683 | ||
|
a8773a7ba1 | ||
|
71e67ca3f1 | ||
|
b76c7a55b4 | ||
|
4f806f4b02 | ||
|
a515a164fc | ||
|
b9e645b20d | ||
|
87caf6225b | ||
|
474bcdc5e9 | ||
|
19ab8f5271 | ||
|
6706a7f9d6 | ||
|
7c35bb59d0 | ||
|
47527b8a73 | ||
|
49921bf8dc | ||
|
35540243c6 | ||
|
963966d201 | ||
|
6d5d859283 | ||
|
fe7be5d8d6 | ||
|
71f87ff143 | ||
|
e29090a2a2 | ||
|
924b0356f5 | ||
|
41cb3113b9 | ||
|
dcebbf2e83 | ||
|
66d2e69927 | ||
|
89aa631b75 | ||
|
e75a31ebb7 | ||
|
e622580493 | ||
|
b3a4266da1 | ||
|
fe67ff63f1 | ||
|
ce1061dfb3 | ||
|
c4d070ee89 | ||
|
032f656d51 | ||
|
65e243e391 | ||
|
8a4d0ac035 | ||
|
3be6847238 | ||
|
683ff4e6d5 | ||
|
8e12eac627 | ||
|
83c0bb5283 | ||
|
8257e9ab51 | ||
|
67ebd559d7 | ||
|
6f09afcf96 | ||
|
a7362a42fa | ||
|
a191f6bb35 | ||
|
88cdd986e6 | ||
|
1607503103 | ||
|
31c06bcce4 | ||
|
b2449db6f9 | ||
|
b79e5b5d73 | ||
|
d28d545109 | ||
|
577d7382f4 | ||
|
d4dfccdddd | ||
|
88fc94ed8c | ||
|
0be50389cc | ||
|
9351696732 | ||
|
bc21127479 | ||
|
1dbd03a0f0 | ||
|
61e78beb4a | ||
|
d905aeafe9 | ||
|
60675ecf0f | ||
|
61715cda08 | ||
|
3d26564b8f | ||
|
74b1c40ffd | ||
|
186ae4e4ee | ||
|
f2afd653ae | ||
|
c5e5c7727b | ||
|
8bb720becd | ||
|
756a49af50 | ||
|
e2f972bbc0 | ||
|
9009b41f57 | ||
|
1c3784a223 | ||
|
489b268f73 | ||
|
01c709f9b7 | ||
|
ef3dd420f6 | ||
|
3505673652 | ||
|
8ca51a2888 | ||
|
d4ea1c9f98 | ||
|
6af0af57b8 | ||
|
8ce8deb400 | ||
|
5e24726e7b | ||
|
0b1c87323a | ||
|
787e39eff1 | ||
|
683df36164 | ||
|
9e1701c2da | ||
|
f220df08ac | ||
|
29d6486743 | ||
|
09ffcba84e | ||
|
87eab2a550 | ||
|
5bc3fdb153 | ||
|
de421b5000 | ||
|
7941b04ce8 | ||
|
022e4b804b | ||
|
4c7182a6d6 | ||
|
5ac1ead5b9 | ||
|
4e25eb4b81 | ||
|
6440ba50e2 | ||
|
ea83632285 | ||
|
f319ec4569 | ||
|
21298b09f4 | ||
|
bf17b9b864 | ||
|
acaa5d9f1d | ||
|
5dd4fb3f1e | ||
|
4aae1b912c | ||
|
50c534cbe5 | ||
|
635be88c11 | ||
|
53c953de01 | ||
|
d967d8efd9 | ||
|
bbdbf88a76 | ||
|
47bae4d28e | ||
|
ce8e8bbe7b | ||
|
0ca60ec71f | ||
|
d7981851bd | ||
|
2a419c10d1 | ||
|
b265dba422 | ||
|
74a0598905 | ||
|
3b7be30363 | ||
|
5889ebda1e | ||
|
ec77b873a8 | ||
|
04120a0490 | ||
|
b5928cb201 | ||
|
22f9a2d228 | ||
|
343aea7ebe | ||
|
19e67cb678 | ||
|
379dff1d22 | ||
|
e82cd2aeae | ||
|
6262cec27d | ||
|
a9347c7e03 | ||
|
60adcabd81 | ||
|
411cec08c7 | ||
|
b6fcf94191 | ||
|
e9ef632cce | ||
|
7d4c42a47c | ||
|
9ce6d54b80 | ||
|
2e96e4aea8 | ||
|
775ba53260 | ||
|
6e0af97574 | ||
|
531baa917e | ||
|
7f73f22759 | ||
|
0fad08ccc5 | ||
|
fcfc8df625 | ||
|
e54c1d2518 | ||
|
027e98d2de | ||
|
91227b0728 | ||
|
ddeca29f8e | ||
|
15d3371437 | ||
|
ac51c52c74 | ||
|
1148a23bb4 | ||
|
1ddd8bc669 | ||
|
7664215d23 | ||
|
9eb356bd43 | ||
|
d1b94ce2b0 | ||
|
d4b78a0e1b | ||
|
646d8f8d12 |
20
.github/workflows/doc-build.yaml
vendored
@ -4,13 +4,14 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
#- dev
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- uses: ammaraskar/sphinx-action@master
|
- uses: ammaraskar/sphinx-action@master
|
||||||
with:
|
with:
|
||||||
@ -21,6 +22,7 @@ jobs:
|
|||||||
pip install docutils==0.16
|
pip install docutils==0.16
|
||||||
pip install pygments==2.11.1
|
pip install pygments==2.11.1
|
||||||
pip install furo==2022.1.2
|
pip install furo==2022.1.2
|
||||||
|
pip install sphinx-copybutton
|
||||||
pip list
|
pip list
|
||||||
build-command: "sphinx-build -b html ./source ../docs"
|
build-command: "sphinx-build -b html ./source ../docs"
|
||||||
|
|
||||||
@ -38,9 +40,19 @@ jobs:
|
|||||||
git config --local user.name "GitHub Action"
|
git config --local user.name "GitHub Action"
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Update documentation" -a || true
|
git commit -m "Update documentation" -a || true
|
||||||
# git push https://${{secrets.token}}@github.com/mp-se/gravitymon.git
|
|
||||||
# The above command will fail if no changes were present, so we ignore
|
- uses: wangyucode/sftp-upload-action@v1.4.8
|
||||||
# the return code.
|
with:
|
||||||
|
host: ${{ secrets.SFTP_HOST }}
|
||||||
|
port: 22
|
||||||
|
username: ${{ secrets.SFTP_USER }}
|
||||||
|
password: ${{ secrets.SFTP_PASSWD }}
|
||||||
|
forceUpload: false
|
||||||
|
localDir: 'docs/'
|
||||||
|
remoteDir: '/run/www/docs/'
|
||||||
|
exclude: ''
|
||||||
|
dryRun: false
|
||||||
|
|
||||||
- name: Push changes
|
- name: Push changes
|
||||||
uses: ad-m/github-push-action@master
|
uses: ad-m/github-push-action@master
|
||||||
with:
|
with:
|
||||||
|
10
.github/workflows/pio-build-patch.yaml
vendored
@ -10,10 +10,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Cache pip
|
- name: Cache pip
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ~/.cache/pip
|
path: ~/.cache/pip
|
||||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
||||||
@ -21,13 +21,13 @@ jobs:
|
|||||||
${{ runner.os }}-pip-
|
${{ runner.os }}-pip-
|
||||||
|
|
||||||
- name: Cache PlatformIO
|
- name: Cache PlatformIO
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ~/.platformio
|
path: ~/.platformio
|
||||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v3
|
||||||
|
|
||||||
- name: Install PlatformIO
|
- name: Install PlatformIO
|
||||||
run: |
|
run: |
|
||||||
@ -38,7 +38,7 @@ jobs:
|
|||||||
- name: Run PlatformIO
|
- name: Run PlatformIO
|
||||||
run: pio run -e gravity-release
|
run: pio run -e gravity-release
|
||||||
|
|
||||||
- uses: EndBug/add-and-commit@v7 # You can change this to use a specific version. https://github.com/marketplace/actions/add-commit
|
- uses: EndBug/add-and-commit@v9 # You can change this to use a specific version. https://github.com/marketplace/actions/add-commit
|
||||||
with:
|
with:
|
||||||
add: 'bin'
|
add: 'bin'
|
||||||
author_name: GitHub Action
|
author_name: GitHub Action
|
||||||
|
10
.github/workflows/pio-build.yaml
vendored
@ -10,10 +10,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Cache pip
|
- name: Cache pip
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ~/.cache/pip
|
path: ~/.cache/pip
|
||||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
||||||
@ -21,7 +21,7 @@ jobs:
|
|||||||
${{ runner.os }}-pip-
|
${{ runner.os }}-pip-
|
||||||
|
|
||||||
- name: Cache PlatformIO
|
- name: Cache PlatformIO
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ~/.platformio
|
path: ~/.platformio
|
||||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||||
@ -36,9 +36,9 @@ jobs:
|
|||||||
git config --global advice.detachedHead false
|
git config --global advice.detachedHead false
|
||||||
|
|
||||||
- name: Run PlatformIO
|
- name: Run PlatformIO
|
||||||
run: pio run -e gravity-release -e gravity-perf -e gravity32-release -e gravity32-perf
|
run: pio run -e gravity-release -e gravity32-release -e gravity32c3-release -e gravity32s2-release -e gravity32c3v1-release -e gravity32lite-release
|
||||||
|
|
||||||
- uses: EndBug/add-and-commit@v7 # You can change this to use a specific version. https://github.com/marketplace/actions/add-commit
|
- uses: EndBug/add-and-commit@v9 # You can change this to use a specific version. https://github.com/marketplace/actions/add-commit
|
||||||
with:
|
with:
|
||||||
add: 'bin'
|
add: 'bin'
|
||||||
author_name: GitHub Action
|
author_name: GitHub Action
|
||||||
|
6
.github/workflows/pre-commit.yaml
vendored
@ -11,9 +11,9 @@ jobs:
|
|||||||
pre-commit:
|
pre-commit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-python@v2
|
- uses: actions/setup-python@v3
|
||||||
- name: clang format support
|
- name: clang format support
|
||||||
run: |
|
run: |
|
||||||
sudo apt install clang-format cppcheck
|
sudo apt install clang-format cppcheck
|
||||||
- uses: pre-commit/action@v2.0.3
|
- uses: pre-commit/action@v3.0.0
|
||||||
|
7
.gitignore
vendored
@ -1,9 +1,6 @@
|
|||||||
.pio/*
|
.pio/*
|
||||||
.vscode/*
|
.vscode/*
|
||||||
*.map
|
*.map
|
||||||
test/*.md
|
|
||||||
test/env/*
|
|
||||||
test/configure_*.py
|
|
||||||
TODO.md
|
|
||||||
src_docs/_build/*
|
src_docs/_build/*
|
||||||
data/*.min.htm
|
.env/*
|
||||||
|
*.pyc
|
48
README.md
@ -3,42 +3,30 @@
|
|||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
# Gravity Monitor for Beer Brewing
|
# Gravity Monitor for Beer Brewing
|
||||||
|
|
||||||
GravityMon is a replacement firmware for the iSpindle firmware. It's 100% compatible with the iSpindle hardware design so it does not require any hardware changes.
|

|
||||||
|
|
||||||
Now also works with ESP32 (use ESP32 d1 mini which is compatible with ESP8266)
|
GravityMon is a replacement firmware for the iSpindle firmware. It's 100% compatible with the iSpindle hardware design so it does not require any hardware changes. From v1.2 you can also use GravityMon for the DIY Floaty Hardware with ESP32 Lite.
|
||||||
|
|
||||||
Installation can be made using https://www.brewflasher.com or https://web.brewflasher.com
|
Now also works with ESP32 d1 mini, ESP32 c3 mini, ESP32 S2 mini which both are pin compatible with ESP8266.
|
||||||
|
|
||||||
The documenation can be found here: https://mp-se.github.io/gravitymon/index.html
|
Installation can be made using https://www.brewflasher.com or the web version at https://web.brewflasher.com
|
||||||
|
|
||||||
Note! If Brewflasher being flagged as malware by your antivirus software, try the web version.
|
The documentation can be found here: https://www.gravitymon.com/docs.html
|
||||||
|
|
||||||
The main differences:
|
Visit the gravitymon homepage here for more information about the project: https://www.gravitymon.com
|
||||||
---------------------
|
|
||||||
|
|
||||||
* Operates in two modes gravity monitoring and configuration mode
|
If you want to support my work you can do that through these options
|
||||||
* Gravity mode is comparable to how the iSpindle works when collectintg data
|
|
||||||
* Configuration mode has a modern HTML5 based web UI. No need to start the access point to change settings
|
[<img src="https://gravitymon.com/images/buymecoffee.png" height=40>](https://www.buymeacoffee.com/mpse/) [<img src="https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86" height=40>](https://github.com/sponsors/mp-se)
|
||||||
* Offloading some of the functionallity to run in the web browser, this allows for more advanced features.
|
|
||||||
* REST API to enable scripted configuration
|
# Supporters
|
||||||
* Send data to multiple endpoints and services at once (2xHTTP POST, HTTP GET, MQTT, INFLUXDB2)
|
|
||||||
* Directly test all endpoints from user interface with feedback to simplify troubleshooting
|
Thanks to the following persons for supporting me and this project:
|
||||||
* Complete format customization for all endpoints using templates (dont really need to change the software to support new services)
|
|
||||||
* Setup guides for how to send data to many popular services. Currently 10+ are documented
|
* David Conde, @davidconde
|
||||||
* Automatic temperature adjustment of gravity (just tick a checkbox)
|
* Lars H.
|
||||||
* OTA support from webserver
|
|
||||||
* Firmware update via web interface
|
|
||||||
* Built in function to create gravity formulas, no need for additional software, just enter tilt/gravity and let GravityMon creates a formula
|
|
||||||
* Visual graph showing how formula will be interpreted based on entered values
|
|
||||||
* Using the temperature sensor in gyro instead of DS18B20 (faster)
|
|
||||||
* SSL support in all endpoints (no certificate validation due to limitations on esp8266).
|
|
||||||
* Built in performance measurements (used to optimise code)
|
|
||||||
* Storage mode when placed on cap (indefinite sleep)
|
|
||||||
* Customize various hardware parameters to opimize device functionallity.
|
|
||||||
*
|
|
||||||
No code has been reused from the iSpindle project.
|
|
||||||
|
31
TEST.md
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# Unit testing - Python Script
|
||||||
|
|
||||||
|
I have moved my test scripts into this project now. They are mainly based on python scrips and validate the features from the API's.
|
||||||
|
|
||||||
|
Create a virtual environment and install the needed dependecies
|
||||||
|
```
|
||||||
|
python -m venv .env
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
Before you runt the script you need to update the IP adress to match the device that you have on your network.
|
||||||
|
|
||||||
|
Running the ALL tests
|
||||||
|
```
|
||||||
|
cd src/test
|
||||||
|
python3 -m unittest -v apitests.py -v
|
||||||
|
```
|
||||||
|
|
||||||
|
Running the ONE test
|
||||||
|
```
|
||||||
|
cd src/test
|
||||||
|
python3 -m unittest -v apitests.API.test_status -v
|
||||||
|
```
|
||||||
|
|
||||||
|
# Unit testing - Specific build
|
||||||
|
|
||||||
|
I've added a specific build that uses the AUnit (https://github.com/bxparks/AUnit) testing framework so that we can test functions or classes on the device itself. I hope this will simplify the release and testing cycle.
|
||||||
|
|
||||||
|
1. Select the build target (gravity-unit)
|
||||||
|
2. Build/upload the code to an iSpindle device.
|
||||||
|
3. Check the output from the serial console.
|
BIN
battery-test-1.2.xlsx
Normal file
@ -1 +0,0 @@
|
|||||||
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="description" content=""><title>Beer Gravity Monitor</title><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"><style>.row-margin-10{margin-top:1em}</style></head><body class="py-4"><!-- START MENU --><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script><nav class="navbar navbar-expand-lg navbar-dark bg-primary"><div class="container"><a class="navbar-brand" href="/index.htm">Beer Gravity Monitor</a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="navbarNav"><ul class="navbar-nav"><li class="nav-item"><a class="nav-link" href="/index.htm">Home</a></li><li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">Configuration</a><ul class="dropdown-menu"><li><a class="dropdown-item" href="/config.htm">Configuration</a></li><li><a class="dropdown-item" href="/format.htm">Format editor</a></li><li><a class="dropdown-item" href="/test.htm">Test push</a></li><li><a class="dropdown-item" href="/firmware.htm">Upload firmware</a></li></ul></li><li class="nav-item"><a class="nav-link" href="/calibration.htm">Calibration</a></li><li class="nav-item"><a class="nav-link active" href="#">About</a></li></ul></div><div class="spinner-border text-light" id="spinner" role="status"></div></div></nav><!-- START BODY --><div class="container row-margin-10"><div class="accordion row-margin-10" id="accordion"><div class="accordion-item"><h2 class="accordion-header" id="headingAbout"><button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseAbout" aria-expanded="true" aria-controls="collapseAbout"><b>About</b></button></h2><div id="collapseAbout" class="accordion-collapse collapse show" aria-labelledby="headingAbout" data-bs-parent="#accordion"><div class="accordion-body"><div class="row h3 col-sm-8">Beer Gravity Monitor</div><div class="row col-sm-8 mb-3">This is a piece of software for the iSpindle hardware and will work in a similar way. No part of this software is copied from the iSpindle project.</div><div class="row h3 col-sm-8 mb-3">MIT License</div><div class="row col-sm-8 mb-3">Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</div><div class="row h3 col-sm-8 mb-3">Credits to</div><div class="row col-sm-8 mb-3">This software uses the following libraries and without these this software would have been much more difficult to acheive:<br><br><ul><li>https://github.com/jrowberg/i2cdevlib</li><li>https://github.com/codeplea/tinyexpr</li><li>https://github.com/graphitemaster/incbin</li><li>https://github.com/khoih-prog/ESP_DoubleResetDetector</li><li>https://github.com/khoih-prog/ESP_WiFiManager</li><li>https://github.com/thijse/Arduino-Log</li><li>https://github.com/bblanchon/ArduinoJson</li><li>https://github.com/PaulStoffregen/OneWire</li><li>https://github.com/milesburton/Arduino-Temperature-Control-Library</li><li>https://github.com/Rotario</li><li>https://github.com/256dpi/arduino-mqtt</li><li>https://graphjs.com</li><li>https://getbootstrap.com</li><li>https://github.com/lorol/LITTLEFS</li><li>https://github.com/h2zero/NimBLE-Arduino</li><li>https://github.com/spouliot/tilt-sim</li></ul></div></div></div></div></div></div><!-- START FOOTER --><div class="container themed-container bg-primary text-light row-margin-10">(C) Copyright 2021-22 Magnus Persson</div></body></html>
|
|
BIN
bin/firmware.bin
BIN
bin/firmware32c3.bin
Normal file
BIN
bin/firmware32c3v1.bin
Normal file
BIN
bin/firmware32lite.bin
Normal file
BIN
bin/firmware32s2.bin
Normal file
BIN
bin/partitions32c3.bin
Normal file
BIN
bin/partitions32lite.bin
Normal file
BIN
bin/partitions32s2.bin
Normal file
@ -1 +1 @@
|
|||||||
{ "project":"gravmon", "version":"1.1.0", "html": [ ] }
|
{ "project":"gravmon", "version":"1.2.1", "html": [ ] }
|
@ -39,7 +39,7 @@
|
|||||||
<li><a class="dropdown-item" href="/firmware.htm">Upload firmware</a></li>
|
<li><a class="dropdown-item" href="/firmware.htm">Upload firmware</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="/calibration.htm">Calibration</a>
|
<a class="nav-link" href="/calibration.htm">Calibration</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
|
156
html/config.htm
@ -109,6 +109,10 @@
|
|||||||
<div id="collapseDevice" class="accordion-collapse collapse show" aria-labelledby="headingDevice" data-bs-parent="#accordion">
|
<div id="collapseDevice" class="accordion-collapse collapse show" aria-labelledby="headingDevice" data-bs-parent="#accordion">
|
||||||
<div class="accordion-body">
|
<div class="accordion-body">
|
||||||
|
|
||||||
|
<input type="text" name="runtime-average" id="runtime-average" hidden>
|
||||||
|
<input type="text" name="platform" id="platform" hidden>
|
||||||
|
<input type="text" name="voltage-factor-calc" id="voltage-factor-calc" hidden>
|
||||||
|
|
||||||
<form action="/api/config/device" method="post">
|
<form action="/api/config/device" method="post">
|
||||||
<input type="text" name="id" id="id1" hidden>
|
<input type="text" name="id" id="id1" hidden>
|
||||||
|
|
||||||
@ -152,6 +156,21 @@
|
|||||||
|
|
||||||
<hr class="my-2">
|
<hr class="my-2">
|
||||||
|
|
||||||
|
<div class="row mb-3">
|
||||||
|
<label class="col-sm-2 col-form-label">Wifi</label>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<label class="col-sm-4 col-form-label" id="wifi-ssid"></label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-3">
|
||||||
|
<label class="col-sm-2 col-form-label">Wifi 2</label>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<label class="col-sm-4 col-form-label" id="wifi-ssid2"></label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr class="my-2">
|
||||||
|
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<label for="calibrate-btn" class="col-sm-2 col-form-label">Current calibration</label>
|
<label for="calibrate-btn" class="col-sm-2 col-form-label">Current calibration</label>
|
||||||
<label for="calibrate-btn" class="col-sm-2 col-form-label" id="gyro-calibration-data">Loading...</label>
|
<label for="calibrate-btn" class="col-sm-2 col-form-label" id="gyro-calibration-data">Loading...</label>
|
||||||
@ -225,17 +244,11 @@
|
|||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-sm-8 offset-sm-2">
|
<div class="col-sm-8 offset-sm-2">
|
||||||
<button type="submit" class="btn btn-primary" id="push-btn" data-bs-toggle="tooltip" title="Save changes in this section">Save</button>
|
<button type="submit" class="btn btn-primary" id="push-btn" data-bs-toggle="tooltip" title="Save changes in this section">Save</button>
|
||||||
</div>
|
<button type="button" class="btn btn-secondary" id="format-btn" data-bs-toggle="tooltip" title="Open up the format editor to change data format posted">Format editor</button>
|
||||||
|
<button type="button" class="btn btn-secondary" id="test-btn" data-bs-toggle="tooltip" title="Test posting data to defined push targets">Test Push</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col-sm-8 offset-sm-2">
|
|
||||||
<button class="btn btn-secondary" id="format-btn" data-bs-toggle="tooltip" title="Open up the format editor to change data format posted">Format editor</button>
|
|
||||||
<button class="btn btn-secondary" id="test-btn" data-bs-toggle="tooltip" title="Test posting data to defined push targets">Test Push</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -314,17 +327,12 @@
|
|||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-sm-8 offset-sm-2">
|
<div class="col-sm-8 offset-sm-2">
|
||||||
<button type="submit" class="btn btn-primary" id="push-btn2" data-bs-toggle="tooltip" title="Save changes in this section">Save</button>
|
<button type="submit" class="btn btn-primary" id="push-btn2" data-bs-toggle="tooltip" title="Save changes in this section">Save</button>
|
||||||
</div>
|
<button type="button" class="btn btn-secondary" id="format-btn2" data-bs-toggle="tooltip" title="Open up the format editor to change data format posted">Format editor</button>
|
||||||
|
<button type="button" class="btn btn-secondary" id="test-btn2" data-bs-toggle="tooltip" title="Test posting data to defined push targets">Test Push</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col-sm-8 offset-sm-2">
|
|
||||||
<button class="btn btn-secondary" id="format-btn2" data-bs-toggle="tooltip" title="Open up the format editor to change data format posted">Format editor</button>
|
|
||||||
<button class="btn btn-secondary" id="test-btn2" data-bs-toggle="tooltip" title="Test posting data to defined push targets">Test Push</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -400,7 +408,15 @@
|
|||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
<input type="number" step=".01" class="form-control" name="voltage-factor" id="voltage-factor" placeholder="1.59" data-bs-toggle="tooltip" title="Factor used to calculate the battery voltage. Can vary depending on the R2 value">
|
<input type="number" step=".01" class="form-control" name="voltage-factor" id="voltage-factor" placeholder="1.59" data-bs-toggle="tooltip" title="Factor used to calculate the battery voltage. Can vary depending on the R2 value">
|
||||||
</div>
|
</div>
|
||||||
<label for="voltage-factor" class="col-sm-3 col-form-label" id="battery">Loading...</label>
|
<div class="col-sm-2">
|
||||||
|
<label for="voltage-factor" class="col-sm-3 col-form-label" id="battery">Loading...</label>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-1">
|
||||||
|
<button type="button" class="btn btn-secondary" id="volt-factor-btn" data-bs-toggle="tooltip" title="Calcualte the voltage factor based on measured battery voltage">Calculate</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<input type="number" step=".01" class="form-control" name="measured-voltage" id="measured-voltage" placeholder="" data-bs-toggle="tooltip" title="Enter the measured battery voltage to calcualte the factor">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
@ -452,23 +468,62 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row mb-3">
|
<div class="row mb-3" id="ota-hide">
|
||||||
<label for="ota-url" class="col-sm-2 col-form-label">OTA base URL</label>
|
<label for="ota-url" class="col-sm-2 col-form-label">OTA base URL</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input type="url" maxlength="90" class="form-control" name="ota-url" id="ota-url" placeholder="http://www.local.com/path/" data-bs-toggle="tooltip" title="Base URL to where firmware and version.json file can be found. Needs to end with '/', example: http://www.mysite.com/firmware/">
|
<input type="url" maxlength="90" class="form-control" name="ota-url" id="ota-url" placeholder="http://www.local.com/path/" data-bs-toggle="tooltip" title="Base URL to where firmware and version.json file can be found. Needs to end with '/', example: http://www.mysite.com/firmware/">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row mb-3">
|
||||||
|
<div class="col-sm-4 offset-sm-2">
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" name="gravitymon-com" id="gravitymon-com" data-bs-toggle="tooltip" title="If enabled gravitymon.com will be checked for new versions.">
|
||||||
|
<label class="form-check-label" for="gravitymon-com">OTA from gravitymon.com</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$("#volt-factor-btn").click(function(e) {
|
||||||
|
var f = $("#voltage-factor-calc").val();
|
||||||
|
var mv = parseFloat( $("#measured-voltage").val() );
|
||||||
|
|
||||||
|
if( isNaN(mv) ) {
|
||||||
|
showError("You need to enter a measured voltage in order to calculate the factor");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var vf = mv / f;
|
||||||
|
$("#voltage-factor").val( parseFloat(vf).toFixed(2) );
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var gravitymonUrl = "https://www.gravitymon.com/firmware/";
|
||||||
|
|
||||||
|
$("#gravitymon-com").click(function(e){
|
||||||
|
var b = $("#gravitymon-com").is(":checked");
|
||||||
|
|
||||||
|
if ( b ) {
|
||||||
|
$("#ota-url").val(gravitymonUrl);
|
||||||
|
$('#ota-hide').hide();
|
||||||
|
} else {
|
||||||
|
$('#ota-hide').show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-sm-8 offset-sm-2">
|
<div class="col-sm-8 offset-sm-2">
|
||||||
<button type="submit" class="btn btn-primary" id="hardware-btn" data-bs-toggle="tooltip" title="Save changes in this section">Save</button>
|
<button type="submit" class="btn btn-primary" id="hardware-btn" data-bs-toggle="tooltip" title="Save changes in this section">Save</button>
|
||||||
|
<button type="button" class="btn btn-secondary" id="firmware-btn" checked data-bs-toggle="tooltip" title="Manually upload a new firmware version to the device">Upload firmware</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-sm-8 offset-sm-2">
|
<div class="col-sm-8 offset-sm-2">
|
||||||
<button class="btn btn-secondary" id="firmware-btn" checked data-bs-toggle="tooltip" title="Manually upload a new firmware version to the device">Upload firmware</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -725,10 +780,40 @@
|
|||||||
// MPU-6050 consumes 4mA
|
// MPU-6050 consumes 4mA
|
||||||
// DS18B20 consumes 1mA
|
// DS18B20 consumes 1mA
|
||||||
// For this estimation we use an average of 160mA
|
// For this estimation we use an average of 160mA
|
||||||
|
var pwrActive = 160; // mA per hour (120-170 mA)
|
||||||
|
var pwrSleep = 15; // mA per day (include all pheripials as well)
|
||||||
|
var batt = 2200; // mA
|
||||||
|
var ble = false;
|
||||||
|
var wifi = true;
|
||||||
|
var platform = $("#platform").val();
|
||||||
|
|
||||||
var pwrActive = 170; // mA per hour
|
if($("#ble").val() != "")
|
||||||
var pwrSleep = 15; // mA per day
|
ble = true;
|
||||||
var batt = 2000; // mA
|
|
||||||
|
if($("#http-push").val() == "" && $("#http-push2").val() == "" && $("#http-push3").val() == "" && $("#influxdb2-push").val() == "" && $("#mqtt-push").val() == "")
|
||||||
|
wifi = false;
|
||||||
|
|
||||||
|
console.log( "Connection options: BLE=" + (ble?"on":"off") + " WIFI=" + (wifi?"on":"off") );
|
||||||
|
|
||||||
|
if(platform == "esp32" && wifi) {
|
||||||
|
var pwrActive = 320; // mA per hour (260-379 mA)
|
||||||
|
} else if(platform == "esp32" && !wifi) {
|
||||||
|
var pwrActive = 160;
|
||||||
|
} else if(platform == "esp32c3" && wifi) {
|
||||||
|
var pwrActive = 320; // mA per hour (290-350 mA)
|
||||||
|
} else if(platform == "esp32c3" && !wifi) {
|
||||||
|
var pwrActive = 160;
|
||||||
|
} else if(platform == "esp32s2" && wifi) {
|
||||||
|
var pwrActive = 280; // mA per hour (260-300 mA)
|
||||||
|
} else if(platform == "esp32s2" && !wifi) {
|
||||||
|
var pwrActive = 160;
|
||||||
|
} else if(platform == "esp32lite" && wifi) {
|
||||||
|
var pwrActive = 330; // mA per hour (260-379 mA)
|
||||||
|
} else if(platform == "esp32lite" && !wifi) {
|
||||||
|
var pwrActive = 160;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log( "Estimated power per hour = " + pwrActive.toString() + "mA on platform = " + platform);
|
||||||
|
|
||||||
if(rt<1) rt = 2;
|
if(rt<1) rt = 2;
|
||||||
|
|
||||||
@ -742,8 +827,11 @@
|
|||||||
var rt = parseInt($("#runtime-average").val());
|
var rt = parseInt($("#runtime-average").val());
|
||||||
var j = 0;
|
var j = 0;
|
||||||
|
|
||||||
if( rt>0 )
|
console.log("Average runtime " + $("#runtime-average").val() )
|
||||||
|
|
||||||
|
if( rt>0 ) {
|
||||||
j = estimateBatteryLife(i, rt);
|
j = estimateBatteryLife(i, rt);
|
||||||
|
}
|
||||||
|
|
||||||
var t1 = Math.floor(i/60) + " m " + (i%60) + " s";
|
var t1 = Math.floor(i/60) + " m " + (i%60) + " s";
|
||||||
var t2 = Math.floor(j/7) + " weeks " + Math.floor(j%7) + " days";
|
var t2 = Math.floor(j/7) + " weeks " + Math.floor(j%7) + " days";
|
||||||
@ -780,14 +868,14 @@
|
|||||||
$("#test-btn2").prop("disabled", b);
|
$("#test-btn2").prop("disabled", b);
|
||||||
$("#advanced-btn").prop("disabled", b);
|
$("#advanced-btn").prop("disabled", b);
|
||||||
|
|
||||||
checkAdvancedSection( b );
|
checkAdvancedSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#adv-config").click(function(e){
|
$("#adv-config").click(function(e){
|
||||||
checkAdvancedSection();
|
checkAdvancedSection();
|
||||||
});
|
});
|
||||||
|
|
||||||
function checkAdvancedSection( b ) {
|
function checkAdvancedSection() {
|
||||||
var b = $("#adv-config").is(":checked");
|
var b = $("#adv-config").is(":checked");
|
||||||
|
|
||||||
$("#advanced-btn").prop("disabled", b);
|
$("#advanced-btn").prop("disabled", b);
|
||||||
@ -854,11 +942,15 @@
|
|||||||
$.getJSON(url, function (cfg) {
|
$.getJSON(url, function (cfg) {
|
||||||
console.log( cfg );
|
console.log( cfg );
|
||||||
|
|
||||||
if(cfg["platform"]=="esp32") {
|
if(cfg["platform"]=="esp32" || cfg["platform"]=="esp32c3" || cfg["platform"]=="esp32lite") {
|
||||||
$('#ble').prop('disabled', false);
|
$('#ble').prop('disabled', false);
|
||||||
$("#ble").val(cfg["ble"]);
|
$("#ble").val(cfg["ble"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(cfg["platform"]=="esp32lite") {
|
||||||
|
$('#gyro-temp').prop('disabled', true);
|
||||||
|
}
|
||||||
|
|
||||||
$("#id1").val(cfg["id"]);
|
$("#id1").val(cfg["id"]);
|
||||||
$("#id2").val(cfg["id"]);
|
$("#id2").val(cfg["id"]);
|
||||||
$("#id3").val(cfg["id"]);
|
$("#id3").val(cfg["id"]);
|
||||||
@ -871,6 +963,12 @@
|
|||||||
if( cfg["gravity-format"] == "G" ) $("#gravity-format-g").click();
|
if( cfg["gravity-format"] == "G" ) $("#gravity-format-g").click();
|
||||||
else $("#gravity-format-p").click();
|
else $("#gravity-format-p").click();
|
||||||
$("#ota-url").val(cfg["ota-url"]);
|
$("#ota-url").val(cfg["ota-url"]);
|
||||||
|
|
||||||
|
if( cfg["ota-url"] == gravitymonUrl) {
|
||||||
|
$("#gravitymon-com").prop( "checked", true );
|
||||||
|
$("#ota-hide").hide();
|
||||||
|
}
|
||||||
|
|
||||||
$("#token").val(cfg["token"]);
|
$("#token").val(cfg["token"]);
|
||||||
$("#token2").val(cfg["token2"]);
|
$("#token2").val(cfg["token2"]);
|
||||||
$("#http-push").val(cfg["http-push"]);
|
$("#http-push").val(cfg["http-push"]);
|
||||||
@ -901,6 +999,10 @@
|
|||||||
$("#angle").text(cfg["angle"]);
|
$("#angle").text(cfg["angle"]);
|
||||||
$("#runtime-average").val(cfg["runtime-average"]);
|
$("#runtime-average").val(cfg["runtime-average"]);
|
||||||
$("#water-angle").text( "(Water angle: " + cfg["formula-calculation-data"]["a1"] + ") - default off");
|
$("#water-angle").text( "(Water angle: " + cfg["formula-calculation-data"]["a1"] + ") - default off");
|
||||||
|
$("#wifi-ssid").text(cfg["wifi-ssid"]);
|
||||||
|
$("#wifi-ssid2").text(cfg["wifi-ssid2"]);
|
||||||
|
$("#platform").val(cfg["platform"]);
|
||||||
|
$("#voltage-factor-calc").val( cfg["battery"] / cfg["voltage-factor"] );
|
||||||
//$("#gravity").text(cfg["gravity"] + " SG");
|
//$("#gravity").text(cfg["gravity"] + " SG");
|
||||||
})
|
})
|
||||||
.fail(function () {
|
.fail(function () {
|
||||||
|
@ -90,7 +90,7 @@
|
|||||||
|
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<button class="btn btn-primary" id="test-btn" data-bs-toggle="tooltip" title="Test all push targets">Test</button>
|
<button type="button" class="btn btn-primary" id="test-btn" data-bs-toggle="tooltip" title="Test all push targets">Test</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
179
html/upload.htm
@ -1,179 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
||||||
<meta name="description" content="">
|
|
||||||
<title>Beer Gravity Monitor</title>
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
|
|
||||||
<style>
|
|
||||||
.row-margin-10 { margin-top: 1.0em; }
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body class="py-4">
|
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
|
|
||||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
|
||||||
|
|
||||||
<!-- START MENU -->
|
|
||||||
|
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
|
||||||
<div class="container">
|
|
||||||
<a class="navbar-brand" href="/index.htm">Beer Gravity Monitor</a>
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="spinner-border text-light" id="spinner" role="status"></div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<!-- START MAIN INDEX -->
|
|
||||||
|
|
||||||
<div class="container row-margin-10">
|
|
||||||
|
|
||||||
<div class="alert alert-success alert-dismissible hide fade d-none" role="alert">
|
|
||||||
<div id="alert"></div>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
function showError( msg ) {
|
|
||||||
$('.alert').removeClass('alert-success').addClass('alert-danger').removeClass('hide').addClass('show').removeClass('d-none');
|
|
||||||
$('#alert').text( msg );
|
|
||||||
}
|
|
||||||
|
|
||||||
function showSuccess( msg ) {
|
|
||||||
$('.alert').addClass('alert-success').removeClass('alert-danger').removeClass('hide').addClass('show').removeClass('d-none');
|
|
||||||
$('#alert').text( msg );
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#alert-btn").click(function(e){
|
|
||||||
$('.alert').addClass('hide').removeClass('show').addClass('d-none');
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="accordion" id="accordion">
|
|
||||||
<div class="accordion-item">
|
|
||||||
<h2 class="accordion-header" id="headingUpload">
|
|
||||||
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseUpload" aria-expanded="true" aria-controls="collapseUpload">
|
|
||||||
<b>Upload missing html files</b>
|
|
||||||
</button>
|
|
||||||
</h2>
|
|
||||||
<div id="collapseUpload" class="accordion-collapse collapse show" aria-labelledby="headingUpload" data-bs-parent="#accordion">
|
|
||||||
<div class="accordion-body">
|
|
||||||
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col-md-8 bg-light">The listed files below needs to be uploaded to the FileSystem in order for the GUI to work.
|
|
||||||
You can also flash the LittleFS filesystem but in that case you will loose your device settings. An OTA upgrade will automatically download
|
|
||||||
the files if they are found in the same location as the firmware.bin. This page is a fallback option.
|
|
||||||
</div>
|
|
||||||
<div class="col-md-8 bg-light"><br><strong>Once all the files are confirmed, please reboot the device for normal operation.</strong></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col-md-2 bg-light">index.min.htm</div>
|
|
||||||
<div class="col-md-6 bg-light" id="index">Checking...</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col-md-2 bg-light">config.min.htm</div>
|
|
||||||
<div class="col-md-6 bg-light" id="config">Checking...</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col-md-2 bg-light">calibration.min.htm</div>
|
|
||||||
<div class="col-md-6 bg-light" id="calibration">Checking...</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col-md-2 bg-light">format.min.htm</div>
|
|
||||||
<div class="col-md-6 bg-light" id="format">Checking...</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col-md-2 bg-light">test.min.htm</div>
|
|
||||||
<div class="col-md-6 bg-light" id="test">Checking...</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col-md-2 bg-light">about.min.htm</div>
|
|
||||||
<div class="col-md-6 bg-light" id="about">Checking...</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<form action="/api/upload" method="post" enctype="multipart/form-data">
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col-md-8 custom-file">
|
|
||||||
<input type="file" accept=".min.htm" class="custom-file-input" name="name" id="name" data-bs-toggle="tooltip" title="Select a file that matches the name in the list above to upload it to the device">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col-md-3">
|
|
||||||
<button type="submit" class="btn btn-primary" id="upload-btn" value="upload" data-bs-toggle="tooltip" title="Upload the selected file to the device">Upload</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
window.onload = getUpload;
|
|
||||||
|
|
||||||
// Add the following code if you want the name of the file appear on select
|
|
||||||
$(".custom-file-input").on("change", function() {
|
|
||||||
var fileName = $(this).val().split("\\").pop();
|
|
||||||
$(this).siblings(".custom-file-label").addClass("selected").html(fileName);
|
|
||||||
});
|
|
||||||
|
|
||||||
function getUpload() {
|
|
||||||
var url = "/api/upload";
|
|
||||||
//var url = "/test/upload.json";
|
|
||||||
$('#spinner').show();
|
|
||||||
$.getJSON(url, function (cfg) {
|
|
||||||
console.log( cfg );
|
|
||||||
|
|
||||||
if( cfg["index"] )
|
|
||||||
$("#index").text("Completed.");
|
|
||||||
else
|
|
||||||
$("#index").text("File is missing.");
|
|
||||||
|
|
||||||
if( cfg["config"] )
|
|
||||||
$("#config").text("Completed.");
|
|
||||||
else
|
|
||||||
$("#config").text("File is missing.");
|
|
||||||
|
|
||||||
if( cfg["calibration"] )
|
|
||||||
$("#calibration").text("Completed.");
|
|
||||||
else
|
|
||||||
$("#calibration").text("File is missing.");
|
|
||||||
|
|
||||||
if( cfg["test"] )
|
|
||||||
$("#test").text("Completed.");
|
|
||||||
else
|
|
||||||
$("#test").text("File is missing.");
|
|
||||||
|
|
||||||
if( cfg["format"] )
|
|
||||||
$("#format").text("Completed.");
|
|
||||||
else
|
|
||||||
$("#format").text("File is missing.");
|
|
||||||
|
|
||||||
if( cfg["about"] )
|
|
||||||
$("#about").text("Completed.");
|
|
||||||
else
|
|
||||||
$("#about").text("File is missing.");
|
|
||||||
|
|
||||||
|
|
||||||
})
|
|
||||||
.fail(function () {
|
|
||||||
showError('Unable to get data from the device.');
|
|
||||||
})
|
|
||||||
.always(function() {
|
|
||||||
$('#spinner').hide();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<!-- START FOOTER -->
|
|
||||||
|
|
||||||
<div class="container themed-container bg-primary text-light row-margin-10">(C) Copyright 2021-22 Magnus Persson</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
Built by Khoi Hoang https://github.com/khoih-prog/ESP_DoubleResetDetector
|
Built by Khoi Hoang https://github.com/khoih-prog/ESP_DoubleResetDetector
|
||||||
Licensed under MIT license
|
Licensed under MIT license
|
||||||
Version: 1.3.1
|
Version: 1.3.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -24,6 +24,7 @@
|
|||||||
1.2.1 K Hoang 26/11/2021 Fix compile error for ESP32 core v1.0.5-
|
1.2.1 K Hoang 26/11/2021 Fix compile error for ESP32 core v1.0.5-
|
||||||
1.3.0 K Hoang 10/02/2022 Add support to new ESP32-S3
|
1.3.0 K Hoang 10/02/2022 Add support to new ESP32-S3
|
||||||
1.3.1 K Hoang 04/03/2022 Add waitingForDRD() function to signal in DRD wating period
|
1.3.1 K Hoang 04/03/2022 Add waitingForDRD() function to signal in DRD wating period
|
||||||
|
1.3.2 K Hoang 09/09/2022 Fix ESP32 chipID for example ConfigOnDoubleReset
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -42,13 +43,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ESP_DOUBLE_RESET_DETECTOR_VERSION
|
#ifndef ESP_DOUBLE_RESET_DETECTOR_VERSION
|
||||||
#define ESP_DOUBLE_RESET_DETECTOR_VERSION "ESP_DoubleResetDetector v1.3.1"
|
#define ESP_DOUBLE_RESET_DETECTOR_VERSION "ESP_DoubleResetDetector v1.3.2"
|
||||||
|
|
||||||
#define ESP_DOUBLE_RESET_DETECTOR_VERSION_MAJOR 1
|
#define ESP_DOUBLE_RESET_DETECTOR_VERSION_MAJOR 1
|
||||||
#define ESP_DOUBLE_RESET_DETECTOR_VERSION_MINOR 3
|
#define ESP_DOUBLE_RESET_DETECTOR_VERSION_MINOR 3
|
||||||
#define ESP_DOUBLE_RESET_DETECTOR_VERSION_PATCH 1
|
#define ESP_DOUBLE_RESET_DETECTOR_VERSION_PATCH 2
|
||||||
|
|
||||||
#define ESP_DOUBLE_RESET_DETECTOR_VERSION_INT 1003001
|
#define ESP_DOUBLE_RESET_DETECTOR_VERSION_INT 1003002
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ESP_DOUBLERESETDETECTOR_VERSION ESP_DOUBLE_RESET_DETECTOR_VERSION
|
#define ESP_DOUBLERESETDETECTOR_VERSION ESP_DOUBLE_RESET_DETECTOR_VERSION
|
||||||
|
@ -16,47 +16,18 @@
|
|||||||
Built by Khoi Hoang https://github.com/khoih-prog/ESP_WiFiManager
|
Built by Khoi Hoang https://github.com/khoih-prog/ESP_WiFiManager
|
||||||
Licensed under MIT license
|
Licensed under MIT license
|
||||||
|
|
||||||
Version: 1.8.0
|
Version: 1.11.0
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
1.0.0 K Hoang 07/10/2019 Initial coding
|
1.0.0 K Hoang 07/10/2019 Initial coding
|
||||||
1.0.1 K Hoang 13/12/2019 Fix bug. Add features. Add support for ESP32
|
...
|
||||||
1.0.2 K Hoang 19/12/2019 Fix bug thatkeeps ConfigPortal in endless loop if Portal/Router SSID or Password is NULL.
|
1.8.0 K Hoang 29/12/2021 Fix `multiple-definitions` linker error and weird bug related to src_cpp
|
||||||
1.0.3 K Hoang 05/01/2020 Option not displaying AvailablePages in Info page. Enhance README.md. Modify examples
|
1.9.0 K Hoang 17/01/2022 Enable compatibility with old code to include only ESP_WiFiManager.h
|
||||||
1.0.4 K Hoang 07/01/2020 Add RFC952 setHostname feature.
|
1.10.0 K Hoang 10/02/2022 Add support to new ESP32-S3
|
||||||
1.0.5 K Hoang 15/01/2020 Add configurable DNS feature. Thanks to @Amorphous of https://community.blynk.cc
|
1.10.1 K Hoang 11/02/2022 Add LittleFS support to ESP32-C3. Use core LittleFS instead of Lorol's LITTLEFS for v2.0.0+
|
||||||
1.0.6 K Hoang 03/02/2020 Add support for ArduinoJson version 6.0.0+ ( tested with v6.14.1 )
|
1.10.2 K Hoang 13/03/2022 Send CORS header in handleWifiSave() function
|
||||||
1.0.7 K Hoang 13/04/2020 Reduce start time, fix SPIFFS bug in examples, update README.md
|
1.11.0 K Hoang 09/09/2022 Fix ESP32 chipID and add ESP_getChipOUI()
|
||||||
1.0.8 K Hoang 10/06/2020 Fix STAstaticIP issue. Restructure code. Add LittleFS support for ESP8266 core 2.7.1+
|
|
||||||
1.0.9 K Hoang 29/07/2020 Fix ESP32 STAstaticIP bug. Permit changing from DHCP <-> static IP using Config Portal.
|
|
||||||
Add, enhance examples (fix MDNS for ESP32)
|
|
||||||
1.0.10 K Hoang 08/08/2020 Add more features to Config Portal. Use random WiFi AP channel to avoid conflict.
|
|
||||||
1.0.11 K Hoang 17/08/2020 Add CORS feature. Fix bug in softAP, autoConnect, resetSettings.
|
|
||||||
1.1.0 K Hoang 28/08/2020 Add MultiWiFi feature to autoconnect to best WiFi at runtime
|
|
||||||
1.1.1 K Hoang 30/08/2020 Add setCORSHeader function to allow flexible CORS. Fix typo and minor improvement.
|
|
||||||
1.1.2 K Hoang 17/08/2020 Fix bug. Add example.
|
|
||||||
1.2.0 K Hoang 09/10/2020 Restore cpp code besides Impl.h code to use if linker error. Fix bug.
|
|
||||||
1.3.0 K Hoang 04/12/2020 Add LittleFS support to ESP32 using LITTLEFS Library
|
|
||||||
1.4.1 K Hoang 22/12/2020 Fix staticIP not saved. Add functions. Add complex examples. Sync with ESPAsync_WiFiManager
|
|
||||||
1.4.2 K Hoang 14/01/2021 Fix examples' bug not using saved WiFi Credentials after losing all WiFi connections.
|
|
||||||
1.4.3 K Hoang 23/01/2021 Fix examples' bug not saving Static IP in certain cases.
|
|
||||||
1.5.0 K Hoang 12/02/2021 Add support to new ESP32-S2
|
|
||||||
1.5.1 K Hoang 26/03/2021 Fix compiler error if setting Compiler Warnings to All. Retest with esp32 core v1.0.6
|
|
||||||
1.5.2 K Hoang 08/04/2021 Fix example misleading messages.
|
|
||||||
1.5.3 K Hoang 13/04/2021 Add dnsServer error message.
|
|
||||||
1.6.0 K Hoang 20/04/2021 Add support to new ESP32-C3 using SPIFFS or EEPROM
|
|
||||||
1.6.1 K Hoang 25/04/2021 Fix MultiWiFi bug. Fix captive-portal bug if CP AP address is not default 192.168.4.1
|
|
||||||
1.7.0 K Hoang 06/05/2021 Set _timezoneName. Add support to new ESP32-S2 (METRO_ESP32S2, FUNHOUSE_ESP32S2, etc.)
|
|
||||||
1.7.1 K Hoang 08/05/2021 Fix Json bug. Fix timezoneName not displayed in Info page.
|
|
||||||
1.7.2 K Hoang 08/05/2021 Fix warnings with ESP8266 core v3.0.0
|
|
||||||
1.7.3 K Hoang 29/07/2021 Fix MultiWiFi connection issue with ESP32 core v2.0.0-rc1+
|
|
||||||
1.7.4 K Hoang 13/08/2021 Add WiFi scanning of hidden SSIDs
|
|
||||||
1.7.5 K Hoang 10/10/2021 Update `platform.ini` and `library.json`
|
|
||||||
1.7.6 K Hoang 26/11/2021 Auto detect ESP32 core and use either built-in LittleFS or LITTLEFS library
|
|
||||||
1.7.7 K Hoang 26/11/2021 Fix compile error for ESP32 core v1.0.5-
|
|
||||||
1.7.8 K Hoang 30/11/2021 Fix bug to permit using HTTP port different from 80. Fix bug
|
|
||||||
1.8.0 K Hoang 29/12/2021 Enable compatibility with old code to include only ESP_WiFiManager.h
|
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -80,7 +51,7 @@ ESP_WMParameter::ESP_WMParameter(const char *custom)
|
|||||||
|
|
||||||
//////////////////////////////////////////
|
//////////////////////////////////////////
|
||||||
|
|
||||||
ESP_WMParameter::ESP_WMParameter(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom, int labelPlacement)
|
ESP_WMParameter::ESP_WMParameter(const char *id, const char *placeholder, const char *defaultValue, const int& length, const char *custom, const int& labelPlacement)
|
||||||
{
|
{
|
||||||
init(id, placeholder, defaultValue, length, custom, labelPlacement);
|
init(id, placeholder, defaultValue, length, custom, labelPlacement);
|
||||||
}
|
}
|
||||||
@ -94,7 +65,7 @@ ESP_WMParameter::ESP_WMParameter(const WMParam_Data& WMParam_data)
|
|||||||
//////
|
//////
|
||||||
//////////////////////////////////////////
|
//////////////////////////////////////////
|
||||||
|
|
||||||
void ESP_WMParameter::init(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom, int labelPlacement)
|
void ESP_WMParameter::init(const char *id, const char *placeholder, const char *defaultValue, const int& length, const char *custom, const int& labelPlacement)
|
||||||
{
|
{
|
||||||
_WMParam_data._id = id;
|
_WMParam_data._id = id;
|
||||||
_WMParam_data._placeholder = placeholder;
|
_WMParam_data._placeholder = placeholder;
|
||||||
@ -252,7 +223,8 @@ ESP_WiFiManager::ESP_WiFiManager(const char *iHostname)
|
|||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
String _hostname = "ESP8266-" + String(ESP.getChipId(), HEX);
|
String _hostname = "ESP8266-" + String(ESP.getChipId(), HEX);
|
||||||
#else //ESP32
|
#else //ESP32
|
||||||
String _hostname = "ESP32-" + String((uint32_t)ESP.getEfuseMac(), HEX);
|
String _hostname = "ESP32-" + String(ESP_getChipId(), HEX);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
_hostname.toUpperCase();
|
_hostname.toUpperCase();
|
||||||
|
|
||||||
@ -461,7 +433,8 @@ bool ESP_WiFiManager::autoConnect()
|
|||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
String ssid = "ESP_" + String(ESP.getChipId());
|
String ssid = "ESP_" + String(ESP.getChipId());
|
||||||
#else //ESP32
|
#else //ESP32
|
||||||
String ssid = "ESP_" + String((uint32_t)ESP.getEfuseMac());
|
String ssid = "ESP_" + String(ESP_getChipId());
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return autoConnect(ssid.c_str(), NULL);
|
return autoConnect(ssid.c_str(), NULL);
|
||||||
@ -522,7 +495,7 @@ bool ESP_WiFiManager::startConfigPortal()
|
|||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
String ssid = "ESP_" + String(ESP.getChipId());
|
String ssid = "ESP_" + String(ESP.getChipId());
|
||||||
#else //ESP32
|
#else //ESP32
|
||||||
String ssid = "ESP_" + String((uint32_t)ESP.getEfuseMac());
|
String ssid = "ESP_" + String(ESP_getChipId());
|
||||||
#endif
|
#endif
|
||||||
ssid.toUpperCase();
|
ssid.toUpperCase();
|
||||||
|
|
||||||
@ -864,7 +837,7 @@ void ESP_WiFiManager::startWPS()
|
|||||||
|
|
||||||
//Convenient for debugging but wasteful of program space.
|
//Convenient for debugging but wasteful of program space.
|
||||||
//Remove if short of space
|
//Remove if short of space
|
||||||
const char* ESP_WiFiManager::getStatus(int status)
|
const char* ESP_WiFiManager::getStatus(const int& status)
|
||||||
{
|
{
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
@ -920,21 +893,21 @@ void ESP_WiFiManager::resetSettings()
|
|||||||
|
|
||||||
//////////////////////////////////////////
|
//////////////////////////////////////////
|
||||||
|
|
||||||
void ESP_WiFiManager::setTimeout(unsigned long seconds)
|
void ESP_WiFiManager::setTimeout(const unsigned long& seconds)
|
||||||
{
|
{
|
||||||
setConfigPortalTimeout(seconds);
|
setConfigPortalTimeout(seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////
|
//////////////////////////////////////////
|
||||||
|
|
||||||
void ESP_WiFiManager::setConfigPortalTimeout(unsigned long seconds)
|
void ESP_WiFiManager::setConfigPortalTimeout(const unsigned long& seconds)
|
||||||
{
|
{
|
||||||
_configPortalTimeout = seconds * 1000;
|
_configPortalTimeout = seconds * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////
|
//////////////////////////////////////////
|
||||||
|
|
||||||
void ESP_WiFiManager::setConnectTimeout(unsigned long seconds)
|
void ESP_WiFiManager::setConnectTimeout(const unsigned long& seconds)
|
||||||
{
|
{
|
||||||
_connectTimeout = seconds * 1000;
|
_connectTimeout = seconds * 1000;
|
||||||
}
|
}
|
||||||
@ -949,7 +922,7 @@ void ESP_WiFiManager::setDebugOutput(bool debug)
|
|||||||
//////////////////////////////////////////
|
//////////////////////////////////////////
|
||||||
|
|
||||||
// KH, new from v1.0.10 to enable dynamic/random channel
|
// KH, new from v1.0.10 to enable dynamic/random channel
|
||||||
int ESP_WiFiManager::setConfigPortalChannel(int channel)
|
int ESP_WiFiManager::setConfigPortalChannel(const int& channel)
|
||||||
{
|
{
|
||||||
// If channel < MIN_WIFI_CHANNEL - 1 or channel > MAX_WIFI_CHANNEL => channel = 1
|
// If channel < MIN_WIFI_CHANNEL - 1 or channel > MAX_WIFI_CHANNEL => channel = 1
|
||||||
// If channel == 0 => will use random channel from MIN_WIFI_CHANNEL to MAX_WIFI_CHANNEL
|
// If channel == 0 => will use random channel from MIN_WIFI_CHANNEL to MAX_WIFI_CHANNEL
|
||||||
@ -1037,7 +1010,7 @@ void ESP_WiFiManager::setSTAStaticIPConfig(const IPAddress& ip, const IPAddress&
|
|||||||
|
|
||||||
//////////////////////////////////////////
|
//////////////////////////////////////////
|
||||||
|
|
||||||
void ESP_WiFiManager::setMinimumSignalQuality(int quality)
|
void ESP_WiFiManager::setMinimumSignalQuality(const int& quality)
|
||||||
{
|
{
|
||||||
_minimumQuality = quality;
|
_minimumQuality = quality;
|
||||||
}
|
}
|
||||||
@ -1393,6 +1366,11 @@ void ESP_WiFiManager::handleWifiSave()
|
|||||||
|
|
||||||
///////////////////////
|
///////////////////////
|
||||||
|
|
||||||
|
#if USING_CORS_FEATURE
|
||||||
|
// New from v1.10.2, for configure CORS Header, default to WM_HTTP_CORS_ALLOW_ALL = "*"
|
||||||
|
server->sendHeader(FPSTR(WM_HTTP_CORS), _CORS_Header);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if USE_ESP_WIFIMANAGER_NTP
|
#if USE_ESP_WIFIMANAGER_NTP
|
||||||
|
|
||||||
if (server->arg("timezone") != "")
|
if (server->arg("timezone") != "")
|
||||||
@ -1584,10 +1562,23 @@ void ESP_WiFiManager::handleInfo()
|
|||||||
page += F("<table class=\"table\">");
|
page += F("<table class=\"table\">");
|
||||||
page += F("<thead><tr><th>Name</th><th>Value</th></tr></thead><tbody><tr><td>Chip ID</td><td>");
|
page += F("<thead><tr><th>Name</th><th>Value</th></tr></thead><tbody><tr><td>Chip ID</td><td>");
|
||||||
|
|
||||||
|
page += F("0x");
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
page += String(ESP.getChipId(), HEX); //ESP.getChipId();
|
page += String(ESP.getChipId(), HEX); //ESP.getChipId();
|
||||||
#else //ESP32
|
#else //ESP32
|
||||||
page += String((uint32_t)ESP.getEfuseMac(), HEX); //ESP.getChipId();
|
|
||||||
|
page += String(ESP_getChipId(), HEX); //ESP.getChipId();
|
||||||
|
|
||||||
|
page += F("</td></tr>");
|
||||||
|
page += F("<tr><td>Chip OUI</td><td>");
|
||||||
|
page += F("0x");
|
||||||
|
page += String(getChipOUI(), HEX); //ESP.getChipId();
|
||||||
|
|
||||||
|
page += F("</td></tr>");
|
||||||
|
page += F("<tr><td>Chip Model</td><td>");
|
||||||
|
page += ESP.getChipModel();
|
||||||
|
page += F(" Rev");
|
||||||
|
page += ESP.getChipRevision();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
page += F("</td></tr>");
|
page += F("</td></tr>");
|
||||||
@ -2019,7 +2010,7 @@ int ESP_WiFiManager::scanWifiNetworks(int **indicesptr)
|
|||||||
|
|
||||||
//////////////////////////////////////////
|
//////////////////////////////////////////
|
||||||
|
|
||||||
int ESP_WiFiManager::getRSSIasQuality(int RSSI)
|
int ESP_WiFiManager::getRSSIasQuality(const int& RSSI)
|
||||||
{
|
{
|
||||||
int quality = 0;
|
int quality = 0;
|
||||||
|
|
||||||
@ -2116,6 +2107,31 @@ String ESP_WiFiManager::getStoredWiFiPass()
|
|||||||
|
|
||||||
return String(reinterpret_cast<char*>(conf.sta.password));
|
return String(reinterpret_cast<char*>(conf.sta.password));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t getChipID()
|
||||||
|
{
|
||||||
|
uint64_t chipId64 = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
chipId64 |= ( ( (uint64_t) ESP.getEfuseMac() >> (40 - (i * 8)) ) & 0xff ) << (i * 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (uint32_t) (chipId64 & 0xFFFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t getChipOUI()
|
||||||
|
{
|
||||||
|
uint64_t chipId64 = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
chipId64 |= ( ( (uint64_t) ESP.getEfuseMac() >> (40 - (i * 8)) ) & 0xff ) << (i * 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (uint32_t) (chipId64 >> 24);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,48 +16,18 @@
|
|||||||
Built by Khoi Hoang https://github.com/khoih-prog/ESP_WiFiManager
|
Built by Khoi Hoang https://github.com/khoih-prog/ESP_WiFiManager
|
||||||
Licensed under MIT license
|
Licensed under MIT license
|
||||||
|
|
||||||
Version: 1.9.0
|
Version: 1.11.0
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
1.0.0 K Hoang 07/10/2019 Initial coding
|
1.0.0 K Hoang 07/10/2019 Initial coding
|
||||||
1.0.1 K Hoang 13/12/2019 Fix bug. Add features. Add support for ESP32
|
...
|
||||||
1.0.2 K Hoang 19/12/2019 Fix bug thatkeeps ConfigPortal in endless loop if Portal/Router SSID or Password is NULL.
|
|
||||||
1.0.3 K Hoang 05/01/2020 Option not displaying AvailablePages in Info page. Enhance README.md. Modify examples
|
|
||||||
1.0.4 K Hoang 07/01/2020 Add RFC952 setHostname feature.
|
|
||||||
1.0.5 K Hoang 15/01/2020 Add configurable DNS feature. Thanks to @Amorphous of https://community.blynk.cc
|
|
||||||
1.0.6 K Hoang 03/02/2020 Add support for ArduinoJson version 6.0.0+ ( tested with v6.14.1 )
|
|
||||||
1.0.7 K Hoang 13/04/2020 Reduce start time, fix SPIFFS bug in examples, update README.md
|
|
||||||
1.0.8 K Hoang 10/06/2020 Fix STAstaticIP issue. Restructure code. Add LittleFS support for ESP8266 core 2.7.1+
|
|
||||||
1.0.9 K Hoang 29/07/2020 Fix ESP32 STAstaticIP bug. Permit changing from DHCP <-> static IP using Config Portal.
|
|
||||||
Add, enhance examples (fix MDNS for ESP32)
|
|
||||||
1.0.10 K Hoang 08/08/2020 Add more features to Config Portal. Use random WiFi AP channel to avoid conflict.
|
|
||||||
1.0.11 K Hoang 17/08/2020 Add CORS feature. Fix bug in softAP, autoConnect, resetSettings.
|
|
||||||
1.1.0 K Hoang 28/08/2020 Add MultiWiFi feature to autoconnect to best WiFi at runtime
|
|
||||||
1.1.1 K Hoang 30/08/2020 Add setCORSHeader function to allow flexible CORS. Fix typo and minor improvement.
|
|
||||||
1.1.2 K Hoang 17/08/2020 Fix bug. Add example.
|
|
||||||
1.2.0 K Hoang 09/10/2020 Restore cpp code besides Impl.h code to use if linker error. Fix bug.
|
|
||||||
1.3.0 K Hoang 04/12/2020 Add LittleFS support to ESP32 using LITTLEFS Library
|
|
||||||
1.4.1 K Hoang 22/12/2020 Fix staticIP not saved. Add functions. Add complex examples. Sync with ESPAsync_WiFiManager
|
|
||||||
1.4.2 K Hoang 14/01/2021 Fix examples' bug not using saved WiFi Credentials after losing all WiFi connections.
|
|
||||||
1.4.3 K Hoang 23/01/2021 Fix examples' bug not saving Static IP in certain cases.
|
|
||||||
1.5.0 K Hoang 12/02/2021 Add support to new ESP32-S2
|
|
||||||
1.5.1 K Hoang 26/03/2021 Fix compiler error if setting Compiler Warnings to All. Retest with esp32 core v1.0.6
|
|
||||||
1.5.2 K Hoang 08/04/2021 Fix example misleading messages.
|
|
||||||
1.5.3 K Hoang 13/04/2021 Add dnsServer error message.
|
|
||||||
1.6.0 K Hoang 20/04/2021 Add support to new ESP32-C3 using SPIFFS or EEPROM
|
|
||||||
1.6.1 K Hoang 25/04/2021 Fix MultiWiFi bug. Fix captive-portal bug if CP AP address is not default 192.168.4.1
|
|
||||||
1.7.0 K Hoang 06/05/2021 Set _timezoneName. Add support to new ESP32-S2 (METRO_ESP32S2, FUNHOUSE_ESP32S2, etc.)
|
|
||||||
1.7.1 K Hoang 08/05/2021 Fix Json bug. Fix timezoneName not displayed in Info page.
|
|
||||||
1.7.2 K Hoang 08/05/2021 Fix warnings with ESP8266 core v3.0.0
|
|
||||||
1.7.3 K Hoang 29/07/2021 Fix MultiWiFi connection issue with ESP32 core v2.0.0-rc1+
|
|
||||||
1.7.4 K Hoang 13/08/2021 Add WiFi scanning of hidden SSIDs
|
|
||||||
1.7.5 K Hoang 10/10/2021 Update `platform.ini` and `library.json`
|
|
||||||
1.7.6 K Hoang 26/11/2021 Auto detect ESP32 core and use either built-in LittleFS or LITTLEFS library
|
|
||||||
1.7.7 K Hoang 26/11/2021 Fix compile error for ESP32 core v1.0.5-
|
|
||||||
1.7.8 K Hoang 30/11/2021 Fix bug to permit using HTTP port different from 80. Fix bug
|
|
||||||
1.8.0 K Hoang 29/12/2021 Fix `multiple-definitions` linker error and weird bug related to src_cpp
|
1.8.0 K Hoang 29/12/2021 Fix `multiple-definitions` linker error and weird bug related to src_cpp
|
||||||
1.9.0 K Hoang 17/01/2022 Enable compatibility with old code to include only ESP_WiFiManager.h
|
1.9.0 K Hoang 17/01/2022 Enable compatibility with old code to include only ESP_WiFiManager.h
|
||||||
|
1.10.0 K Hoang 10/02/2022 Add support to new ESP32-S3
|
||||||
|
1.10.1 K Hoang 11/02/2022 Add LittleFS support to ESP32-C3. Use core LittleFS instead of Lorol's LITTLEFS for v2.0.0+
|
||||||
|
1.10.2 K Hoang 13/03/2022 Send CORS header in handleWifiSave() function
|
||||||
|
1.11.0 K Hoang 09/09/2022 Fix ESP32 chipID and add ESP_getChipOUI()
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -16,48 +16,18 @@
|
|||||||
Built by Khoi Hoang https://github.com/khoih-prog/ESP_WiFiManager
|
Built by Khoi Hoang https://github.com/khoih-prog/ESP_WiFiManager
|
||||||
Licensed under MIT license
|
Licensed under MIT license
|
||||||
|
|
||||||
Version: 1.9.0
|
Version: 1.11.0
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
1.0.0 K Hoang 07/10/2019 Initial coding
|
1.0.0 K Hoang 07/10/2019 Initial coding
|
||||||
1.0.1 K Hoang 13/12/2019 Fix bug. Add features. Add support for ESP32
|
...
|
||||||
1.0.2 K Hoang 19/12/2019 Fix bug thatkeeps ConfigPortal in endless loop if Portal/Router SSID or Password is NULL.
|
|
||||||
1.0.3 K Hoang 05/01/2020 Option not displaying AvailablePages in Info page. Enhance README.md. Modify examples
|
|
||||||
1.0.4 K Hoang 07/01/2020 Add RFC952 setHostname feature.
|
|
||||||
1.0.5 K Hoang 15/01/2020 Add configurable DNS feature. Thanks to @Amorphous of https://community.blynk.cc
|
|
||||||
1.0.6 K Hoang 03/02/2020 Add support for ArduinoJson version 6.0.0+ ( tested with v6.14.1 )
|
|
||||||
1.0.7 K Hoang 13/04/2020 Reduce start time, fix SPIFFS bug in examples, update README.md
|
|
||||||
1.0.8 K Hoang 10/06/2020 Fix STAstaticIP issue. Restructure code. Add LittleFS support for ESP8266 core 2.7.1+
|
|
||||||
1.0.9 K Hoang 29/07/2020 Fix ESP32 STAstaticIP bug. Permit changing from DHCP <-> static IP using Config Portal.
|
|
||||||
Add, enhance examples (fix MDNS for ESP32)
|
|
||||||
1.0.10 K Hoang 08/08/2020 Add more features to Config Portal. Use random WiFi AP channel to avoid conflict.
|
|
||||||
1.0.11 K Hoang 17/08/2020 Add CORS feature. Fix bug in softAP, autoConnect, resetSettings.
|
|
||||||
1.1.0 K Hoang 28/08/2020 Add MultiWiFi feature to autoconnect to best WiFi at runtime
|
|
||||||
1.1.1 K Hoang 30/08/2020 Add setCORSHeader function to allow flexible CORS. Fix typo and minor improvement.
|
|
||||||
1.1.2 K Hoang 17/08/2020 Fix bug. Add example.
|
|
||||||
1.2.0 K Hoang 09/10/2020 Restore cpp code besides Impl.h code to use if linker error. Fix bug.
|
|
||||||
1.3.0 K Hoang 04/12/2020 Add LittleFS support to ESP32 using LITTLEFS Library
|
|
||||||
1.4.1 K Hoang 22/12/2020 Fix staticIP not saved. Add functions. Add complex examples. Sync with ESPAsync_WiFiManager
|
|
||||||
1.4.2 K Hoang 14/01/2021 Fix examples' bug not using saved WiFi Credentials after losing all WiFi connections.
|
|
||||||
1.4.3 K Hoang 23/01/2021 Fix examples' bug not saving Static IP in certain cases.
|
|
||||||
1.5.0 K Hoang 12/02/2021 Add support to new ESP32-S2
|
|
||||||
1.5.1 K Hoang 26/03/2021 Fix compiler error if setting Compiler Warnings to All. Retest with esp32 core v1.0.6
|
|
||||||
1.5.2 K Hoang 08/04/2021 Fix example misleading messages.
|
|
||||||
1.5.3 K Hoang 13/04/2021 Add dnsServer error message.
|
|
||||||
1.6.0 K Hoang 20/04/2021 Add support to new ESP32-C3 using SPIFFS or EEPROM
|
|
||||||
1.6.1 K Hoang 25/04/2021 Fix MultiWiFi bug. Fix captive-portal bug if CP AP address is not default 192.168.4.1
|
|
||||||
1.7.0 K Hoang 06/05/2021 Set _timezoneName. Add support to new ESP32-S2 (METRO_ESP32S2, FUNHOUSE_ESP32S2, etc.)
|
|
||||||
1.7.1 K Hoang 08/05/2021 Fix Json bug. Fix timezoneName not displayed in Info page.
|
|
||||||
1.7.2 K Hoang 08/05/2021 Fix warnings with ESP8266 core v3.0.0
|
|
||||||
1.7.3 K Hoang 29/07/2021 Fix MultiWiFi connection issue with ESP32 core v2.0.0-rc1+
|
|
||||||
1.7.4 K Hoang 13/08/2021 Add WiFi scanning of hidden SSIDs
|
|
||||||
1.7.5 K Hoang 10/10/2021 Update `platform.ini` and `library.json`
|
|
||||||
1.7.6 K Hoang 26/11/2021 Auto detect ESP32 core and use either built-in LittleFS or LITTLEFS library
|
|
||||||
1.7.7 K Hoang 26/11/2021 Fix compile error for ESP32 core v1.0.5-
|
|
||||||
1.7.8 K Hoang 30/11/2021 Fix bug to permit using HTTP port different from 80. Fix bug
|
|
||||||
1.8.0 K Hoang 29/12/2021 Fix `multiple-definitions` linker error and weird bug related to src_cpp
|
1.8.0 K Hoang 29/12/2021 Fix `multiple-definitions` linker error and weird bug related to src_cpp
|
||||||
1.9.0 K Hoang 17/01/2022 Enable compatibility with old code to include only ESP_WiFiManager.h
|
1.9.0 K Hoang 17/01/2022 Enable compatibility with old code to include only ESP_WiFiManager.h
|
||||||
|
1.10.0 K Hoang 10/02/2022 Add support to new ESP32-S3
|
||||||
|
1.10.1 K Hoang 11/02/2022 Add LittleFS support to ESP32-C3. Use core LittleFS instead of Lorol's LITTLEFS for v2.0.0+
|
||||||
|
1.10.2 K Hoang 13/03/2022 Send CORS header in handleWifiSave() function
|
||||||
|
1.11.0 K Hoang 09/09/2022 Fix ESP32 chipID and add ESP_getChipOUI()
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -70,33 +40,48 @@
|
|||||||
#elif ( ARDUINO_ESP32S2_DEV || ARDUINO_FEATHERS2 || ARDUINO_ESP32S2_THING_PLUS || ARDUINO_MICROS2 || \
|
#elif ( ARDUINO_ESP32S2_DEV || ARDUINO_FEATHERS2 || ARDUINO_ESP32S2_THING_PLUS || ARDUINO_MICROS2 || \
|
||||||
ARDUINO_METRO_ESP32S2 || ARDUINO_MAGTAG29_ESP32S2 || ARDUINO_FUNHOUSE_ESP32S2 || \
|
ARDUINO_METRO_ESP32S2 || ARDUINO_MAGTAG29_ESP32S2 || ARDUINO_FUNHOUSE_ESP32S2 || \
|
||||||
ARDUINO_ADAFRUIT_FEATHER_ESP32S2_NOPSRAM )
|
ARDUINO_ADAFRUIT_FEATHER_ESP32S2_NOPSRAM )
|
||||||
#warning Using ESP32_S2. To follow library instructions to install esp32-s2 core and WebServer Patch
|
#if (_WIFIMGR_LOGLEVEL_ > 3)
|
||||||
#warning You have to select HUGE APP or 1.9-2.0 MB APP to be able to run Config Portal. Must use PSRAM
|
#warning Using ESP32_S2. To follow library instructions to install esp32-s2 core and WebServer Patch
|
||||||
|
#warning You have to select HUGE APP or 1.9-2.0 MB APP to be able to run Config Portal. Must use PSRAM
|
||||||
|
#endif
|
||||||
#define USING_ESP32_S2 true
|
#define USING_ESP32_S2 true
|
||||||
#elif ( ARDUINO_ESP32C3_DEV )
|
#elif ( ARDUINO_ESP32C3_DEV )
|
||||||
#warning Using ESP32_C3. To follow library instructions to install esp32-c3 core. Only SPIFFS and EEPROM OK.
|
#if (_WIFIMGR_LOGLEVEL_ > 3)
|
||||||
#warning You have to select Flash size 2MB and Minimal APP (1.3MB + 700KB) for some boards
|
#if ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 2) )
|
||||||
|
#warning Using ESP32_C3 using core v2.0.0+. Either LittleFS, SPIFFS or EEPROM OK.
|
||||||
|
#else
|
||||||
|
#warning Using ESP32_C3 using core v1.0.6-. To follow library instructions to install esp32-c3 core. Only SPIFFS and EEPROM OK.
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// #warning You have to select Flash size 2MB and Minimal APP (1.3MB + 700KB) for some boards
|
||||||
#define USING_ESP32_C3 true
|
#define USING_ESP32_C3 true
|
||||||
|
#elif ( defined(ARDUINO_ESP32S3_DEV) || defined(ARDUINO_ESP32_S3_BOX) || defined(ARDUINO_TINYS3) || \
|
||||||
|
defined(ARDUINO_PROS3) || defined(ARDUINO_FEATHERS3) )
|
||||||
|
#if (_WIFIMGR_LOGLEVEL_ > 3)
|
||||||
|
#warning Using ESP32_S3. To install esp32-s3-support branch if using core v2.0.2-
|
||||||
|
#endif
|
||||||
|
#define USING_ESP32_S3 true
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ESP_WIFIMANAGER_VERSION "ESP_WiFiManager v1.9.0"
|
#define ESP_WIFIMANAGER_VERSION "ESP_WiFiManager v1.11.0"
|
||||||
|
|
||||||
#define ESP_WIFIMANAGER_VERSION_MAJOR 1
|
#define ESP_WIFIMANAGER_VERSION_MAJOR 1
|
||||||
#define ESP_WIFIMANAGER_VERSION_MINOR 9
|
#define ESP_WIFIMANAGER_VERSION_MINOR 11
|
||||||
#define ESP_WIFIMANAGER_VERSION_PATCH 0
|
#define ESP_WIFIMANAGER_VERSION_PATCH 0
|
||||||
|
|
||||||
#define ESP_WIFIMANAGER_VERSION_INT 1009000
|
#define ESP_WIFIMANAGER_VERSION_INT 1011000
|
||||||
|
|
||||||
#include "ESP_WiFiManager_Debug.h"
|
#include "ESP_WiFiManager_Debug.h"
|
||||||
|
|
||||||
#if ( defined(HTTP_PORT) && (HTTP_PORT < 65536) && (HTTP_PORT > 0) )
|
#if ( defined(HTTP_PORT) && (HTTP_PORT < 65536) && (HTTP_PORT > 0) )
|
||||||
#if (_WIFIMGR_LOGLEVEL_ > 2)
|
#if (_WIFIMGR_LOGLEVEL_ > 3)
|
||||||
#warning Using custom HTTP_PORT
|
#warning Using custom HTTP_PORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HTTP_PORT_TO_USE HTTP_PORT
|
#define HTTP_PORT_TO_USE HTTP_PORT
|
||||||
#else
|
#else
|
||||||
#if (_WIFIMGR_LOGLEVEL_ > 2)
|
#if (_WIFIMGR_LOGLEVEL_ > 3)
|
||||||
#warning Using default HTTP_PORT = 80
|
#warning Using default HTTP_PORT = 80
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -126,9 +111,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define ESP_getChipId() (ESP.getChipId())
|
#define ESP_getChipId() (ESP.getChipId())
|
||||||
|
|
||||||
#else //ESP32
|
#else //ESP32
|
||||||
|
|
||||||
#include <esp_wifi.h>
|
#include <esp_wifi.h>
|
||||||
#define ESP_getChipId() ((uint32_t)ESP.getEfuseMac())
|
|
||||||
|
uint32_t getChipID();
|
||||||
|
uint32_t getChipOUI();
|
||||||
|
|
||||||
|
#if defined(ESP_getChipId)
|
||||||
|
#undef ESP_getChipId
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ESP_getChipId() getChipID() // ((uint32_t)ESP.getEfuseMac())
|
||||||
|
#define ESP_getChipOUI() getChipOUI() // ((uint32_t)ESP.getEfuseMac())
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// New in v1.4.0
|
// New in v1.4.0
|
||||||
@ -199,7 +195,10 @@ const char WM_HTTP_SCRIPT_NTP_HIDDEN[] PROGMEM = "<p><input type='hidden' id='ti
|
|||||||
#if !(USE_CLOUDFLARE_NTP)
|
#if !(USE_CLOUDFLARE_NTP)
|
||||||
#undef USE_CLOUDFLARE_NTP
|
#undef USE_CLOUDFLARE_NTP
|
||||||
#define USE_CLOUDFLARE_NTP true
|
#define USE_CLOUDFLARE_NTP true
|
||||||
#warning Forcing USE_CLOUDFLARE_NTP for ESP8266 as low memory can cause blank page
|
|
||||||
|
#if (_WIFIMGR_LOGLEVEL_ > 3)
|
||||||
|
#warning Forcing USE_CLOUDFLARE_NTP for ESP8266 as low memory can cause blank page
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -291,8 +290,8 @@ class ESP_WMParameter
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ESP_WMParameter(const char *custom);
|
ESP_WMParameter(const char *custom);
|
||||||
ESP_WMParameter(const char *id, const char *placeholder, const char *defaultValue, int length,
|
ESP_WMParameter(const char *id, const char *placeholder, const char *defaultValue, const int& length,
|
||||||
const char *custom = "", int labelPlacement = WFM_LABEL_BEFORE);
|
const char *custom = "", const int& labelPlacement = WFM_LABEL_BEFORE);
|
||||||
|
|
||||||
// New in v1.4.0
|
// New in v1.4.0
|
||||||
ESP_WMParameter(const WMParam_Data& WMParam_data);
|
ESP_WMParameter(const WMParam_Data& WMParam_data);
|
||||||
@ -302,7 +301,7 @@ class ESP_WMParameter
|
|||||||
|
|
||||||
// New in v1.4.0
|
// New in v1.4.0
|
||||||
void setWMParam_Data(const WMParam_Data& WMParam_data);
|
void setWMParam_Data(const WMParam_Data& WMParam_data);
|
||||||
void getWMParam_Data(WMParam_Data &WMParam_data);
|
void getWMParam_Data(WMParam_Data& WMParam_data);
|
||||||
//////
|
//////
|
||||||
|
|
||||||
const char *getID();
|
const char *getID();
|
||||||
@ -318,7 +317,8 @@ class ESP_WMParameter
|
|||||||
|
|
||||||
const char *_customHTML;
|
const char *_customHTML;
|
||||||
|
|
||||||
void init(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom, int labelPlacement);
|
void init(const char *id, const char *placeholder, const char *defaultValue, const int& length,
|
||||||
|
const char *custom, const int& labelPlacement);
|
||||||
|
|
||||||
friend class ESP_WiFiManager;
|
friend class ESP_WiFiManager;
|
||||||
};
|
};
|
||||||
@ -359,27 +359,27 @@ class ESP_WiFiManager
|
|||||||
//sets timeout before webserver loop ends and exits even if there has been no setup.
|
//sets timeout before webserver loop ends and exits even if there has been no setup.
|
||||||
//usefully for devices that failed to connect at some point and got stuck in a webserver loop
|
//usefully for devices that failed to connect at some point and got stuck in a webserver loop
|
||||||
//in seconds setConfigPortalTimeout is a new name for setTimeout
|
//in seconds setConfigPortalTimeout is a new name for setTimeout
|
||||||
void setConfigPortalTimeout(unsigned long seconds);
|
void setConfigPortalTimeout(const unsigned long& seconds);
|
||||||
void setTimeout(unsigned long seconds);
|
void setTimeout(const unsigned long& seconds);
|
||||||
|
|
||||||
//sets timeout for which to attempt connecting, usefull if you get a lot of failed connects
|
//sets timeout for which to attempt connecting, usefull if you get a lot of failed connects
|
||||||
void setConnectTimeout(unsigned long seconds);
|
void setConnectTimeout(const unsigned long& seconds);
|
||||||
|
|
||||||
|
|
||||||
void setDebugOutput(bool debug);
|
void setDebugOutput(bool debug);
|
||||||
//defaults to not showing anything under 8% signal quality if called
|
//defaults to not showing anything under 8% signal quality if called
|
||||||
void setMinimumSignalQuality(int quality = 8);
|
void setMinimumSignalQuality(const int& quality = 8);
|
||||||
|
|
||||||
// KH, new from v1.0.10 to enable dynamic/random channel
|
// KH, new from v1.0.10 to enable dynamic/random channel
|
||||||
int setConfigPortalChannel(int channel = 1);
|
int setConfigPortalChannel(const int& channel = 1);
|
||||||
//////
|
//////
|
||||||
|
|
||||||
//sets a custom ip /gateway /subnet configuration
|
//sets a custom ip /gateway /subnet configuration
|
||||||
void setAPStaticIPConfig(const IPAddress& ip, const IPAddress& gw, const IPAddress& sn);
|
void setAPStaticIPConfig(const IPAddress& ip, const IPAddress& gw, const IPAddress& sn);
|
||||||
|
|
||||||
// New in v1.4.0
|
// New in v1.4.0
|
||||||
void setAPStaticIPConfig(const WiFi_AP_IPConfig& WM_AP_IPconfig);
|
void setAPStaticIPConfig(const WiFi_AP_IPConfig& WM_AP_IPconfig);
|
||||||
void getAPStaticIPConfig(WiFi_AP_IPConfig &WM_AP_IPconfig);
|
void getAPStaticIPConfig(WiFi_AP_IPConfig& WM_AP_IPconfig);
|
||||||
//////
|
//////
|
||||||
|
|
||||||
//sets config for a static IP
|
//sets config for a static IP
|
||||||
@ -387,7 +387,7 @@ class ESP_WiFiManager
|
|||||||
|
|
||||||
// New in v1.4.0
|
// New in v1.4.0
|
||||||
void setSTAStaticIPConfig(const WiFi_STA_IPConfig& WM_STA_IPconfig);
|
void setSTAStaticIPConfig(const WiFi_STA_IPConfig& WM_STA_IPconfig);
|
||||||
void getSTAStaticIPConfig(WiFi_STA_IPConfig &WM_STA_IPconfig);
|
void getSTAStaticIPConfig(WiFi_STA_IPConfig& WM_STA_IPconfig);
|
||||||
//////
|
//////
|
||||||
|
|
||||||
#if USE_CONFIGURABLE_DNS
|
#if USE_CONFIGURABLE_DNS
|
||||||
@ -447,7 +447,7 @@ class ESP_WiFiManager
|
|||||||
|
|
||||||
#define MAX_WIFI_CREDENTIALS 2
|
#define MAX_WIFI_CREDENTIALS 2
|
||||||
|
|
||||||
String getSSID(uint8_t index)
|
String getSSID(const uint8_t& index)
|
||||||
{
|
{
|
||||||
if (index == 0)
|
if (index == 0)
|
||||||
return _ssid;
|
return _ssid;
|
||||||
@ -457,7 +457,7 @@ class ESP_WiFiManager
|
|||||||
return String("");
|
return String("");
|
||||||
}
|
}
|
||||||
|
|
||||||
String getPW(uint8_t index)
|
String getPW(const uint8_t& index)
|
||||||
{
|
{
|
||||||
if (index == 0)
|
if (index == 0)
|
||||||
return _pass;
|
return _pass;
|
||||||
@ -488,7 +488,7 @@ class ESP_WiFiManager
|
|||||||
// returns the Parameters Count
|
// returns the Parameters Count
|
||||||
int getParametersCount();
|
int getParametersCount();
|
||||||
|
|
||||||
const char* getStatus(int status);
|
const char* getStatus(const int& status);
|
||||||
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
String getStoredWiFiSSID();
|
String getStoredWiFiSSID();
|
||||||
@ -605,7 +605,7 @@ class ESP_WiFiManager
|
|||||||
|
|
||||||
void setupConfigPortal();
|
void setupConfigPortal();
|
||||||
void startWPS();
|
void startWPS();
|
||||||
//const char* getStatus(int status);
|
//const char* getStatus(const int& status);
|
||||||
|
|
||||||
const char* _apName = "no-net";
|
const char* _apName = "no-net";
|
||||||
const char* _apPassword = NULL;
|
const char* _apPassword = NULL;
|
||||||
@ -686,13 +686,13 @@ class ESP_WiFiManager
|
|||||||
void handleNotFound();
|
void handleNotFound();
|
||||||
bool captivePortal();
|
bool captivePortal();
|
||||||
|
|
||||||
void reportStatus(String &page);
|
void reportStatus(String& page);
|
||||||
|
|
||||||
// DNS server
|
// DNS server
|
||||||
const byte DNS_PORT = 53;
|
const byte DNS_PORT = 53;
|
||||||
|
|
||||||
//helpers
|
//helpers
|
||||||
int getRSSIasQuality(int RSSI);
|
int getRSSIasQuality(const int& RSSI);
|
||||||
bool isIp(const String& str);
|
bool isIp(const String& str);
|
||||||
String toStringIp(const IPAddress& ip);
|
String toStringIp(const IPAddress& ip);
|
||||||
|
|
||||||
@ -715,10 +715,13 @@ class ESP_WiFiManager
|
|||||||
void DEBUG_WM(Generic text);
|
void DEBUG_WM(Generic text);
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
auto optionalIPFromString(T *obj, const char *s) -> decltype(obj->fromString(s)) {
|
auto optionalIPFromString(T *obj, const char *s) -> decltype(obj->fromString(s))
|
||||||
|
{
|
||||||
return obj->fromString(s);
|
return obj->fromString(s);
|
||||||
}
|
}
|
||||||
auto optionalIPFromString(...) -> bool {
|
|
||||||
|
auto optionalIPFromString(...) -> bool
|
||||||
|
{
|
||||||
LOGINFO("NO fromString METHOD ON IPAddress, you need ESP8266 core 2.1.0 or newer for Custom IP configuration to work.");
|
LOGINFO("NO fromString METHOD ON IPAddress, you need ESP8266 core 2.1.0 or newer for Custom IP configuration to work.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -16,48 +16,18 @@
|
|||||||
Built by Khoi Hoang https://github.com/khoih-prog/ESP_WiFiManager
|
Built by Khoi Hoang https://github.com/khoih-prog/ESP_WiFiManager
|
||||||
Licensed under MIT license
|
Licensed under MIT license
|
||||||
|
|
||||||
Version: 1.9.0
|
Version: 1.11.0
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
1.0.0 K Hoang 07/10/2019 Initial coding
|
1.0.0 K Hoang 07/10/2019 Initial coding
|
||||||
1.0.1 K Hoang 13/12/2019 Fix bug. Add features. Add support for ESP32
|
...
|
||||||
1.0.2 K Hoang 19/12/2019 Fix bug thatkeeps ConfigPortal in endless loop if Portal/Router SSID or Password is NULL.
|
|
||||||
1.0.3 K Hoang 05/01/2020 Option not displaying AvailablePages in Info page. Enhance README.md. Modify examples
|
|
||||||
1.0.4 K Hoang 07/01/2020 Add RFC952 setHostname feature.
|
|
||||||
1.0.5 K Hoang 15/01/2020 Add configurable DNS feature. Thanks to @Amorphous of https://community.blynk.cc
|
|
||||||
1.0.6 K Hoang 03/02/2020 Add support for ArduinoJson version 6.0.0+ ( tested with v6.14.1 )
|
|
||||||
1.0.7 K Hoang 13/04/2020 Reduce start time, fix SPIFFS bug in examples, update README.md
|
|
||||||
1.0.8 K Hoang 10/06/2020 Fix STAstaticIP issue. Restructure code. Add LittleFS support for ESP8266 core 2.7.1+
|
|
||||||
1.0.9 K Hoang 29/07/2020 Fix ESP32 STAstaticIP bug. Permit changing from DHCP <-> static IP using Config Portal.
|
|
||||||
Add, enhance examples (fix MDNS for ESP32)
|
|
||||||
1.0.10 K Hoang 08/08/2020 Add more features to Config Portal. Use random WiFi AP channel to avoid conflict.
|
|
||||||
1.0.11 K Hoang 17/08/2020 Add CORS feature. Fix bug in softAP, autoConnect, resetSettings.
|
|
||||||
1.1.0 K Hoang 28/08/2020 Add MultiWiFi feature to autoconnect to best WiFi at runtime
|
|
||||||
1.1.1 K Hoang 30/08/2020 Add setCORSHeader function to allow flexible CORS. Fix typo and minor improvement.
|
|
||||||
1.1.2 K Hoang 17/08/2020 Fix bug. Add example.
|
|
||||||
1.2.0 K Hoang 09/10/2020 Restore cpp code besides Impl.h code to use if linker error. Fix bug.
|
|
||||||
1.3.0 K Hoang 04/12/2020 Add LittleFS support to ESP32 using LITTLEFS Library
|
|
||||||
1.4.1 K Hoang 22/12/2020 Fix staticIP not saved. Add functions. Add complex examples. Sync with ESPAsync_WiFiManager
|
|
||||||
1.4.2 K Hoang 14/01/2021 Fix examples' bug not using saved WiFi Credentials after losing all WiFi connections.
|
|
||||||
1.4.3 K Hoang 23/01/2021 Fix examples' bug not saving Static IP in certain cases.
|
|
||||||
1.5.0 K Hoang 12/02/2021 Add support to new ESP32-S2
|
|
||||||
1.5.1 K Hoang 26/03/2021 Fix compiler error if setting Compiler Warnings to All. Retest with esp32 core v1.0.6
|
|
||||||
1.5.2 K Hoang 08/04/2021 Fix example misleading messages.
|
|
||||||
1.5.3 K Hoang 13/04/2021 Add dnsServer error message.
|
|
||||||
1.6.0 K Hoang 20/04/2021 Add support to new ESP32-C3 using SPIFFS or EEPROM
|
|
||||||
1.6.1 K Hoang 25/04/2021 Fix MultiWiFi bug. Fix captive-portal bug if CP AP address is not default 192.168.4.1
|
|
||||||
1.7.0 K Hoang 06/05/2021 Set _timezoneName. Add support to new ESP32-S2 (METRO_ESP32S2, FUNHOUSE_ESP32S2, etc.)
|
|
||||||
1.7.1 K Hoang 08/05/2021 Fix Json bug. Fix timezoneName not displayed in Info page.
|
|
||||||
1.7.2 K Hoang 08/05/2021 Fix warnings with ESP8266 core v3.0.0
|
|
||||||
1.7.3 K Hoang 29/07/2021 Fix MultiWiFi connection issue with ESP32 core v2.0.0-rc1+
|
|
||||||
1.7.4 K Hoang 13/08/2021 Add WiFi scanning of hidden SSIDs
|
|
||||||
1.7.5 K Hoang 10/10/2021 Update `platform.ini` and `library.json`
|
|
||||||
1.7.6 K Hoang 26/11/2021 Auto detect ESP32 core and use either built-in LittleFS or LITTLEFS library
|
|
||||||
1.7.7 K Hoang 26/11/2021 Fix compile error for ESP32 core v1.0.5-
|
|
||||||
1.7.8 K Hoang 30/11/2021 Fix bug to permit using HTTP port different from 80. Fix bug
|
|
||||||
1.8.0 K Hoang 29/12/2021 Fix `multiple-definitions` linker error and weird bug related to src_cpp
|
1.8.0 K Hoang 29/12/2021 Fix `multiple-definitions` linker error and weird bug related to src_cpp
|
||||||
1.9.0 K Hoang 17/01/2022 Enable compatibility with old code to include only ESP_WiFiManager.h
|
1.9.0 K Hoang 17/01/2022 Enable compatibility with old code to include only ESP_WiFiManager.h
|
||||||
|
1.10.0 K Hoang 10/02/2022 Add support to new ESP32-S3
|
||||||
|
1.10.1 K Hoang 11/02/2022 Add LittleFS support to ESP32-C3. Use core LittleFS instead of Lorol's LITTLEFS for v2.0.0+
|
||||||
|
1.10.2 K Hoang 13/03/2022 Send CORS header in handleWifiSave() function
|
||||||
|
1.11.0 K Hoang 09/09/2022 Fix ESP32 chipID and add ESP_getChipOUI()
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -71,8 +71,6 @@
|
|||||||
|
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
|
|
||||||
#if 1
|
|
||||||
|
|
||||||
#define TZ_Africa_Abidjan ("GMT0")
|
#define TZ_Africa_Abidjan ("GMT0")
|
||||||
#define TZ_Africa_Accra ("GMT0")
|
#define TZ_Africa_Accra ("GMT0")
|
||||||
#define TZ_Africa_Addis_Ababa ("EAT-3")
|
#define TZ_Africa_Addis_Ababa ("EAT-3")
|
||||||
@ -534,479 +532,11 @@
|
|||||||
#define TZ_Etc_Universal ("UTC0")
|
#define TZ_Etc_Universal ("UTC0")
|
||||||
#define TZ_Etc_Zulu ("UTC0")
|
#define TZ_Etc_Zulu ("UTC0")
|
||||||
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
|
|
||||||
#define TZ_Africa_Abidjan PSTR("GMT0")
|
|
||||||
#define TZ_Africa_Accra PSTR("GMT0")
|
|
||||||
#define TZ_Africa_Addis_Ababa PSTR("EAT-3")
|
|
||||||
#define TZ_Africa_Algiers PSTR("CET-1")
|
|
||||||
#define TZ_Africa_Asmara PSTR("EAT-3")
|
|
||||||
#define TZ_Africa_Bamako PSTR("GMT0")
|
|
||||||
#define TZ_Africa_Bangui PSTR("WAT-1")
|
|
||||||
#define TZ_Africa_Banjul PSTR("GMT0")
|
|
||||||
#define TZ_Africa_Bissau PSTR("GMT0")
|
|
||||||
#define TZ_Africa_Blantyre PSTR("CAT-2")
|
|
||||||
#define TZ_Africa_Brazzaville PSTR("WAT-1")
|
|
||||||
#define TZ_Africa_Bujumbura PSTR("CAT-2")
|
|
||||||
#define TZ_Africa_Cairo PSTR("EET-2")
|
|
||||||
#define TZ_Africa_Casablanca PSTR("<+01>-1")
|
|
||||||
#define TZ_Africa_Ceuta PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Africa_Conakry PSTR("GMT0")
|
|
||||||
#define TZ_Africa_Dakar PSTR("GMT0")
|
|
||||||
#define TZ_Africa_Dar_es_Salaam PSTR("EAT-3")
|
|
||||||
#define TZ_Africa_Djibouti PSTR("EAT-3")
|
|
||||||
#define TZ_Africa_Douala PSTR("WAT-1")
|
|
||||||
#define TZ_Africa_El_Aaiun PSTR("<+01>-1")
|
|
||||||
#define TZ_Africa_Freetown PSTR("GMT0")
|
|
||||||
#define TZ_Africa_Gaborone PSTR("CAT-2")
|
|
||||||
#define TZ_Africa_Harare PSTR("CAT-2")
|
|
||||||
#define TZ_Africa_Johannesburg PSTR("SAST-2")
|
|
||||||
#define TZ_Africa_Juba PSTR("EAT-3")
|
|
||||||
#define TZ_Africa_Kampala PSTR("EAT-3")
|
|
||||||
#define TZ_Africa_Khartoum PSTR("CAT-2")
|
|
||||||
#define TZ_Africa_Kigali PSTR("CAT-2")
|
|
||||||
#define TZ_Africa_Kinshasa PSTR("WAT-1")
|
|
||||||
#define TZ_Africa_Lagos PSTR("WAT-1")
|
|
||||||
#define TZ_Africa_Libreville PSTR("WAT-1")
|
|
||||||
#define TZ_Africa_Lome PSTR("GMT0")
|
|
||||||
#define TZ_Africa_Luanda PSTR("WAT-1")
|
|
||||||
#define TZ_Africa_Lubumbashi PSTR("CAT-2")
|
|
||||||
#define TZ_Africa_Lusaka PSTR("CAT-2")
|
|
||||||
#define TZ_Africa_Malabo PSTR("WAT-1")
|
|
||||||
#define TZ_Africa_Maputo PSTR("CAT-2")
|
|
||||||
#define TZ_Africa_Maseru PSTR("SAST-2")
|
|
||||||
#define TZ_Africa_Mbabane PSTR("SAST-2")
|
|
||||||
#define TZ_Africa_Mogadishu PSTR("EAT-3")
|
|
||||||
#define TZ_Africa_Monrovia PSTR("GMT0")
|
|
||||||
#define TZ_Africa_Nairobi PSTR("EAT-3")
|
|
||||||
#define TZ_Africa_Ndjamena PSTR("WAT-1")
|
|
||||||
#define TZ_Africa_Niamey PSTR("WAT-1")
|
|
||||||
#define TZ_Africa_Nouakchott PSTR("GMT0")
|
|
||||||
#define TZ_Africa_Ouagadougou PSTR("GMT0")
|
|
||||||
#define TZ_Africa_PortomNovo PSTR("WAT-1")
|
|
||||||
#define TZ_Africa_Sao_Tome PSTR("GMT0")
|
|
||||||
#define TZ_Africa_Tripoli PSTR("EET-2")
|
|
||||||
#define TZ_Africa_Tunis PSTR("CET-1")
|
|
||||||
#define TZ_Africa_Windhoek PSTR("CAT-2")
|
|
||||||
#define TZ_America_Adak PSTR("HST10HDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Anchorage PSTR("AKST9AKDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Anguilla PSTR("AST4")
|
|
||||||
#define TZ_America_Antigua PSTR("AST4")
|
|
||||||
#define TZ_America_Araguaina PSTR("<-03>3")
|
|
||||||
#define TZ_America_Argentina_Buenos_Aires PSTR("<-03>3")
|
|
||||||
#define TZ_America_Argentina_Catamarca PSTR("<-03>3")
|
|
||||||
#define TZ_America_Argentina_Cordoba PSTR("<-03>3")
|
|
||||||
#define TZ_America_Argentina_Jujuy PSTR("<-03>3")
|
|
||||||
#define TZ_America_Argentina_La_Rioja PSTR("<-03>3")
|
|
||||||
#define TZ_America_Argentina_Mendoza PSTR("<-03>3")
|
|
||||||
#define TZ_America_Argentina_Rio_Gallegos PSTR("<-03>3")
|
|
||||||
#define TZ_America_Argentina_Salta PSTR("<-03>3")
|
|
||||||
#define TZ_America_Argentina_San_Juan PSTR("<-03>3")
|
|
||||||
#define TZ_America_Argentina_San_Luis PSTR("<-03>3")
|
|
||||||
#define TZ_America_Argentina_Tucuman PSTR("<-03>3")
|
|
||||||
#define TZ_America_Argentina_Ushuaia PSTR("<-03>3")
|
|
||||||
#define TZ_America_Aruba PSTR("AST4")
|
|
||||||
#define TZ_America_Asuncion PSTR("<-04>4<-03>,M10.1.0/0,M3.4.0/0")
|
|
||||||
#define TZ_America_Atikokan PSTR("EST5")
|
|
||||||
#define TZ_America_Bahia PSTR("<-03>3")
|
|
||||||
#define TZ_America_Bahia_Banderas PSTR("CST6CDT,M4.1.0,M10.5.0")
|
|
||||||
#define TZ_America_Barbados PSTR("AST4")
|
|
||||||
#define TZ_America_Belem PSTR("<-03>3")
|
|
||||||
#define TZ_America_Belize PSTR("CST6")
|
|
||||||
#define TZ_America_BlancmSablon PSTR("AST4")
|
|
||||||
#define TZ_America_Boa_Vista PSTR("<-04>4")
|
|
||||||
#define TZ_America_Bogota PSTR("<-05>5")
|
|
||||||
#define TZ_America_Boise PSTR("MST7MDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Cambridge_Bay PSTR("MST7MDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Campo_Grande PSTR("<-04>4")
|
|
||||||
#define TZ_America_Cancun PSTR("EST5")
|
|
||||||
#define TZ_America_Caracas PSTR("<-04>4")
|
|
||||||
#define TZ_America_Cayenne PSTR("<-03>3")
|
|
||||||
#define TZ_America_Cayman PSTR("EST5")
|
|
||||||
#define TZ_America_Chicago PSTR("CST6CDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Chihuahua PSTR("MST7MDT,M4.1.0,M10.5.0")
|
|
||||||
#define TZ_America_Costa_Rica PSTR("CST6")
|
|
||||||
#define TZ_America_Creston PSTR("MST7")
|
|
||||||
#define TZ_America_Cuiaba PSTR("<-04>4")
|
|
||||||
#define TZ_America_Curacao PSTR("AST4")
|
|
||||||
#define TZ_America_Danmarkshavn PSTR("GMT0")
|
|
||||||
#define TZ_America_Dawson PSTR("MST7")
|
|
||||||
#define TZ_America_Dawson_Creek PSTR("MST7")
|
|
||||||
#define TZ_America_Denver PSTR("MST7MDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Detroit PSTR("EST5EDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Dominica PSTR("AST4")
|
|
||||||
#define TZ_America_Edmonton PSTR("MST7MDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Eirunepe PSTR("<-05>5")
|
|
||||||
#define TZ_America_El_Salvador PSTR("CST6")
|
|
||||||
#define TZ_America_Fortaleza PSTR("<-03>3")
|
|
||||||
#define TZ_America_Fort_Nelson PSTR("MST7")
|
|
||||||
#define TZ_America_Glace_Bay PSTR("AST4ADT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Godthab PSTR("<-03>3<-02>,M3.5.0/-2,M10.5.0/-1")
|
|
||||||
#define TZ_America_Goose_Bay PSTR("AST4ADT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Grand_Turk PSTR("EST5EDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Grenada PSTR("AST4")
|
|
||||||
#define TZ_America_Guadeloupe PSTR("AST4")
|
|
||||||
#define TZ_America_Guatemala PSTR("CST6")
|
|
||||||
#define TZ_America_Guayaquil PSTR("<-05>5")
|
|
||||||
#define TZ_America_Guyana PSTR("<-04>4")
|
|
||||||
#define TZ_America_Halifax PSTR("AST4ADT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Havana PSTR("CST5CDT,M3.2.0/0,M11.1.0/1")
|
|
||||||
#define TZ_America_Hermosillo PSTR("MST7")
|
|
||||||
#define TZ_America_Indiana_Indianapolis PSTR("EST5EDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Indiana_Knox PSTR("CST6CDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Indiana_Marengo PSTR("EST5EDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Indiana_Petersburg PSTR("EST5EDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Indiana_Tell_City PSTR("CST6CDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Indiana_Vevay PSTR("EST5EDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Indiana_Vincennes PSTR("EST5EDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Indiana_Winamac PSTR("EST5EDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Inuvik PSTR("MST7MDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Iqaluit PSTR("EST5EDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Jamaica PSTR("EST5")
|
|
||||||
#define TZ_America_Juneau PSTR("AKST9AKDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Kentucky_Louisville PSTR("EST5EDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Kentucky_Monticello PSTR("EST5EDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Kralendijk PSTR("AST4")
|
|
||||||
#define TZ_America_La_Paz PSTR("<-04>4")
|
|
||||||
#define TZ_America_Lima PSTR("<-05>5")
|
|
||||||
#define TZ_America_Los_Angeles PSTR("PST8PDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Lower_Princes PSTR("AST4")
|
|
||||||
#define TZ_America_Maceio PSTR("<-03>3")
|
|
||||||
#define TZ_America_Managua PSTR("CST6")
|
|
||||||
#define TZ_America_Manaus PSTR("<-04>4")
|
|
||||||
#define TZ_America_Marigot PSTR("AST4")
|
|
||||||
#define TZ_America_Martinique PSTR("AST4")
|
|
||||||
#define TZ_America_Matamoros PSTR("CST6CDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Mazatlan PSTR("MST7MDT,M4.1.0,M10.5.0")
|
|
||||||
#define TZ_America_Menominee PSTR("CST6CDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Merida PSTR("CST6CDT,M4.1.0,M10.5.0")
|
|
||||||
#define TZ_America_Metlakatla PSTR("AKST9AKDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Mexico_City PSTR("CST6CDT,M4.1.0,M10.5.0")
|
|
||||||
#define TZ_America_Miquelon PSTR("<-03>3<-02>,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Moncton PSTR("AST4ADT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Monterrey PSTR("CST6CDT,M4.1.0,M10.5.0")
|
|
||||||
#define TZ_America_Montevideo PSTR("<-03>3")
|
|
||||||
#define TZ_America_Montreal PSTR("EST5EDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Montserrat PSTR("AST4")
|
|
||||||
#define TZ_America_Nassau PSTR("EST5EDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_New_York PSTR("EST5EDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Nipigon PSTR("EST5EDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Nome PSTR("AKST9AKDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Noronha PSTR("<-02>2")
|
|
||||||
#define TZ_America_North_Dakota_Beulah PSTR("CST6CDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_North_Dakota_Center PSTR("CST6CDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_North_Dakota_New_Salem PSTR("CST6CDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Ojinaga PSTR("MST7MDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Panama PSTR("EST5")
|
|
||||||
#define TZ_America_Pangnirtung PSTR("EST5EDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Paramaribo PSTR("<-03>3")
|
|
||||||
#define TZ_America_Phoenix PSTR("MST7")
|
|
||||||
#define TZ_America_PortmaumPrince PSTR("EST5EDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Port_of_Spain PSTR("AST4")
|
|
||||||
#define TZ_America_Porto_Velho PSTR("<-04>4")
|
|
||||||
#define TZ_America_Puerto_Rico PSTR("AST4")
|
|
||||||
#define TZ_America_Punta_Arenas PSTR("<-03>3")
|
|
||||||
#define TZ_America_Rainy_River PSTR("CST6CDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Rankin_Inlet PSTR("CST6CDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Recife PSTR("<-03>3")
|
|
||||||
#define TZ_America_Regina PSTR("CST6")
|
|
||||||
#define TZ_America_Resolute PSTR("CST6CDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Rio_Branco PSTR("<-05>5")
|
|
||||||
#define TZ_America_Santarem PSTR("<-03>3")
|
|
||||||
#define TZ_America_Santiago PSTR("<-04>4<-03>,M9.1.6/24,M4.1.6/24")
|
|
||||||
#define TZ_America_Santo_Domingo PSTR("AST4")
|
|
||||||
#define TZ_America_Sao_Paulo PSTR("<-03>3")
|
|
||||||
#define TZ_America_Scoresbysund PSTR("<-01>1<+00>,M3.5.0/0,M10.5.0/1")
|
|
||||||
#define TZ_America_Sitka PSTR("AKST9AKDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_St_Barthelemy PSTR("AST4")
|
|
||||||
#define TZ_America_St_Johns PSTR("NST3:30NDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_St_Kitts PSTR("AST4")
|
|
||||||
#define TZ_America_St_Lucia PSTR("AST4")
|
|
||||||
#define TZ_America_St_Thomas PSTR("AST4")
|
|
||||||
#define TZ_America_St_Vincent PSTR("AST4")
|
|
||||||
#define TZ_America_Swift_Current PSTR("CST6")
|
|
||||||
#define TZ_America_Tegucigalpa PSTR("CST6")
|
|
||||||
#define TZ_America_Thule PSTR("AST4ADT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Thunder_Bay PSTR("EST5EDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Tijuana PSTR("PST8PDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Toronto PSTR("EST5EDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Tortola PSTR("AST4")
|
|
||||||
#define TZ_America_Vancouver PSTR("PST8PDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Whitehorse PSTR("MST7")
|
|
||||||
#define TZ_America_Winnipeg PSTR("CST6CDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Yakutat PSTR("AKST9AKDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_America_Yellowknife PSTR("MST7MDT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_Antarctica_Casey PSTR("<+11>-11")
|
|
||||||
#define TZ_Antarctica_Davis PSTR("<+07>-7")
|
|
||||||
#define TZ_Antarctica_DumontDUrville PSTR("<+10>-10")
|
|
||||||
#define TZ_Antarctica_Macquarie PSTR("AEST-10AEDT,M10.1.0,M4.1.0/3")
|
|
||||||
#define TZ_Antarctica_Mawson PSTR("<+05>-5")
|
|
||||||
#define TZ_Antarctica_McMurdo PSTR("NZST-12NZDT,M9.5.0,M4.1.0/3")
|
|
||||||
#define TZ_Antarctica_Palmer PSTR("<-03>3")
|
|
||||||
#define TZ_Antarctica_Rothera PSTR("<-03>3")
|
|
||||||
#define TZ_Antarctica_Syowa PSTR("<+03>-3")
|
|
||||||
#define TZ_Antarctica_Troll PSTR("<+00>0<+02>-2,M3.5.0/1,M10.5.0/3")
|
|
||||||
#define TZ_Antarctica_Vostok PSTR("<+06>-6")
|
|
||||||
#define TZ_Arctic_Longyearbyen PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Asia_Aden PSTR("<+03>-3")
|
|
||||||
#define TZ_Asia_Almaty PSTR("<+06>-6")
|
|
||||||
#define TZ_Asia_Amman PSTR("EET-2EEST,M3.5.4/24,M10.5.5/1")
|
|
||||||
#define TZ_Asia_Anadyr PSTR("<+12>-12")
|
|
||||||
#define TZ_Asia_Aqtau PSTR("<+05>-5")
|
|
||||||
#define TZ_Asia_Aqtobe PSTR("<+05>-5")
|
|
||||||
#define TZ_Asia_Ashgabat PSTR("<+05>-5")
|
|
||||||
#define TZ_Asia_Atyrau PSTR("<+05>-5")
|
|
||||||
#define TZ_Asia_Baghdad PSTR("<+03>-3")
|
|
||||||
#define TZ_Asia_Bahrain PSTR("<+03>-3")
|
|
||||||
#define TZ_Asia_Baku PSTR("<+04>-4")
|
|
||||||
#define TZ_Asia_Bangkok PSTR("<+07>-7")
|
|
||||||
#define TZ_Asia_Barnaul PSTR("<+07>-7")
|
|
||||||
#define TZ_Asia_Beirut PSTR("EET-2EEST,M3.5.0/0,M10.5.0/0")
|
|
||||||
#define TZ_Asia_Bishkek PSTR("<+06>-6")
|
|
||||||
#define TZ_Asia_Brunei PSTR("<+08>-8")
|
|
||||||
#define TZ_Asia_Chita PSTR("<+09>-9")
|
|
||||||
#define TZ_Asia_Choibalsan PSTR("<+08>-8")
|
|
||||||
#define TZ_Asia_Colombo PSTR("<+0530>-5:30")
|
|
||||||
#define TZ_Asia_Damascus PSTR("EET-2EEST,M3.5.5/0,M10.5.5/0")
|
|
||||||
#define TZ_Asia_Dhaka PSTR("<+06>-6")
|
|
||||||
#define TZ_Asia_Dili PSTR("<+09>-9")
|
|
||||||
#define TZ_Asia_Dubai PSTR("<+04>-4")
|
|
||||||
#define TZ_Asia_Dushanbe PSTR("<+05>-5")
|
|
||||||
#define TZ_Asia_Famagusta PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
|
||||||
#define TZ_Asia_Gaza PSTR("EET-2EEST,M3.4.4/48,M10.4.4/49")
|
|
||||||
#define TZ_Asia_Hebron PSTR("EET-2EEST,M3.4.4/48,M10.4.4/49")
|
|
||||||
#define TZ_Asia_Ho_Chi_Minh PSTR("<+07>-7")
|
|
||||||
#define TZ_Asia_Hong_Kong PSTR("HKT-8")
|
|
||||||
#define TZ_Asia_Hovd PSTR("<+07>-7")
|
|
||||||
#define TZ_Asia_Irkutsk PSTR("<+08>-8")
|
|
||||||
#define TZ_Asia_Jakarta PSTR("WIB-7")
|
|
||||||
#define TZ_Asia_Jayapura PSTR("WIT-9")
|
|
||||||
#define TZ_Asia_Jerusalem PSTR("IST-2IDT,M3.4.4/26,M10.5.0")
|
|
||||||
#define TZ_Asia_Kabul PSTR("<+0430>-4:30")
|
|
||||||
#define TZ_Asia_Kamchatka PSTR("<+12>-12")
|
|
||||||
#define TZ_Asia_Karachi PSTR("PKT-5")
|
|
||||||
#define TZ_Asia_Kathmandu PSTR("<+0545>-5:45")
|
|
||||||
#define TZ_Asia_Khandyga PSTR("<+09>-9")
|
|
||||||
#define TZ_Asia_Kolkata PSTR("IST-5:30")
|
|
||||||
#define TZ_Asia_Krasnoyarsk PSTR("<+07>-7")
|
|
||||||
#define TZ_Asia_Kuala_Lumpur PSTR("<+08>-8")
|
|
||||||
#define TZ_Asia_Kuching PSTR("<+08>-8")
|
|
||||||
#define TZ_Asia_Kuwait PSTR("<+03>-3")
|
|
||||||
#define TZ_Asia_Macau PSTR("CST-8")
|
|
||||||
#define TZ_Asia_Magadan PSTR("<+11>-11")
|
|
||||||
#define TZ_Asia_Makassar PSTR("WITA-8")
|
|
||||||
#define TZ_Asia_Manila PSTR("PST-8")
|
|
||||||
#define TZ_Asia_Muscat PSTR("<+04>-4")
|
|
||||||
#define TZ_Asia_Nicosia PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
|
||||||
#define TZ_Asia_Novokuznetsk PSTR("<+07>-7")
|
|
||||||
#define TZ_Asia_Novosibirsk PSTR("<+07>-7")
|
|
||||||
#define TZ_Asia_Omsk PSTR("<+06>-6")
|
|
||||||
#define TZ_Asia_Oral PSTR("<+05>-5")
|
|
||||||
#define TZ_Asia_Phnom_Penh PSTR("<+07>-7")
|
|
||||||
#define TZ_Asia_Pontianak PSTR("WIB-7")
|
|
||||||
#define TZ_Asia_Pyongyang PSTR("KST-9")
|
|
||||||
#define TZ_Asia_Qatar PSTR("<+03>-3")
|
|
||||||
#define TZ_Asia_Qyzylorda PSTR("<+05>-5")
|
|
||||||
#define TZ_Asia_Riyadh PSTR("<+03>-3")
|
|
||||||
#define TZ_Asia_Sakhalin PSTR("<+11>-11")
|
|
||||||
#define TZ_Asia_Samarkand PSTR("<+05>-5")
|
|
||||||
#define TZ_Asia_Seoul PSTR("KST-9")
|
|
||||||
#define TZ_Asia_Shanghai PSTR("CST-8")
|
|
||||||
#define TZ_Asia_Singapore PSTR("<+08>-8")
|
|
||||||
#define TZ_Asia_Srednekolymsk PSTR("<+11>-11")
|
|
||||||
#define TZ_Asia_Taipei PSTR("CST-8")
|
|
||||||
#define TZ_Asia_Tashkent PSTR("<+05>-5")
|
|
||||||
#define TZ_Asia_Tbilisi PSTR("<+04>-4")
|
|
||||||
#define TZ_Asia_Tehran PSTR("<+0330>-3:30<+0430>,J79/24,J263/24")
|
|
||||||
#define TZ_Asia_Thimphu PSTR("<+06>-6")
|
|
||||||
#define TZ_Asia_Tokyo PSTR("JST-9")
|
|
||||||
#define TZ_Asia_Tomsk PSTR("<+07>-7")
|
|
||||||
#define TZ_Asia_Ulaanbaatar PSTR("<+08>-8")
|
|
||||||
#define TZ_Asia_Urumqi PSTR("<+06>-6")
|
|
||||||
#define TZ_Asia_UstmNera PSTR("<+10>-10")
|
|
||||||
#define TZ_Asia_Vientiane PSTR("<+07>-7")
|
|
||||||
#define TZ_Asia_Vladivostok PSTR("<+10>-10")
|
|
||||||
#define TZ_Asia_Yakutsk PSTR("<+09>-9")
|
|
||||||
#define TZ_Asia_Yangon PSTR("<+0630>-6:30")
|
|
||||||
#define TZ_Asia_Yekaterinburg PSTR("<+05>-5")
|
|
||||||
#define TZ_Asia_Yerevan PSTR("<+04>-4")
|
|
||||||
#define TZ_Atlantic_Azores PSTR("<-01>1<+00>,M3.5.0/0,M10.5.0/1")
|
|
||||||
#define TZ_Atlantic_Bermuda PSTR("AST4ADT,M3.2.0,M11.1.0")
|
|
||||||
#define TZ_Atlantic_Canary PSTR("WET0WEST,M3.5.0/1,M10.5.0")
|
|
||||||
#define TZ_Atlantic_Cape_Verde PSTR("<-01>1")
|
|
||||||
#define TZ_Atlantic_Faroe PSTR("WET0WEST,M3.5.0/1,M10.5.0")
|
|
||||||
#define TZ_Atlantic_Madeira PSTR("WET0WEST,M3.5.0/1,M10.5.0")
|
|
||||||
#define TZ_Atlantic_Reykjavik PSTR("GMT0")
|
|
||||||
#define TZ_Atlantic_South_Georgia PSTR("<-02>2")
|
|
||||||
#define TZ_Atlantic_Stanley PSTR("<-03>3")
|
|
||||||
#define TZ_Atlantic_St_Helena PSTR("GMT0")
|
|
||||||
#define TZ_Australia_Adelaide PSTR("ACST-9:30ACDT,M10.1.0,M4.1.0/3")
|
|
||||||
#define TZ_Australia_Brisbane PSTR("AEST-10")
|
|
||||||
#define TZ_Australia_Broken_Hill PSTR("ACST-9:30ACDT,M10.1.0,M4.1.0/3")
|
|
||||||
#define TZ_Australia_Currie PSTR("AEST-10AEDT,M10.1.0,M4.1.0/3")
|
|
||||||
#define TZ_Australia_Darwin PSTR("ACST-9:30")
|
|
||||||
#define TZ_Australia_Eucla PSTR("<+0845>-8:45")
|
|
||||||
#define TZ_Australia_Hobart PSTR("AEST-10AEDT,M10.1.0,M4.1.0/3")
|
|
||||||
#define TZ_Australia_Lindeman PSTR("AEST-10")
|
|
||||||
#define TZ_Australia_Lord_Howe PSTR("<+1030>-10:30<+11>-11,M10.1.0,M4.1.0")
|
|
||||||
#define TZ_Australia_Melbourne PSTR("AEST-10AEDT,M10.1.0,M4.1.0/3")
|
|
||||||
#define TZ_Australia_Perth PSTR("AWST-8")
|
|
||||||
#define TZ_Australia_Sydney PSTR("AEST-10AEDT,M10.1.0,M4.1.0/3")
|
|
||||||
#define TZ_Europe_Amsterdam PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Andorra PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Astrakhan PSTR("<+04>-4")
|
|
||||||
#define TZ_Europe_Athens PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
|
||||||
#define TZ_Europe_Belgrade PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Berlin PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Bratislava PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Brussels PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Bucharest PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
|
||||||
#define TZ_Europe_Budapest PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Busingen PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Chisinau PSTR("EET-2EEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Copenhagen PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Dublin PSTR("IST-1GMT0,M10.5.0,M3.5.0/1")
|
|
||||||
#define TZ_Europe_Gibraltar PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Guernsey PSTR("GMT0BST,M3.5.0/1,M10.5.0")
|
|
||||||
#define TZ_Europe_Helsinki PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
|
||||||
#define TZ_Europe_Isle_of_Man PSTR("GMT0BST,M3.5.0/1,M10.5.0")
|
|
||||||
#define TZ_Europe_Istanbul PSTR("<+03>-3")
|
|
||||||
#define TZ_Europe_Jersey PSTR("GMT0BST,M3.5.0/1,M10.5.0")
|
|
||||||
#define TZ_Europe_Kaliningrad PSTR("EET-2")
|
|
||||||
#define TZ_Europe_Kiev PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
|
||||||
#define TZ_Europe_Kirov PSTR("<+03>-3")
|
|
||||||
#define TZ_Europe_Lisbon PSTR("WET0WEST,M3.5.0/1,M10.5.0")
|
|
||||||
#define TZ_Europe_Ljubljana PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_London PSTR("GMT0BST,M3.5.0/1,M10.5.0")
|
|
||||||
#define TZ_Europe_Luxembourg PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Madrid PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Malta PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Mariehamn PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
|
||||||
#define TZ_Europe_Minsk PSTR("<+03>-3")
|
|
||||||
#define TZ_Europe_Monaco PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Moscow PSTR("MSK-3")
|
|
||||||
#define TZ_Europe_Oslo PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Paris PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Podgorica PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Prague PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Riga PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
|
||||||
#define TZ_Europe_Rome PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Samara PSTR("<+04>-4")
|
|
||||||
#define TZ_Europe_San_Marino PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Sarajevo PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Saratov PSTR("<+04>-4")
|
|
||||||
#define TZ_Europe_Simferopol PSTR("MSK-3")
|
|
||||||
#define TZ_Europe_Skopje PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Sofia PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
|
||||||
#define TZ_Europe_Stockholm PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Tallinn PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
|
||||||
#define TZ_Europe_Tirane PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Ulyanovsk PSTR("<+04>-4")
|
|
||||||
#define TZ_Europe_Uzhgorod PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
|
||||||
#define TZ_Europe_Vaduz PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Vatican PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Vienna PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Vilnius PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
|
||||||
#define TZ_Europe_Volgograd PSTR("<+04>-4")
|
|
||||||
#define TZ_Europe_Warsaw PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Zagreb PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Europe_Zaporozhye PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4")
|
|
||||||
#define TZ_Europe_Zurich PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
#define TZ_Indian_Antananarivo PSTR("EAT-3")
|
|
||||||
#define TZ_Indian_Chagos PSTR("<+06>-6")
|
|
||||||
#define TZ_Indian_Christmas PSTR("<+07>-7")
|
|
||||||
#define TZ_Indian_Cocos PSTR("<+0630>-6:30")
|
|
||||||
#define TZ_Indian_Comoro PSTR("EAT-3")
|
|
||||||
#define TZ_Indian_Kerguelen PSTR("<+05>-5")
|
|
||||||
#define TZ_Indian_Mahe PSTR("<+04>-4")
|
|
||||||
#define TZ_Indian_Maldives PSTR("<+05>-5")
|
|
||||||
#define TZ_Indian_Mauritius PSTR("<+04>-4")
|
|
||||||
#define TZ_Indian_Mayotte PSTR("EAT-3")
|
|
||||||
#define TZ_Indian_Reunion PSTR("<+04>-4")
|
|
||||||
#define TZ_Pacific_Apia PSTR("<+13>-13<+14>,M9.5.0/3,M4.1.0/4")
|
|
||||||
#define TZ_Pacific_Auckland PSTR("NZST-12NZDT,M9.5.0,M4.1.0/3")
|
|
||||||
#define TZ_Pacific_Bougainville PSTR("<+11>-11")
|
|
||||||
#define TZ_Pacific_Chatham PSTR("<+1245>-12:45<+1345>,M9.5.0/2:45,M4.1.0/3:45")
|
|
||||||
#define TZ_Pacific_Chuuk PSTR("<+10>-10")
|
|
||||||
#define TZ_Pacific_Easter PSTR("<-06>6<-05>,M9.1.6/22,M4.1.6/22")
|
|
||||||
#define TZ_Pacific_Efate PSTR("<+11>-11")
|
|
||||||
#define TZ_Pacific_Enderbury PSTR("<+13>-13")
|
|
||||||
#define TZ_Pacific_Fakaofo PSTR("<+13>-13")
|
|
||||||
#define TZ_Pacific_Fiji PSTR("<+12>-12<+13>,M11.2.0,M1.2.3/99")
|
|
||||||
#define TZ_Pacific_Funafuti PSTR("<+12>-12")
|
|
||||||
#define TZ_Pacific_Galapagos PSTR("<-06>6")
|
|
||||||
#define TZ_Pacific_Gambier PSTR("<-09>9")
|
|
||||||
#define TZ_Pacific_Guadalcanal PSTR("<+11>-11")
|
|
||||||
#define TZ_Pacific_Guam PSTR("ChST-10")
|
|
||||||
#define TZ_Pacific_Honolulu PSTR("HST10")
|
|
||||||
#define TZ_Pacific_Kiritimati PSTR("<+14>-14")
|
|
||||||
#define TZ_Pacific_Kosrae PSTR("<+11>-11")
|
|
||||||
#define TZ_Pacific_Kwajalein PSTR("<+12>-12")
|
|
||||||
#define TZ_Pacific_Majuro PSTR("<+12>-12")
|
|
||||||
#define TZ_Pacific_Marquesas PSTR("<-0930>9:30")
|
|
||||||
#define TZ_Pacific_Midway PSTR("SST11")
|
|
||||||
#define TZ_Pacific_Nauru PSTR("<+12>-12")
|
|
||||||
#define TZ_Pacific_Niue PSTR("<-11>11")
|
|
||||||
#define TZ_Pacific_Norfolk PSTR("<+11>-11<+12>,M10.1.0,M4.1.0/3")
|
|
||||||
#define TZ_Pacific_Noumea PSTR("<+11>-11")
|
|
||||||
#define TZ_Pacific_Pago_Pago PSTR("SST11")
|
|
||||||
#define TZ_Pacific_Palau PSTR("<+09>-9")
|
|
||||||
#define TZ_Pacific_Pitcairn PSTR("<-08>8")
|
|
||||||
#define TZ_Pacific_Pohnpei PSTR("<+11>-11")
|
|
||||||
#define TZ_Pacific_Port_Moresby PSTR("<+10>-10")
|
|
||||||
#define TZ_Pacific_Rarotonga PSTR("<-10>10")
|
|
||||||
#define TZ_Pacific_Saipan PSTR("ChST-10")
|
|
||||||
#define TZ_Pacific_Tahiti PSTR("<-10>10")
|
|
||||||
#define TZ_Pacific_Tarawa PSTR("<+12>-12")
|
|
||||||
#define TZ_Pacific_Tongatapu PSTR("<+13>-13")
|
|
||||||
#define TZ_Pacific_Wake PSTR("<+12>-12")
|
|
||||||
#define TZ_Pacific_Wallis PSTR("<+12>-12")
|
|
||||||
#define TZ_Etc_GMT PSTR("GMT0")
|
|
||||||
#define TZ_Etc_GMTm0 PSTR("GMT0")
|
|
||||||
#define TZ_Etc_GMTm1 PSTR("<+01>-1")
|
|
||||||
#define TZ_Etc_GMTm2 PSTR("<+02>-2")
|
|
||||||
#define TZ_Etc_GMTm3 PSTR("<+03>-3")
|
|
||||||
#define TZ_Etc_GMTm4 PSTR("<+04>-4")
|
|
||||||
#define TZ_Etc_GMTm5 PSTR("<+05>-5")
|
|
||||||
#define TZ_Etc_GMTm6 PSTR("<+06>-6")
|
|
||||||
#define TZ_Etc_GMTm7 PSTR("<+07>-7")
|
|
||||||
#define TZ_Etc_GMTm8 PSTR("<+08>-8")
|
|
||||||
#define TZ_Etc_GMTm9 PSTR("<+09>-9")
|
|
||||||
#define TZ_Etc_GMTm10 PSTR("<+10>-10")
|
|
||||||
#define TZ_Etc_GMTm11 PSTR("<+11>-11")
|
|
||||||
#define TZ_Etc_GMTm12 PSTR("<+12>-12")
|
|
||||||
#define TZ_Etc_GMTm13 PSTR("<+13>-13")
|
|
||||||
#define TZ_Etc_GMTm14 PSTR("<+14>-14")
|
|
||||||
#define TZ_Etc_GMT0 PSTR("GMT0")
|
|
||||||
#define TZ_Etc_GMTp0 PSTR("GMT0")
|
|
||||||
#define TZ_Etc_GMTp1 PSTR("<-01>1")
|
|
||||||
#define TZ_Etc_GMTp2 PSTR("<-02>2")
|
|
||||||
#define TZ_Etc_GMTp3 PSTR("<-03>3")
|
|
||||||
#define TZ_Etc_GMTp4 PSTR("<-04>4")
|
|
||||||
#define TZ_Etc_GMTp5 PSTR("<-05>5")
|
|
||||||
#define TZ_Etc_GMTp6 PSTR("<-06>6")
|
|
||||||
#define TZ_Etc_GMTp7 PSTR("<-07>7")
|
|
||||||
#define TZ_Etc_GMTp8 PSTR("<-08>8")
|
|
||||||
#define TZ_Etc_GMTp9 PSTR("<-09>9")
|
|
||||||
#define TZ_Etc_GMTp10 PSTR("<-10>10")
|
|
||||||
#define TZ_Etc_GMTp11 PSTR("<-11>11")
|
|
||||||
#define TZ_Etc_GMTp12 PSTR("<-12>12")
|
|
||||||
#define TZ_Etc_UCT PSTR("UTC0")
|
|
||||||
#define TZ_Etc_UTC PSTR("UTC0")
|
|
||||||
#define TZ_Etc_Greenwich PSTR("GMT0")
|
|
||||||
#define TZ_Etc_Universal PSTR("UTC0")
|
|
||||||
#define TZ_Etc_Zulu PSTR("UTC0")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define TIMEZONE_MAX_LEN 50
|
#define TIMEZONE_MAX_LEN 50
|
||||||
|
|
||||||
#if 1
|
static const char TZ_NAME[][TIMEZONE_MAX_LEN] /*PROGMEM*/ =
|
||||||
|
|
||||||
const char TZ_NAME[][TIMEZONE_MAX_LEN] /*PROGMEM*/ =
|
|
||||||
{
|
{
|
||||||
#if USING_AFRICA
|
#if USING_AFRICA
|
||||||
"Africa/Abidjan", //PSTR("GMT0")
|
"Africa/Abidjan", //PSTR("GMT0")
|
||||||
@ -1503,7 +1033,7 @@ const char TZ_NAME[][TIMEZONE_MAX_LEN] /*PROGMEM*/ =
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
const char ESP_TZ_NAME[][TIMEZONE_MAX_LEN] /*PROGMEM*/ =
|
static const char ESP_TZ_NAME[][TIMEZONE_MAX_LEN] /*PROGMEM*/ =
|
||||||
{
|
{
|
||||||
#if USING_AFRICA
|
#if USING_AFRICA
|
||||||
TZ_Africa_Abidjan, //PSTR("GMT0")
|
TZ_Africa_Abidjan, //PSTR("GMT0")
|
||||||
@ -1999,152 +1529,4 @@ const char ESP_TZ_NAME[][TIMEZONE_MAX_LEN] /*PROGMEM*/ =
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
|
||||||
const char TZ_NAME[][TIMEZONE_MAX_LEN] =
|
|
||||||
{
|
|
||||||
"Pacific/Pago_Pago",
|
|
||||||
"America/Adak",
|
|
||||||
"Pacific/Honolulu",
|
|
||||||
"Pacific/Marquesas",
|
|
||||||
"Pacific/Gambier",
|
|
||||||
"America/Anchorage",
|
|
||||||
"America/Los_Angeles",
|
|
||||||
"Pacific/Pitcairn",
|
|
||||||
"America/Phoenix",
|
|
||||||
"America/Denver",
|
|
||||||
"America/Guatemala",
|
|
||||||
"America/Chicago",
|
|
||||||
"Pacific/Easter",
|
|
||||||
"America/Bogota",
|
|
||||||
"America/New_York",
|
|
||||||
"America/Caracas",
|
|
||||||
"America/Halifax",
|
|
||||||
"America/Santo_Domingo",
|
|
||||||
"America/Santiago",
|
|
||||||
"America/St_Johns",
|
|
||||||
"America/Godthab",
|
|
||||||
"America/Argentina/Buenos_Aires",
|
|
||||||
"America/Montevideo",
|
|
||||||
"Etc/GMT+2",
|
|
||||||
"Atlantic/Azores",
|
|
||||||
"Atlantic/Cape_Verde",
|
|
||||||
"Etc/UTC",
|
|
||||||
"Europe/London",
|
|
||||||
"Europe/Berlin",
|
|
||||||
"Africa/Lagos",
|
|
||||||
"Africa/Windhoek",
|
|
||||||
"Asia/Beirut",
|
|
||||||
"Africa/Johannesburg",
|
|
||||||
"Asia/Baghdad",
|
|
||||||
"Europe/Moscow",
|
|
||||||
"Asia/Tehran",
|
|
||||||
"Asia/Dubai",
|
|
||||||
"Asia/Baku",
|
|
||||||
"Asia/Kabul",
|
|
||||||
"Asia/Yekaterinburg",
|
|
||||||
"Asia/Karachi",
|
|
||||||
"Asia/Kolkata",
|
|
||||||
"Asia/Kathmandu",
|
|
||||||
"Asia/Dhaka",
|
|
||||||
"Asia/Omsk",
|
|
||||||
"Asia/Krasnoyarsk",
|
|
||||||
"Asia/Jakarta",
|
|
||||||
"Asia/Shanghai",
|
|
||||||
"Asia/Irkutsk",
|
|
||||||
"Australia/Eucla",
|
|
||||||
"Asia/Yakutsk",
|
|
||||||
"Asia/Tokyo",
|
|
||||||
"Australia/Darwin",
|
|
||||||
"Australia/Adelaide",
|
|
||||||
"Australia/Brisbane",
|
|
||||||
"Asia/Vladivostok",
|
|
||||||
"Australia/Sydney",
|
|
||||||
"Australia/Lord_Howe",
|
|
||||||
"Asia/Kamchatka",
|
|
||||||
"Pacific/Noumea",
|
|
||||||
"Pacific/Norfolk",
|
|
||||||
"Pacific/Auckland",
|
|
||||||
"Pacific/Tarawa",
|
|
||||||
"Pacific/Chatham",
|
|
||||||
"Pacific/Tongatapu",
|
|
||||||
"Pacific/Apia",
|
|
||||||
"Pacific/Kiritimati",
|
|
||||||
};
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
const char ESP_TZ_NAME[][TIMEZONE_MAX_LEN] =
|
|
||||||
{
|
|
||||||
TZ_Pacific_Pago_Pago, //PSTR("SST11")
|
|
||||||
TZ_America_Adak, //PSTR("HST10HDT,M3.2.0,M11.1.0")
|
|
||||||
TZ_Pacific_Honolulu, //PSTR("HST10")
|
|
||||||
TZ_Pacific_Marquesas, //PSTR("<-0930>9:30")
|
|
||||||
TZ_Pacific_Gambier, //PSTR("<-09>9")
|
|
||||||
TZ_America_Anchorage, //PSTR("AKST9AKDT,M3.2.0,M11.1.0")
|
|
||||||
TZ_America_Los_Angeles, //"PST8PDT,M3.2.0,M11.1.0", //"America/Los_Angeles",
|
|
||||||
TZ_Pacific_Pitcairn, //PSTR("<-08>8")
|
|
||||||
TZ_America_Phoenix, //PSTR("MST7")
|
|
||||||
TZ_America_Denver, //"MST7MDT,M3.2.0,M11.1.0", //"America/Denver",
|
|
||||||
TZ_America_Guatemala, //PSTR("CST6")
|
|
||||||
TZ_America_Chicago, //"CST6CDT,M3.2.0,M11.1.0", //"America/Chicago",
|
|
||||||
TZ_Pacific_Easter, //PSTR("<-06>6<-05>,M9.1.6/22,M4.1.6/22")
|
|
||||||
TZ_America_Bogota, //PSTR("<-05>5")
|
|
||||||
TZ_America_New_York, //"EST5EDT,M3.2.0,M11.1.0", //"America/New_York",
|
|
||||||
TZ_America_Caracas, //PSTR("<-04>4")
|
|
||||||
TZ_America_Halifax, //"AST4ADT,M3.2.0,M11.1.0", //"America/Halifax",
|
|
||||||
TZ_America_Santo_Domingo, //PSTR("AST4")
|
|
||||||
TZ_America_Santiago, //"<-04>4<-03>,M9.1.6/24,M4.1.6/24", //"America/Santiago",
|
|
||||||
TZ_America_St_Johns, //PSTR("NST3:30NDT,M3.2.0,M11.1.0")
|
|
||||||
TZ_America_Godthab, //"<-03>3<-02>,M3.5.0/-2,M10.5.0/-1", //"America/Godthab",
|
|
||||||
TZ_America_Argentina_Buenos_Aires, //PSTR("<-03>3")
|
|
||||||
TZ_America_Montevideo, //"<-03>3", //"America/Montevideo",
|
|
||||||
TZ_Etc_GMTp2, //PSTR("<-02>2")
|
|
||||||
TZ_Atlantic_Azores, //PSTR("<-01>1<+00>,M3.5.0/0,M10.5.0/1")
|
|
||||||
TZ_Atlantic_Cape_Verde, //PSTR("<-01>1")
|
|
||||||
TZ_Etc_UTC, //PSTR("UTC0")
|
|
||||||
TZ_Europe_London, //PSTR("GMT0BST,M3.5.0/1,M10.5.0")
|
|
||||||
TZ_Europe_Berlin, //PSTR("CET-1CEST,M3.5.0,M10.5.0/3")
|
|
||||||
TZ_Africa_Lagos, //PSTR("WAT-1")
|
|
||||||
TZ_Africa_Windhoek, //PSTR("CAT-2")
|
|
||||||
TZ_Asia_Beirut, //"EET-2EEST,M3.5.0/0,M10.5.0/0" //"Asia/Beirut",
|
|
||||||
TZ_Africa_Johannesburg, //"SAST-2", //"Africa/Johannesburg",
|
|
||||||
TZ_Asia_Baghdad, //"<+03>-3", //"Asia/Baghdad",
|
|
||||||
TZ_Europe_Moscow, //PSTR("MSK-3")
|
|
||||||
TZ_Asia_Tehran, //PSTR("<+0330>-3:30<+0430>,J79/24,J263/24")
|
|
||||||
TZ_Asia_Dubai, //"<+04>-4", //"Asia/Dubai",
|
|
||||||
TZ_Asia_Baku, //PSTR("<+04>-4")
|
|
||||||
TZ_Asia_Kabul, //PSTR("<+0430>-4:30")
|
|
||||||
TZ_Asia_Yekaterinburg, //PSTR("<+05>-5")
|
|
||||||
TZ_Asia_Karachi, //PSTR("PKT-5")
|
|
||||||
TZ_Asia_Kolkata, //PSTR("IST-5:30")
|
|
||||||
TZ_Asia_Kathmandu, //PSTR("<+0545>-5:45")
|
|
||||||
TZ_Asia_Dhaka, //"<+06>-6", //"Asia/Dhaka",
|
|
||||||
TZ_Asia_Omsk, //PSTR("<+06>-6")
|
|
||||||
TZ_Asia_Krasnoyarsk, //PSTR("<+07>-7")
|
|
||||||
TZ_Asia_Jakarta, //"WIB-7", //"Asia/Jakarta",
|
|
||||||
TZ_Asia_Shanghai, //"CST-8", //"Asia/Shanghai",
|
|
||||||
TZ_Asia_Irkutsk, //PSTR("<+08>-8")
|
|
||||||
TZ_Australia_Eucla, //PSTR("<+0845>-8:45")
|
|
||||||
TZ_Asia_Yakutsk, //PSTR("<+09>-9")
|
|
||||||
TZ_Asia_Tokyo, //"JST-9", //"Asia/Tokyo",
|
|
||||||
TZ_Australia_Darwin, //PSTR("ACST-9:30")
|
|
||||||
TZ_Australia_Adelaide, //PSTR("ACST-9:30ACDT,M10.1.0,M4.1.0/3")
|
|
||||||
TZ_Australia_Brisbane, //"AEST-10", //"Australia/Brisbane",
|
|
||||||
TZ_Asia_Vladivostok, //PSTR("<+10>-10")
|
|
||||||
TZ_Australia_Sydney, //PSTR("AEST-10AEDT,M10.1.0,M4.1.0/3")
|
|
||||||
TZ_Australia_Lord_Howe, //PSTR("<+1030>-10:30<+11>-11,M10.1.0,M4.1.0")
|
|
||||||
TZ_Asia_Kamchatka, //PSTR("<+12>-12")
|
|
||||||
TZ_Pacific_Noumea, //"<+11>-11", //"Pacific/Noumea",
|
|
||||||
TZ_Pacific_Norfolk, //PSTR("<+11>-11<+12>,M10.1.0,M4.1.0/3")
|
|
||||||
TZ_Pacific_Auckland, //"NZST-12NZDT,M9.5.0,M4.1.0/3", //"Pacific/Auckland",
|
|
||||||
TZ_Pacific_Tarawa, //"<+12>-12", //"Pacific/Tarawa",
|
|
||||||
TZ_Pacific_Chatham, //PSTR("<+1245>-12:45<+1345>,M9.5.0/2:45,M4.1.0/3:45")
|
|
||||||
TZ_Pacific_Tongatapu, //PSTR("<+13>-13")
|
|
||||||
TZ_Pacific_Apia, //PSTR("<+13>-13<+14>,M9.5.0/3,M4.1.0/4")
|
|
||||||
TZ_Pacific_Kiritimati, //PSTR("<+14>-14")
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // TZDB_H
|
#endif // TZDB_H
|
||||||
|
@ -234,9 +234,7 @@ int8_t I2Cdev::readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8
|
|||||||
useWire->beginTransmission(devAddr);
|
useWire->beginTransmission(devAddr);
|
||||||
useWire->send(regAddr);
|
useWire->send(regAddr);
|
||||||
useWire->endTransmission();
|
useWire->endTransmission();
|
||||||
useWire->beginTransmission(devAddr);
|
|
||||||
useWire->requestFrom((uint8_t)devAddr, (uint8_t)min((int)length - k, I2CDEVLIB_WIRE_BUFFER_LENGTH));
|
useWire->requestFrom((uint8_t)devAddr, (uint8_t)min((int)length - k, I2CDEVLIB_WIRE_BUFFER_LENGTH));
|
||||||
|
|
||||||
for (; useWire->available() && (timeout == 0 || millis() - t1 < timeout); count++) {
|
for (; useWire->available() && (timeout == 0 || millis() - t1 < timeout); count++) {
|
||||||
data[count] = useWire->receive();
|
data[count] = useWire->receive();
|
||||||
#ifdef I2CDEV_SERIAL_DEBUG
|
#ifdef I2CDEV_SERIAL_DEBUG
|
||||||
@ -244,8 +242,6 @@ int8_t I2Cdev::readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8
|
|||||||
if (count + 1 < length) Serial.print(" ");
|
if (count + 1 < length) Serial.print(" ");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
useWire->endTransmission();
|
|
||||||
}
|
}
|
||||||
#elif (ARDUINO == 100)
|
#elif (ARDUINO == 100)
|
||||||
// Arduino v1.0.0, Wire library
|
// Arduino v1.0.0, Wire library
|
||||||
@ -258,9 +254,7 @@ int8_t I2Cdev::readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8
|
|||||||
useWire->beginTransmission(devAddr);
|
useWire->beginTransmission(devAddr);
|
||||||
useWire->write(regAddr);
|
useWire->write(regAddr);
|
||||||
useWire->endTransmission();
|
useWire->endTransmission();
|
||||||
useWire->beginTransmission(devAddr);
|
|
||||||
useWire->requestFrom((uint8_t)devAddr, (uint8_t)min((int)length - k, I2CDEVLIB_WIRE_BUFFER_LENGTH));
|
useWire->requestFrom((uint8_t)devAddr, (uint8_t)min((int)length - k, I2CDEVLIB_WIRE_BUFFER_LENGTH));
|
||||||
|
|
||||||
for (; useWire->available() && (timeout == 0 || millis() - t1 < timeout); count++) {
|
for (; useWire->available() && (timeout == 0 || millis() - t1 < timeout); count++) {
|
||||||
data[count] = useWire->read();
|
data[count] = useWire->read();
|
||||||
#ifdef I2CDEV_SERIAL_DEBUG
|
#ifdef I2CDEV_SERIAL_DEBUG
|
||||||
@ -268,8 +262,6 @@ int8_t I2Cdev::readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8
|
|||||||
if (count + 1 < length) Serial.print(" ");
|
if (count + 1 < length) Serial.print(" ");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
useWire->endTransmission();
|
|
||||||
}
|
}
|
||||||
#elif (ARDUINO > 100)
|
#elif (ARDUINO > 100)
|
||||||
// Arduino v1.0.1+, Wire library
|
// Arduino v1.0.1+, Wire library
|
||||||
@ -282,10 +274,7 @@ int8_t I2Cdev::readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8
|
|||||||
useWire->beginTransmission(devAddr);
|
useWire->beginTransmission(devAddr);
|
||||||
useWire->write(regAddr);
|
useWire->write(regAddr);
|
||||||
useWire->endTransmission();
|
useWire->endTransmission();
|
||||||
// See: https://github.com/espressif/arduino-esp32/issues/6674
|
|
||||||
// useWire->beginTransmission(devAddr);
|
|
||||||
useWire->requestFrom((uint8_t)devAddr, (uint8_t)min((int)length - k, I2CDEVLIB_WIRE_BUFFER_LENGTH));
|
useWire->requestFrom((uint8_t)devAddr, (uint8_t)min((int)length - k, I2CDEVLIB_WIRE_BUFFER_LENGTH));
|
||||||
|
|
||||||
for (; useWire->available() && (timeout == 0 || millis() - t1 < timeout); count++) {
|
for (; useWire->available() && (timeout == 0 || millis() - t1 < timeout); count++) {
|
||||||
data[count] = useWire->read();
|
data[count] = useWire->read();
|
||||||
#ifdef I2CDEV_SERIAL_DEBUG
|
#ifdef I2CDEV_SERIAL_DEBUG
|
||||||
@ -357,7 +346,6 @@ int8_t I2Cdev::readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint1
|
|||||||
useWire->beginTransmission(devAddr);
|
useWire->beginTransmission(devAddr);
|
||||||
useWire->send(regAddr);
|
useWire->send(regAddr);
|
||||||
useWire->endTransmission();
|
useWire->endTransmission();
|
||||||
useWire->beginTransmission(devAddr);
|
|
||||||
useWire->requestFrom(devAddr, (uint8_t)(length * 2)); // length=words, this wants bytes
|
useWire->requestFrom(devAddr, (uint8_t)(length * 2)); // length=words, this wants bytes
|
||||||
|
|
||||||
bool msb = true; // starts with MSB, then LSB
|
bool msb = true; // starts with MSB, then LSB
|
||||||
@ -376,8 +364,6 @@ int8_t I2Cdev::readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint1
|
|||||||
}
|
}
|
||||||
msb = !msb;
|
msb = !msb;
|
||||||
}
|
}
|
||||||
|
|
||||||
useWire->endTransmission();
|
|
||||||
}
|
}
|
||||||
#elif (ARDUINO == 100)
|
#elif (ARDUINO == 100)
|
||||||
// Arduino v1.0.0, Wire library
|
// Arduino v1.0.0, Wire library
|
||||||
@ -390,7 +376,6 @@ int8_t I2Cdev::readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint1
|
|||||||
useWire->beginTransmission(devAddr);
|
useWire->beginTransmission(devAddr);
|
||||||
useWire->write(regAddr);
|
useWire->write(regAddr);
|
||||||
useWire->endTransmission();
|
useWire->endTransmission();
|
||||||
useWire->beginTransmission(devAddr);
|
|
||||||
useWire->requestFrom(devAddr, (uint8_t)(length * 2)); // length=words, this wants bytes
|
useWire->requestFrom(devAddr, (uint8_t)(length * 2)); // length=words, this wants bytes
|
||||||
|
|
||||||
bool msb = true; // starts with MSB, then LSB
|
bool msb = true; // starts with MSB, then LSB
|
||||||
@ -409,8 +394,6 @@ int8_t I2Cdev::readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint1
|
|||||||
}
|
}
|
||||||
msb = !msb;
|
msb = !msb;
|
||||||
}
|
}
|
||||||
|
|
||||||
useWire->endTransmission();
|
|
||||||
}
|
}
|
||||||
#elif (ARDUINO > 100)
|
#elif (ARDUINO > 100)
|
||||||
// Arduino v1.0.1+, Wire library
|
// Arduino v1.0.1+, Wire library
|
||||||
@ -423,7 +406,6 @@ int8_t I2Cdev::readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint1
|
|||||||
useWire->beginTransmission(devAddr);
|
useWire->beginTransmission(devAddr);
|
||||||
useWire->write(regAddr);
|
useWire->write(regAddr);
|
||||||
useWire->endTransmission();
|
useWire->endTransmission();
|
||||||
useWire->beginTransmission(devAddr);
|
|
||||||
useWire->requestFrom(devAddr, (uint8_t)(length * 2)); // length=words, this wants bytes
|
useWire->requestFrom(devAddr, (uint8_t)(length * 2)); // length=words, this wants bytes
|
||||||
|
|
||||||
bool msb = true; // starts with MSB, then LSB
|
bool msb = true; // starts with MSB, then LSB
|
||||||
@ -442,8 +424,6 @@ int8_t I2Cdev::readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint1
|
|||||||
}
|
}
|
||||||
msb = !msb;
|
msb = !msb;
|
||||||
}
|
}
|
||||||
|
|
||||||
useWire->endTransmission();
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
363
platformio.ini
@ -16,172 +16,327 @@ include_dir = lib
|
|||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
platform = espressif8266 @ 4.0.1
|
platform = espressif8266 @ 4.0.1
|
||||||
|
platform32 = espressif32 @ 5.2.0
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = d1_mini
|
board = d1_mini
|
||||||
build_unflags =
|
build_unflags =
|
||||||
build_flags =
|
build_flags =
|
||||||
-Wl,-Map,output.map
|
-Wl,-Map,output.map
|
||||||
-D BAUD=${common_env_data.monitor_speed}
|
-DBAUD=${common_env_data.monitor_speed}
|
||||||
-D ACTIVATE_OTA
|
|
||||||
#-D DEBUG_ESP_HTTP_CLIENT
|
|
||||||
#-D DEBUG_ESP_HTTP_SERVER
|
|
||||||
#-D DEBUG_ESP_PORT=Serial
|
|
||||||
#-D DEBUG_ESP_WIFI
|
|
||||||
#-D DEBUG_ESP_SSL
|
|
||||||
#-D DEBUG_ESP_CORE
|
|
||||||
#-D SKIP_SLEEPMODE
|
#-D SKIP_SLEEPMODE
|
||||||
-D USE_LITTLEFS=true
|
#-D FORCE_GRAVITY_MODE
|
||||||
-D EMBED_HTML # If this is not used the html files needs to be on the file system (can be uploaded)
|
#-D DOUBLERESETDETECTOR_DEBUG=true
|
||||||
-D USER_SSID=\""\"" # =\""myssid\""
|
-DACTIVATE_OTA
|
||||||
-D USER_SSID_PWD=\""\"" # =\""mypwd\""
|
-DCFG_DISABLE_LOGGING # Turn off verbose/notice logging to reduce size and dont overload uart (applies to LOG_LEVEL6)
|
||||||
-D CFG_APPVER="\"1.1.1\""
|
-DGYRO_DISABLE_LOGGING
|
||||||
#-D CFG_GITREV=\""beta-4\""
|
-DCALC_DISABLE_LOGGING
|
||||||
|
-DHELPER_DISABLE_LOGGING
|
||||||
|
-DPUSH_DISABLE_LOGGING
|
||||||
|
-DTSEN_DISABLE_LOGGING
|
||||||
|
-DWIFI_DISABLE_LOGGING
|
||||||
|
-DWEB_DISABLE_LOGGING
|
||||||
|
-DMAIN_DISABLE_LOGGING
|
||||||
|
-DUSE_LITTLEFS=true
|
||||||
|
-DUSER_SSID=\""\"" # =\""myssid\""
|
||||||
|
-DUSER_SSID_PWD=\""\"" # =\""mypwd\""
|
||||||
|
-DCFG_APPVER="\"1.2.1\""
|
||||||
|
#-DCFG_GITREV=\""beta-3\""
|
||||||
!python script/git_rev.py
|
!python script/git_rev.py
|
||||||
lib_deps = # Switched to forks for better version control.
|
lib_deps =
|
||||||
# Using local copy of these libraries
|
# Using local copy of these libraries
|
||||||
#https://github.com/mp-se/i2cdevlib.git#<document>
|
# https://github.com/mp-se/i2cdevlib.git#<document>
|
||||||
#https://github.com/mp-se/OneWire # Using this version; https://github.com/arendst/Tasmota/tree/development/lib/lib_basic/OneWire-Stickbreaker
|
# https://github.com/mp-se/OneWire
|
||||||
#https://github.com/mp-se/Arduino-Temperature-Control-Library
|
# https://github.com/mp-se/Arduino-Temperature-Control-Library
|
||||||
#https://github.com/khoih-prog/ESP_WiFiManager
|
# https://github.com/khoih-prog/ESP_WiFiManager
|
||||||
#https://github.com/khoih-prog/ESP_DoubleResetDetector
|
# https://github.com/khoih-prog/ESP_DoubleResetDetector
|
||||||
https://github.com/mp-se/tinyexpr # https://github.com/codeplea/tinyexpr
|
https://github.com/mp-se/tinyexpr # https://github.com/codeplea/tinyexpr
|
||||||
https://github.com/mp-se/incbin # https://github.com/graphitemaster/incbin
|
https://github.com/mp-se/Arduino-Log#1.1.1 # https://github.com/thijse/Arduino-Log
|
||||||
https://github.com/mp-se/Arduino-Log#1.1.1 # https://github.com/thijse/Arduino-Log
|
https://github.com/mp-se/ArduinoJson#v6.18.5 # https://github.com/bblanchon/ArduinoJson
|
||||||
https://github.com/mp-se/ArduinoJson#v6.18.5 # https://github.com/bblanchon/ArduinoJson
|
https://github.com/mp-se/arduinoCurveFitting#v1.0.6 # https://github.com/Rotario/arduinoCurveFitting
|
||||||
https://github.com/mp-se/arduinoCurveFitting#v1.0.6 # https://github.com/Rotario/arduinoCurveFitting
|
https://github.com/mp-se/arduino-mqtt#v2.5.0 # https://github.com/256dpi/arduino-mqtt
|
||||||
https://github.com/mp-se/arduino-mqtt#v2.5.0 # https://github.com/256dpi/arduino-mqtt
|
lib_deps32 =
|
||||||
|
https://github.com/mp-se/NimBLE-Arduino#1.3.8 # https://github.com/h2zero/NimBLE-Arduino
|
||||||
[env:gravity-debug]
|
|
||||||
upload_speed = ${common_env_data.upload_speed}
|
|
||||||
monitor_speed = ${common_env_data.monitor_speed}
|
|
||||||
framework = ${common_env_data.framework}
|
|
||||||
platform = ${common_env_data.platform}
|
|
||||||
extra_scripts =
|
extra_scripts =
|
||||||
script/copy_html.py
|
|
||||||
script/copy_firmware.py
|
script/copy_firmware.py
|
||||||
script/create_versionjson.py
|
script/create_versionjson.py
|
||||||
build_unflags =
|
|
||||||
${common_env_data.build_unflags}
|
; [env:gravity-debug]
|
||||||
build_flags =
|
; upload_speed = ${common_env_data.upload_speed}
|
||||||
${common_env_data.build_flags}
|
; monitor_speed = ${common_env_data.monitor_speed}
|
||||||
-D PIO_FRAMEWORK_ARDUINO_ENABLE_EXCEPTIONS
|
; framework = ${common_env_data.framework}
|
||||||
#-D SKIP_SLEEPMODE
|
; platform = ${common_env_data.platform}
|
||||||
#-D DOUBLERESETDETECTOR_DEBUG=true
|
; extra_scripts = ${common_env_data.extra_scripts}
|
||||||
#-D FORCE_GRAVITY_MODE # used to debug gravity mode
|
; build_unflags = ${common_env_data.build_unflags}
|
||||||
-D COLLECT_PERFDATA # This option will collect runtime data for a few defined methods to measure time, dumped to serial and/or influxdb
|
; build_flags =
|
||||||
-D LOG_LEVEL=6 # Maximum log level for the debug build.
|
; ${common_env_data.build_flags}
|
||||||
-D CFG_DISABLE_LOGGING # Turn off verbose/notice logging to reduce size and dont overload uart.
|
; #-D DEBUG_ESP_HTTP_CLIENT
|
||||||
-D GYRO_DISABLE_LOGGING
|
; #-D DEBUG_ESP_HTTP_SERVER
|
||||||
-D CALC_DISABLE_LOGGING
|
; #-D DEBUG_ESP_PORT=Serial
|
||||||
-D HELPER_DISABLE_LOGGING
|
; #-D DEBUG_ESP_WIFI
|
||||||
-D PUSH_DISABLE_LOGGING
|
; #-D DEBUG_ESP_SSL
|
||||||
-D TSEN_DISABLE_LOGGING
|
; #-D DEBUG_ESP_CORE
|
||||||
-D WIFI_DISABLE_LOGGING
|
; -DPIO_FRAMEWORK_ARDUINO_ENABLE_EXCEPTIONS
|
||||||
-D WEB_DISABLE_LOGGING
|
; -DCOLLECT_PERFDATA # Collect runtime data for a few defined methods to measure time, dumped to serial and/or influxdb
|
||||||
-D MAIN_DISABLE_LOGGING
|
; -DLOG_LEVEL=6
|
||||||
lib_deps =
|
; lib_deps =
|
||||||
${common_env_data.lib_deps}
|
; https://github.com/mp-se/incbin # https://github.com/graphitemaster/incbin
|
||||||
board = ${common_env_data.board}
|
; ${common_env_data.lib_deps}
|
||||||
#build_type = debug
|
; board = ${common_env_data.board}
|
||||||
build_type = release
|
; build_type = release
|
||||||
board_build.filesystem = littlefs
|
; board_build.filesystem = littlefs
|
||||||
monitor_filters = esp8266_exception_decoder
|
; monitor_filters = esp8266_exception_decoder
|
||||||
|
|
||||||
[env:gravity-release]
|
[env:gravity-release]
|
||||||
upload_speed = ${common_env_data.upload_speed}
|
upload_speed = ${common_env_data.upload_speed}
|
||||||
monitor_speed = ${common_env_data.monitor_speed}
|
monitor_speed = ${common_env_data.monitor_speed}
|
||||||
framework = ${common_env_data.framework}
|
framework = ${common_env_data.framework}
|
||||||
platform = ${common_env_data.platform}
|
platform = ${common_env_data.platform}
|
||||||
extra_scripts =
|
extra_scripts = ${common_env_data.extra_scripts}
|
||||||
script/copy_html.py
|
|
||||||
script/copy_firmware.py
|
|
||||||
script/create_versionjson.py
|
|
||||||
build_unflags = ${common_env_data.build_unflags}
|
build_unflags = ${common_env_data.build_unflags}
|
||||||
build_flags =
|
build_flags =
|
||||||
${common_env_data.build_flags}
|
${common_env_data.build_flags}
|
||||||
-D LOG_LEVEL=4
|
-D LOG_LEVEL=4
|
||||||
|
#-DUSE_SERIAL_PINS # Use the TX/RX pins for the serial port
|
||||||
lib_deps =
|
lib_deps =
|
||||||
|
https://github.com/mp-se/incbin # https://github.com/graphitemaster/incbin
|
||||||
${common_env_data.lib_deps}
|
${common_env_data.lib_deps}
|
||||||
board = ${common_env_data.board}
|
board = ${common_env_data.board}
|
||||||
build_type = release
|
build_type = release
|
||||||
|
#build_type = debug
|
||||||
board_build.filesystem = littlefs
|
board_build.filesystem = littlefs
|
||||||
|
build_src_filter = +<*> -<../test/tests*.cpp>
|
||||||
|
monitor_filters = esp8266_exception_decoder
|
||||||
|
|
||||||
[env:gravity-perf]
|
[env:gravity-unit]
|
||||||
upload_speed = ${common_env_data.upload_speed}
|
upload_speed = ${common_env_data.upload_speed}
|
||||||
monitor_speed = ${common_env_data.monitor_speed}
|
monitor_speed = ${common_env_data.monitor_speed}
|
||||||
framework = ${common_env_data.framework}
|
framework = ${common_env_data.framework}
|
||||||
platform = ${common_env_data.platform}
|
platform = ${common_env_data.platform}
|
||||||
extra_scripts =
|
extra_scripts = ${common_env_data.extra_scripts}
|
||||||
script/copy_html.py
|
|
||||||
script/copy_firmware.py
|
|
||||||
script/create_versionjson.py
|
|
||||||
build_unflags = ${common_env_data.build_unflags}
|
build_unflags = ${common_env_data.build_unflags}
|
||||||
build_flags =
|
build_flags =
|
||||||
${common_env_data.build_flags}
|
${common_env_data.build_flags}
|
||||||
-D COLLECT_PERFDATA
|
-D LOG_LEVEL=4
|
||||||
-D LOG_LEVEL=5
|
|
||||||
lib_deps =
|
lib_deps =
|
||||||
|
https://github.com/mp-se/incbin # https://github.com/graphitemaster/incbin
|
||||||
|
https://github.com/bxparks/AUnit#v1.6.1
|
||||||
${common_env_data.lib_deps}
|
${common_env_data.lib_deps}
|
||||||
board = ${common_env_data.board}
|
board = ${common_env_data.board}
|
||||||
build_type = release
|
build_type = debug
|
||||||
board_build.filesystem = littlefs
|
board_build.filesystem = littlefs
|
||||||
|
build_src_filter = +<*> -<main.cpp> +<../test/tests*.cpp>
|
||||||
|
monitor_filters = esp8266_exception_decoder
|
||||||
|
|
||||||
[env:gravity32-release]
|
[env:gravity32-release]
|
||||||
framework = arduino
|
framework = ${common_env_data.framework}
|
||||||
platform = espressif32 @ 5.0.0
|
platform = ${common_env_data.platform32}
|
||||||
upload_speed = ${common_env_data.upload_speed}
|
upload_speed = ${common_env_data.upload_speed}
|
||||||
monitor_speed = ${common_env_data.monitor_speed}
|
monitor_speed = ${common_env_data.monitor_speed}
|
||||||
extra_scripts =
|
extra_scripts = ${common_env_data.extra_scripts}
|
||||||
script/copy_html.py
|
|
||||||
script/copy_firmware.py
|
|
||||||
script/create_versionjson.py
|
|
||||||
build_unflags =
|
build_unflags =
|
||||||
${common_env_data.build_unflags}
|
${common_env_data.build_unflags}
|
||||||
build_flags =
|
build_flags =
|
||||||
-Wl,-Map,output.map
|
-Wl,-Map,output.map
|
||||||
|
#-DCORE_DEBUG_LEVEL=0
|
||||||
${common_env_data.build_flags}
|
${common_env_data.build_flags}
|
||||||
#-D COLLECT_PERFDATA
|
|
||||||
-D LOG_LEVEL=5
|
-D LOG_LEVEL=5
|
||||||
-D CFG_DISABLE_LOGGING # Turn off verbose/notice logging to reduce size and dont overload uart (applies to LOG_LEVEL6)
|
-DESP32D1
|
||||||
-D GYRO_DISABLE_LOGGING
|
-DCORE_DEBUG_LEVEL=0
|
||||||
-D CALC_DISABLE_LOGGING
|
#-DUSE_SERIAL_PINS # Use the TX/RX pins for the serial port
|
||||||
-D HELPER_DISABLE_LOGGING
|
|
||||||
-D PUSH_DISABLE_LOGGING
|
|
||||||
-D TSEN_DISABLE_LOGGING
|
|
||||||
-D WIFI_DISABLE_LOGGING
|
|
||||||
-D WEB_DISABLE_LOGGING
|
|
||||||
-D MAIN_DISABLE_LOGGING
|
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common_env_data.lib_deps}
|
${common_env_data.lib_deps}
|
||||||
https://github.com/mp-se/NimBLE-Arduino#1.3.8 # https://github.com/h2zero/NimBLE-Arduino
|
${common_env_data.lib_deps32}
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
board = featheresp32
|
board = wemos_d1_mini32
|
||||||
build_type = release
|
build_type = release
|
||||||
board_build.partitions = part32.csv
|
board_build.partitions = part32.csv
|
||||||
board_build.filesystem = littlefs
|
board_build.filesystem = littlefs
|
||||||
monitor_filters = esp32_exception_decoder
|
board_build.embed_txtfiles =
|
||||||
|
html/calibration.min.htm
|
||||||
|
html/config.min.htm
|
||||||
|
html/firmware.min.htm
|
||||||
|
html/format.min.htm
|
||||||
|
html/about.min.htm
|
||||||
|
html/index.min.htm
|
||||||
|
html/test.min.htm
|
||||||
|
|
||||||
[env:gravity32-perf]
|
[env:gravity32c3-release]
|
||||||
framework = arduino
|
framework = ${common_env_data.framework}
|
||||||
platform = espressif32 @ 5.0.0
|
platform = ${common_env_data.platform32}
|
||||||
upload_speed = ${common_env_data.upload_speed}
|
upload_speed = ${common_env_data.upload_speed}
|
||||||
monitor_speed = ${common_env_data.monitor_speed}
|
monitor_speed = ${common_env_data.monitor_speed}
|
||||||
extra_scripts =
|
extra_scripts = ${common_env_data.extra_scripts}
|
||||||
script/copy_html.py
|
|
||||||
script/copy_firmware.py
|
|
||||||
script/create_versionjson.py
|
|
||||||
build_unflags =
|
build_unflags =
|
||||||
${common_env_data.build_unflags}
|
${common_env_data.build_unflags}
|
||||||
build_flags =
|
build_flags =
|
||||||
-Wl,-Map,output.map
|
-Wl,-Map,output.map
|
||||||
${common_env_data.build_flags}
|
${common_env_data.build_flags}
|
||||||
-D COLLECT_PERFDATA
|
-DLOG_LEVEL=5
|
||||||
-D LOG_LEVEL=5
|
-DCORE_DEBUG_LEVEL=0
|
||||||
|
-DESP32C3
|
||||||
|
-DARDUINO_ESP32C3_DEV
|
||||||
|
#-DUSE_SERIAL_PINS # Use the TX/RX pins for the serial port
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common_env_data.lib_deps}
|
${common_env_data.lib_deps}
|
||||||
https://github.com/mp-se/NimBLE-Arduino#1.3.8 # https://github.com/h2zero/NimBLE-Arduino
|
${common_env_data.lib_deps32}
|
||||||
board = featheresp32
|
lib_ignore =
|
||||||
|
board = lolin_c3_mini
|
||||||
build_type = release
|
build_type = release
|
||||||
board_build.partitions = part32.csv
|
board_build.partitions = part32.csv
|
||||||
board_build.filesystem = littlefs
|
board_build.filesystem = littlefs
|
||||||
monitor_filters = esp32_exception_decoder
|
board_build.embed_txtfiles =
|
||||||
|
html/calibration.min.htm
|
||||||
|
html/config.min.htm
|
||||||
|
html/firmware.min.htm
|
||||||
|
html/format.min.htm
|
||||||
|
html/about.min.htm
|
||||||
|
html/index.min.htm
|
||||||
|
html/test.min.htm
|
||||||
|
|
||||||
|
[env:gravity32c3v1-release]
|
||||||
|
framework = ${common_env_data.framework}
|
||||||
|
platform = ${common_env_data.platform32}
|
||||||
|
upload_speed = ${common_env_data.upload_speed}
|
||||||
|
monitor_speed = ${common_env_data.monitor_speed}
|
||||||
|
extra_scripts = ${common_env_data.extra_scripts}
|
||||||
|
build_unflags =
|
||||||
|
${common_env_data.build_unflags}
|
||||||
|
build_flags =
|
||||||
|
-Wl,-Map,output.map
|
||||||
|
${common_env_data.build_flags}
|
||||||
|
-DLOG_LEVEL=5
|
||||||
|
-DCORE_DEBUG_LEVEL=0
|
||||||
|
-DESP32C3
|
||||||
|
-DARDUINO_ESP32C3_DEV
|
||||||
|
-DREDUCE_WIFI_POWER # Enable this if v1.0 chip is used
|
||||||
|
#-DUSE_SERIAL_PINS # Use the TX/RX pins for the serial port
|
||||||
|
lib_deps =
|
||||||
|
${common_env_data.lib_deps}
|
||||||
|
${common_env_data.lib_deps32}
|
||||||
|
lib_ignore =
|
||||||
|
board = lolin_c3_mini
|
||||||
|
build_type = release
|
||||||
|
board_build.partitions = part32.csv
|
||||||
|
board_build.filesystem = littlefs
|
||||||
|
board_build.embed_txtfiles =
|
||||||
|
html/calibration.min.htm
|
||||||
|
html/config.min.htm
|
||||||
|
html/firmware.min.htm
|
||||||
|
html/format.min.htm
|
||||||
|
html/about.min.htm
|
||||||
|
html/index.min.htm
|
||||||
|
html/test.min.htm
|
||||||
|
|
||||||
|
[env:gravity32s2-release]
|
||||||
|
framework = ${common_env_data.framework}
|
||||||
|
platform = ${common_env_data.platform32}
|
||||||
|
upload_speed = ${common_env_data.upload_speed}
|
||||||
|
monitor_speed = ${common_env_data.monitor_speed}
|
||||||
|
extra_scripts = ${common_env_data.extra_scripts}
|
||||||
|
build_unflags =
|
||||||
|
${common_env_data.build_unflags}
|
||||||
|
build_flags =
|
||||||
|
-Wl,-Map,output.map
|
||||||
|
${common_env_data.build_flags}
|
||||||
|
-DLOG_LEVEL=5
|
||||||
|
-DCORE_DEBUG_LEVEL=0
|
||||||
|
-DESP32S2
|
||||||
|
-DARDUINO_ESP32S2_DEV
|
||||||
|
#-DUSE_SERIAL_PINS # Use the TX/RX pins for the serial port
|
||||||
|
lib_deps =
|
||||||
|
${common_env_data.lib_deps}
|
||||||
|
lib_ignore =
|
||||||
|
board = lolin_s2_mini
|
||||||
|
build_type = release
|
||||||
|
board_build.partitions = part32.csv
|
||||||
|
board_build.filesystem = littlefs
|
||||||
|
board_build.embed_txtfiles =
|
||||||
|
html/calibration.min.htm
|
||||||
|
html/config.min.htm
|
||||||
|
html/firmware.min.htm
|
||||||
|
html/format.min.htm
|
||||||
|
html/about.min.htm
|
||||||
|
html/index.min.htm
|
||||||
|
html/test.min.htm
|
||||||
|
|
||||||
|
[env:gravity32c3-debug]
|
||||||
|
framework = ${common_env_data.framework}
|
||||||
|
platform = ${common_env_data.platform32}
|
||||||
|
upload_speed = ${common_env_data.upload_speed}
|
||||||
|
monitor_speed = ${common_env_data.monitor_speed}
|
||||||
|
monitor_filters = time, colorize, log2file, esp32_exception_decoder
|
||||||
|
extra_scripts = ${common_env_data.extra_scripts}
|
||||||
|
upload_port = COM8
|
||||||
|
debug_tool = esp-prog
|
||||||
|
debug_init_break = break setup
|
||||||
|
build_unflags =
|
||||||
|
-DCFG_DISABLE_LOGGING
|
||||||
|
-DGYRO_DISABLE_LOGGING
|
||||||
|
-DCALC_DISABLE_LOGGING
|
||||||
|
-DHELPER_DISABLE_LOGGING
|
||||||
|
-DPUSH_DISABLE_LOGGING
|
||||||
|
-DTSEN_DISABLE_LOGGING
|
||||||
|
-DWIFI_DISABLE_LOGGING
|
||||||
|
-DWEB_DISABLE_LOGGING
|
||||||
|
-DMAIN_DISABLE_LOGGING
|
||||||
|
${common_env_data.build_unflags}
|
||||||
|
build_flags =
|
||||||
|
-Wl,-Map,output.map
|
||||||
|
${common_env_data.build_flags}
|
||||||
|
-DLOG_LEVEL=6
|
||||||
|
-DCORE_DEBUG_LEVEL=5
|
||||||
|
-DJTAG_DEBUG
|
||||||
|
-DESP32C3
|
||||||
|
#-DUSE_SERIAL_PINS # Use the TX/RX pins for the serial port
|
||||||
|
-DARDUINO_ESP32C3_DEV
|
||||||
|
-DCOLLECT_PERFDATA # Collect runtime data for a few defined methods to measure time, dumped to serial and/or influxdb
|
||||||
|
lib_deps =
|
||||||
|
${common_env_data.lib_deps}
|
||||||
|
${common_env_data.lib_deps32}
|
||||||
|
lib_ignore =
|
||||||
|
board = esp32-c3-devkitm-1
|
||||||
|
build_type = debug
|
||||||
|
board_build.partitions = part32.csv
|
||||||
|
board_build.filesystem = littlefs
|
||||||
|
board_build.embed_txtfiles =
|
||||||
|
html/calibration.min.htm
|
||||||
|
html/config.min.htm
|
||||||
|
html/firmware.min.htm
|
||||||
|
html/format.min.htm
|
||||||
|
html/about.min.htm
|
||||||
|
html/index.min.htm
|
||||||
|
html/test.min.htm
|
||||||
|
|
||||||
|
# This is a version for the floaty hardware. No DSB18 sensor and no battery measurement.
|
||||||
|
[env:gravity32lite-release]
|
||||||
|
framework = ${common_env_data.framework}
|
||||||
|
platform = ${common_env_data.platform32}
|
||||||
|
upload_speed = ${common_env_data.upload_speed}
|
||||||
|
monitor_speed = ${common_env_data.monitor_speed}
|
||||||
|
extra_scripts = ${common_env_data.extra_scripts}
|
||||||
|
build_unflags =
|
||||||
|
${common_env_data.build_unflags}
|
||||||
|
build_flags =
|
||||||
|
-Wl,-Map,output.map
|
||||||
|
${common_env_data.build_flags}
|
||||||
|
-DLOG_LEVEL=5
|
||||||
|
-DCORE_DEBUG_LEVEL=0
|
||||||
|
-DESP32LITE
|
||||||
|
-DFLOATY
|
||||||
|
#-DUSE_SERIAL_PINS # Use the TX/RX pins for the serial port
|
||||||
|
lib_deps =
|
||||||
|
${common_env_data.lib_deps}
|
||||||
|
${common_env_data.lib_deps32}
|
||||||
|
lib_ignore =
|
||||||
|
board = lolin32_lite
|
||||||
|
build_type = release
|
||||||
|
board_build.partitions = part32.csv
|
||||||
|
board_build.filesystem = littlefs
|
||||||
|
board_build.embed_txtfiles =
|
||||||
|
html/calibration.min.htm
|
||||||
|
html/config.min.htm
|
||||||
|
html/firmware.min.htm
|
||||||
|
html/format.min.htm
|
||||||
|
html/about.min.htm
|
||||||
|
html/index.min.htm
|
||||||
|
html/test.min.htm
|
||||||
|
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
requests
|
@ -23,12 +23,6 @@ def after_build(source, target, env):
|
|||||||
print( "Copy file : " + source + " -> " + target )
|
print( "Copy file : " + source + " -> " + target )
|
||||||
shutil.copyfile( source, target )
|
shutil.copyfile( source, target )
|
||||||
|
|
||||||
if name == "gravity-perf" :
|
|
||||||
target = dir + "/bin/firmware-perf.bin"
|
|
||||||
source = dir + "/.pio/build/" + name + "/firmware.bin"
|
|
||||||
print( "Copy file : " + source + " -> " + target )
|
|
||||||
shutil.copyfile( source, target )
|
|
||||||
|
|
||||||
if name == "gravity32-release" :
|
if name == "gravity32-release" :
|
||||||
target = dir + "/bin/firmware32.bin"
|
target = dir + "/bin/firmware32.bin"
|
||||||
source = dir + "/.pio/build/" + name + "/firmware.bin"
|
source = dir + "/.pio/build/" + name + "/firmware.bin"
|
||||||
@ -40,18 +34,44 @@ def after_build(source, target, env):
|
|||||||
print( "Copy file : " + source + " -> " + target )
|
print( "Copy file : " + source + " -> " + target )
|
||||||
shutil.copyfile( source, target )
|
shutil.copyfile( source, target )
|
||||||
|
|
||||||
if name == "gravity32-perf" :
|
if name == "gravity32c3-release" :
|
||||||
target = dir + "/bin/firmware32-perf.bin"
|
target = dir + "/bin/firmware32c3.bin"
|
||||||
source = dir + "/.pio/build/" + name + "/firmware.bin"
|
source = dir + "/.pio/build/" + name + "/firmware.bin"
|
||||||
print( "Copy file : " + source + " -> " + target )
|
print( "Copy file : " + source + " -> " + target )
|
||||||
shutil.copyfile( source, target )
|
shutil.copyfile( source, target )
|
||||||
|
|
||||||
if name == "gravity32-release2" :
|
target = dir + "/bin/partitions32c3.bin"
|
||||||
target = dir + "/bin/firmware32_2.bin"
|
source = dir + "/.pio/build/" + name + "/partitions.bin"
|
||||||
|
print( "Copy file : " + source + " -> " + target )
|
||||||
|
shutil.copyfile( source, target )
|
||||||
|
|
||||||
|
if name == "gravity32c3v1-release" :
|
||||||
|
target = dir + "/bin/firmware32c3v1.bin"
|
||||||
source = dir + "/.pio/build/" + name + "/firmware.bin"
|
source = dir + "/.pio/build/" + name + "/firmware.bin"
|
||||||
print( "Copy file : " + source + " -> " + target )
|
print( "Copy file : " + source + " -> " + target )
|
||||||
shutil.copyfile( source, target )
|
shutil.copyfile( source, target )
|
||||||
|
|
||||||
|
if name == "gravity32s2-release" :
|
||||||
|
target = dir + "/bin/firmware32s2.bin"
|
||||||
|
source = dir + "/.pio/build/" + name + "/firmware.bin"
|
||||||
|
print( "Copy file : " + source + " -> " + target )
|
||||||
|
shutil.copyfile( source, target )
|
||||||
|
|
||||||
|
target = dir + "/bin/partitions32s2.bin"
|
||||||
|
source = dir + "/.pio/build/" + name + "/partitions.bin"
|
||||||
|
print( "Copy file : " + source + " -> " + target )
|
||||||
|
shutil.copyfile( source, target )
|
||||||
|
|
||||||
|
if name == "gravity32lite-release" :
|
||||||
|
target = dir + "/bin/firmware32lite.bin"
|
||||||
|
source = dir + "/.pio/build/" + name + "/firmware.bin"
|
||||||
|
print( "Copy file : " + source + " -> " + target )
|
||||||
|
shutil.copyfile( source, target )
|
||||||
|
|
||||||
|
target = dir + "/bin/partitions32lite.bin"
|
||||||
|
source = dir + "/.pio/build/" + name + "/partitions.bin"
|
||||||
|
print( "Copy file : " + source + " -> " + target )
|
||||||
|
shutil.copyfile( source, target )
|
||||||
|
|
||||||
print( "Adding custom build step (copy firmware): ")
|
print( "Adding custom build step (copy firmware): ")
|
||||||
env.AddPostAction("buildprog", after_build)
|
env.AddPostAction("buildprog", after_build)
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
Import("env")
|
|
||||||
import shutil, os
|
|
||||||
|
|
||||||
print( "Executing custom step " )
|
|
||||||
dir = env.GetLaunchDir()
|
|
||||||
source = dir + "/html/"
|
|
||||||
target = dir + "/data/"
|
|
||||||
print( "Copy html-files from " + source + " -> " + target )
|
|
||||||
|
|
||||||
os.makedirs(os.path.dirname( target ), exist_ok=True)
|
|
||||||
file = "about.min.htm"
|
|
||||||
#print( "Copy file: " + source + file + "->" + target + file)
|
|
||||||
shutil.copyfile( source + file, target + file )
|
|
||||||
file = "calibration.min.htm"
|
|
||||||
#print( "Copy file: " + source + file + "->" + target + file)
|
|
||||||
shutil.copyfile( source + file, target + file )
|
|
||||||
file = "config.min.htm"
|
|
||||||
#print( "Copy file: " + source + file + "->" + target + file)
|
|
||||||
shutil.copyfile( source + file, target + file )
|
|
||||||
file = "index.min.htm"
|
|
||||||
#print( "Copy file: " + source + file + "->" + target + file)
|
|
||||||
shutil.copyfile( source + file, target + file )
|
|
||||||
file = "upload.min.htm"
|
|
||||||
#print( "Copy file: " + source + file + "->" + target + file)
|
|
||||||
shutil.copyfile( source + file, target + file )
|
|
||||||
file = "format.min.htm"
|
|
||||||
#print( "Copy file: " + source + file + "->" + target + file)
|
|
||||||
shutil.copyfile( source + file, target + file )
|
|
||||||
file = "test.min.htm"
|
|
||||||
#print( "Copy file: " + source + file + "->" + target + file)
|
|
||||||
shutil.copyfile( source + file, target + file )
|
|
||||||
file = "firmware.min.htm"
|
|
||||||
#print( "Copy file: " + source + file + "->" + target + file)
|
|
||||||
shutil.copyfile( source + file, target + file )
|
|
@ -12,42 +12,6 @@ def after_build(source, target, env):
|
|||||||
dir = env.GetLaunchDir()
|
dir = env.GetLaunchDir()
|
||||||
#name = env.get( "PIOENV" )
|
#name = env.get( "PIOENV" )
|
||||||
|
|
||||||
# Copy file 1
|
|
||||||
source = dir + "/data/index.min.htm"
|
|
||||||
target = dir + "/bin/index.min.htm"
|
|
||||||
print( "Copy file : " + source + " -> " + target )
|
|
||||||
shutil.copyfile( source, target )
|
|
||||||
|
|
||||||
# Copy file 2
|
|
||||||
source = dir + "/data/config.min.htm"
|
|
||||||
target = dir + "/bin/config.min.htm"
|
|
||||||
print( "Copy file : " + source + " -> " + target )
|
|
||||||
shutil.copyfile( source, target )
|
|
||||||
|
|
||||||
# Copy file 3
|
|
||||||
source = dir + "/data/about.min.htm"
|
|
||||||
target = dir + "/bin/about.min.htm"
|
|
||||||
print( "Copy file : " + source + " -> " + target )
|
|
||||||
shutil.copyfile( source, target )
|
|
||||||
|
|
||||||
# Copy file 4
|
|
||||||
source = dir + "/data/calibration.min.htm"
|
|
||||||
target = dir + "/bin/calibration.min.htm"
|
|
||||||
print( "Copy file : " + source + " -> " + target )
|
|
||||||
shutil.copyfile( source, target )
|
|
||||||
|
|
||||||
# Copy file 5
|
|
||||||
source = dir + "/data/format.min.htm"
|
|
||||||
target = dir + "/bin/format.min.htm"
|
|
||||||
print( "Copy file : " + source + " -> " + target )
|
|
||||||
shutil.copyfile( source, target )
|
|
||||||
|
|
||||||
# Copy file 6
|
|
||||||
source = dir + "/data/test.min.htm"
|
|
||||||
target = dir + "/bin/test.min.htm"
|
|
||||||
print( "Copy file : " + source + " -> " + target )
|
|
||||||
shutil.copyfile( source, target )
|
|
||||||
|
|
||||||
target = dir + "/bin/version.json"
|
target = dir + "/bin/version.json"
|
||||||
ver = get_build_flag_value("CFG_APPVER")
|
ver = get_build_flag_value("CFG_APPVER")
|
||||||
|
|
||||||
|
10
src/ble.cpp
@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#if defined(ESP32)
|
#if defined(ESP32) && !defined(ESP32S2)
|
||||||
|
|
||||||
#include <ble.hpp>
|
#include <ble.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -41,9 +41,15 @@ BleSender::BleSender(const char* color) {
|
|||||||
|
|
||||||
// boost power to maximum, these might be changed once battery life using BLE
|
// boost power to maximum, these might be changed once battery life using BLE
|
||||||
// has been tested.
|
// has been tested.
|
||||||
|
#if defined(ESP32C3) && defined(REDUCE_WIFI_POWER)
|
||||||
|
esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_DEFAULT, ESP_PWR_LVL_P6);
|
||||||
|
esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_ADV, ESP_PWR_LVL_P6);
|
||||||
|
esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_SCAN, ESP_PWR_LVL_P6);
|
||||||
|
#else
|
||||||
esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_DEFAULT, ESP_PWR_LVL_P9);
|
esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_DEFAULT, ESP_PWR_LVL_P9);
|
||||||
esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_ADV, ESP_PWR_LVL_P9);
|
esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_ADV, ESP_PWR_LVL_P9);
|
||||||
esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_SCAN, ESP_PWR_LVL_P9);
|
esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_SCAN, ESP_PWR_LVL_P9);
|
||||||
|
#endif
|
||||||
|
|
||||||
_advertising = BLEDevice::getAdvertising();
|
_advertising = BLEDevice::getAdvertising();
|
||||||
_color = color;
|
_color = color;
|
||||||
@ -99,4 +105,4 @@ void BleSender::sendData(float tempF, float gravSG) {
|
|||||||
delay(100);
|
delay(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ESP32
|
#endif // ESP32 && !ESP32S2
|
||||||
|
@ -24,14 +24,12 @@ SOFTWARE.
|
|||||||
#ifndef SRC_BLE_HPP_
|
#ifndef SRC_BLE_HPP_
|
||||||
#define SRC_BLE_HPP_
|
#define SRC_BLE_HPP_
|
||||||
|
|
||||||
#if defined(ESP32)
|
#if defined(ESP32) && !defined(ESP32S2)
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
#include <NimBLEBeacon.h>
|
#include <NimBLEBeacon.h>
|
||||||
#include <NimBLEDevice.h>
|
#include <NimBLEDevice.h>
|
||||||
|
|
||||||
#include <config.hpp>
|
|
||||||
#include <main.hpp>
|
|
||||||
|
|
||||||
class BleSender {
|
class BleSender {
|
||||||
private:
|
private:
|
||||||
BLEAdvertising* _advertising;
|
BLEAdvertising* _advertising;
|
||||||
@ -43,5 +41,5 @@ class BleSender {
|
|||||||
void sendData(float tempF, float gravSG);
|
void sendData(float tempF, float gravSG);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ESP32
|
#endif // ESP32 && !ESP32S2
|
||||||
#endif // SRC_BLE_HPP_
|
#endif // SRC_BLE_HPP_
|
||||||
|
@ -27,9 +27,6 @@ SOFTWARE.
|
|||||||
#include <calc.hpp>
|
#include <calc.hpp>
|
||||||
#include <main.hpp>
|
#include <main.hpp>
|
||||||
|
|
||||||
//
|
|
||||||
// Use values to derive a formula
|
|
||||||
//
|
|
||||||
int createFormula(RawFormulaData &fd, char *formulaBuffer,
|
int createFormula(RawFormulaData &fd, char *formulaBuffer,
|
||||||
int formulaBufferSize, int order) {
|
int formulaBufferSize, int order) {
|
||||||
int noAngles = 0;
|
int noAngles = 0;
|
||||||
@ -118,10 +115,6 @@ int createFormula(RawFormulaData &fd, char *formulaBuffer,
|
|||||||
return ERR_FORMULA_INTERNAL;
|
return ERR_FORMULA_INTERNAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Calculates gravity according to supplied formula, compatible with
|
|
||||||
// iSpindle/Fermentrack formula
|
|
||||||
//
|
|
||||||
double calculateGravity(double angle, double temp, const char *tempFormula) {
|
double calculateGravity(double angle, double temp, const char *tempFormula) {
|
||||||
const char *formula = myConfig.getGravityFormula();
|
const char *formula = myConfig.getGravityFormula();
|
||||||
|
|
||||||
@ -163,12 +156,10 @@ double calculateGravity(double angle, double temp, const char *tempFormula) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Do a standard gravity temperature correction. This is a simple way to adjust
|
// Do a standard gravity temperature correction. This is a simple way to adjust
|
||||||
// for differnt worth temperatures. This function uses C as temperature.
|
// for differnt worth temperatures. This function uses C as temperature.
|
||||||
//
|
//
|
||||||
// Source: https://homebrewacademy.com/hydrometer-temperature-correction/
|
// Source: https://homebrewacademy.com/hydrometer-temperature-correction/
|
||||||
//
|
|
||||||
double gravityTemperatureCorrectionC(double gravitySG, double tempC,
|
double gravityTemperatureCorrectionC(double gravitySG, double tempC,
|
||||||
double calTempC) {
|
double calTempC) {
|
||||||
#if LOG_LEVEL == 6 && !defined(CALC_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(CALC_DISABLE_LOGGING)
|
||||||
|
@ -153,8 +153,8 @@ bool Config::saveFile() {
|
|||||||
createJson(doc);
|
createJson(doc);
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(DISABLE_LOGGING)
|
||||||
serializeJson(doc, Serial);
|
serializeJson(doc, EspSerial);
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
serializeJson(doc, configFile);
|
serializeJson(doc, configFile);
|
||||||
@ -192,8 +192,8 @@ bool Config::loadFile() {
|
|||||||
DynamicJsonDocument doc(3000);
|
DynamicJsonDocument doc(3000);
|
||||||
DeserializationError err = deserializeJson(doc, configFile);
|
DeserializationError err = deserializeJson(doc, configFile);
|
||||||
#if LOG_LEVEL == 6
|
#if LOG_LEVEL == 6
|
||||||
serializeJson(doc, Serial);
|
serializeJson(doc, EspSerial);
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
#endif
|
#endif
|
||||||
configFile.close();
|
configFile.close();
|
||||||
|
|
||||||
@ -395,8 +395,8 @@ bool AdvancedConfig::saveFile() {
|
|||||||
doc[PARAM_HW_IGNORE_LOW_ANGLES] = this->isIgnoreLowAnges();
|
doc[PARAM_HW_IGNORE_LOW_ANGLES] = this->isIgnoreLowAnges();
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(DISABLE_LOGGING)
|
||||||
serializeJson(doc, Serial);
|
serializeJson(doc, EspSerial);
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
serializeJson(doc, configFile);
|
serializeJson(doc, configFile);
|
||||||
@ -434,8 +434,8 @@ bool AdvancedConfig::loadFile() {
|
|||||||
DynamicJsonDocument doc(512);
|
DynamicJsonDocument doc(512);
|
||||||
DeserializationError err = deserializeJson(doc, configFile);
|
DeserializationError err = deserializeJson(doc, configFile);
|
||||||
#if LOG_LEVEL == 6
|
#if LOG_LEVEL == 6
|
||||||
serializeJson(doc, Serial);
|
serializeJson(doc, EspSerial);
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
#endif
|
#endif
|
||||||
configFile.close();
|
configFile.close();
|
||||||
|
|
||||||
|
@ -143,11 +143,25 @@ class Config {
|
|||||||
String _mDNS = "";
|
String _mDNS = "";
|
||||||
String _otaURL = "";
|
String _otaURL = "";
|
||||||
char _tempFormat = 'C';
|
char _tempFormat = 'C';
|
||||||
|
#if defined(ESP8266)
|
||||||
float _voltageFactor = 1.59;
|
float _voltageFactor = 1.59;
|
||||||
|
#elif defined(ESP32C3)
|
||||||
|
float _voltageFactor = 1.3;
|
||||||
|
#elif defined(ESP32S2)
|
||||||
|
float _voltageFactor = 0.59;
|
||||||
|
#elif defined(ESP32LITE)
|
||||||
|
float _voltageFactor = 1.59;
|
||||||
|
#else // ESP32
|
||||||
|
float _voltageFactor = 1.3;
|
||||||
|
#endif
|
||||||
float _voltageConfig = 4.15;
|
float _voltageConfig = 4.15;
|
||||||
float _tempSensorAdjC = 0;
|
float _tempSensorAdjC = 0;
|
||||||
int _sleepInterval = 900;
|
int _sleepInterval = 900;
|
||||||
|
#if defined(FLOATY)
|
||||||
|
bool _gyroTemp = true;
|
||||||
|
#else
|
||||||
bool _gyroTemp = false;
|
bool _gyroTemp = false;
|
||||||
|
#endif
|
||||||
bool _storageSleep = false;
|
bool _storageSleep = false;
|
||||||
|
|
||||||
// Wifi Config
|
// Wifi Config
|
||||||
@ -203,8 +217,12 @@ class Config {
|
|||||||
|
|
||||||
const bool isGyroTemp() { return _gyroTemp; }
|
const bool isGyroTemp() { return _gyroTemp; }
|
||||||
void setGyroTemp(bool b) {
|
void setGyroTemp(bool b) {
|
||||||
|
#if defined(FLOATY)
|
||||||
|
// Floaty hardware dont have a temp sensor, uses gyro temperature
|
||||||
|
#else
|
||||||
_gyroTemp = b;
|
_gyroTemp = b;
|
||||||
_saveNeeded = true;
|
_saveNeeded = true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool isStorageSleep() { return _storageSleep; }
|
const bool isStorageSleep() { return _storageSleep; }
|
||||||
|
77
src/gyro.cpp
@ -30,22 +30,41 @@ MPU6050 accelgyro;
|
|||||||
#define GYRO_USE_INTERRUPT // Use interrupt to detect when new sample is ready
|
#define GYRO_USE_INTERRUPT // Use interrupt to detect when new sample is ready
|
||||||
#define GYRO_SHOW_MINMAX // Will calculate the min/max values when doing
|
#define GYRO_SHOW_MINMAX // Will calculate the min/max values when doing
|
||||||
// calibration
|
// calibration
|
||||||
// #define GYRO_CALIBRATE_STARTUP // Will calibrate sensor at startup
|
|
||||||
|
|
||||||
//
|
|
||||||
// Initialize the sensor chip.
|
|
||||||
//
|
|
||||||
bool GyroSensor::setup() {
|
bool GyroSensor::setup() {
|
||||||
|
int clock = 400000;
|
||||||
|
#if defined(FLOATY)
|
||||||
|
pinMode(PIN_VCC, OUTPUT);
|
||||||
|
pinMode(PIN_GND, OUTPUT_OPEN_DRAIN);
|
||||||
|
digitalWrite(PIN_VCC, HIGH);
|
||||||
|
digitalWrite(PIN_GND, LOW);
|
||||||
|
delay(10); // Wait for the pins to settle or we will fail to connect
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
/* For testing pin config of new boards with led.
|
||||||
|
pinMode(PIN_SDA, OUTPUT);
|
||||||
|
pinMode(PIN_SCL, OUTPUT);
|
||||||
|
for(int i = 0, j = LOW, k = LOW; i < 100; i++) {
|
||||||
|
|
||||||
|
digitalWrite(PIN_SDA, k);
|
||||||
|
digitalWrite(PIN_SCL, j);
|
||||||
|
k = !k;
|
||||||
|
delay(300);
|
||||||
|
digitalWrite(PIN_SDA, k);
|
||||||
|
k = !k;
|
||||||
|
j = !j;
|
||||||
|
delay(300);
|
||||||
|
}*/
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(GYRO_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(GYRO_DISABLE_LOGGING)
|
||||||
Log.verbose(F("GYRO: Setting up hardware." CR));
|
Log.verbose(F("GYRO: Setting up hardware." CR));
|
||||||
#endif
|
#endif
|
||||||
Wire.begin(PIN_SDA, PIN_SCL);
|
Wire.begin(PIN_SDA, PIN_SCL);
|
||||||
Wire.setClock(400000); // 400kHz I2C clock. Comment this line if having
|
Wire.setClock(clock); // 400kHz I2C clock.
|
||||||
// compilation difficulties
|
|
||||||
|
|
||||||
uint8_t id = accelgyro.getDeviceID();
|
uint8_t id = accelgyro.getDeviceID();
|
||||||
|
|
||||||
if (id != 0x34 && id != 0x38) { // Allow both MPU6050 and MPU6000
|
if (id != 0x34 && id != 0x38) { // Allow both MPU6050 and MPU6500
|
||||||
writeErrorLog("GYRO: Failed to connect to gyro, is it connected?");
|
writeErrorLog("GYRO: Failed to connect to gyro, is it connected?");
|
||||||
_sensorConnected = false;
|
_sensorConnected = false;
|
||||||
} else {
|
} else {
|
||||||
@ -68,11 +87,6 @@ bool GyroSensor::setup() {
|
|||||||
accelgyro.setIntDataReadyEnabled(true);
|
accelgyro.setIntDataReadyEnabled(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(GYRO_CALIBRATE_STARTUP)
|
|
||||||
// Run the calibration at start, useful for testing.
|
|
||||||
calibrateSensor();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Once we have calibration values stored we just apply them from the
|
// Once we have calibration values stored we just apply them from the
|
||||||
// config.
|
// config.
|
||||||
_calibrationOffset = myConfig.getGyroCalibration();
|
_calibrationOffset = myConfig.getGyroCalibration();
|
||||||
@ -81,19 +95,17 @@ bool GyroSensor::setup() {
|
|||||||
return _sensorConnected;
|
return _sensorConnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Set sensor in sleep mode to conserve battery
|
|
||||||
//
|
|
||||||
void GyroSensor::enterSleep() {
|
void GyroSensor::enterSleep() {
|
||||||
#if LOG_LEVEL == 6 && !defined(GYRO_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(GYRO_DISABLE_LOGGING)
|
||||||
Log.verbose(F("GYRO: Setting up hardware." CR));
|
Log.verbose(F("GYRO: Setting up hardware." CR));
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(FLOATY)
|
||||||
|
digitalWrite(PIN_VCC, LOW);
|
||||||
|
#else
|
||||||
accelgyro.setSleepEnabled(true);
|
accelgyro.setSleepEnabled(true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Do a number of reads to get a more stable value.
|
|
||||||
//
|
|
||||||
void GyroSensor::readSensor(RawGyroData &raw, const int noIterations,
|
void GyroSensor::readSensor(RawGyroData &raw, const int noIterations,
|
||||||
const int delayTime) {
|
const int delayTime) {
|
||||||
RawGyroDataL average = {0, 0, 0, 0, 0, 0};
|
RawGyroDataL average = {0, 0, 0, 0, 0, 0};
|
||||||
@ -105,7 +117,8 @@ void GyroSensor::readSensor(RawGyroData &raw, const int noIterations,
|
|||||||
|
|
||||||
// Set some initial values
|
// Set some initial values
|
||||||
#if defined(GYRO_SHOW_MINMAX)
|
#if defined(GYRO_SHOW_MINMAX)
|
||||||
RawGyroData min, max;
|
RawGyroData min = {0, 0, 0};
|
||||||
|
RawGyroData max = {0, 0, 0};
|
||||||
accelgyro.getAcceleration(&min.ax, &min.ay, &min.az);
|
accelgyro.getAcceleration(&min.ax, &min.ay, &min.az);
|
||||||
min.temp = accelgyro.getTemperature();
|
min.temp = accelgyro.getTemperature();
|
||||||
max = min;
|
max = min;
|
||||||
@ -179,9 +192,6 @@ void GyroSensor::readSensor(RawGyroData &raw, const int noIterations,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Calcuate the angles (tilt)
|
|
||||||
//
|
|
||||||
float GyroSensor::calculateAngle(RawGyroData &raw) {
|
float GyroSensor::calculateAngle(RawGyroData &raw) {
|
||||||
#if LOG_LEVEL == 6 && !defined(GYRO_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(GYRO_DISABLE_LOGGING)
|
||||||
Log.verbose(F("GYRO: Calculating the angle." CR));
|
Log.verbose(F("GYRO: Calculating the angle." CR));
|
||||||
@ -209,9 +219,6 @@ float GyroSensor::calculateAngle(RawGyroData &raw) {
|
|||||||
return vY;
|
return vY;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Check if the values are high that indicate that the sensor is moving.
|
|
||||||
//
|
|
||||||
bool GyroSensor::isSensorMoving(RawGyroData &raw) {
|
bool GyroSensor::isSensorMoving(RawGyroData &raw) {
|
||||||
#if LOG_LEVEL == 6 && !defined(GYRO_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(GYRO_DISABLE_LOGGING)
|
||||||
Log.verbose(F("GYRO: Checking for sensor movement." CR));
|
Log.verbose(F("GYRO: Checking for sensor movement." CR));
|
||||||
@ -229,9 +236,6 @@ bool GyroSensor::isSensorMoving(RawGyroData &raw) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Read the tilt angle from the gyro.
|
|
||||||
//
|
|
||||||
bool GyroSensor::read() {
|
bool GyroSensor::read() {
|
||||||
#if LOG_LEVEL == 6 && !defined(GYRO_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(GYRO_DISABLE_LOGGING)
|
||||||
Log.verbose(F("GYRO: Getting new gyro position." CR));
|
Log.verbose(F("GYRO: Getting new gyro position." CR));
|
||||||
@ -270,9 +274,6 @@ bool GyroSensor::read() {
|
|||||||
return _validValue;
|
return _validValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Dump the stored calibration values.
|
|
||||||
//
|
|
||||||
void GyroSensor::dumpCalibration() {
|
void GyroSensor::dumpCalibration() {
|
||||||
#if LOG_LEVEL == 6 && !defined(GYRO_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(GYRO_DISABLE_LOGGING)
|
||||||
Log.verbose(F("GYRO: Accel offset\t%d\t%d\t%d" CR), _calibrationOffset.ax,
|
Log.verbose(F("GYRO: Accel offset\t%d\t%d\t%d" CR), _calibrationOffset.ax,
|
||||||
@ -282,9 +283,6 @@ void GyroSensor::dumpCalibration() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Update the sensor with out calculated offsets.
|
|
||||||
//
|
|
||||||
void GyroSensor::applyCalibration() {
|
void GyroSensor::applyCalibration() {
|
||||||
#if LOG_LEVEL == 6 && !defined(GYRO_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(GYRO_DISABLE_LOGGING)
|
||||||
Log.verbose(F("GYRO: Applying calibration offsets to sensor." CR));
|
Log.verbose(F("GYRO: Applying calibration offsets to sensor." CR));
|
||||||
@ -306,22 +304,19 @@ void GyroSensor::applyCalibration() {
|
|||||||
accelgyro.setZGyroOffset(_calibrationOffset.gz);
|
accelgyro.setZGyroOffset(_calibrationOffset.gz);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Calculate the offsets for calibration.
|
|
||||||
//
|
|
||||||
void GyroSensor::calibrateSensor() {
|
void GyroSensor::calibrateSensor() {
|
||||||
#if LOG_LEVEL == 6 && !defined(GYRO_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(GYRO_DISABLE_LOGGING)
|
||||||
Log.verbose(F("GYRO: Calibrating sensor" CR));
|
Log.verbose(F("GYRO: Calibrating sensor" CR));
|
||||||
#endif
|
#endif
|
||||||
// accelgyro.PrintActiveOffsets();
|
// accelgyro.PrintActiveOffsets();
|
||||||
// Serial.print( CR );
|
// EspSerial.print( CR );
|
||||||
|
|
||||||
accelgyro.setDLPFMode(MPU6050_DLPF_BW_5);
|
accelgyro.setDLPFMode(MPU6050_DLPF_BW_5);
|
||||||
accelgyro.CalibrateAccel(6); // 6 = 600 readings
|
accelgyro.CalibrateAccel(6); // 6 = 600 readings
|
||||||
accelgyro.CalibrateGyro(6);
|
accelgyro.CalibrateGyro(6);
|
||||||
|
|
||||||
accelgyro.PrintActiveOffsets();
|
accelgyro.PrintActiveOffsets();
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
|
|
||||||
_calibrationOffset.ax = accelgyro.getXAccelOffset();
|
_calibrationOffset.ax = accelgyro.getXAccelOffset();
|
||||||
_calibrationOffset.ay = accelgyro.getYAccelOffset();
|
_calibrationOffset.ay = accelgyro.getYAccelOffset();
|
||||||
@ -330,14 +325,10 @@ void GyroSensor::calibrateSensor() {
|
|||||||
_calibrationOffset.gy = accelgyro.getYGyroOffset();
|
_calibrationOffset.gy = accelgyro.getYGyroOffset();
|
||||||
_calibrationOffset.gz = accelgyro.getZGyroOffset();
|
_calibrationOffset.gz = accelgyro.getZGyroOffset();
|
||||||
|
|
||||||
// Save the calibrated values
|
|
||||||
myConfig.setGyroCalibration(_calibrationOffset);
|
myConfig.setGyroCalibration(_calibrationOffset);
|
||||||
myConfig.saveFile();
|
myConfig.saveFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Calibrate the device.
|
|
||||||
//
|
|
||||||
void GyroSensor::debug() {
|
void GyroSensor::debug() {
|
||||||
#if LOG_LEVEL == 6 && !defined(GYRO_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(GYRO_DISABLE_LOGGING)
|
||||||
Log.verbose(F("GYRO: Debug - Clock src %d." CR),
|
Log.verbose(F("GYRO: Debug - Clock src %d." CR),
|
||||||
|
117
src/helper.cpp
@ -36,9 +36,6 @@ SOFTWARE.
|
|||||||
#include <tempsensor.hpp>
|
#include <tempsensor.hpp>
|
||||||
#include <wifi.hpp>
|
#include <wifi.hpp>
|
||||||
|
|
||||||
SerialDebug mySerial;
|
|
||||||
BatteryVoltage myBatteryVoltage;
|
|
||||||
|
|
||||||
// tcp cleanup, to avoid memory crash.
|
// tcp cleanup, to avoid memory crash.
|
||||||
struct tcp_pcb;
|
struct tcp_pcb;
|
||||||
extern struct tcp_pcb* tcp_tw_pcbs;
|
extern struct tcp_pcb* tcp_tw_pcbs;
|
||||||
@ -64,7 +61,66 @@ void checkResetReason() {
|
|||||||
writeErrorLog(&s[0]);
|
writeErrorLog(&s[0]);
|
||||||
}
|
}
|
||||||
#else // defined (ESP32)
|
#else // defined (ESP32)
|
||||||
#warning "Todo: Handle reset reasons on ESP32"
|
RESET_REASON r = rtc_get_reset_reason(
|
||||||
|
0); // We only check cpu0 since we dont use cpu1 on the esp32
|
||||||
|
String rStr;
|
||||||
|
|
||||||
|
switch (r) {
|
||||||
|
case 0:
|
||||||
|
rStr = F("None");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
rStr = F("vbat power on reset");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
rStr = F("software reset digital core");
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
rStr = F("legacy watch dog reset digital core");
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
rStr = F("deep Sleep reset digital core");
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
rStr = F("reset by SLC module, reset digital core");
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
rStr = F("timer Group0 Watch dog reset digital core");
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
rStr = F("timer Group1 Watch dog reset digital core");
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
rStr = F("RTC Watch dog Reset digital core");
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
rStr = F("instrusion tested to reset CPU");
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
rStr = F("time Group reset CPU");
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
rStr = F("software reset CPU");
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
rStr = F("RTC Watch dog Reset CPU");
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
rStr = F("for APP CPU, reseted by PRO CPU");
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
rStr = F("reset when the vdd voltage is not stable");
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
rStr = F("RTC Watch dog reset digital core and rtc module");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
rStr = F("unknown reset reason");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.notice(F("HELP: Last reset cause '%s' (%d)" CR), rStr.c_str(), r);
|
||||||
|
// Havent found a good way to get exception cause from an ESP32
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,10 +237,30 @@ void printBuildOptions() {
|
|||||||
|
|
||||||
SerialDebug::SerialDebug(const uint32_t serialSpeed) {
|
SerialDebug::SerialDebug(const uint32_t serialSpeed) {
|
||||||
// Start serial with auto-detected rate (default to defined BAUD)
|
// Start serial with auto-detected rate (default to defined BAUD)
|
||||||
Serial.flush();
|
#if defined(USE_SERIAL_PINS) && defined(ESP8266)
|
||||||
Serial.begin(serialSpeed);
|
uint8_t txPin = 3;
|
||||||
|
EspSerial.begin(serialSpeed, SERIAL_8N1, SERIAL_TX_ONLY, txPin);
|
||||||
|
#elif defined(ESP8266)
|
||||||
|
EspSerial.begin(serialSpeed);
|
||||||
|
#elif defined(USE_SERIAL_PINS) && defined(ESP32C3)
|
||||||
|
EspSerial.begin(115200L, SERIAL_8N1, 20, 21);
|
||||||
|
#elif defined(ESP32C3)
|
||||||
|
EspSerial.begin(115200L);
|
||||||
|
#elif defined(USE_SERIAL_PINS) && defined(ESP32S2)
|
||||||
|
EspSerial.begin(115200L, SERIAL_8N1, 37, 39);
|
||||||
|
#elif defined(ESP32S2)
|
||||||
|
EspSerial.begin(115200L);
|
||||||
|
#elif defined(USE_SERIAL_PINS) && defined(ESP32LITE)
|
||||||
|
EspSerial.begin(serialSpeed, SERIAL_8N1, 16, 17);
|
||||||
|
#elif defined(USE_SERIAL_PINS) && defined(ESP32)
|
||||||
|
EspSerial.begin(serialSpeed, SERIAL_8N1, 1, 3);
|
||||||
|
#elif defined(ESP32)
|
||||||
|
EspSerial.begin(115200L);
|
||||||
|
#endif
|
||||||
|
|
||||||
getLog()->begin(LOG_LEVEL, &Serial, true);
|
EspSerial.println("Serial connection established");
|
||||||
|
EspSerial.setDebugOutput(true);
|
||||||
|
getLog()->begin(LOG_LEVEL, &EspSerial, true);
|
||||||
getLog()->setPrefix(printTimestamp);
|
getLog()->setPrefix(printTimestamp);
|
||||||
getLog()->notice(F("SDBG: Serial logging started at %u." CR), serialSpeed);
|
getLog()->notice(F("SDBG: Serial logging started at %u." CR), serialSpeed);
|
||||||
}
|
}
|
||||||
@ -195,11 +271,34 @@ void printTimestamp(Print* _logOutput, int _logLevel) {
|
|||||||
_logOutput->print(c);
|
_logOutput->print(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool checkPinConnected() {
|
||||||
|
#if defined(ESP8266)
|
||||||
|
pinMode(PIN_CFG1, INPUT);
|
||||||
|
#else
|
||||||
|
pinMode(PIN_CFG1, INPUT_PULLDOWN);
|
||||||
|
#endif
|
||||||
|
pinMode(PIN_CFG2, OUTPUT);
|
||||||
|
delay(5);
|
||||||
|
digitalWrite(PIN_CFG2, 1);
|
||||||
|
delay(5);
|
||||||
|
int i = digitalRead(PIN_CFG1);
|
||||||
|
digitalWrite(PIN_CFG2, 0);
|
||||||
|
return i == LOW ? false : true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BatteryVoltage::BatteryVoltage() {
|
||||||
|
#if defined(ESP8266)
|
||||||
|
pinMode(PIN_VOLT, INPUT);
|
||||||
|
#else
|
||||||
|
pinMode(PIN_VOLT, INPUT_PULLDOWN);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void BatteryVoltage::read() {
|
void BatteryVoltage::read() {
|
||||||
// The analog pin can only handle 3.3V maximum voltage so we need to reduce
|
// The analog pin can only handle 3.3V maximum voltage so we need to reduce
|
||||||
// the voltage (from max 5V)
|
// the voltage (from max 5V)
|
||||||
float factor = myConfig.getVoltageFactor(); // Default value is 1.63
|
float factor = myConfig.getVoltageFactor(); // Default value is 1.63
|
||||||
int v = analogRead(PIN_A0);
|
int v = analogRead(PIN_VOLT);
|
||||||
|
|
||||||
// An ESP8266 has a ADC range of 0-1023 and a maximum voltage of 3.3V
|
// An ESP8266 has a ADC range of 0-1023 and a maximum voltage of 3.3V
|
||||||
// An ESP32 has an ADC range of 0-4095 and a maximum voltage of 3.3V
|
// An ESP32 has an ADC range of 0-4095 and a maximum voltage of 3.3V
|
||||||
@ -342,7 +441,7 @@ void PerfLogging::pushInflux() {
|
|||||||
// Send HTTP POST request
|
// Send HTTP POST request
|
||||||
String auth = "Token " + String(myConfig.getInfluxDb2PushToken());
|
String auth = "Token " + String(myConfig.getInfluxDb2PushToken());
|
||||||
http.addHeader(F("Authorization"), auth.c_str());
|
http.addHeader(F("Authorization"), auth.c_str());
|
||||||
http.setTimeout(myAdvancedConfig.getPushTimeout());
|
http.setTimeout(myAdvancedConfig.getPushTimeout() * 1000);
|
||||||
int httpResponseCode = http.POST(body);
|
int httpResponseCode = http.POST(body);
|
||||||
|
|
||||||
if (httpResponseCode == 204) {
|
if (httpResponseCode == 204) {
|
||||||
|
@ -43,6 +43,9 @@ void checkResetReason();
|
|||||||
// Sleep mode
|
// Sleep mode
|
||||||
void deepSleep(int t);
|
void deepSleep(int t);
|
||||||
|
|
||||||
|
// Force config mode
|
||||||
|
bool checkPinConnected();
|
||||||
|
|
||||||
// Show build options
|
// Show build options
|
||||||
void printBuildOptions();
|
void printBuildOptions();
|
||||||
|
|
||||||
@ -88,9 +91,10 @@ class FloatHistoryLog {
|
|||||||
|
|
||||||
class BatteryVoltage {
|
class BatteryVoltage {
|
||||||
private:
|
private:
|
||||||
float _batteryLevel;
|
float _batteryLevel = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
BatteryVoltage();
|
||||||
void read();
|
void read();
|
||||||
float getVoltage() { return _batteryLevel; }
|
float getVoltage() { return _batteryLevel; }
|
||||||
};
|
};
|
||||||
|
41
src/main.cpp
@ -22,6 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <ble.hpp>
|
#include <ble.hpp>
|
||||||
|
#undef LOG_LEVEL_ERROR
|
||||||
|
#undef LOG_LEVEL_INFO
|
||||||
#include <calc.hpp>
|
#include <calc.hpp>
|
||||||
#include <config.hpp>
|
#include <config.hpp>
|
||||||
#include <gyro.hpp>
|
#include <gyro.hpp>
|
||||||
@ -33,12 +35,14 @@ SOFTWARE.
|
|||||||
#include <wifi.hpp>
|
#include <wifi.hpp>
|
||||||
|
|
||||||
// #define FORCE_GRAVITY_MODE
|
// #define FORCE_GRAVITY_MODE
|
||||||
|
SerialDebug mySerial;
|
||||||
|
BatteryVoltage myBatteryVoltage;
|
||||||
|
|
||||||
// Define constats for this program
|
// Define constats for this program
|
||||||
#ifdef DEACTIVATE_SLEEPMODE
|
#ifdef DEACTIVATE_SLEEPMODE
|
||||||
const int interval = 1000; // ms, time to wait between changes to output
|
const int interval = 1000; // ms, time to wait between changes to output
|
||||||
#else
|
#else
|
||||||
int interval = 200; // ms, time to wait between changes to output
|
int interval = 200; // ms, time to wait between changes to output
|
||||||
#endif
|
#endif
|
||||||
bool sleepModeAlwaysSkip =
|
bool sleepModeAlwaysSkip =
|
||||||
false; // Flag set in web interface to override normal behaviour
|
false; // Flag set in web interface to override normal behaviour
|
||||||
@ -117,12 +121,8 @@ void checkSleepMode(float angle, float volt) {
|
|||||||
Log.notice(
|
Log.notice(
|
||||||
F("Main: Storage mode entered, going to sleep for maximum time." CR));
|
F("Main: Storage mode entered, going to sleep for maximum time." CR));
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
// ESP.deepSleep(ESP.deepSleepMax());
|
|
||||||
ESP.deepSleep(0); // indefinite sleep
|
ESP.deepSleep(0); // indefinite sleep
|
||||||
#else
|
#else
|
||||||
#warning "Check and test the max deep sleep for esp32"
|
|
||||||
// deepSleep(70 * 60); // quick search on internet suggest max time is 70
|
|
||||||
// min
|
|
||||||
ESP.deepSleep(0); // indefinite sleep
|
ESP.deepSleep(0); // indefinite sleep
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -133,12 +133,7 @@ void setup() {
|
|||||||
LOG_PERF_START("main-setup");
|
LOG_PERF_START("main-setup");
|
||||||
runtimeMillis = millis();
|
runtimeMillis = millis();
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(MAIN_DISABLE_LOGGING)
|
|
||||||
// Add a delay so that serial is started.
|
|
||||||
// delay(3000);
|
|
||||||
#endif
|
|
||||||
// Main startup
|
// Main startup
|
||||||
|
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
Log.notice(F("Main: Started setup for %s." CR),
|
Log.notice(F("Main: Started setup for %s." CR),
|
||||||
String(ESP.getChipId(), HEX).c_str());
|
String(ESP.getChipId(), HEX).c_str());
|
||||||
@ -163,6 +158,11 @@ void setup() {
|
|||||||
myAdvancedConfig.loadFile();
|
myAdvancedConfig.loadFile();
|
||||||
LOG_PERF_STOP("main-config-load");
|
LOG_PERF_STOP("main-config-load");
|
||||||
|
|
||||||
|
sleepModeAlwaysSkip = checkPinConnected();
|
||||||
|
if (sleepModeAlwaysSkip) {
|
||||||
|
Log.notice(F("Main: Forcing config mode since D7/D8 are connected." CR));
|
||||||
|
}
|
||||||
|
|
||||||
// Setup watchdog
|
// Setup watchdog
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
ESP.wdtDisable();
|
ESP.wdtDisable();
|
||||||
@ -205,6 +205,8 @@ void setup() {
|
|||||||
|
|
||||||
myBatteryVoltage.read();
|
myBatteryVoltage.read();
|
||||||
checkSleepMode(myGyro.getAngle(), myBatteryVoltage.getVoltage());
|
checkSleepMode(myGyro.getAngle(), myBatteryVoltage.getVoltage());
|
||||||
|
Log.notice(F("Main: Battery %F V, Gyro=%F, Run-mode=%d." CR),
|
||||||
|
myBatteryVoltage.getVoltage(), myGyro.getAngle(), runMode);
|
||||||
|
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
if (!myConfig.isWifiPushActive() && runMode == RunMode::gravityMode) {
|
if (!myConfig.isWifiPushActive() && runMode == RunMode::gravityMode) {
|
||||||
@ -254,11 +256,8 @@ void setup() {
|
|||||||
millis(); // Dont include time for wifi connection
|
millis(); // Dont include time for wifi connection
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Main loop that does gravity readings and push data to targets
|
// Main loop that does gravity readings and push data to targets
|
||||||
//
|
|
||||||
// Return true if gravity reading was successful
|
// Return true if gravity reading was successful
|
||||||
//
|
|
||||||
bool loopReadGravity() {
|
bool loopReadGravity() {
|
||||||
float angle = 0;
|
float angle = 0;
|
||||||
|
|
||||||
@ -308,13 +307,13 @@ bool loopReadGravity() {
|
|||||||
pushMillis = millis();
|
pushMillis = millis();
|
||||||
LOG_PERF_START("loop-push");
|
LOG_PERF_START("loop-push");
|
||||||
|
|
||||||
#if defined(ESP32)
|
#if defined(ESP32) && !defined(ESP32S2)
|
||||||
if (myConfig.isBLEActive()) {
|
if (myConfig.isBLEActive()) {
|
||||||
BleSender ble(myConfig.getColorBLE());
|
BleSender ble(myConfig.getColorBLE());
|
||||||
ble.sendData(convertCtoF(tempC), gravitySG);
|
ble.sendData(convertCtoF(tempC), gravitySG);
|
||||||
Log.notice(F("MAIN: Broadcast data over bluetooth." CR));
|
Log.notice(F("MAIN: Broadcast data over bluetooth." CR));
|
||||||
}
|
}
|
||||||
#endif
|
#endif // ESP32 && !ESP32S2
|
||||||
|
|
||||||
if (myWifi.isConnected()) { // no need to try if there is no wifi
|
if (myWifi.isConnected()) { // no need to try if there is no wifi
|
||||||
// connection.
|
// connection.
|
||||||
@ -332,15 +331,14 @@ bool loopReadGravity() {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Log.error(F("MAIN: No gyro value found, the device might be moving." CR));
|
// Log.error(F("MAIN: No gyro value found, the device might be moving."
|
||||||
|
// CR));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Wrapper for loopGravity that only calls every 200ms so that we dont overload
|
// Wrapper for loopGravity that only calls every 200ms so that we dont overload
|
||||||
// this.
|
// this.
|
||||||
//
|
|
||||||
void loopGravityOnInterval() {
|
void loopGravityOnInterval() {
|
||||||
if (abs((int32_t)(millis() - loopMillis)) > interval) {
|
if (abs((int32_t)(millis() - loopMillis)) > interval) {
|
||||||
loopReadGravity();
|
loopReadGravity();
|
||||||
@ -356,9 +354,6 @@ void loopGravityOnInterval() {
|
|||||||
|
|
||||||
bool skipRunTimeLog = false;
|
bool skipRunTimeLog = false;
|
||||||
|
|
||||||
//
|
|
||||||
// Main loop that determines if device should go to sleep
|
|
||||||
//
|
|
||||||
void goToSleep(int sleepInterval) {
|
void goToSleep(int sleepInterval) {
|
||||||
float volt = myBatteryVoltage.getVoltage();
|
float volt = myBatteryVoltage.getVoltage();
|
||||||
float runtime = (millis() - runtimeMillis);
|
float runtime = (millis() - runtimeMillis);
|
||||||
@ -386,10 +381,10 @@ void loop() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RunMode::configurationMode:
|
case RunMode::configurationMode:
|
||||||
if (myWifi.isConnected()) myWebServerHandler.loop();
|
myWebServerHandler.loop();
|
||||||
|
|
||||||
myWifi.loop();
|
myWifi.loop();
|
||||||
loopGravityOnInterval();
|
loopGravityOnInterval();
|
||||||
|
delay(1);
|
||||||
|
|
||||||
// If we switched mode, dont include this in the log.
|
// If we switched mode, dont include this in the log.
|
||||||
if (runMode != RunMode::configurationMode) skipRunTimeLog = true;
|
if (runMode != RunMode::configurationMode) skipRunTimeLog = true;
|
||||||
|
94
src/main.hpp
@ -38,26 +38,104 @@ enum RunMode {
|
|||||||
extern RunMode runMode;
|
extern RunMode runMode;
|
||||||
|
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
|
// Hardware config for ESP8266-d1, iSpindel hardware
|
||||||
|
// ------------------------------------------------------
|
||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
#define ESP_RESET ESP.reset
|
#define ESP_RESET ESP.reset
|
||||||
#define PIN_SDA D3
|
#define PIN_SDA D3
|
||||||
#define PIN_SCL D4
|
#define PIN_SCL D4
|
||||||
|
#define PIN_CFG1 D8
|
||||||
|
#define PIN_CFG2 D7
|
||||||
#define PIN_DS D6
|
#define PIN_DS D6
|
||||||
#define PIN_LED 2
|
#define PIN_LED 2
|
||||||
// #define PIN_A0 A0
|
#define PIN_VOLT PIN_A0
|
||||||
#else // defined (ESP32)
|
#elif defined(ESP32C3)
|
||||||
|
// Hardware config for ESP32-c3-mini, iSpindel hardware
|
||||||
|
// ------------------------------------------------------
|
||||||
#include <FS.h>
|
#include <FS.h>
|
||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
|
|
||||||
|
#include "esp32c3/rom/rtc.h"
|
||||||
#define ESPhttpUpdate httpUpdate
|
#define ESPhttpUpdate httpUpdate
|
||||||
#define ESP_RESET ESP.restart
|
#define ESP_RESET ESP.restart
|
||||||
#define ESP8266WebServer WebServer
|
#define ESP8266WebServer WebServer
|
||||||
#define PIN_SDA 17
|
#if defined(JTAG_DEBUG)
|
||||||
#define PIN_SCL 16
|
#define PIN_SDA 8
|
||||||
#define PIN_DS 19
|
#define PIN_SCL 9
|
||||||
#define PIN_A0 36
|
#warning "ESP32C3 JTAG debugging enabled, using GYRO on GPIO 8/9"
|
||||||
#define PIN_LED 2
|
#else
|
||||||
|
#define PIN_SDA 7
|
||||||
|
#define PIN_SCL 6
|
||||||
|
#endif // JTAG_DEBUG
|
||||||
|
#define PIN_CFG1 A5
|
||||||
|
#define PIN_CFG2 A4
|
||||||
|
#define PIN_DS A3
|
||||||
|
#define PIN_VOLT A0
|
||||||
|
// This should be the LED_BUILTIN, but that is also connected SDA (Gyro) so we
|
||||||
|
// cannot use both. So we point LED to pin 8 which is not used.
|
||||||
|
#define PIN_LED 8
|
||||||
|
#elif defined(ESP32S2)
|
||||||
|
// Hardware config for ESP32-s2-mini, iSpindel hardware
|
||||||
|
// ------------------------------------------------------
|
||||||
|
#include <FS.h>
|
||||||
|
#include <LittleFS.h>
|
||||||
|
|
||||||
|
#include "esp32s2/rom/rtc.h"
|
||||||
|
#define ESPhttpUpdate httpUpdate
|
||||||
|
#define ESP_RESET ESP.restart
|
||||||
|
#define ESP8266WebServer WebServer
|
||||||
|
#define PIN_SDA A17
|
||||||
|
#define PIN_SCL A15
|
||||||
|
#define PIN_CFG1 A11
|
||||||
|
#define PIN_CFG2 A10
|
||||||
|
#define PIN_DS A8
|
||||||
|
#define PIN_VOLT A2
|
||||||
|
#define PIN_LED LED_BUILTIN
|
||||||
|
#elif defined(ESP32LITE)
|
||||||
|
// Hardware config for ESP32-lite, Floaty hardware
|
||||||
|
// ------------------------------------------------------
|
||||||
|
#include <FS.h>
|
||||||
|
#include <LittleFS.h>
|
||||||
|
|
||||||
|
#include "esp32/rom/rtc.h"
|
||||||
|
#define ESPhttpUpdate httpUpdate
|
||||||
|
#define ESP_RESET ESP.restart
|
||||||
|
#define ESP8266WebServer WebServer
|
||||||
|
#define PIN_SDA A17
|
||||||
|
#define PIN_SCL A19
|
||||||
|
#define PIN_DS A3
|
||||||
|
#define PIN_VOLT A7
|
||||||
|
#define PIN_CFG1 A14
|
||||||
|
#define PIN_CFG2 A13
|
||||||
|
#define PIN_VCC A5
|
||||||
|
#define PIN_GND A18
|
||||||
|
#define PIN_LED LED_BUILTIN
|
||||||
|
#else // defined (ESP32)
|
||||||
|
// Hardware config for ESP32-d1-min, iSpindel hardware
|
||||||
|
// ------------------------------------------------------
|
||||||
|
#include <FS.h>
|
||||||
|
#include <LittleFS.h>
|
||||||
|
|
||||||
|
#include "esp32/rom/rtc.h"
|
||||||
|
#define ESPhttpUpdate httpUpdate
|
||||||
|
#define ESP_RESET ESP.restart
|
||||||
|
#define ESP8266WebServer WebServer
|
||||||
|
#define PIN_SDA D3
|
||||||
|
#define PIN_SCL D4
|
||||||
|
#define PIN_DS D6
|
||||||
|
#define PIN_CFG1 D8
|
||||||
|
#define PIN_CFG2 D7
|
||||||
|
#define PIN_LED LED_BUILTIN
|
||||||
|
#define PIN_VOLT PIN_A0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PIN_LED 2
|
#if defined(USE_SERIAL_PINS) && (defined(ESP32C3) || defined(ESP32S2))
|
||||||
|
// #define EspSerial Serial0 // We cant use Serial on newer boards since this is
|
||||||
|
// using USBC port
|
||||||
|
#define EspSerial \
|
||||||
|
Serial0 // We cant use Serial on newer boards since this is using USBC port
|
||||||
|
#else
|
||||||
|
#define EspSerial Serial
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // SRC_MAIN_HPP_
|
#endif // SRC_MAIN_HPP_
|
||||||
|
@ -23,23 +23,16 @@ SOFTWARE.
|
|||||||
*/
|
*/
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
#define INCBIN_OUTPUT_SECTION ".irom.text"
|
#define INCBIN_OUTPUT_SECTION ".irom.text"
|
||||||
#endif
|
|
||||||
#include <incbin.h>
|
#include <incbin.h>
|
||||||
|
|
||||||
#include <resources.hpp>
|
#include <resources.hpp>
|
||||||
|
INCBIN(IndexHtm, "html/index.min.htm");
|
||||||
#if defined(EMBED_HTML)
|
INCBIN(ConfigHtm, "html/config.min.htm");
|
||||||
// Using minify to reduce memory usage. Reducing RAM memory usage with about 7%
|
INCBIN(CalibrationHtm, "html/calibration.min.htm");
|
||||||
INCBIN(IndexHtm, "data/index.min.htm");
|
INCBIN(FormatHtm, "html/format.min.htm");
|
||||||
INCBIN(ConfigHtm, "data/config.min.htm");
|
INCBIN(TestHtm, "html/test.min.htm");
|
||||||
INCBIN(CalibrationHtm, "data/calibration.min.htm");
|
INCBIN(AboutHtm, "html/about.min.htm");
|
||||||
INCBIN(FormatHtm, "data/format.min.htm");
|
INCBIN(FirmwareHtm, "html/firmware.min.htm");
|
||||||
INCBIN(TestHtm, "data/test.min.htm");
|
|
||||||
INCBIN(AboutHtm, "data/about.min.htm");
|
|
||||||
#else
|
|
||||||
// Minium web interface for uploading htm files
|
|
||||||
INCBIN(UploadHtm, "data/upload.min.htm");
|
|
||||||
#endif
|
#endif
|
||||||
INCBIN(FirmwareHtm, "data/firmware.min.htm");
|
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
@ -80,9 +80,6 @@ const char mqttFormat[] PROGMEM =
|
|||||||
"ispindel/${mdns}/interval:${sleep-interval}|"
|
"ispindel/${mdns}/interval:${sleep-interval}|"
|
||||||
"ispindel/${mdns}/RSSI:${rssi}|";
|
"ispindel/${mdns}/RSSI:${rssi}|";
|
||||||
|
|
||||||
//
|
|
||||||
// Initialize the variables
|
|
||||||
//
|
|
||||||
void TemplatingEngine::initialize(float angle, float gravitySG,
|
void TemplatingEngine::initialize(float angle, float gravitySG,
|
||||||
float corrGravitySG, float tempC,
|
float corrGravitySG, float tempC,
|
||||||
float runTime) {
|
float runTime) {
|
||||||
@ -138,10 +135,9 @@ void TemplatingEngine::initialize(float angle, float gravitySG,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// the useDefaultTemplate param is there to support unit tests.
|
||||||
// Create the data using defined template.
|
const char* TemplatingEngine::create(TemplatingEngine::Templates idx,
|
||||||
//
|
bool useDefaultTemplate) {
|
||||||
const char* TemplatingEngine::create(TemplatingEngine::Templates idx) {
|
|
||||||
String fname;
|
String fname;
|
||||||
_baseTemplate.reserve(600);
|
_baseTemplate.reserve(600);
|
||||||
|
|
||||||
@ -169,15 +165,16 @@ const char* TemplatingEngine::create(TemplatingEngine::Templates idx) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add code to load templates from disk if they exist.
|
if (!useDefaultTemplate) {
|
||||||
File file = LittleFS.open(fname, "r");
|
File file = LittleFS.open(fname, "r");
|
||||||
if (file) {
|
if (file) {
|
||||||
char buf[file.size() + 1];
|
char buf[file.size() + 1];
|
||||||
memset(&buf[0], 0, file.size() + 1);
|
memset(&buf[0], 0, file.size() + 1);
|
||||||
file.readBytes(&buf[0], file.size());
|
file.readBytes(&buf[0], file.size());
|
||||||
_baseTemplate = String(&buf[0]);
|
_baseTemplate = String(&buf[0]);
|
||||||
file.close();
|
file.close();
|
||||||
Log.notice(F("TPL : Template loaded from disk %s." CR), fname.c_str());
|
Log.notice(F("TPL : Template loaded from disk %s." CR), fname.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LOG_LEVEL == 6
|
#if LOG_LEVEL == 6
|
||||||
@ -197,4 +194,17 @@ const char* TemplatingEngine::create(TemplatingEngine::Templates idx) {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// added to support more unit test scenarios.
|
||||||
|
const char* TemplatingEngine::create(const char* formatTemplate) {
|
||||||
|
_baseTemplate = String(formatTemplate);
|
||||||
|
|
||||||
|
// Insert data into template.
|
||||||
|
transform();
|
||||||
|
_baseTemplate.clear();
|
||||||
|
|
||||||
|
if (_output) return _output;
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
@ -160,7 +160,8 @@ class TemplatingEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strncat(_output, format + k, size - k);
|
// strncat(_output, format + k, size - k);
|
||||||
|
strncat(_output, format + k, strlen(format + k));
|
||||||
Log.notice(F("TPL : Transformed template %d chars to %d chars" CR),
|
Log.notice(F("TPL : Transformed template %d chars to %d chars" CR),
|
||||||
strlen(format), strlen(_output));
|
strlen(format), strlen(_output));
|
||||||
|
|
||||||
@ -174,11 +175,11 @@ class TemplatingEngine {
|
|||||||
void dumpAll() {
|
void dumpAll() {
|
||||||
int max = sizeof(_items) / sizeof(KeyVal);
|
int max = sizeof(_items) / sizeof(KeyVal);
|
||||||
for (int i = 0; i < max; i++) {
|
for (int i = 0; i < max; i++) {
|
||||||
Serial.print("Key=\'");
|
EspSerial.print("Key=\'");
|
||||||
Serial.print(_items[i].key.c_str());
|
EspSerial.print(_items[i].key.c_str());
|
||||||
Serial.print("\', Val=\'");
|
EspSerial.print("\', Val=\'");
|
||||||
Serial.print(_items[i].val.c_str());
|
EspSerial.print(_items[i].val.c_str());
|
||||||
Serial.println("\'");
|
EspSerial.println("\'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,12 +197,13 @@ class TemplatingEngine {
|
|||||||
|
|
||||||
void freeMemory() {
|
void freeMemory() {
|
||||||
if (_output) free(_output);
|
if (_output) free(_output);
|
||||||
|
|
||||||
_output = 0;
|
_output = 0;
|
||||||
}
|
}
|
||||||
void initialize(float angle, float gravitySG, float corrGravitySG,
|
void initialize(float angle, float gravitySG, float corrGravitySG,
|
||||||
float tempC, float runTime);
|
float tempC, float runTime);
|
||||||
const char *create(TemplatingEngine::Templates idx);
|
const char *create(TemplatingEngine::Templates idx,
|
||||||
|
bool useDefaultTemplate = false);
|
||||||
|
const char *create(const char *formatTemplate);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SRC_TEMPLATING_HPP_
|
#endif // SRC_TEMPLATING_HPP_
|
||||||
|
@ -35,15 +35,7 @@ DallasTemperature mySensors(&myOneWire);
|
|||||||
|
|
||||||
TempSensor myTempSensor;
|
TempSensor myTempSensor;
|
||||||
|
|
||||||
//
|
|
||||||
// Setup DS18B20 temp sensor. Doing setup is not that time consuming.
|
|
||||||
//
|
|
||||||
void TempSensor::setup() {
|
void TempSensor::setup() {
|
||||||
#if defined(SIMULATE_TEMP)
|
|
||||||
hasSensors = true;
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(TSEN_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(TSEN_DISABLE_LOGGING)
|
||||||
Log.verbose(F("TSEN: Looking for temp sensors." CR));
|
Log.verbose(F("TSEN: Looking for temp sensors." CR));
|
||||||
#endif
|
#endif
|
||||||
@ -66,14 +58,7 @@ void TempSensor::setup() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Retrieving value from sensor, value is in Celcius
|
|
||||||
//
|
|
||||||
float TempSensor::getValue(bool useGyro) {
|
float TempSensor::getValue(bool useGyro) {
|
||||||
#if defined(SIMULATE_TEMP)
|
|
||||||
return 21;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (useGyro) {
|
if (useGyro) {
|
||||||
// When using the gyro temperature only the first read value will be
|
// When using the gyro temperature only the first read value will be
|
||||||
// accurate so we will use this for processing.
|
// accurate so we will use this for processing.
|
||||||
|
@ -37,9 +37,6 @@ WebServerHandler myWebServerHandler; // My wrapper class fr webserver functions
|
|||||||
extern bool sleepModeActive;
|
extern bool sleepModeActive;
|
||||||
extern bool sleepModeAlwaysSkip;
|
extern bool sleepModeAlwaysSkip;
|
||||||
|
|
||||||
//
|
|
||||||
// Callback from webServer when / has been accessed.
|
|
||||||
//
|
|
||||||
void WebServerHandler::webHandleConfig() {
|
void WebServerHandler::webHandleConfig() {
|
||||||
LOG_PERF_START("webserver-api-config");
|
LOG_PERF_START("webserver-api-config");
|
||||||
Log.notice(F("WEB : webServer callback for /api/config(get)." CR));
|
Log.notice(F("WEB : webServer callback for /api/config(get)." CR));
|
||||||
@ -90,13 +87,19 @@ void WebServerHandler::webHandleConfig() {
|
|||||||
|
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
doc[PARAM_PLATFORM] = "esp8266";
|
doc[PARAM_PLATFORM] = "esp8266";
|
||||||
#else
|
#elif defined(ESP32C3)
|
||||||
|
doc[PARAM_PLATFORM] = "esp32c3";
|
||||||
|
#elif defined(ESP32S2)
|
||||||
|
doc[PARAM_PLATFORM] = "esp32s2";
|
||||||
|
#elif defined(ESP32LITE)
|
||||||
|
doc[PARAM_PLATFORM] = "esp32lite";
|
||||||
|
#else // esp32 mini
|
||||||
doc[PARAM_PLATFORM] = "esp32";
|
doc[PARAM_PLATFORM] = "esp32";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||||
serializeJson(doc, Serial);
|
serializeJson(doc, EspSerial);
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
String out;
|
String out;
|
||||||
@ -107,173 +110,64 @@ void WebServerHandler::webHandleConfig() {
|
|||||||
LOG_PERF_STOP("webserver-api-config");
|
LOG_PERF_STOP("webserver-api-config");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Callback from webServer when / has been accessed.
|
|
||||||
//
|
|
||||||
void WebServerHandler::webHandleUpload() {
|
|
||||||
LOG_PERF_START("webserver-api-upload");
|
|
||||||
Log.notice(F("WEB : webServer callback for /api/upload(get)." CR));
|
|
||||||
DynamicJsonDocument doc(300);
|
|
||||||
|
|
||||||
doc["index"] = checkHtmlFile(WebServerHandler::HTML_INDEX);
|
|
||||||
doc["config"] = checkHtmlFile(WebServerHandler::HTML_CONFIG);
|
|
||||||
doc["calibration"] = checkHtmlFile(WebServerHandler::HTML_CALIBRATION);
|
|
||||||
doc["format"] = checkHtmlFile(WebServerHandler::HTML_FORMAT);
|
|
||||||
doc["about"] = checkHtmlFile(WebServerHandler::HTML_ABOUT);
|
|
||||||
doc["test"] = checkHtmlFile(WebServerHandler::HTML_TEST);
|
|
||||||
|
|
||||||
#if defined(ESP8266)
|
|
||||||
JsonArray files = doc.createNestedArray(PARAM_FILES);
|
|
||||||
|
|
||||||
// Show files in the filessytem at startup
|
|
||||||
FSInfo fs;
|
|
||||||
LittleFS.info(fs);
|
|
||||||
Dir dir = LittleFS.openDir("/");
|
|
||||||
while (dir.next()) {
|
|
||||||
JsonObject obj = files.createNestedObject();
|
|
||||||
obj[PARAM_FILE_NAME] = dir.fileName();
|
|
||||||
obj[PARAM_FILE_SIZE] = dir.fileSize();
|
|
||||||
}
|
|
||||||
#else // defined(ESP32)
|
|
||||||
JsonArray files = doc.createNestedArray(PARAM_FILES);
|
|
||||||
|
|
||||||
File dir = LittleFS.open("/");
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
File entry = dir.openNextFile();
|
|
||||||
if (!entry) {
|
|
||||||
// no more files
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!entry.isDirectory()) {
|
|
||||||
JsonObject obj = files.createNestedObject();
|
|
||||||
obj[PARAM_FILE_NAME] = entry.name();
|
|
||||||
obj[PARAM_FILE_SIZE] = entry.size();
|
|
||||||
}
|
|
||||||
entry.close();
|
|
||||||
}
|
|
||||||
dir.close();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
|
||||||
serializeJson(doc, Serial);
|
|
||||||
Serial.print(CR);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
String out;
|
|
||||||
out.reserve(300);
|
|
||||||
serializeJson(doc, out);
|
|
||||||
doc.clear();
|
|
||||||
_server->send(200, "application/json", out.c_str());
|
|
||||||
LOG_PERF_STOP("webserver-api-upload");
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebServerHandler::webHandleUploadFile() {
|
void WebServerHandler::webHandleUploadFile() {
|
||||||
LOG_PERF_START("webserver-api-upload-file");
|
LOG_PERF_START("webserver-api-upload-file");
|
||||||
Log.verbose(F("WEB : webServer callback for /api/upload(post)." CR));
|
Log.verbose(F("WEB : webServer callback for /api/upload(post)." CR));
|
||||||
HTTPUpload& upload = _server->upload();
|
HTTPUpload& upload = _server->upload();
|
||||||
String f = upload.filename;
|
String f = upload.filename;
|
||||||
bool validFilename = false;
|
|
||||||
bool firmware = false;
|
|
||||||
|
|
||||||
if (f.equalsIgnoreCase("index.min.htm") ||
|
|
||||||
f.equalsIgnoreCase("calibration.min.htm") ||
|
|
||||||
f.equalsIgnoreCase("config.min.htm") ||
|
|
||||||
f.equalsIgnoreCase("format.min.htm") ||
|
|
||||||
f.equalsIgnoreCase("test.min.htm") ||
|
|
||||||
f.equalsIgnoreCase("about.min.htm")) {
|
|
||||||
validFilename = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (f.endsWith(".bin")) {
|
|
||||||
validFilename = true;
|
|
||||||
firmware = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||||
Log.verbose(
|
Log.verbose(F("WEB : webServer callback for /api/upload, receiving file %s, "
|
||||||
F("WEB : webServer callback for /api/upload, receiving file %s, %d(%d) "
|
"%d(%d)." CR),
|
||||||
"valid=%s, firmware=%s." CR),
|
f.c_str(), upload.currentSize, upload.totalSize);
|
||||||
f.c_str(), upload.currentSize, upload.totalSize,
|
|
||||||
validFilename ? "yes" : "no", firmware ? "yes" : "no");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (firmware) {
|
// Handle firmware update, hardcode since function return wrong value.
|
||||||
// Handle firmware update, hardcode since function return wrong value.
|
// (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
|
||||||
// (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
|
uint32_t maxSketchSpace = MAX_SKETCH_SPACE;
|
||||||
uint32_t maxSketchSpace = MAX_SKETCH_SPACE;
|
|
||||||
|
|
||||||
if (upload.status == UPLOAD_FILE_START) {
|
if (upload.status == UPLOAD_FILE_START) {
|
||||||
_uploadReturn = 200;
|
_uploadReturn = 200;
|
||||||
Log.notice(F("WEB : Start firmware upload, max sketch size %d kb." CR),
|
Log.notice(F("WEB : Start firmware upload, max sketch size %d kb." CR),
|
||||||
maxSketchSpace / 1024);
|
maxSketchSpace / 1024);
|
||||||
|
|
||||||
if (!Update.begin(maxSketchSpace, U_FLASH, PIN_LED)) {
|
if (!Update.begin(maxSketchSpace, U_FLASH, PIN_LED)) {
|
||||||
writeErrorLog("WEB : Not enough space to store for this firmware.");
|
writeErrorLog("WEB : Not enough space to store for this firmware.");
|
||||||
_uploadReturn = 500;
|
|
||||||
}
|
|
||||||
} else if (upload.status == UPLOAD_FILE_WRITE) {
|
|
||||||
Log.notice(F("WEB : Writing firmware upload %d (%d)." CR),
|
|
||||||
upload.totalSize, maxSketchSpace);
|
|
||||||
|
|
||||||
if (upload.totalSize > maxSketchSpace) {
|
|
||||||
Log.error(F("WEB : Firmware file is to large." CR));
|
|
||||||
_uploadReturn = 500;
|
|
||||||
} else if (Update.write(upload.buf, upload.currentSize) !=
|
|
||||||
upload.currentSize) {
|
|
||||||
Log.warning(F("WEB : Firmware write was unsuccessful." CR));
|
|
||||||
_uploadReturn = 500;
|
|
||||||
}
|
|
||||||
} else if (upload.status == UPLOAD_FILE_END) {
|
|
||||||
Log.notice(F("WEB : Finish firmware upload." CR));
|
|
||||||
if (Update.end(true)) {
|
|
||||||
_server->send(200);
|
|
||||||
delay(500);
|
|
||||||
ESP_RESET();
|
|
||||||
} else {
|
|
||||||
writeErrorLog("WEB : Failed to finish firmware flashing error=%d",
|
|
||||||
Update.getError());
|
|
||||||
_uploadReturn = 500;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Update.end();
|
|
||||||
Log.notice(F("WEB : Firmware flashing aborted." CR));
|
|
||||||
_uploadReturn = 500;
|
_uploadReturn = 500;
|
||||||
}
|
}
|
||||||
|
} else if (upload.status == UPLOAD_FILE_WRITE) {
|
||||||
|
Log.notice(F("WEB : Writing firmware upload %d (%d)." CR), upload.totalSize,
|
||||||
|
maxSketchSpace);
|
||||||
|
|
||||||
delay(0);
|
if (upload.totalSize > maxSketchSpace) {
|
||||||
|
Log.error(F("WEB : Firmware file is to large." CR));
|
||||||
} else {
|
_uploadReturn = 500;
|
||||||
// Handle HTML file upload
|
} else if (Update.write(upload.buf, upload.currentSize) !=
|
||||||
if (upload.status == UPLOAD_FILE_START) {
|
upload.currentSize) {
|
||||||
_uploadReturn = 200;
|
Log.warning(F("WEB : Firmware write was unsuccessful." CR));
|
||||||
Log.notice(F("WEB : Start html upload." CR));
|
_uploadReturn = 500;
|
||||||
|
|
||||||
if (validFilename) _uploadFile = LittleFS.open(f, "w");
|
|
||||||
} else if (upload.status == UPLOAD_FILE_WRITE) {
|
|
||||||
Log.notice(F("WEB : Writing html upload." CR));
|
|
||||||
if (_uploadFile) _uploadFile.write(upload.buf, upload.currentSize);
|
|
||||||
} else if (upload.status == UPLOAD_FILE_END) {
|
|
||||||
Log.notice(F("WEB : Finish html upload." CR));
|
|
||||||
if (_uploadFile) {
|
|
||||||
_uploadFile.close();
|
|
||||||
Log.notice(F("WEB : Html file uploaded %d bytes." CR),
|
|
||||||
upload.totalSize);
|
|
||||||
}
|
|
||||||
_server->sendHeader("Location", "/");
|
|
||||||
_server->send(303);
|
|
||||||
} else {
|
|
||||||
_server->send(500, "text/plain", "Couldn't upload html file.");
|
|
||||||
}
|
}
|
||||||
|
} else if (upload.status == UPLOAD_FILE_END) {
|
||||||
|
Log.notice(F("WEB : Finish firmware upload." CR));
|
||||||
|
if (Update.end(true)) {
|
||||||
|
_server->send(200);
|
||||||
|
delay(500);
|
||||||
|
ESP_RESET();
|
||||||
|
} else {
|
||||||
|
writeErrorLog("WEB : Failed to finish firmware flashing error=%d",
|
||||||
|
Update.getError());
|
||||||
|
_uploadReturn = 500;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Update.end();
|
||||||
|
Log.notice(F("WEB : Firmware flashing aborted." CR));
|
||||||
|
_uploadReturn = 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delay(0);
|
||||||
LOG_PERF_STOP("webserver-api-upload-file");
|
LOG_PERF_STOP("webserver-api-upload-file");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Callback from webServer when / has been accessed.
|
|
||||||
//
|
|
||||||
void WebServerHandler::webHandleCalibrate() {
|
void WebServerHandler::webHandleCalibrate() {
|
||||||
LOG_PERF_START("webserver-api-calibrate");
|
LOG_PERF_START("webserver-api-calibrate");
|
||||||
String id = _server->arg(PARAM_ID);
|
String id = _server->arg(PARAM_ID);
|
||||||
@ -307,6 +201,7 @@ void WebServerHandler::webHandleFactoryDefaults() {
|
|||||||
LittleFS.remove(TPL_FNAME_INFLUXDB);
|
LittleFS.remove(TPL_FNAME_INFLUXDB);
|
||||||
LittleFS.remove(TPL_FNAME_MQTT);
|
LittleFS.remove(TPL_FNAME_MQTT);
|
||||||
LittleFS.end();
|
LittleFS.end();
|
||||||
|
Log.notice(F("WEB : Deleted files in filesystem, rebooting." CR));
|
||||||
delay(500);
|
delay(500);
|
||||||
ESP_RESET();
|
ESP_RESET();
|
||||||
} else {
|
} else {
|
||||||
@ -377,13 +272,19 @@ void WebServerHandler::webHandleStatus() {
|
|||||||
|
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
doc[PARAM_PLATFORM] = "esp8266";
|
doc[PARAM_PLATFORM] = "esp8266";
|
||||||
#else
|
#elif defined(ESP32C3)
|
||||||
|
doc[PARAM_PLATFORM] = "esp32c3";
|
||||||
|
#elif defined(ESP32S2)
|
||||||
|
doc[PARAM_PLATFORM] = "esp32s2";
|
||||||
|
#elif defined(ESP32LITE)
|
||||||
|
doc[PARAM_PLATFORM] = "esp32lite";
|
||||||
|
#else // esp32 mini
|
||||||
doc[PARAM_PLATFORM] = "esp32";
|
doc[PARAM_PLATFORM] = "esp32";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||||
serializeJson(doc, Serial);
|
serializeJson(doc, EspSerial);
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
String out;
|
String out;
|
||||||
@ -439,9 +340,6 @@ void WebServerHandler::webHandleStatusSleepmode() {
|
|||||||
LOG_PERF_STOP("webserver-api-sleepmode");
|
LOG_PERF_STOP("webserver-api-sleepmode");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Update device settings.
|
|
||||||
//
|
|
||||||
void WebServerHandler::webHandleConfigDevice() {
|
void WebServerHandler::webHandleConfigDevice() {
|
||||||
LOG_PERF_START("webserver-api-config-device");
|
LOG_PERF_START("webserver-api-config-device");
|
||||||
String id = _server->arg(PARAM_ID);
|
String id = _server->arg(PARAM_ID);
|
||||||
@ -471,9 +369,6 @@ void WebServerHandler::webHandleConfigDevice() {
|
|||||||
LOG_PERF_STOP("webserver-api-config-device");
|
LOG_PERF_STOP("webserver-api-config-device");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Update push settings.
|
|
||||||
//
|
|
||||||
void WebServerHandler::webHandleConfigPush() {
|
void WebServerHandler::webHandleConfigPush() {
|
||||||
LOG_PERF_START("webserver-api-config-push");
|
LOG_PERF_START("webserver-api-config-push");
|
||||||
String id = _server->arg(PARAM_ID);
|
String id = _server->arg(PARAM_ID);
|
||||||
@ -535,9 +430,6 @@ void WebServerHandler::webHandleConfigPush() {
|
|||||||
LOG_PERF_STOP("webserver-api-config-push");
|
LOG_PERF_STOP("webserver-api-config-push");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Get string with all received arguments. Used for debugging only.
|
|
||||||
//
|
|
||||||
String WebServerHandler::getRequestArguments() {
|
String WebServerHandler::getRequestArguments() {
|
||||||
String debug;
|
String debug;
|
||||||
|
|
||||||
@ -554,9 +446,6 @@ String WebServerHandler::getRequestArguments() {
|
|||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Update gravity settings.
|
|
||||||
//
|
|
||||||
void WebServerHandler::webHandleConfigGravity() {
|
void WebServerHandler::webHandleConfigGravity() {
|
||||||
LOG_PERF_START("webserver-api-config-gravity");
|
LOG_PERF_START("webserver-api-config-gravity");
|
||||||
String id = _server->arg(PARAM_ID);
|
String id = _server->arg(PARAM_ID);
|
||||||
@ -591,9 +480,6 @@ void WebServerHandler::webHandleConfigGravity() {
|
|||||||
LOG_PERF_STOP("webserver-api-config-gravity");
|
LOG_PERF_STOP("webserver-api-config-gravity");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Update hardware settings.
|
|
||||||
//
|
|
||||||
void WebServerHandler::webHandleConfigHardware() {
|
void WebServerHandler::webHandleConfigHardware() {
|
||||||
LOG_PERF_START("webserver-api-config-hardware");
|
LOG_PERF_START("webserver-api-config-hardware");
|
||||||
String id = _server->arg(PARAM_ID);
|
String id = _server->arg(PARAM_ID);
|
||||||
@ -645,9 +531,6 @@ void WebServerHandler::webHandleConfigHardware() {
|
|||||||
LOG_PERF_STOP("webserver-api-config-hardware");
|
LOG_PERF_STOP("webserver-api-config-hardware");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Update advanced settings.
|
|
||||||
//
|
|
||||||
void WebServerHandler::webHandleConfigAdvancedWrite() {
|
void WebServerHandler::webHandleConfigAdvancedWrite() {
|
||||||
LOG_PERF_START("webserver-api-config-advanced");
|
LOG_PERF_START("webserver-api-config-advanced");
|
||||||
String id = _server->arg(PARAM_ID);
|
String id = _server->arg(PARAM_ID);
|
||||||
@ -723,9 +606,6 @@ void WebServerHandler::webHandleConfigAdvancedWrite() {
|
|||||||
LOG_PERF_STOP("webserver-api-config-advanced");
|
LOG_PERF_STOP("webserver-api-config-advanced");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Read advanced settings
|
|
||||||
//
|
|
||||||
void WebServerHandler::webHandleConfigAdvancedRead() {
|
void WebServerHandler::webHandleConfigAdvancedRead() {
|
||||||
LOG_PERF_START("webserver-api-config-advanced");
|
LOG_PERF_START("webserver-api-config-advanced");
|
||||||
Log.notice(F("WEB : webServer callback for /api/config/advanced(get)." CR));
|
Log.notice(F("WEB : webServer callback for /api/config/advanced(get)." CR));
|
||||||
@ -754,8 +634,8 @@ void WebServerHandler::webHandleConfigAdvancedRead() {
|
|||||||
doc[PARAM_HW_IGNORE_LOW_ANGLES] = myAdvancedConfig.isIgnoreLowAnges();
|
doc[PARAM_HW_IGNORE_LOW_ANGLES] = myAdvancedConfig.isIgnoreLowAnges();
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||||
serializeJson(doc, Serial);
|
serializeJson(doc, EspSerial);
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
String out;
|
String out;
|
||||||
@ -766,9 +646,6 @@ void WebServerHandler::webHandleConfigAdvancedRead() {
|
|||||||
LOG_PERF_STOP("webserver-api-config-advanced");
|
LOG_PERF_STOP("webserver-api-config-advanced");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Callback from webServer when / has been accessed.
|
|
||||||
//
|
|
||||||
void WebServerHandler::webHandleFormulaRead() {
|
void WebServerHandler::webHandleFormulaRead() {
|
||||||
LOG_PERF_START("webserver-api-formula-read");
|
LOG_PERF_START("webserver-api-formula-read");
|
||||||
Log.notice(F("WEB : webServer callback for /api/formula(get)." CR));
|
Log.notice(F("WEB : webServer callback for /api/formula(get)." CR));
|
||||||
@ -840,8 +717,8 @@ void WebServerHandler::webHandleFormulaRead() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||||
serializeJson(doc, Serial);
|
serializeJson(doc, EspSerial);
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
String out;
|
String out;
|
||||||
@ -852,9 +729,6 @@ void WebServerHandler::webHandleFormulaRead() {
|
|||||||
LOG_PERF_STOP("webserver-api-formula-read");
|
LOG_PERF_STOP("webserver-api-formula-read");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Update format template
|
|
||||||
//
|
|
||||||
void WebServerHandler::webHandleConfigFormatWrite() {
|
void WebServerHandler::webHandleConfigFormatWrite() {
|
||||||
LOG_PERF_START("webserver-api-config-format-write");
|
LOG_PERF_START("webserver-api-config-format-write");
|
||||||
String id = _server->arg(PARAM_ID);
|
String id = _server->arg(PARAM_ID);
|
||||||
@ -898,9 +772,6 @@ void WebServerHandler::webHandleConfigFormatWrite() {
|
|||||||
LOG_PERF_STOP("webserver-api-config-format-write");
|
LOG_PERF_STOP("webserver-api-config-format-write");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Get format with real data
|
|
||||||
//
|
|
||||||
void WebServerHandler::webHandleTestPush() {
|
void WebServerHandler::webHandleTestPush() {
|
||||||
LOG_PERF_START("webserver-api-test-push");
|
LOG_PERF_START("webserver-api-test-push");
|
||||||
String id = _server->arg(PARAM_ID);
|
String id = _server->arg(PARAM_ID);
|
||||||
@ -961,18 +832,14 @@ void WebServerHandler::webHandleTestPush() {
|
|||||||
doc.clear();
|
doc.clear();
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||||
serializeJson(doc, Serial);
|
serializeJson(doc, EspSerial);
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_server->send(200, "application/json", out.c_str());
|
_server->send(200, "application/json", out.c_str());
|
||||||
LOG_PERF_STOP("webserver-api-test-push");
|
LOG_PERF_STOP("webserver-api-test-push");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Write file to disk, if there is no data then delete the current file (if it
|
|
||||||
// exists) = reset to default.
|
|
||||||
//
|
|
||||||
bool WebServerHandler::writeFile(String fname, String data) {
|
bool WebServerHandler::writeFile(String fname, String data) {
|
||||||
if (data.length()) {
|
if (data.length()) {
|
||||||
data = urldecode(data);
|
data = urldecode(data);
|
||||||
@ -998,9 +865,6 @@ bool WebServerHandler::writeFile(String fname, String data) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Read file from disk
|
|
||||||
//
|
|
||||||
String WebServerHandler::readFile(String fname) {
|
String WebServerHandler::readFile(String fname) {
|
||||||
File file = LittleFS.open(fname, "r");
|
File file = LittleFS.open(fname, "r");
|
||||||
if (file) {
|
if (file) {
|
||||||
@ -1014,9 +878,6 @@ String WebServerHandler::readFile(String fname) {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Get format templates
|
|
||||||
//
|
|
||||||
void WebServerHandler::webHandleConfigFormatRead() {
|
void WebServerHandler::webHandleConfigFormatRead() {
|
||||||
LOG_PERF_START("webserver-api-config-format-read");
|
LOG_PERF_START("webserver-api-config-format-read");
|
||||||
Log.notice(F("WEB : webServer callback for /api/config/formula(get)." CR));
|
Log.notice(F("WEB : webServer callback for /api/config/formula(get)." CR));
|
||||||
@ -1063,17 +924,14 @@ void WebServerHandler::webHandleConfigFormatRead() {
|
|||||||
out += "\"}";
|
out += "\"}";
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||||
Serial.print(out.c_str());
|
EspSerial.print(out.c_str());
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_server->send(200, "application/json", out.c_str());
|
_server->send(200, "application/json", out.c_str());
|
||||||
LOG_PERF_STOP("webserver-api-config-format-read");
|
LOG_PERF_STOP("webserver-api-config-format-read");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Update hardware settings.
|
|
||||||
//
|
|
||||||
void WebServerHandler::webHandleFormulaWrite() {
|
void WebServerHandler::webHandleFormulaWrite() {
|
||||||
LOG_PERF_START("webserver-api-formula-write");
|
LOG_PERF_START("webserver-api-formula-write");
|
||||||
String id = _server->arg(PARAM_ID);
|
String id = _server->arg(PARAM_ID);
|
||||||
@ -1166,62 +1024,14 @@ void WebServerHandler::webHandleFormulaWrite() {
|
|||||||
LOG_PERF_STOP("webserver-api-formula-write");
|
LOG_PERF_STOP("webserver-api-formula-write");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Helper function to check if files exist on file system.
|
|
||||||
//
|
|
||||||
const char* WebServerHandler::getHtmlFileName(HtmlFile item) {
|
|
||||||
Log.notice(F("WEB : Looking up filename for %d." CR), item);
|
|
||||||
|
|
||||||
switch (item) {
|
|
||||||
case HtmlFile::HTML_INDEX:
|
|
||||||
return "index.min.htm";
|
|
||||||
case HtmlFile::HTML_CONFIG:
|
|
||||||
return "config.min.htm";
|
|
||||||
case HtmlFile::HTML_CALIBRATION:
|
|
||||||
return "calibration.min.htm";
|
|
||||||
case HtmlFile::HTML_FORMAT:
|
|
||||||
return "format.min.htm";
|
|
||||||
case HtmlFile::HTML_ABOUT:
|
|
||||||
return "about.min.htm";
|
|
||||||
case HtmlFile::HTML_TEST:
|
|
||||||
return "test.min.htm";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Helper function to check if files exist on file system.
|
|
||||||
//
|
|
||||||
bool WebServerHandler::checkHtmlFile(HtmlFile item) {
|
|
||||||
const char* fn = getHtmlFileName(item);
|
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
|
||||||
Log.verbose(F("WEB : Checking for file %s." CR), fn);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// TODO: We might need to add more checks here like zero file size etc. But
|
|
||||||
// for now we only check if the file exist.
|
|
||||||
|
|
||||||
return LittleFS.exists(fn);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Handler for page not found
|
|
||||||
//
|
|
||||||
void WebServerHandler::webHandlePageNotFound() {
|
void WebServerHandler::webHandlePageNotFound() {
|
||||||
Log.error(F("WEB : URL not found %s received." CR), _server->uri().c_str());
|
Log.error(F("WEB : URL not found %s received." CR), _server->uri().c_str());
|
||||||
_server->send(404, "text/plain", F("URL not found"));
|
_server->send(404, "text/plain", F("URL not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Setup the Web Server callbacks and start it
|
|
||||||
//
|
|
||||||
bool WebServerHandler::setupWebServer() {
|
bool WebServerHandler::setupWebServer() {
|
||||||
Log.notice(F("WEB : Configuring web server." CR));
|
Log.notice(F("WEB : Configuring web server." CR));
|
||||||
|
|
||||||
_server = new ESP8266WebServer();
|
_server = new ESP8266WebServer();
|
||||||
|
|
||||||
MDNS.begin(myConfig.getMDNS());
|
MDNS.begin(myConfig.getMDNS());
|
||||||
MDNS.addService("http", "tcp", 80);
|
MDNS.addService("http", "tcp", 80);
|
||||||
|
|
||||||
@ -1240,7 +1050,7 @@ bool WebServerHandler::setupWebServer() {
|
|||||||
LittleFS.remove(dir.fileName().c_str());
|
LittleFS.remove(dir.fileName().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else // defined( ESP32 )
|
#else // ESP32
|
||||||
File root = LittleFS.open("/");
|
File root = LittleFS.open("/");
|
||||||
File f = root.openNextFile();
|
File f = root.openNextFile();
|
||||||
while (f) {
|
while (f) {
|
||||||
@ -1258,7 +1068,6 @@ bool WebServerHandler::setupWebServer() {
|
|||||||
|
|
||||||
// Static content
|
// Static content
|
||||||
Log.notice(F("WEB : Setting up handlers for web server." CR));
|
Log.notice(F("WEB : Setting up handlers for web server." CR));
|
||||||
#if defined(EMBED_HTML)
|
|
||||||
_server->on("/", std::bind(&WebServerHandler::webReturnIndexHtm, this));
|
_server->on("/", std::bind(&WebServerHandler::webReturnIndexHtm, this));
|
||||||
_server->on("/index.htm",
|
_server->on("/index.htm",
|
||||||
std::bind(&WebServerHandler::webReturnIndexHtm, this));
|
std::bind(&WebServerHandler::webReturnIndexHtm, this));
|
||||||
@ -1272,31 +1081,6 @@ bool WebServerHandler::setupWebServer() {
|
|||||||
std::bind(&WebServerHandler::webReturnAboutHtm, this));
|
std::bind(&WebServerHandler::webReturnAboutHtm, this));
|
||||||
_server->on("/test.htm",
|
_server->on("/test.htm",
|
||||||
std::bind(&WebServerHandler::webReturnTestHtm, this));
|
std::bind(&WebServerHandler::webReturnTestHtm, this));
|
||||||
#else
|
|
||||||
// Check if the html files exist, if so serve them, else show the static
|
|
||||||
// upload page.
|
|
||||||
if (checkHtmlFile(HTML_INDEX) && checkHtmlFile(HTML_CONFIG) &&
|
|
||||||
checkHtmlFile(HTML_CALIBRATION) && checkHtmlFile(HTML_FORMAT) &&
|
|
||||||
checkHtmlFile(HTML_ABOUT) && checkHtmlFile(HTML_TEST)) {
|
|
||||||
Log.notice(F("WEB : All html files exist, starting in normal mode." CR));
|
|
||||||
|
|
||||||
_server->serveStatic("/", LittleFS, "/index.min.htm");
|
|
||||||
_server->serveStatic("/index.htm", LittleFS, "/index.min.htm");
|
|
||||||
_server->serveStatic("/config.htm", LittleFS, "/config.min.htm");
|
|
||||||
_server->serveStatic("/about.htm", LittleFS, "/about.min.htm");
|
|
||||||
_server->serveStatic("/test.htm", LittleFS, "/test.min.htm");
|
|
||||||
_server->serveStatic("/calibration.htm", LittleFS, "/calibration.min.htm");
|
|
||||||
_server->serveStatic("/format.htm", LittleFS, "/format.min.htm");
|
|
||||||
|
|
||||||
// Also add the static upload view in case we we have issues that needs to
|
|
||||||
// be fixed.
|
|
||||||
_server->on("/upload.htm",
|
|
||||||
std::bind(&WebServerHandler::webReturnUploadHtm, this));
|
|
||||||
} else {
|
|
||||||
Log.error(F("WEB : Missing html files, starting with upload UI." CR));
|
|
||||||
_server->on("/", std::bind(&WebServerHandler::webReturnUploadHtm, this));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
_server->on("/firmware.htm",
|
_server->on("/firmware.htm",
|
||||||
std::bind(&WebServerHandler::webReturnFirmwareHtm, this));
|
std::bind(&WebServerHandler::webReturnFirmwareHtm, this));
|
||||||
_server->serveStatic("/log", LittleFS, ERR_FILENAME);
|
_server->serveStatic("/log", LittleFS, ERR_FILENAME);
|
||||||
@ -1320,9 +1104,6 @@ bool WebServerHandler::setupWebServer() {
|
|||||||
std::bind(&WebServerHandler::webHandleStatus, this));
|
std::bind(&WebServerHandler::webHandleStatus, this));
|
||||||
_server->on("/api/clearwifi", HTTP_GET,
|
_server->on("/api/clearwifi", HTTP_GET,
|
||||||
std::bind(&WebServerHandler::webHandleClearWIFI, this));
|
std::bind(&WebServerHandler::webHandleClearWIFI, this));
|
||||||
_server->on(
|
|
||||||
"/api/upload", HTTP_GET,
|
|
||||||
std::bind(&WebServerHandler::webHandleUpload, this)); // Get upload.json
|
|
||||||
|
|
||||||
_server->on("/api/upload", HTTP_POST,
|
_server->on("/api/upload", HTTP_POST,
|
||||||
std::bind(&WebServerHandler::webReturnOK, this),
|
std::bind(&WebServerHandler::webReturnOK, this),
|
||||||
|
@ -29,26 +29,42 @@ SOFTWARE.
|
|||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#include <ESP8266mDNS.h>
|
#include <ESP8266mDNS.h>
|
||||||
#define MAX_SKETCH_SPACE 1044464
|
#define MAX_SKETCH_SPACE 1044464
|
||||||
#else // defined (ESP32)
|
#else
|
||||||
#include <ESPmDNS.h>
|
#include <ESPmDNS.h>
|
||||||
#include <Update.h>
|
#include <Update.h>
|
||||||
#include <WebServer.h>
|
#include <WebServer.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#define MAX_SKETCH_SPACE 1835008
|
#define MAX_SKETCH_SPACE 1835008
|
||||||
#endif
|
#endif
|
||||||
#include <incbin.h>
|
|
||||||
|
|
||||||
#if defined(EMBED_HTML)
|
#if defined(ESP8266)
|
||||||
|
#include <incbin.h>
|
||||||
INCBIN_EXTERN(IndexHtm);
|
INCBIN_EXTERN(IndexHtm);
|
||||||
INCBIN_EXTERN(ConfigHtm);
|
INCBIN_EXTERN(ConfigHtm);
|
||||||
INCBIN_EXTERN(CalibrationHtm);
|
INCBIN_EXTERN(CalibrationHtm);
|
||||||
INCBIN_EXTERN(FormatHtm);
|
INCBIN_EXTERN(FormatHtm);
|
||||||
INCBIN_EXTERN(TestHtm);
|
INCBIN_EXTERN(TestHtm);
|
||||||
INCBIN_EXTERN(AboutHtm);
|
INCBIN_EXTERN(AboutHtm);
|
||||||
#else
|
|
||||||
INCBIN_EXTERN(UploadHtm);
|
|
||||||
#endif
|
|
||||||
INCBIN_EXTERN(FirmwareHtm);
|
INCBIN_EXTERN(FirmwareHtm);
|
||||||
|
#else // ESP32
|
||||||
|
extern const uint8_t indexHtmStart[] asm("_binary_html_index_min_htm_start");
|
||||||
|
extern const uint8_t indexHtmEnd[] asm("_binary_html_index_min_htm_end");
|
||||||
|
extern const uint8_t configHtmStart[] asm("_binary_html_config_min_htm_start");
|
||||||
|
extern const uint8_t configHtmEnd[] asm("_binary_html_config_min_htm_end");
|
||||||
|
extern const uint8_t calibrationHtmStart[] asm(
|
||||||
|
"_binary_html_calibration_min_htm_start");
|
||||||
|
extern const uint8_t calibrationHtmEnd[] asm(
|
||||||
|
"_binary_html_calibration_min_htm_end");
|
||||||
|
extern const uint8_t formatHtmStart[] asm("_binary_html_format_min_htm_start");
|
||||||
|
extern const uint8_t formatHtmEnd[] asm("_binary_html_format_min_htm_end");
|
||||||
|
extern const uint8_t testHtmStart[] asm("_binary_html_test_min_htm_start");
|
||||||
|
extern const uint8_t testHtmEnd[] asm("_binary_html_test_min_htm_end");
|
||||||
|
extern const uint8_t aboutHtmStart[] asm("_binary_html_about_min_htm_start");
|
||||||
|
extern const uint8_t aboutHtmEnd[] asm("_binary_html_about_min_htm_end");
|
||||||
|
extern const uint8_t firmwareHtmStart[] asm(
|
||||||
|
"_binary_html_firmware_min_htm_start");
|
||||||
|
extern const uint8_t firmwareHtmEnd[] asm("_binary_html_firmware_min_htm_end");
|
||||||
|
#endif
|
||||||
|
|
||||||
class WebServerHandler {
|
class WebServerHandler {
|
||||||
private:
|
private:
|
||||||
@ -75,7 +91,6 @@ class WebServerHandler {
|
|||||||
void webHandleFactoryDefaults();
|
void webHandleFactoryDefaults();
|
||||||
void webHandleCalibrate();
|
void webHandleCalibrate();
|
||||||
void webHandleUploadFile();
|
void webHandleUploadFile();
|
||||||
void webHandleUpload();
|
|
||||||
void webHandleLogClear();
|
void webHandleLogClear();
|
||||||
void webHandlePageNotFound();
|
void webHandlePageNotFound();
|
||||||
|
|
||||||
@ -86,7 +101,7 @@ class WebServerHandler {
|
|||||||
|
|
||||||
// Inline functions.
|
// Inline functions.
|
||||||
void webReturnOK() { _server->send(_uploadReturn); }
|
void webReturnOK() { _server->send(_uploadReturn); }
|
||||||
#if defined(EMBED_HTML)
|
#if defined(ESP8266)
|
||||||
void webReturnIndexHtm() {
|
void webReturnIndexHtm() {
|
||||||
_server->send_P(200, "text/html", (const char*)gIndexHtmData,
|
_server->send_P(200, "text/html", (const char*)gIndexHtmData,
|
||||||
gIndexHtmSize);
|
gIndexHtmSize);
|
||||||
@ -110,31 +125,46 @@ class WebServerHandler {
|
|||||||
void webReturnTestHtm() {
|
void webReturnTestHtm() {
|
||||||
_server->send_P(200, "text/html", (const char*)gTestHtmData, gTestHtmSize);
|
_server->send_P(200, "text/html", (const char*)gTestHtmData, gTestHtmSize);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
void webReturnUploadHtm() {
|
|
||||||
_server->send_P(200, "text/html", (const char*)gUploadHtmData,
|
|
||||||
gUploadHtmSize);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
void webReturnFirmwareHtm() {
|
void webReturnFirmwareHtm() {
|
||||||
_server->send_P(200, "text/html", (const char*)gFirmwareHtmData,
|
_server->send_P(200, "text/html", (const char*)gFirmwareHtmData,
|
||||||
gFirmwareHtmSize);
|
gFirmwareHtmSize);
|
||||||
}
|
}
|
||||||
|
#else // ESP32
|
||||||
|
void webReturnIndexHtm() {
|
||||||
|
_server->send_P(200, "text/html", (const char*)indexHtmStart,
|
||||||
|
strlen(reinterpret_cast<const char*>(&indexHtmStart[0])));
|
||||||
|
}
|
||||||
|
void webReturnConfigHtm() {
|
||||||
|
_server->send_P(200, "text/html", (const char*)configHtmStart,
|
||||||
|
strlen(reinterpret_cast<const char*>(&configHtmStart[0])));
|
||||||
|
}
|
||||||
|
void webReturnCalibrationHtm() {
|
||||||
|
_server->send_P(
|
||||||
|
200, "text/html", (const char*)calibrationHtmStart,
|
||||||
|
strlen(reinterpret_cast<const char*>(&calibrationHtmStart[0])));
|
||||||
|
}
|
||||||
|
void webReturnFormatHtm() {
|
||||||
|
_server->send_P(200, "text/html", (const char*)formatHtmStart,
|
||||||
|
strlen(reinterpret_cast<const char*>(&formatHtmStart[0])));
|
||||||
|
}
|
||||||
|
void webReturnAboutHtm() {
|
||||||
|
_server->send_P(200, "text/html", (const char*)aboutHtmStart,
|
||||||
|
strlen(reinterpret_cast<const char*>(&aboutHtmStart[0])));
|
||||||
|
}
|
||||||
|
void webReturnTestHtm() {
|
||||||
|
_server->send_P(200, "text/html", (const char*)testHtmStart,
|
||||||
|
strlen(reinterpret_cast<const char*>(&testHtmStart[0])));
|
||||||
|
}
|
||||||
|
void webReturnFirmwareHtm() {
|
||||||
|
_server->send_P(
|
||||||
|
200, "text/html", (const char*)firmwareHtmStart,
|
||||||
|
strlen(reinterpret_cast<const char*>(&firmwareHtmStart[0])));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum HtmlFile {
|
|
||||||
HTML_INDEX = 0,
|
|
||||||
HTML_CONFIG = 1,
|
|
||||||
HTML_ABOUT = 2,
|
|
||||||
HTML_CALIBRATION = 3,
|
|
||||||
HTML_FORMAT = 4,
|
|
||||||
HTML_TEST = 5
|
|
||||||
};
|
|
||||||
|
|
||||||
bool setupWebServer();
|
bool setupWebServer();
|
||||||
void loop();
|
void loop();
|
||||||
bool checkHtmlFile(HtmlFile item);
|
|
||||||
const char* getHtmlFileName(HtmlFile item);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Global instance created
|
// Global instance created
|
||||||
|
94
src/wifi.cpp
@ -30,7 +30,6 @@ SOFTWARE.
|
|||||||
#include <WiFiClient.h>
|
#include <WiFiClient.h>
|
||||||
#include <WiFiClientSecure.h>
|
#include <WiFiClientSecure.h>
|
||||||
#endif
|
#endif
|
||||||
#include <incbin.h>
|
|
||||||
|
|
||||||
#include <config.hpp>
|
#include <config.hpp>
|
||||||
#include <main.hpp>
|
#include <main.hpp>
|
||||||
@ -59,16 +58,10 @@ WifiConnection myWifi;
|
|||||||
const char *userSSID = USER_SSID;
|
const char *userSSID = USER_SSID;
|
||||||
const char *userPWD = USER_SSID_PWD;
|
const char *userPWD = USER_SSID_PWD;
|
||||||
|
|
||||||
//
|
|
||||||
// Initialize
|
|
||||||
//
|
|
||||||
void WifiConnection::init() {
|
void WifiConnection::init() {
|
||||||
myDRD = new DoubleResetDetector(DRD_TIMEOUT, DRD_ADDRESS);
|
myDRD = new DoubleResetDetector(DRD_TIMEOUT, DRD_ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Check if we have a valid wifi configuration
|
|
||||||
//
|
|
||||||
bool WifiConnection::hasConfig() {
|
bool WifiConnection::hasConfig() {
|
||||||
if (strlen(myConfig.getWifiSSID(0))) return true;
|
if (strlen(myConfig.getWifiSSID(0))) return true;
|
||||||
if (strlen(userSSID)) return true;
|
if (strlen(userSSID)) return true;
|
||||||
@ -76,49 +69,37 @@ bool WifiConnection::hasConfig() {
|
|||||||
// Check if there are stored WIFI Settings we can use.
|
// Check if there are stored WIFI Settings we can use.
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
String ssid = WiFi.SSID();
|
String ssid = WiFi.SSID();
|
||||||
|
String pwd = WiFi.psk();
|
||||||
|
#else
|
||||||
|
ESP_WiFiManager wifiMgr;
|
||||||
|
String ssid = wifiMgr.WiFi_SSID();
|
||||||
|
String pwd = wifiMgr.WiFi_Pass();
|
||||||
|
#endif
|
||||||
if (ssid.length()) {
|
if (ssid.length()) {
|
||||||
Log.notice(F("WIFI: Found credentials in EEPORM." CR));
|
Log.notice(F("WIFI: Found stored credentials." CR));
|
||||||
myConfig.setWifiSSID(ssid, 0);
|
myConfig.setWifiSSID(ssid, 0);
|
||||||
|
|
||||||
if (WiFi.psk().length()) myConfig.setWifiPass(WiFi.psk(), 0);
|
if (pwd.length()) myConfig.setWifiPass(pwd, 0);
|
||||||
|
|
||||||
myConfig.saveFile();
|
myConfig.saveFile();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#else // defined( ESP32 )
|
|
||||||
#warning "Cant read SSID property on ESP32 until a connection has been made!"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Check if the wifi is connected
|
|
||||||
//
|
|
||||||
bool WifiConnection::isConnected() { return WiFi.status() == WL_CONNECTED; }
|
bool WifiConnection::isConnected() { return WiFi.status() == WL_CONNECTED; }
|
||||||
|
|
||||||
//
|
|
||||||
// Get the IP adress
|
|
||||||
//
|
|
||||||
String WifiConnection::getIPAddress() { return WiFi.localIP().toString(); }
|
String WifiConnection::getIPAddress() { return WiFi.localIP().toString(); }
|
||||||
|
|
||||||
//
|
|
||||||
// Additional method to detect double reset.
|
|
||||||
//
|
|
||||||
bool WifiConnection::isDoubleResetDetected() {
|
bool WifiConnection::isDoubleResetDetected() {
|
||||||
if (strlen(userSSID))
|
if (strlen(userSSID))
|
||||||
return false; // Ignore this if we have hardcoded settings.
|
return false; // Ignore this if we have hardcoded settings.
|
||||||
return myDRD->detectDoubleReset();
|
return myDRD->detectDoubleReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Stop double reset detection
|
|
||||||
//
|
|
||||||
void WifiConnection::stopDoubleReset() { myDRD->stop(); }
|
void WifiConnection::stopDoubleReset() { myDRD->stop(); }
|
||||||
|
|
||||||
//
|
|
||||||
// Start the wifi manager
|
|
||||||
//
|
|
||||||
void WifiConnection::startPortal() {
|
void WifiConnection::startPortal() {
|
||||||
Log.notice(F("WIFI: Starting Wifi config portal." CR));
|
Log.notice(F("WIFI: Starting Wifi config portal." CR));
|
||||||
|
|
||||||
@ -137,6 +118,11 @@ void WifiConnection::startPortal() {
|
|||||||
ESP_WMParameter deviceName(mdns.c_str());
|
ESP_WMParameter deviceName(mdns.c_str());
|
||||||
myWifiManager->addParameter(&deviceName);
|
myWifiManager->addParameter(&deviceName);
|
||||||
|
|
||||||
|
#if defined(ESP32C3) && defined(REDUCE_WIFI_POWER)
|
||||||
|
Log.notice(F("WIFI: Reducing wifi power for c3 chip." CR));
|
||||||
|
WiFi.setTxPower(WIFI_POWER_8_5dBm); // Required for ESP32C3 Mini
|
||||||
|
#endif
|
||||||
|
|
||||||
myWifiManager->startConfigPortal(WIFI_DEFAULT_SSID, WIFI_DEFAULT_PWD);
|
myWifiManager->startConfigPortal(WIFI_DEFAULT_SSID, WIFI_DEFAULT_PWD);
|
||||||
|
|
||||||
if (myWifiManager->getSSID(0).length()) {
|
if (myWifiManager->getSSID(0).length()) {
|
||||||
@ -165,17 +151,17 @@ void WifiConnection::startPortal() {
|
|||||||
ESP_RESET();
|
ESP_RESET();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Call the wifi manager in loop
|
|
||||||
//
|
|
||||||
void WifiConnection::loop() { myDRD->loop(); }
|
void WifiConnection::loop() { myDRD->loop(); }
|
||||||
|
|
||||||
//
|
|
||||||
// Connect to last known access point, non blocking mode.
|
|
||||||
//
|
|
||||||
void WifiConnection::connectAsync(int wifiIndex) {
|
void WifiConnection::connectAsync(int wifiIndex) {
|
||||||
WiFi.persistent(true);
|
WiFi.persistent(true);
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
|
|
||||||
|
#if defined(ESP32C3) && defined(REDUCE_WIFI_POWER)
|
||||||
|
Log.notice(F("WIFI: Reducing wifi power for c3 chip." CR));
|
||||||
|
WiFi.setTxPower(WIFI_POWER_8_5dBm); // Required for ESP32C3 Mini
|
||||||
|
#endif
|
||||||
|
|
||||||
if (strlen(userSSID)) {
|
if (strlen(userSSID)) {
|
||||||
Log.notice(F("WIFI: Connecting to wifi using hardcoded settings %s." CR),
|
Log.notice(F("WIFI: Connecting to wifi using hardcoded settings %s." CR),
|
||||||
userSSID);
|
userSSID);
|
||||||
@ -188,37 +174,31 @@ void WifiConnection::connectAsync(int wifiIndex) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Blocks until wifi connection has been found
|
|
||||||
//
|
|
||||||
bool WifiConnection::waitForConnection(int maxTime) {
|
bool WifiConnection::waitForConnection(int maxTime) {
|
||||||
#if DEBUG_LEVEL == 6
|
#if DEBUG_LEVEL == 6
|
||||||
WiFi.printDiag(Serial);
|
WiFi.printDiag(EspSerial);
|
||||||
#endif
|
#endif
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
delay(100);
|
delay(100);
|
||||||
|
|
||||||
if (i % 10) Serial.print(".");
|
if (i % 10) EspSerial.print(".");
|
||||||
|
|
||||||
if (i++ >
|
if (i++ >
|
||||||
(maxTime * 10)) { // Try for maxTime seconds. Since delay is 100ms.
|
(maxTime * 10)) { // Try for maxTime seconds. Since delay is 100ms.
|
||||||
writeErrorLog("WIFI: Failed to connect to wifi %d", WiFi.status());
|
writeErrorLog("WIFI: Failed to connect to wifi %d", WiFi.status());
|
||||||
WiFi.disconnect();
|
WiFi.disconnect();
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
return false; // Return to main that we have failed to connect.
|
return false; // Return to main that we have failed to connect.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
Log.notice(F("WIFI: Connected to wifi %s ip=%s." CR), WiFi.SSID().c_str(),
|
Log.notice(F("WIFI: Connected to wifi %s ip=%s." CR), WiFi.SSID().c_str(),
|
||||||
getIPAddress().c_str());
|
getIPAddress().c_str());
|
||||||
Log.notice(F("WIFI: Using mDNS name %s." CR), myConfig.getMDNS());
|
Log.notice(F("WIFI: Using mDNS name %s." CR), myConfig.getMDNS());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Check what network is the strongest.
|
|
||||||
//
|
|
||||||
int WifiConnection::findStrongestNetwork() {
|
int WifiConnection::findStrongestNetwork() {
|
||||||
if (!myConfig.dualWifiConfigured()) {
|
if (!myConfig.dualWifiConfigured()) {
|
||||||
Log.notice(F("WIFI: Only one wifi SSID is configured, skipping scan." CR));
|
Log.notice(F("WIFI: Only one wifi SSID is configured, skipping scan." CR));
|
||||||
@ -252,9 +232,6 @@ int WifiConnection::findStrongestNetwork() {
|
|||||||
return 1; // Second network is the strongest
|
return 1; // Second network is the strongest
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Connect to last known access point, blocking mode.
|
|
||||||
//
|
|
||||||
bool WifiConnection::connect() {
|
bool WifiConnection::connect() {
|
||||||
/*
|
/*
|
||||||
// Alternative code for connecting to strongest wifi.
|
// Alternative code for connecting to strongest wifi.
|
||||||
@ -300,10 +277,6 @@ bool WifiConnection::connect() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// This will erase the stored credentials and forcing the WIFI manager to AP
|
|
||||||
// mode.
|
|
||||||
//
|
|
||||||
bool WifiConnection::disconnect() {
|
bool WifiConnection::disconnect() {
|
||||||
Log.notice(F("WIFI: Erasing stored WIFI credentials." CR));
|
Log.notice(F("WIFI: Erasing stored WIFI credentials." CR));
|
||||||
// Erase WIFI credentials
|
// Erase WIFI credentials
|
||||||
@ -311,10 +284,6 @@ bool WifiConnection::disconnect() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ACTIVATE_OTA)
|
#if defined(ACTIVATE_OTA)
|
||||||
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
bool WifiConnection::updateFirmware() {
|
bool WifiConnection::updateFirmware() {
|
||||||
if (!_newFirmware) {
|
if (!_newFirmware) {
|
||||||
Log.notice(F("WIFI: No newer version exist, skipping update." CR));
|
Log.notice(F("WIFI: No newer version exist, skipping update." CR));
|
||||||
@ -330,6 +299,12 @@ bool WifiConnection::updateFirmware() {
|
|||||||
String serverPath = myConfig.getOtaURL();
|
String serverPath = myConfig.getOtaURL();
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
serverPath += "firmware.bin";
|
serverPath += "firmware.bin";
|
||||||
|
#elif defined(ESP32C3)
|
||||||
|
serverPath += "firmware32c3.bin";
|
||||||
|
#elif defined(ESP32S2)
|
||||||
|
serverPath += "firmware32s2.bin";
|
||||||
|
#elif defined(ESP32LITE)
|
||||||
|
serverPath += "firmware32lite.bin";
|
||||||
#else // defined (ESP32)
|
#else // defined (ESP32)
|
||||||
serverPath += "firmware32.bin";
|
serverPath += "firmware32.bin";
|
||||||
#endif
|
#endif
|
||||||
@ -359,9 +334,6 @@ bool WifiConnection::updateFirmware() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Download and save file
|
|
||||||
//
|
|
||||||
void WifiConnection::downloadFile(HTTPClient &http, String &fname) {
|
void WifiConnection::downloadFile(HTTPClient &http, String &fname) {
|
||||||
#if LOG_LEVEL == 6 && !defined(WIFI_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(WIFI_DISABLE_LOGGING)
|
||||||
Log.verbose(F("WIFI: Download file %s." CR), fname);
|
Log.verbose(F("WIFI: Download file %s." CR), fname);
|
||||||
@ -378,9 +350,6 @@ void WifiConnection::downloadFile(HTTPClient &http, String &fname) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Check what firmware version is available over OTA
|
|
||||||
//
|
|
||||||
bool WifiConnection::checkFirmwareVersion() {
|
bool WifiConnection::checkFirmwareVersion() {
|
||||||
#if LOG_LEVEL == 6 && !defined(WIFI_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(WIFI_DISABLE_LOGGING)
|
||||||
Log.verbose(F("WIFI: Checking if new version exist." CR));
|
Log.verbose(F("WIFI: Checking if new version exist." CR));
|
||||||
@ -461,6 +430,8 @@ bool WifiConnection::checkFirmwareVersion() {
|
|||||||
}
|
}
|
||||||
http.end();
|
http.end();
|
||||||
|
|
||||||
|
if (_newFirmware) Log.notice(F("WIFI: Found new version." CR));
|
||||||
|
|
||||||
#if LOG_LEVEL == 6
|
#if LOG_LEVEL == 6
|
||||||
Log.verbose(F("WIFI: OTA found new version %s." CR),
|
Log.verbose(F("WIFI: OTA found new version %s." CR),
|
||||||
_newFirmware ? "true" : "false");
|
_newFirmware ? "true" : "false");
|
||||||
@ -469,9 +440,6 @@ bool WifiConnection::checkFirmwareVersion() {
|
|||||||
return _newFirmware;
|
return _newFirmware;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Parse a version string in the format M.m.p (eg. 1.2.10)
|
|
||||||
//
|
|
||||||
bool WifiConnection::parseFirmwareVersionString(int (&num)[3],
|
bool WifiConnection::parseFirmwareVersionString(int (&num)[3],
|
||||||
const char *version) {
|
const char *version) {
|
||||||
#if LOG_LEVEL == 6 && !defined(WIFI_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(WIFI_DISABLE_LOGGING)
|
||||||
|
@ -10,7 +10,7 @@ To reduce the need for adding custom endpoints for various services there is an
|
|||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
|
|
||||||
Since the format templates can be big this function can be quite slow on a small device such as the esp8266.
|
If format templates are large this feature can be slow on a small device such as the esp8266.
|
||||||
|
|
||||||
.. image:: images/format.png
|
.. image:: images/format.png
|
||||||
:width: 800
|
:width: 800
|
||||||
|
@ -84,7 +84,7 @@ GET: /api/status
|
|||||||
Retrieve the current device status via an HTTP GET command. Payload is in JSON format.
|
Retrieve the current device status via an HTTP GET command. Payload is in JSON format.
|
||||||
|
|
||||||
* ``temp-format`` can be either ``C`` or ``F``
|
* ``temp-format`` can be either ``C`` or ``F``
|
||||||
* ``platform`` can be either ``esp8266`` or ``esp32``
|
* ``platform`` can be either ``esp8266``, ``esp32c3``, ``esp32s2``, ``esp32`` or ``esp32lite`` (floaty hardware)
|
||||||
* ``temp-c`` will be set to -273 C if there is no temp sensor
|
* ``temp-c`` will be set to -273 C if there is no temp sensor
|
||||||
* ``angle`` will be set to 0 if no valid angle is found and -1 if there is no gyro
|
* ``angle`` will be set to 0 if no valid angle is found and -1 if there is no gyro
|
||||||
|
|
||||||
|
@ -29,19 +29,36 @@ In the platformio config there are 3 targets defined
|
|||||||
|
|
||||||
* gravity-debug; Maximum logging for trouble shooting, deep sleep is disabled.
|
* gravity-debug; Maximum logging for trouble shooting, deep sleep is disabled.
|
||||||
* gravity-release; Standard release
|
* gravity-release; Standard release
|
||||||
* gravity-perf; Standard release but contains code for measuring performance.
|
* gravity32-release: Version for ESP32 mini.
|
||||||
* gravity32-release: Version for ESP32.
|
* gravity32c3-release: Version for ESP32 C3 mini v2.1+.
|
||||||
* gravity32-perf: Version for ESP32 but contains code for measuring performance.
|
* gravity32c3v1-release: Version for ESP32 C3 mini v1.0.
|
||||||
|
* gravity32s2-release: Version for ESP32 S2 mini.
|
||||||
.. note::
|
* gravity32lite-release: Version for ESP32 lite (Floaty hardware).
|
||||||
There is an experimental ESP32 target but since platformio only supports SDK 1.0.6 and the WIFI connection is really slow compared to ESP8266,
|
|
||||||
so the recommendation is to wait for support on 2.0.x branch. With the tested version an wifi connection takes 3-8s on a ESP32 compared
|
|
||||||
to 0.5s on an ESP8266. There is also a bug in OneWire connected to ESP32 that has not been fixed in the main repository yet.
|
|
||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
The debug target can be unstable and crash the device under certain circumstanses. Excessive logging to the serial port can cause corruption and crashes.
|
The debug target can be unstable and crash the device under certain circumstanses. Excessive logging to the serial port can cause corruption and crashes.
|
||||||
So only enable enough debugging to troubleshoot your changes.
|
So only enable enough debugging to troubleshoot your changes.
|
||||||
|
|
||||||
|
Serial debugging on battery
|
||||||
|
===========================
|
||||||
|
|
||||||
|
.. image:: images/serial.png
|
||||||
|
:width: 600
|
||||||
|
:alt: Serial output
|
||||||
|
|
||||||
|
On the ESP32 builds the serial output can be written to UART0 which is connected to the RX/TX pins on the chip. This way the serial output can be viewed
|
||||||
|
without a connection to the USB port, convinient when running the device on battery power. In order to get this to work you need to compile the sofware
|
||||||
|
with the option **DUSE_SERIAL_PINS** and attach as USB to TTL cable to the correct pins.
|
||||||
|
|
||||||
|
You connect the USB to TTL cable that you connect the TX, RX and GND pins. **Dont connect the power pin** if you are powering the device from USB or Battery.
|
||||||
|
|
||||||
|
.. image:: images/usb-ttl.jpg
|
||||||
|
:width: 300
|
||||||
|
:alt: USB to TTL cable
|
||||||
|
|
||||||
|
.. image:: images/serial_esp32c3.jpg
|
||||||
|
:width: 300
|
||||||
|
:alt: Serial output ESP32c3
|
||||||
|
|
||||||
Source structure
|
Source structure
|
||||||
================
|
================
|
||||||
@ -91,12 +108,15 @@ This is a list of C++ defines that is used to enable/disable functions in the co
|
|||||||
- Done include verbose logging in the corresponding class. Excessive logging may crash device.
|
- Done include verbose logging in the corresponding class. Excessive logging may crash device.
|
||||||
* - USE_LITTLEFS
|
* - USE_LITTLEFS
|
||||||
- Use the new filesystem in Ardurino
|
- Use the new filesystem in Ardurino
|
||||||
* - EMBED_HTML
|
|
||||||
- Html files are included in code, if not defined they are served from the file system.
|
|
||||||
* - USER_SSID
|
* - USER_SSID
|
||||||
- If defined the device will always use this SSID
|
- If defined the device will always use this SSID
|
||||||
* - USER_SSID_PWD
|
* - USER_SSID_PWD
|
||||||
- Password to the SSID
|
- Password to the SSID
|
||||||
* - CFG_APPVER
|
* - CFG_APPVER
|
||||||
- Defines the version of the compiled software
|
- Defines the version of the compiled software
|
||||||
|
* - USE_SERIAL_PINS
|
||||||
|
- Will send the serial console to the TX/RX pins on an ESP32 target so that debugging can be done when on battery
|
||||||
|
* - REDUCE_WIFI_POWER
|
||||||
|
- Will reduce wifi power to support the ESP32C3 v1.0 which has a bad antenna
|
||||||
|
* - FLOATY
|
||||||
|
- Build for the ESP32lite FLOATY hardware option (no DS18B20 and no battery monitor)
|
||||||
|
@ -18,11 +18,11 @@
|
|||||||
# -- Project information -----------------------------------------------------
|
# -- Project information -----------------------------------------------------
|
||||||
|
|
||||||
project = 'GravityMon'
|
project = 'GravityMon'
|
||||||
copyright = '2021-2022, Magnus Persson'
|
copyright = '2021-2023, Magnus Persson'
|
||||||
author = 'Magnus Persson'
|
author = 'Magnus Persson'
|
||||||
|
|
||||||
# The full version, including alpha/beta/rc tags
|
# The full version, including alpha/beta/rc tags
|
||||||
release = '1.1.0'
|
release = '1.2.1'
|
||||||
|
|
||||||
|
|
||||||
# -- General configuration ---------------------------------------------------
|
# -- General configuration ---------------------------------------------------
|
||||||
@ -31,6 +31,7 @@ release = '1.1.0'
|
|||||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||||
# ones.
|
# ones.
|
||||||
extensions = [
|
extensions = [
|
||||||
|
'sphinx_copybutton'
|
||||||
]
|
]
|
||||||
|
|
||||||
# Add any paths that contain templates here, relative to this directory.
|
# Add any paths that contain templates here, relative to this directory.
|
||||||
@ -47,6 +48,8 @@ exclude_patterns = []
|
|||||||
# a list of builtin themes.
|
# a list of builtin themes.
|
||||||
#
|
#
|
||||||
html_theme = 'furo'
|
html_theme = 'furo'
|
||||||
|
html_logo = "images/gravitymon_logo.png"
|
||||||
|
html_title = "GravityMon v1.2.0"
|
||||||
|
|
||||||
# Add any paths that contain custom static files (such as style sheets) here,
|
# Add any paths that contain custom static files (such as style sheets) here,
|
||||||
# relative to this directory. They are copied after the builtin static files,
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
|
@ -10,7 +10,7 @@ One of the following conditions will place the device in ``configuration mode``:
|
|||||||
- Gyro has not been calibrated
|
- Gyro has not been calibrated
|
||||||
- Sleep mode has been disabled in the web interface
|
- Sleep mode has been disabled in the web interface
|
||||||
- Placed in horizontal mode 85-90 degrees
|
- Placed in horizontal mode 85-90 degrees
|
||||||
- Charger connected >4.15V
|
- Charger connected >4.15V (or the value that is configured). This does not work on the Floaty variant due to lack of hardware support.
|
||||||
|
|
||||||
|
|
||||||
Status
|
Status
|
||||||
@ -39,7 +39,7 @@ connection. It will show 0 if data has not been collected yet.
|
|||||||
|
|
||||||
The button `view error log` will show the last error messages on the device. This can be useful for checking errors without
|
The button `view error log` will show the last error messages on the device. This can be useful for checking errors without
|
||||||
the need to connect to the serial port or to check what errors has occurred while in `gravity mode`. From v1.1 it will also detect
|
the need to connect to the serial port or to check what errors has occurred while in `gravity mode`. From v1.1 it will also detect
|
||||||
any abnormal restarts or crashes and record these in the logfile.
|
any abnormal restarts or crashes and record these in the logfile (this applies to esp8266 only).
|
||||||
|
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
@ -165,7 +165,7 @@ Name of organisation in Influx.
|
|||||||
|
|
||||||
* **Influx DB v2 Bucket:**
|
* **Influx DB v2 Bucket:**
|
||||||
|
|
||||||
Identifier for bucket.
|
Token for bucket. Don't use the bucket name.
|
||||||
|
|
||||||
* **Influx DB v2 Token:**
|
* **Influx DB v2 Token:**
|
||||||
|
|
||||||
|
@ -136,6 +136,11 @@ The main features
|
|||||||
fermentation vessel. This sequence takes 900 ms seconds to execute and besides wifi connection this is what consumes the most
|
fermentation vessel. This sequence takes 900 ms seconds to execute and besides wifi connection this is what consumes the most
|
||||||
battery. With more testing this might be changes to either speed up or provide more stable readings.
|
battery. With more testing this might be changes to either speed up or provide more stable readings.
|
||||||
|
|
||||||
|
* **Crash detection and Error Logging**
|
||||||
|
|
||||||
|
There is a build in logging function so that errors that occurs can be detected and logged to a file. On the ESP8266 crashes will also
|
||||||
|
be logged so that these problems can be detected and fixed. Crash logging is not available on the ESP32 variants.
|
||||||
|
|
||||||
* **Performance measurements**
|
* **Performance measurements**
|
||||||
|
|
||||||
I've also create a small library to measure execution code in some areas of the code that i know is time consuming. This
|
I've also create a small library to measure execution code in some areas of the code that i know is time consuming. This
|
||||||
@ -152,20 +157,45 @@ The main features
|
|||||||
|
|
||||||
See the :ref:`compiling-the-software` for more information.
|
See the :ref:`compiling-the-software` for more information.
|
||||||
|
|
||||||
* **Power measurements**
|
|
||||||
|
|
||||||
I've also create a project to measure the power consumption of the device, but more on this later.
|
|
||||||
|
|
||||||
|
|
||||||
Battery life
|
Battery life
|
||||||
------------
|
------------
|
||||||
|
|
||||||
The long term battery test has now been completed. Using a 2200 mA battery and sending data every 5 minutes to a local server on my network. The battery lasted 47 days which is excellent battery life.
|
For the 1.2 version I have been running some long term battery tests on a few of the boards and also comparing wifi vs Bluetooth. I was using a standard 2200 mA battery
|
||||||
|
that was fully charged at the start of the tests. All devices started with factory settings with only a change in push destination and sleep interval.
|
||||||
|
|
||||||
In another test I had a device running with an sleep interval of only 30s with ok wifi connection. The device lasted 12 days which i think is excellent considering the short sleep interval.
|
For the wifi tests, I was pushing data every 30 seconds to a local influxdb2 server to reduce errors connected to slow response on the server side. The devices
|
||||||
|
was placed 2 meters from the wifi AP to ensure a good and stable wifi connection (so ideal conditions).
|
||||||
|
|
||||||
From what I have discovered it's the WIFI connection or latency to internet hosted that has the most impact on the battery life. The typical runtime in the tests above was around 2 seconds.
|
For the Bluetooth tests I was pusing data every 10 seconds to a linux server.
|
||||||
|
|
||||||
|
To make this comparable I measured how many times the device was able to wake up and push data before the battery was dead. I theory the power consumption when in
|
||||||
|
deep sleep is to low it can almost be ignored for the calculations. So the impact on battery is mainly caused by how long the device is awake. In the most optimal case
|
||||||
|
this can be as low as 1.5-2.0 seconds but in reality its probably around 3-4 seconds. Wifi consumes a lot of power so Bluetooth is a better option for long battery life.
|
||||||
|
|
||||||
|
.. list-table:: Battery power
|
||||||
|
:widths: 30 20 20 20
|
||||||
|
:header-rows: 1
|
||||||
|
|
||||||
|
* - Device
|
||||||
|
- Transmissions
|
||||||
|
- 30s
|
||||||
|
- 300s / 15min
|
||||||
|
* - ESP 8266 (wifi)
|
||||||
|
- 26,000
|
||||||
|
- 9 days
|
||||||
|
- 90 days
|
||||||
|
* - ESP32 c3 (wifi)
|
||||||
|
- 12,000
|
||||||
|
- 4 days
|
||||||
|
- 43 days
|
||||||
|
* - ESP32 d1 (ble)
|
||||||
|
- 56,000
|
||||||
|
- 20 days
|
||||||
|
- 196 days
|
||||||
|
|
||||||
|
|
||||||
|
As you can see from the table above there is quite some differences between the boards and connection methods.
|
||||||
|
|
||||||
Performance
|
Performance
|
||||||
-----------
|
-----------
|
||||||
|
@ -3,49 +3,91 @@
|
|||||||
Hardware
|
Hardware
|
||||||
########
|
########
|
||||||
|
|
||||||
There are lots of resources out there on how to build the hardware for an iSpindle so I will not go into details on that part. Here are two of my builds using the iSpindle PCB v4.
|
I'm not a hardware designer so I would recommend the following resources for more in depth information on this topic.
|
||||||
|
|
||||||
.. image:: images/ispindel.jpg
|
* `Cherry Philip Hardware design <https://github.com/cherryphilip74/iSpindel-PCB>`_
|
||||||
|
* `OpenSource Distilling <https://www.opensourcedistilling.com/ispindel>`_
|
||||||
|
|
||||||
|
iSpindle based on esp8266
|
||||||
|
=========================
|
||||||
|
|
||||||
|
There are lots of resouces out there on how to build the hardware for an iSpindle so I will not go into details on that part. I typically use one of the
|
||||||
|
excellent pcb boards that, for example the iSpindel PCB v4.0 from Cherry Philip. Here is one of my standard builds using an esp8266.
|
||||||
|
|
||||||
|
.. image:: images/ispindel_esp8266.jpg
|
||||||
:width: 500
|
:width: 500
|
||||||
:alt: Builds of iSpindel
|
:alt: iSpindle esp8266
|
||||||
|
|
||||||
It's possible to use this PCB and mount an ESP32 on top of that. It must be an pin compatible ESP32 and the one I used was called *ESP32 d1 mini*. Since this is the same width as the PCB you need to
|
|
||||||
mount it really close to the PCB in order for it to fit in the PET tube/container. I also had to smooth the edge of the ESP32 in order for it to fit.
|
|
||||||
|
|
||||||
I would suggest that you try how it fits into the PET tube before soldering it to the PCB. Make sure that the battery is attached since this will be a really tight fit.
|
|
||||||
|
|
||||||
You also need to desolder (remove) the RED ON LED from the ESP32 or the battery power will be reduced a lot.
|
|
||||||
|
|
||||||
Final thing is to add a resistor between A0 (Analog PIN) and ground of 470k. The reason is that the esp8266 has a build in resistor which
|
|
||||||
the esp32 does not have. So in order to get a valid voltage (less than 3.2V) on the A0 pin this is needed. Once the modification is done you might
|
|
||||||
need to adjust the voltage factor so the battery reading is correct.
|
|
||||||
|
|
||||||
.. image:: images/esp32.jpg
|
|
||||||
:width: 500
|
|
||||||
:alt: Mounting esp32
|
|
||||||
|
|
||||||
Schema for esp8266 build
|
Schema for esp8266 build
|
||||||
------------------------
|
++++++++++++++++++++++++
|
||||||
|
|
||||||
.. image:: images/schema_esp8266.png
|
.. image:: images/schema_esp8266.png
|
||||||
:width: 700
|
:width: 700
|
||||||
:alt: Schema esp8266
|
:alt: Schema esp8266
|
||||||
|
|
||||||
Schema for esp32 build
|
iSpindle based on esp32
|
||||||
----------------------
|
=======================
|
||||||
|
|
||||||
|
Gravitymon supports a number of ESP32 boards that offers bluetooth support.
|
||||||
|
|
||||||
|
.. image:: images/esp32_hardware.jpg
|
||||||
|
:width: 500
|
||||||
|
:alt: iSpindle esp32 hardware options
|
||||||
|
|
||||||
|
* esp32d1 mini, this was the first board i tried which is a smaller form factor of the first generetion esp32 with 2 cores. Slow on connecting to wifi is the main downside.
|
||||||
|
* esp32c3 mini, a newer version based on the latest risc v7 architecture, is seen as the replacement for the esp8266 with bluetooth support. Don't buy v1.0 since that has a faulty wifi antenna.
|
||||||
|
* esp32s2 mini, similar to the c3 board but without bluetooth support.
|
||||||
|
|
||||||
|
It's possible to use this PCB and mount an ESP32 mini on top of that (c3 or s2 are prefered). The esp32 d1 mini is a larger formfactor and can be hard to fit into the tube.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
This schema assumes that an ESP32 D1 Mini (pin compatible with ESP8266 D1 Mini is used)
|
You need to add a resistor between A0 (Analog PIN) and ground of 470k. The reason is that the esp8266 has a build in resistor for a voltage divider
|
||||||
The ESP32 has two rows of pins but only the inner row is used. The main difference is the added resistor R3 so we
|
which the esp32 does not have. So in order to get a valid voltage (less than 3.2V) on the A0 pin this is needed. Once the modification is done you might
|
||||||
get a voltage divider for measuring battery. The ESP8266 has a built in resistor thats not visible on the schema.
|
need to adjust the voltage factor so the battery reading is correct.
|
||||||
|
|
||||||
|
ESP32c3 mini
|
||||||
|
++++++++++++
|
||||||
|
|
||||||
|
This is model is fully supported by gravitymon.
|
||||||
|
|
||||||
|
.. image:: images/ispindel_esp32c3.jpg
|
||||||
|
:width: 500
|
||||||
|
:alt: Esp32c3 mini build
|
||||||
|
|
||||||
|
Here is an image of where I added the resistor for the voltage divider.
|
||||||
|
|
||||||
|
.. image:: images/esp32_res.jpg
|
||||||
|
:width: 500
|
||||||
|
:alt: Esp32c3 adding resistor as voltage dividier.
|
||||||
|
|
||||||
|
ESP32s2 mini
|
||||||
|
++++++++++++
|
||||||
|
|
||||||
|
This is model is fully supported by gravitymon. Same setup as for ESP32C3 mini.
|
||||||
|
|
||||||
|
ESP32 d1 mini
|
||||||
|
+++++++++++++
|
||||||
|
|
||||||
|
I would suggest that you try how it fits into the PET tube before soldering it to the PCB. Make sure that the battery is attached since this will be a really tight fit.
|
||||||
|
|
||||||
|
.. image:: images/ispindel_esp32.jpg
|
||||||
|
:width: 500
|
||||||
|
:alt: Esp32 mini build
|
||||||
|
|
||||||
|
Schema for esp32 build
|
||||||
|
++++++++++++++++++++++
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
This schema assumes that an ESP32 d1 mini (pin compatible with ESP8266). The ESP32 has two rows of pins but
|
||||||
|
only the inner row is used. The main difference is the added resistor R3 so we get a voltage divider for measuring battery.
|
||||||
|
The ESP8266 has a built in resistor thats not visible on the schema and this acts as a voltage divider.
|
||||||
|
|
||||||
.. image:: images/schema_esp32.png
|
.. image:: images/schema_esp32.png
|
||||||
:width: 700
|
:width: 700
|
||||||
:alt: Schema esp32
|
:alt: Schema esp32
|
||||||
|
|
||||||
Modifying with reed switch
|
Adding a reed (magnetic) reset switch
|
||||||
--------------------------
|
+++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
A reed switch is a switch that reacts to magnetic fields. The ones I have tested are normally open and close in proximity to
|
A reed switch is a switch that reacts to magnetic fields. The ones I have tested are normally open and close in proximity to
|
||||||
a magnet.
|
a magnet.
|
||||||
@ -64,3 +106,35 @@ The reed switch is the glass tube visible under the esp8266.
|
|||||||
:alt: Reed build
|
:alt: Reed build
|
||||||
|
|
||||||
|
|
||||||
|
Floaty Hydrometer DIY based on esp32 lite
|
||||||
|
=========================================
|
||||||
|
|
||||||
|
Here we have another projects that has build a device similar to the iSpindel but based on an ESP32 instead.
|
||||||
|
|
||||||
|
The setup is much simpler and attaches the GYRO to an ESP32 with a build in charger chip. GravityMon works on
|
||||||
|
this hardware platform as well but there are a few limitations:
|
||||||
|
|
||||||
|
* Temperature is read from the GYRO and cannot be changed. This works fine when measuring gravity but when in configuration mode the temperature will increase since it shows the chip temperature.
|
||||||
|
* No possibility to measure battery level (can be added with additional hardware).
|
||||||
|
|
||||||
|
|
||||||
|
Hardware extensions
|
||||||
|
===================
|
||||||
|
|
||||||
|
GravityMon has implemented a few additions to the standard iSpindel hardware. It's possible to channel the serial console to the TX/RX pins on the chip (these position also applies to all the
|
||||||
|
ESP32 chips for iSpindel). You need a USB to TTL converter for this to work. This enables you to read the serial console even when on battery (newer chips dont have a diode to remove).
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
You need to compile the software using the -DUSE_SERIAL_PINS option to enable this feature.
|
||||||
|
|
||||||
|
Its also possible to force the device into configuration mode by connecting D7/D8 on the board during the startup sequence. This will enable the feature "gravity mode enabled during float".
|
||||||
|
|
||||||
|
.. image:: images/8266_pins.jpg
|
||||||
|
:width: 500
|
||||||
|
:alt: iSpindel pins
|
||||||
|
|
||||||
|
For the floaty device pins 16/17 are used as TX/RX pins and the 13/15 pins are used to force the device into configuration mode. Pin 35 can also be connected to the battery voltage via an voltage divider to be able to read the battery voltage.
|
||||||
|
|
||||||
|
.. image:: images/32lite_pins.jpg
|
||||||
|
:width: 500
|
||||||
|
:alt: Floaty pins
|
||||||
|
BIN
src_docs/source/images/32lite_pins.jpg
Normal file
After Width: | Height: | Size: 416 KiB |
BIN
src_docs/source/images/8266_pins.jpg
Normal file
After Width: | Height: | Size: 324 KiB |
BIN
src_docs/source/images/buymecoffee.png
Normal file
After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 931 KiB After Width: | Height: | Size: 888 KiB |
BIN
src_docs/source/images/esp32_hardware.jpg
Normal file
After Width: | Height: | Size: 705 KiB |
BIN
src_docs/source/images/esp32_mini.jpg
Normal file
After Width: | Height: | Size: 528 KiB |
BIN
src_docs/source/images/esp32_res.jpg
Normal file
After Width: | Height: | Size: 594 KiB |
BIN
src_docs/source/images/esp32c3_mini.jpg
Normal file
After Width: | Height: | Size: 661 KiB |
BIN
src_docs/source/images/esp32s2_mini.jpg
Normal file
After Width: | Height: | Size: 596 KiB |
BIN
src_docs/source/images/esp8266.jpg
Normal file
After Width: | Height: | Size: 609 KiB |
BIN
src_docs/source/images/gravitymon_logo.png
Normal file
After Width: | Height: | Size: 171 KiB |
BIN
src_docs/source/images/gravitymon_logo_s.png
Normal file
After Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 2.5 MiB |
BIN
src_docs/source/images/ispindel_esp32.jpg
Normal file
After Width: | Height: | Size: 341 KiB |
BIN
src_docs/source/images/ispindel_esp32c3.jpg
Normal file
After Width: | Height: | Size: 366 KiB |
BIN
src_docs/source/images/ispindel_esp8266.jpg
Normal file
After Width: | Height: | Size: 422 KiB |
BIN
src_docs/source/images/ispindel_pcb4.jpg
Normal file
After Width: | Height: | Size: 386 KiB |
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 127 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 127 KiB |
BIN
src_docs/source/images/serial_esp32c3.jpg
Normal file
After Width: | Height: | Size: 624 KiB |
BIN
src_docs/source/images/usb-ttl.jpg
Normal file
After Width: | Height: | Size: 67 KiB |
@ -3,56 +3,18 @@
|
|||||||
You can adapt this file completely to your liking, but it should at least
|
You can adapt this file completely to your liking, but it should at least
|
||||||
contain the root `toctree` directive.
|
contain the root `toctree` directive.
|
||||||
|
|
||||||
Welcome to GravityMon's documentation!
|
Welcome to GravityMon
|
||||||
######################################
|
#####################
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
This documentation reflects **v1.1**. Last updated 2022-08-14
|
This documentation reflects **v1.2.1**. Last updated 2023-02-03
|
||||||
|
|
||||||
User interface overview
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
This animation shows how the user interface is structured, it reflects an older version but the structure is the same.
|
|
||||||
|
|
||||||
.. image:: images/gravitymon.gif
|
|
||||||
:width: 800
|
|
||||||
:alt: User Inteface Walkthrough
|
|
||||||
|
|
||||||
.. _main_features:
|
|
||||||
|
|
||||||
Main features
|
|
||||||
-------------
|
|
||||||
|
|
||||||
* Operates in two modes gravity monitoring and configuration mode
|
|
||||||
* Gravity mode is comparable to how the iSpindle works when collecting data
|
|
||||||
* Configuration mode has a modern HTML5 based web UI. No need to start the access point to change settings
|
|
||||||
* Offloading some of the functionality to run in the web browser, this allows for more advanced features.
|
|
||||||
* REST API to enable scripted configuration
|
|
||||||
* Send data to multiple endpoints and services at once (2xHTTP POST, HTTP GET, MQTT, INFLUXDB2)
|
|
||||||
* Directly test all endpoints from user interface with feedback to simplify troubleshooting
|
|
||||||
* Complete format customization for all endpoints using templates (don't really need to change the software to support new services)
|
|
||||||
* Setup guides for how to send data to many popular services. Currently 10+ are documented
|
|
||||||
* Automatic temperature adjustment of gravity (just tick a checkbox)
|
|
||||||
* OTA support from webserver
|
|
||||||
* Firmware update via web interface
|
|
||||||
* Built in function to create gravity formulas, no need for additional software, just enter tilt/gravity and let GravityMon creates a formula
|
|
||||||
* Visual graph showing how formula will be interpreted based on entered values
|
|
||||||
* Using the temperature sensor in gyro instead of DS18B20 (faster)
|
|
||||||
* SSL support in all endpoints (no certificate validation due to limitations on esp8266).
|
|
||||||
* Built in performance measurements (used to optimize code)
|
|
||||||
* Storage mode when placed on cap (indefinite sleep)
|
|
||||||
* Customize various hardware parameters to optimize device functionality.
|
|
||||||
|
|
||||||
For a complete breakdown see the :ref:`functionality`
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
If you are missing some feature, please reach out on `Github <https://github.com/mp-se/gravitymon/discussions>`_ or `homebrewtalk.com <https://www.homebrewtalk.com/threads/replacement-firmware-for-ispindel-gravitymon.698058/>`_
|
|
||||||
|
|
||||||
What is GravityMon?
|
What is GravityMon?
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
GravityMon is used to measure gravity and temperature during fermentation of beer and report the progress. The graph below is
|
GravityMon is a electronic hydrometer software that can be used to measure gravity and temperature during fermentation of beer and report the progress to a number of external
|
||||||
an example on how the fermentation process can be tracked. The graph has been rendered using Fermentrack.
|
services. Is uses a gyro to measure the gravity since there is a correlation between gravity an the density of the fluid. Based on the density the hydrometer will float at a different angle.
|
||||||
|
The graph below is an example on how the fermentation process can be tracked. The graph has been rendered using Fermentrack.
|
||||||
|
|
||||||
.. image:: images/fermentation.png
|
.. image:: images/fermentation.png
|
||||||
:width: 500
|
:width: 500
|
||||||
@ -60,10 +22,11 @@ an example on how the fermentation process can be tracked. The graph has been re
|
|||||||
|
|
||||||
GravityMon is a replacement firmware for the iSpindle and uses the same hardware configuration and is 100% compatible. It
|
GravityMon is a replacement firmware for the iSpindle and uses the same hardware configuration and is 100% compatible. It
|
||||||
implements a lot of the features that has been requested in the original iSpindle project but never implemented for
|
implements a lot of the features that has been requested in the original iSpindle project but never implemented for
|
||||||
various reasons. Here is a list of :ref:`main_features`.
|
various reasons.
|
||||||
|
|
||||||
From v0.9 the firmware also supports a iSpindle built using an ESP32 d1 mini (pin compatible with esp8266). Currently this is an experimental
|
The firmware also supports a iSpindle built using an ESP32 which is pin compatible with esp8266, currently there are 3 options that are
|
||||||
version but since it has more memory and processing capacity it could support more functions. See :ref:`hardware`.
|
supported ESP32-D1 mini, ESP32-C3 mini, ESP32-S2 mini, ESP32 lite (floaty). See :ref:`hardware`. The more modern hardware will allow better support for SSL and
|
||||||
|
other memory intensive functions.
|
||||||
|
|
||||||
I started GravityMon because I like to create software and wanted to do some microcontroller programming. I had done a few
|
I started GravityMon because I like to create software and wanted to do some microcontroller programming. I had done a few
|
||||||
projects based on esp8266 and also started to brew beer so this combination was quite natural.
|
projects based on esp8266 and also started to brew beer so this combination was quite natural.
|
||||||
@ -76,18 +39,19 @@ My approach to this software is a little different from that the original iSpind
|
|||||||
The github repository can be found here; `GravityMon on Github <https://github.com/mp-se/gravitymon>`_
|
The github repository can be found here; `GravityMon on Github <https://github.com/mp-se/gravitymon>`_
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
I don't take responsibility for any errors or issues caused by the software. The software is provided as-is. I will however
|
I don't take responsibility for any errors or issues caused by the software or hardware.
|
||||||
try my best to fix issues that might occur.
|
The software is provided as-is. I will however try my best to fix issues that might occur.
|
||||||
|
|
||||||
I have tested this software on 40+ brews with good results.
|
I have tested this software on 40+ brews with good results.
|
||||||
|
|
||||||
|
User interface overview
|
||||||
|
-----------------------
|
||||||
|
|
||||||
Documentation for older versions
|
This animation shows how the features of the user interface. It's for an older version but the main features are the same.
|
||||||
--------------------------------
|
|
||||||
|
|
||||||
* Docs for: `v1.0 <https://mp-se.github.io/gravitymon/v1.0/index.html>`_
|
|
||||||
* Docs for: `v0.9 <https://mp-se.github.io/gravitymon/v0.9/index.html>`_
|
|
||||||
|
|
||||||
|
.. image:: images/gravitymon.gif
|
||||||
|
:width: 800
|
||||||
|
:alt: User Inteface Walkthrough
|
||||||
|
|
||||||
Software architecture
|
Software architecture
|
||||||
---------------------
|
---------------------
|
||||||
@ -173,13 +137,12 @@ the following libraries and without these this would have been much more difficu
|
|||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
:caption: Contents:
|
:caption: Contents:
|
||||||
|
|
||||||
intro
|
|
||||||
releases
|
|
||||||
functionality
|
functionality
|
||||||
|
intro
|
||||||
installation
|
installation
|
||||||
configuration
|
configuration
|
||||||
troubleshooting
|
releases
|
||||||
q_and_a
|
hardware
|
||||||
formula
|
formula
|
||||||
services
|
services
|
||||||
advanced
|
advanced
|
||||||
@ -187,8 +150,9 @@ the following libraries and without these this would have been much more difficu
|
|||||||
data
|
data
|
||||||
compiling
|
compiling
|
||||||
contributing
|
contributing
|
||||||
hardware
|
|
||||||
license
|
license
|
||||||
|
troubleshooting
|
||||||
|
q_and_a
|
||||||
|
|
||||||
Indices and tables
|
Indices and tables
|
||||||
==================
|
==================
|
||||||
|
@ -3,11 +3,13 @@
|
|||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
|
|
||||||
You have these 3 options for flashing this firmware.
|
You have these 5 options for flashing this firmware.
|
||||||
|
|
||||||
* Brewflasher via USB serial
|
* Brewflasher via USB serial
|
||||||
|
* Brewflasher WEB via USB serial
|
||||||
* Esptool via USB serial
|
* Esptool via USB serial
|
||||||
* iSpindel web interface
|
* iSpindel web interface (only ESP8266)
|
||||||
|
* Build from source and flash via VSCode + Platformio
|
||||||
|
|
||||||
Brewflasher
|
Brewflasher
|
||||||
===========
|
===========
|
||||||
@ -16,6 +18,13 @@ The preferred option for flashing GravityMon is using BrewFlasher, its a tools t
|
|||||||
on both Windows and Mac. You can download the latest version from here: `Brewflasher <https://www.brewflasher.com/>`_ there is also a web based version
|
on both Windows and Mac. You can download the latest version from here: `Brewflasher <https://www.brewflasher.com/>`_ there is also a web based version
|
||||||
available here `Brewflasher WEB <https://web.brewflasher.com/>`_.
|
available here `Brewflasher WEB <https://web.brewflasher.com/>`_.
|
||||||
|
|
||||||
|
In order to flash an C3 board you will need Brewflasher 1.5 or newer.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
The S2 and C3 chips might need to be put in flash mode before flashing can be done. Hold the button on the opposite side from the RST button,
|
||||||
|
press the RST button and release it before the first button you pressed. This should force the chip into download mode. If you connect a serial
|
||||||
|
terminal it should say "waiting for download".
|
||||||
|
|
||||||
.. image:: images/brewflasher.png
|
.. image:: images/brewflasher.png
|
||||||
:width: 600
|
:width: 600
|
||||||
:alt: Serial output
|
:alt: Serial output
|
||||||
@ -23,46 +32,53 @@ available here `Brewflasher WEB <https://web.brewflasher.com/>`_.
|
|||||||
Binaries
|
Binaries
|
||||||
********
|
********
|
||||||
|
|
||||||
In the /bin directory you will find 3 different firmware builds;
|
In the /bin directory you will find 4 different firmware builds;
|
||||||
|
|
||||||
* **firmware.bin**
|
* **firmware.bin**
|
||||||
|
|
||||||
This is the standard release build (preferred version)
|
This is the standard release build (preferred version)
|
||||||
|
|
||||||
* **firmware-perf.bin**
|
|
||||||
|
|
||||||
This version also submits performance data to an influx database with detailed execution times.
|
|
||||||
|
|
||||||
* **firmware32.bin**
|
* **firmware32.bin**
|
||||||
|
|
||||||
This is the standard release build for an ESP32 variant. When flashing an ESP32 you also need the **partition32.bin** file that outlines the flash memory structure. Due to
|
This is the release build for an ESP32-d1-mini variant. When flashing an ESP32 you also need the *partition32.bin* file that outlines the flash memory structure. Due to
|
||||||
the size of the firmware we are using a custom partition setup.
|
the size of the firmware we are using a custom partition setup.
|
||||||
|
|
||||||
In these versions all the html files are embedded in the binaries. The file system is currently only used for storing
|
* **firmware32c3.bin**
|
||||||
the configuration file.
|
|
||||||
|
|
||||||
If the software becomes so large the html files can be moved to the file system, but this is not enabled by
|
This is the release build for an ESP32c3-mini variant v2.1 or newer. When flashing an ESP32 you also need the *partition32c3.bin* file that outlines the flash memory structure. Due to
|
||||||
default (see compiling for details). This approach makes installation much easier and ensure that html files
|
the size of the firmware we are using a custom partition setup. If you have a v1.0 board use the firmware32c3v1.bin instead.
|
||||||
and code is in sync.
|
|
||||||
|
|
||||||
Esptool
|
* **firmware32s2.bin**
|
||||||
=======
|
|
||||||
|
This is the release build for an ESP32s2-mini variant. When flashing an ESP32 you also need the *partition32s2.bin* file that outlines the flash memory structure. Due to
|
||||||
|
the size of the firmware we are using a custom partition setup.
|
||||||
|
|
||||||
|
* **firmware32lite.bin**
|
||||||
|
|
||||||
|
This is the release build for an ESP32lite which is used by the floaty build (clone).
|
||||||
|
|
||||||
|
Esptool (esp8266)
|
||||||
|
=================
|
||||||
|
|
||||||
The other option for flashing esp8266 device is via the official esptool. Documentation can be found
|
The other option for flashing esp8266 device is via the official esptool. Documentation can be found
|
||||||
here; `esptool home page <https://docs.espressif.com/projects/esptool/en/latest/esp32/>`_
|
here; `esptool home page <https://docs.espressif.com/projects/esptool/en/latest/esp32/>`_
|
||||||
|
|
||||||
Windows 10 should install a driver for the USB -> Serial automatically when you connect a esp8266.
|
Windows 10 should install a driver for the USB -> Serial automatically when you connect a esp8266.
|
||||||
|
|
||||||
The basic command for flashing on Windows is;
|
The basic command for flashing an ESP8266 on Windows is;
|
||||||
|
|
||||||
``esptool.py --port COM4 write_flash 0x0 firmware.bin``
|
``esptool.py --port COM4 write_flash 0x0 firmware.bin``
|
||||||
|
|
||||||
|
The basic command for flashing an ESP32C3 on Windows is;
|
||||||
|
|
||||||
|
``esptool.py --port COM6 write_flash --flash_mode dio 0x8000 .\partitions32c3.bin 0x10000 .\firmware32c3.bin``
|
||||||
|
|
||||||
If there are issues you can try do erase the flash first using this command;
|
If there are issues you can try do erase the flash first using this command;
|
||||||
|
|
||||||
``esptool.py --port COM4 erase_flash``
|
``esptool.py --port COM4 erase_flash``
|
||||||
|
|
||||||
iSpindel
|
iSpindel (esp8266)
|
||||||
========
|
==================
|
||||||
|
|
||||||
If you already have the device flashed with iSpindel firmware you can go into the configuration mode where you will find
|
If you already have the device flashed with iSpindel firmware you can go into the configuration mode where you will find
|
||||||
an option for updating firmware. The option is under the maintenance menu.
|
an option for updating firmware. The option is under the maintenance menu.
|
||||||
@ -81,7 +97,7 @@ OTA Option
|
|||||||
You can use the OTA option by adding this URL to your configuration and when the device starts up in configuration mode it
|
You can use the OTA option by adding this URL to your configuration and when the device starts up in configuration mode it
|
||||||
will check for a new version and if it finds a newer version it will do an update.
|
will check for a new version and if it finds a newer version it will do an update.
|
||||||
|
|
||||||
``https://mp-se.github.io/gravitymon/release/``
|
``https://gravitymon.com/firmware/``
|
||||||
|
|
||||||
Manual update
|
Manual update
|
||||||
*************
|
*************
|
||||||
@ -100,11 +116,6 @@ Serial Monitoring
|
|||||||
To check output from the device (logs) there are several tools out there. I found this simple tool in the Windows Store called ``Serial Port Monitoring``.
|
To check output from the device (logs) there are several tools out there. I found this simple tool in the Windows Store called ``Serial Port Monitoring``.
|
||||||
Just select a baud rate of 115200, 8N1.
|
Just select a baud rate of 115200, 8N1.
|
||||||
|
|
||||||
.. image:: images/serial.png
|
|
||||||
:width: 800
|
|
||||||
:alt: Serial output
|
|
||||||
|
|
||||||
|
|
||||||
.. _setup_wifi:
|
.. _setup_wifi:
|
||||||
|
|
||||||
Configuring WIFI
|
Configuring WIFI
|
||||||
@ -130,7 +141,7 @@ successful then it will be used as primary. *The second wifi setting is optional
|
|||||||
|
|
||||||
|
|
||||||
.. image:: images/wifi.png
|
.. image:: images/wifi.png
|
||||||
:width: 200
|
:width: 300
|
||||||
:alt: Wifi page
|
:alt: Wifi page
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,22 @@
|
|||||||
Q & A
|
Q & A
|
||||||
#####
|
#####
|
||||||
|
|
||||||
|
User interface does not render correctly
|
||||||
|
----------------------------------------
|
||||||
|
|
||||||
|
Since the user interface is built using bootstrap v5 the device requires access to the internet
|
||||||
|
to download required javascript and css files. Due to size it would not be possible to store these
|
||||||
|
on the device. Make sure the device can access: https://cdn.jsdelivr.net/npm/bootstrap
|
||||||
|
|
||||||
|
Data is not populated in the fields
|
||||||
|
------------------------------------
|
||||||
|
|
||||||
|
The user interface uses JQuery to fetch data from the device. This javascript library needs to be downloaded
|
||||||
|
from the internet. Due to size it would not be possible to store these on the device. Make sure the
|
||||||
|
device can access: https://code.jquery.com
|
||||||
|
|
||||||
|
Also ensure that any security tools does not block the execution of these features.
|
||||||
|
|
||||||
My device is no going in to sleep after fully charged
|
My device is no going in to sleep after fully charged
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
- Calibrate the device in the web interface
|
- Calibrate the device in the web interface
|
||||||
@ -11,7 +27,7 @@ My device is no going in to sleep after fully charged
|
|||||||
My device reports a temperature of -273C or -491F
|
My device reports a temperature of -273C or -491F
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
- The DS18B20 temperature sensor cannot be found and this is the default value reported in this case.
|
- The DS18B20 temperature sensor cannot be found and this is the default value reported in this case.
|
||||||
- Check the orientation of the sensor and soldering.
|
- Check the orientation of the sensor and the soldering.
|
||||||
|
|
||||||
Calibration error (unable to find a valid formula)
|
Calibration error (unable to find a valid formula)
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
@ -30,18 +46,26 @@ To fix these this you can;
|
|||||||
|
|
||||||
In the case above this parameter was changed from 1.6 SG to 4 SG and the formula was accepted. The deviation on this point was just above 3 SG.
|
In the case above this parameter was changed from 1.6 SG to 4 SG and the formula was accepted. The deviation on this point was just above 3 SG.
|
||||||
|
|
||||||
User interface does not render correctly
|
How can I filter data on influxdb without needing to know the time range
|
||||||
----------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
Since the user interface is built using bootstrap v5 the device requires access to the internet
|
You can use any of the available fields to enter your custom data. An option is to use the token fields to
|
||||||
to download required javascript and css files. Due to size it would not be possible to store these
|
add some custom information to identify your brew. This can then be used to filter your data in influxdb.
|
||||||
on the device. Make sure the device can access: https://cdn.jsdelivr.net/npm/bootstrap
|
|
||||||
|
|
||||||
Data is not populated in the fields
|
When you switch brews you need to go in and change the token to identify the brewing session.
|
||||||
------------------------------------
|
|
||||||
|
|
||||||
The user interface uses JQuery to fetch data from the device. This javascript library needs to be downloaded
|
Change the format template for the influx target to include the token field. Now you will have an
|
||||||
from the internet. Due to size it would not be possible to store these on the device. Make sure the
|
field called event that you can filter on in influx.
|
||||||
device can access: https://code.jquery.com
|
|
||||||
|
.. code-block::
|
||||||
|
|
||||||
|
gravity-format=${gravity-unit} gravity=${gravity},corr-gravity=${corr-gravity},
|
||||||
|
angle=${angle},temp=${temp},battery=${battery},rssi=${rssi}
|
||||||
|
|
||||||
|
to
|
||||||
|
|
||||||
|
.. code-block::
|
||||||
|
|
||||||
|
gravity-format=${gravity-unit} gravity=${gravity},corr-gravity=${corr-gravity},
|
||||||
|
angle=${angle},temp=${temp},battery=${battery},rssi=${rssi},event=${token}
|
||||||
|
|
||||||
Also ensure that any security tools does not block the execution of these features.
|
|
||||||
|
@ -3,6 +3,47 @@
|
|||||||
Releases
|
Releases
|
||||||
########
|
########
|
||||||
|
|
||||||
|
v1.2.1
|
||||||
|
======
|
||||||
|
|
||||||
|
Issues adressed
|
||||||
|
++++++++++++++++
|
||||||
|
* BUG: Under some circumstances the last part of the format template was omitted.
|
||||||
|
|
||||||
|
Other
|
||||||
|
+++++
|
||||||
|
* Update tinyexpr library to latest baseline. For forumula evaluation.
|
||||||
|
|
||||||
|
Documentation
|
||||||
|
+++++++++++++
|
||||||
|
* Minor updates and corrections to the documetation.
|
||||||
|
* Updated Q&A section
|
||||||
|
|
||||||
|
v1.2.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Features
|
||||||
|
++++++++
|
||||||
|
* Added function to calcualate voltage factor based on measured value.
|
||||||
|
* Updated battery estimation for the various esp32 boards.
|
||||||
|
* Added support for the ESP32 lite board which is used in the Floaty Hydrometer variant.
|
||||||
|
* Added support for the ESP32 C3 mini board
|
||||||
|
* Added support for the ESP32 S2 mini board
|
||||||
|
* Serial output is written to TX/RX pins instead of the USB connection for the ESP32c3. This way the serial console can be viewed when running on battery power.
|
||||||
|
* Merged in unit tests and api tests into this project
|
||||||
|
* Added option to download firmware updates from https://www.gravitymon.com
|
||||||
|
|
||||||
|
Documentation
|
||||||
|
+++++++++++++
|
||||||
|
* Added section about the Floaty hardware
|
||||||
|
* Fixed schema errors in hardware section and linked PCB options
|
||||||
|
* Updated hardware section with options for ESP32 boards
|
||||||
|
* Updated installation instructions.
|
||||||
|
|
||||||
|
Issues adressed
|
||||||
|
++++++++++++++++
|
||||||
|
* BUG: The first portion of a format template was lost when doing conversion.
|
||||||
|
|
||||||
v1.1.1
|
v1.1.1
|
||||||
======
|
======
|
||||||
* BUG: The text before the first variable was missed in the conversion of a format template.
|
* BUG: The text before the first variable was missed in the conversion of a format template.
|
||||||
|
643
test/apitests.py
Normal file
@ -0,0 +1,643 @@
|
|||||||
|
import unittest, requests, json, time
|
||||||
|
|
||||||
|
ver = "1.2.0"
|
||||||
|
|
||||||
|
#host = "192.168.1.195"
|
||||||
|
#id = "6ac6f6"
|
||||||
|
|
||||||
|
host = "192.168.1.106"
|
||||||
|
id = "3045f4"
|
||||||
|
|
||||||
|
# python3 -m unittest -v apitests.API.test_bug_79
|
||||||
|
# python3 -m unittest -v apitests
|
||||||
|
|
||||||
|
def call_api_post( path, json ):
|
||||||
|
url = "http://" + host + path
|
||||||
|
return requests.post( url, data=json )
|
||||||
|
|
||||||
|
def call_api_get( path ):
|
||||||
|
url = "http://" + host + path
|
||||||
|
return requests.get( url )
|
||||||
|
|
||||||
|
class API(unittest.TestCase):
|
||||||
|
|
||||||
|
# Do factory reset for testing
|
||||||
|
def test_factory(self):
|
||||||
|
r = call_api_get( "/api/status" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["id"], id)
|
||||||
|
r = call_api_get( "/api/factory?id=" + j["id"])
|
||||||
|
time.sleep(4)
|
||||||
|
|
||||||
|
# Check that all parameters exist
|
||||||
|
def test_status(self):
|
||||||
|
r = call_api_get( "/api/status" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["id"], id)
|
||||||
|
self.assertEqual(j["wifi-ssid"], "@home")
|
||||||
|
self.assertNotEqual(j["angle"], 0)
|
||||||
|
self.assertNotEqual(j["gravity"], 2)
|
||||||
|
self.assertNotEqual(j["temp-c"], 0)
|
||||||
|
self.assertNotEqual(j["temp-f"], 0)
|
||||||
|
self.assertNotEqual(j["battery"], 0)
|
||||||
|
self.assertNotEqual(j["temp-format"], "")
|
||||||
|
self.assertNotEqual(j["gravity-format"], "")
|
||||||
|
self.assertNotEqual(j["sleep-mode"], True)
|
||||||
|
self.assertNotEqual(j["rssi"], 0)
|
||||||
|
self.assertNotEqual(j["app-ver"], "0.0.0")
|
||||||
|
self.assertNotEqual(j["app-build"], "test")
|
||||||
|
self.assertNotEqual(j["mdns"], "")
|
||||||
|
self.assertNotEqual(j["platform"], "")
|
||||||
|
self.assertNotEqual(j["runtime-average"], -1)
|
||||||
|
|
||||||
|
# Check that all parameters exist
|
||||||
|
def test_config_1(self):
|
||||||
|
j = { "id": id, "http-push": "https://push.me", "token": "mytoken", "token2": "mytoken2", "http-push2": "http://push.me", "http-push3": "http://push.me", "influxdb2-push": "http://influx.db", "influxdb2-org": "my-org",
|
||||||
|
"influxdb2-bucket": "my-bucket", "influxdb2-auth": "my-secret", "mqtt-push": "mqtt.com", "mqtt-port": 1883, "mqtt-user": "my-user",
|
||||||
|
"mqtt-pass": "my-pass", "http-push-h1": "header1", "http-push-h2": "header2", "http-push2-h1": "header1(2)", "http-push2-h2": "header2(2)" }
|
||||||
|
r = call_api_post( "/api/config/push", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
r = call_api_get( "/api/config" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["http-push-h1"], "header1")
|
||||||
|
self.assertEqual(j["http-push-h2"], "header2")
|
||||||
|
self.assertEqual(j["http-push2-h1"], "header1(2)")
|
||||||
|
self.assertEqual(j["http-push2-h2"], "header2(2)")
|
||||||
|
|
||||||
|
# Check that all parameters exist
|
||||||
|
def test_config_2(self):
|
||||||
|
j = { "id": id, "mdns": "gravmon", "temp-format": "C", "sleep-interval": 300 }
|
||||||
|
r = call_api_post( "/api/config/device", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
def test_config_3(self):
|
||||||
|
j = { "id": id, "http-push": "https://push.me", "token": "mytoken", "token2": "mytoken2", "http-push2": "http://push.me", "http-push3": "http://push.me", "influxdb2-push": "http://influx.db", "influxdb2-org": "my-org",
|
||||||
|
"influxdb2-bucket": "my-bucket", "influxdb2-auth": "my-secret", "mqtt-push": "mqtt.com", "mqtt-port": 1883, "mqtt-user": "my-user",
|
||||||
|
"mqtt-pass": "my-pass" }
|
||||||
|
r = call_api_post( "/api/config/push", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
def test_config_4(self):
|
||||||
|
j = { "id": id, "ota-url": "http://ota.url/path", "voltage-factor": 1.55, "temp-adjustment-value": -2, "gyro-temp": "on", "ble": "color" }
|
||||||
|
r = call_api_post( "/api/config/hardware", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
r = call_api_get( "/api/config" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["id"], id)
|
||||||
|
self.assertEqual(j["ble"], "color")
|
||||||
|
self.assertEqual(j["ota-url"], "http://ota.url/path")
|
||||||
|
self.assertEqual(j["voltage-factor"], 1.55)
|
||||||
|
self.assertEqual(j["temp-adjustment-value"], -2)
|
||||||
|
self.assertEqual(j["gyro-temp"], True)
|
||||||
|
# These are read only here, just checking them.
|
||||||
|
self.assertNotEqual(j["gyro-calibration-data"]["ax"], 0.0001)
|
||||||
|
self.assertNotEqual(j["gyro-calibration-data"]["ay"], 0.0001)
|
||||||
|
self.assertNotEqual(j["gyro-calibration-data"]["az"], 0.0001)
|
||||||
|
self.assertNotEqual(j["gyro-calibration-data"]["gx"], 0.0001)
|
||||||
|
self.assertNotEqual(j["gyro-calibration-data"]["gy"], 0.0001)
|
||||||
|
self.assertNotEqual(j["gyro-calibration-data"]["gz"], 0.0001)
|
||||||
|
self.assertNotEqual(j["formula-calculation-data"]["a1"], 0.0001)
|
||||||
|
self.assertNotEqual(j["formula-calculation-data"]["a2"], 0.0001)
|
||||||
|
self.assertNotEqual(j["formula-calculation-data"]["a3"], 0.0001)
|
||||||
|
self.assertNotEqual(j["formula-calculation-data"]["a4"], 0.0001)
|
||||||
|
self.assertNotEqual(j["formula-calculation-data"]["a5"], 0.0001)
|
||||||
|
self.assertNotEqual(j["formula-calculation-data"]["a6"], 0.0001)
|
||||||
|
self.assertNotEqual(j["formula-calculation-data"]["a7"], 0.0001)
|
||||||
|
self.assertNotEqual(j["formula-calculation-data"]["a8"], 0.0001)
|
||||||
|
self.assertNotEqual(j["formula-calculation-data"]["a9"], 0.0001)
|
||||||
|
self.assertNotEqual(j["formula-calculation-data"]["a10"], 0.0001)
|
||||||
|
self.assertNotEqual(j["formula-calculation-data"]["g1"], 0.0001)
|
||||||
|
self.assertNotEqual(j["formula-calculation-data"]["g2"], 0.0001)
|
||||||
|
self.assertNotEqual(j["formula-calculation-data"]["g3"], 0.0001)
|
||||||
|
self.assertNotEqual(j["formula-calculation-data"]["g4"], 0.0001)
|
||||||
|
self.assertNotEqual(j["formula-calculation-data"]["g5"], 0.0001)
|
||||||
|
self.assertNotEqual(j["formula-calculation-data"]["g6"], 0.0001)
|
||||||
|
self.assertNotEqual(j["formula-calculation-data"]["g7"], 0.0001)
|
||||||
|
self.assertNotEqual(j["formula-calculation-data"]["g8"], 0.0001)
|
||||||
|
self.assertNotEqual(j["formula-calculation-data"]["g9"], 0.0001)
|
||||||
|
self.assertNotEqual(j["formula-calculation-data"]["g10"], 0.0001)
|
||||||
|
self.assertNotEqual(j["angle"], 0)
|
||||||
|
self.assertNotEqual(j["gravity"], -10)
|
||||||
|
self.assertNotEqual(j["battery"], 0)
|
||||||
|
|
||||||
|
def test_config_5(self):
|
||||||
|
j = { "id": id, "gravity-formula": "my-formula", "gravity-temp-adjustment": "on", "gravity-format": "G" }
|
||||||
|
r = call_api_post( "/api/config/gravity", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
r = call_api_get( "/api/config" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["id"], id)
|
||||||
|
self.assertEqual(j["gravity-format"], "G")
|
||||||
|
self.assertEqual(j["gravity-formula"], "my-formula")
|
||||||
|
self.assertEqual(j["gravity-temp-adjustment"], True)
|
||||||
|
|
||||||
|
def test_config_6(self):
|
||||||
|
j = { "id": id, "mdns": "gravmon", "temp-format": "F", "sleep-interval": 300 }
|
||||||
|
r = call_api_post( "/api/config/device", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
r = call_api_get( "/api/config" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["id"], id)
|
||||||
|
self.assertEqual(j["mdns"], "gravmon")
|
||||||
|
self.assertEqual(j["wifi-ssid"], "@home")
|
||||||
|
self.assertEqual(j["wifi-pass"], "") # Should not be displayed in API
|
||||||
|
self.assertEqual(j["temp-format"], "F")
|
||||||
|
self.assertEqual(j["sleep-interval"], 300)
|
||||||
|
|
||||||
|
def test_config_7(self):
|
||||||
|
j = { "id": id, "ota-url": "", "voltage-factor": 1.55, "temp-adjustment-value": -2, "gyro-temp": "off", "ble": "blue" }
|
||||||
|
r = call_api_post( "/api/config/hardware", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
r = call_api_get( "/api/config" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["id"], id)
|
||||||
|
self.assertEqual(j["ble"], "blue")
|
||||||
|
self.assertEqual(j["ota-url"], "")
|
||||||
|
self.assertEqual(j["voltage-factor"], 1.55)
|
||||||
|
self.assertEqual(j["temp-adjustment-value"], -2)
|
||||||
|
self.assertEqual(j["gyro-temp"], False)
|
||||||
|
|
||||||
|
def test_config_8(self):
|
||||||
|
j = { "id": id, "gravity-formula": "", "gravity-temp-adjustment": "off", "gravity-format": "P" }
|
||||||
|
r = call_api_post( "/api/config/gravity", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
r = call_api_get( "/api/config" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["gravity-format"], "P")
|
||||||
|
self.assertEqual(j["gravity-temp-adjustment"], False)
|
||||||
|
self.assertEqual(j["gravity-formula"], "")
|
||||||
|
|
||||||
|
def test_config_9(self):
|
||||||
|
j = { "id": id, "gravity-temp-adjustment": "on" }
|
||||||
|
r = call_api_post( "/api/config/gravity", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
r = call_api_get( "/api/config" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["gravity-temp-adjustment"], True)
|
||||||
|
|
||||||
|
j = { "id": id } # No checkbox tag should set it to false.
|
||||||
|
r = call_api_post( "/api/config/gravity", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
r = call_api_get( "/api/config" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["gravity-temp-adjustment"], False)
|
||||||
|
|
||||||
|
def test_config_A(self):
|
||||||
|
j = { "id": id, "gyro-temp": "on" }
|
||||||
|
r = call_api_post( "/api/config/hardware", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
r = call_api_get( "/api/config" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["gyro-temp"], True)
|
||||||
|
|
||||||
|
j = { "id": id } # No checkbox tag should set it to false.
|
||||||
|
r = call_api_post( "/api/config/hardware", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
r = call_api_get( "/api/config" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["gyro-temp"], False)
|
||||||
|
|
||||||
|
# Check formula api (sg mode)
|
||||||
|
def test_formula_sg_1(self):
|
||||||
|
# Ensure we have SG defined as gravity
|
||||||
|
j = { "id": id, "gravity-formula": "", "gravity-temp-adjustment": "off", "gravity-format": "G" }
|
||||||
|
r = call_api_post("/api/config/gravity", j)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
def test_formula_sg_2(self):
|
||||||
|
# Fails due to wrong id
|
||||||
|
j = { "id": "wrong", "g1": 0, "g2": 1, "g3": 1.02, "g4": 1.0333, "g5": 1.00011, "g6": 1, "g7": 1, "g8": 1, "g9": 1, "g10": 1, "a1": 0, "a2": 25, "a3": 25.5, "a4": 25.55, "a5": 25.555, "a6": 0, "a7": 0, "a8": 0, "a9": 0, "a10": 0, "gravity-formula": "ThisShouldChange" }
|
||||||
|
r = call_api_post("/api/formula", j)
|
||||||
|
self.assertNotEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
# Fails due to to few values
|
||||||
|
j = { "id": id, "g1": 0, "g2": 1, "g3": 1.02, "g4": 1.0333, "g5": 1.00011, "g6": 1, "g7": 1, "g8": 1, "g9": 1, "g10": 1, "a1": 0, "a2": 25, "a3": 0, "a4": 0, "a5": 0, "a6": 0, "a7": 0, "a8": 0, "a9": 0, "a10": 0, "gravity-formula": "ThisShouldChange" }
|
||||||
|
r = call_api_post("/api/formula", j)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
# Checks that values from last call was stored
|
||||||
|
r = call_api_get( "/api/formula" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["gravity-formula"], "")
|
||||||
|
self.assertEqual(j["error"], "Not enough values to create formula, need at least 3 angles.")
|
||||||
|
|
||||||
|
def test_formula_sg_3(self):
|
||||||
|
# Check a simple formula
|
||||||
|
j = { "id": id, "g1": 1.0, "g2": 1.01, "g3": 1.02, "g4": 1.03, "g5": 1.04, "g6": 1.05, "g7": 1.06, "g8": 1.07, "g9": 1.08, "g10": 1.1, "a1": 25, "a2": 30, "a3": 35, "a4": 40, "a5": 45, "a6": 50, "a7": 55, "a8": 60, "a9": 65, "a10": 70, "gravity-formula": "ThisShouldChange" }
|
||||||
|
r = call_api_post("/api/formula", j)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
r = call_api_get( "/api/formula" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["gravity-formula"], "0.00000909*tilt^2+0.00124545*tilt+0.96445455")
|
||||||
|
|
||||||
|
# Check formula api (plato mode)
|
||||||
|
def test_formula_plato_1(self):
|
||||||
|
# Ensure we have Plato defined as gravity
|
||||||
|
j = { "id": id, "gravity-formula": "", "gravity-temp-adjustment": "off", "gravity-format": "P" }
|
||||||
|
r = call_api_post("/api/config/gravity", j)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
def test_formula_plato_2(self):
|
||||||
|
# Fails due to to few values
|
||||||
|
j = { "id": id, "g1": 0, "g2": 3, "g3": 5.3, "g4": 7.44, "g5": 8.555, "g6": 9, "g7": 9.1, "g8": 9.2, "g9": 9.3, "g10": 9.4, "a1": 0, "a2": 25, "a3": 25.5, "a4": 25.55, "a5": 25.555, "a6": 35, "a7": 36, "a8": 37, "a9": 38, "a10": 39, "gravity-formula": "ThisShouldChange" }
|
||||||
|
r = call_api_post("/api/formula", j)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
# Checks that values from last call was stored
|
||||||
|
r = call_api_get( "/api/formula" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["id"], id)
|
||||||
|
self.assertEqual(j["g1"], 0)
|
||||||
|
self.assertEqual(j["g2"], 3)
|
||||||
|
self.assertEqual(j["g3"], 5.3)
|
||||||
|
self.assertEqual(j["g4"], 7.4)
|
||||||
|
self.assertEqual(j["g5"], 8.6)
|
||||||
|
self.assertEqual(j["g6"], 9)
|
||||||
|
self.assertEqual(j["g7"], 9.1)
|
||||||
|
self.assertEqual(j["g8"], 9.2)
|
||||||
|
self.assertEqual(j["g9"], 9.3)
|
||||||
|
self.assertEqual(j["g10"], 9.4)
|
||||||
|
self.assertEqual(j["a1"], 0)
|
||||||
|
self.assertEqual(j["a2"], 25)
|
||||||
|
self.assertEqual(j["a3"], 25.5)
|
||||||
|
self.assertEqual(j["a4"], 25.55)
|
||||||
|
self.assertEqual(j["a5"], 25.56)
|
||||||
|
self.assertEqual(j["a6"], 35)
|
||||||
|
self.assertEqual(j["a7"], 36)
|
||||||
|
self.assertEqual(j["a8"], 37)
|
||||||
|
self.assertEqual(j["a9"], 38)
|
||||||
|
self.assertEqual(j["a10"], 39)
|
||||||
|
self.assertEqual(j["gravity-format"], "P")
|
||||||
|
self.assertEqual(j["gravity-formula"], "-0.00012155*tilt^2+0.00874785*tilt+0.88003318")
|
||||||
|
self.assertEqual(j["error"], "")
|
||||||
|
|
||||||
|
def test_formula_plato_3(self):
|
||||||
|
j = { "id": id, "g1": 0, "g2": 3, "g3": 0, "g4": 0, "g5": 0, "g6": 0, "g7": 0, "g8": 0, "g9": 0, "g10": 0, "a1": 0, "a2": 25, "a3": 0, "a4": 0, "a5": 0, "a6": 0, "a7": 0, "a8": 0, "a9": 0, "a10": 0, "gravity-formula": "ThisShouldChange" }
|
||||||
|
r = call_api_post("/api/formula", j)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
# Checks that values from last call was stored
|
||||||
|
r = call_api_get( "/api/formula" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["error"], "Not enough values to create formula, need at least 3 angles.")
|
||||||
|
|
||||||
|
def test_formula_plato_4(self):
|
||||||
|
# Ensure we have Plato defined as gravity
|
||||||
|
j = { "id": id, "gravity-formula": "", "gravity-temp-adjustment": "off", "gravity-format": "P" }
|
||||||
|
r = call_api_post("/api/config/gravity", j)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
# Check a simple formula
|
||||||
|
j = { "id": id, "g1": 1.0, "g2": 1.1, "g3": 1.2, "g4": 1.3, "g5": 1.4, "g6": 1.5, "g7": 1.6, "g8": 1.7, "g9": 1.8, "g10": 1.9, "a1": 25, "a2": 30, "a3": 35, "a4": 40, "a5": 45, "a6": 50, "a7": 55, "a8": 60, "a9": 65, "a10": 70, "gravity-formula": "ThisShouldChange" }
|
||||||
|
r = call_api_post("/api/formula", j)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
r = call_api_get( "/api/formula" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
#self.assertEqual(j["gravity-formula"], "0.00000001*tilt^2+0.00007752*tilt+1.00193428") # 1.6 max deviation
|
||||||
|
self.assertEqual(j["gravity-formula"], "-0.00000352*tilt^2+0.00045454*tilt+0.99231483") # 3.0 max deviation
|
||||||
|
|
||||||
|
# Check format api
|
||||||
|
def test_pushtest_1(self):
|
||||||
|
j = { "id": id, "http-push": "http://push.me", "token": "mytoken", "token2": "mytoken2", "http-push2": "http://push.me", "http-push3": "http://push.me", "brewfather-push": "http://push.me", "influxdb2-push": "http://influx.db", "influxdb2-org": "my-org",
|
||||||
|
"influxdb2-bucket": "my-bucket", "influxdb2-auth": "my-secret", "mqtt-push": "mqtt.com", "mqtt-port": 1883, "mqtt-user": "my-user",
|
||||||
|
"mqtt-pass": "my-pass", "http-push-h1": "header1", "http-push-h2": "header2", "http-push2-h1": "header1(2)", "http-push2-h2": "header2(2)" }
|
||||||
|
r = call_api_post( "/api/config/push", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
def test_pushtest_2(self):
|
||||||
|
r = call_api_get( "/api/test/push?id=" + id + "&format=http-1" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["success"], False)
|
||||||
|
self.assertEqual(j["enabled"], True)
|
||||||
|
self.assertEqual(j["code"], -1)
|
||||||
|
|
||||||
|
def test_pushtest_3(self):
|
||||||
|
r = call_api_get( "/api/test/push?id=" + id + "&format=http-2" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["success"], False)
|
||||||
|
self.assertEqual(j["enabled"], True)
|
||||||
|
self.assertEqual(j["code"], -1)
|
||||||
|
|
||||||
|
def test_pushtest_4(self):
|
||||||
|
r = call_api_get( "/api/test/push?id=" + id + "&format=http-3" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["success"], False)
|
||||||
|
self.assertEqual(j["enabled"], True)
|
||||||
|
self.assertEqual(j["code"], -1)
|
||||||
|
|
||||||
|
def test_pushtest_5(self):
|
||||||
|
r = call_api_get( "/api/test/push?id=" + id + "&format=influxdb" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["success"], False)
|
||||||
|
self.assertEqual(j["enabled"], True)
|
||||||
|
self.assertEqual(j["code"], -1)
|
||||||
|
|
||||||
|
def test_pushtest_6(self):
|
||||||
|
r = call_api_get( "/api/test/push?id=" + id + "&format=mqtt" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["success"], False)
|
||||||
|
self.assertEqual(j["enabled"], True)
|
||||||
|
self.assertEqual(j["code"], -3)
|
||||||
|
|
||||||
|
# Check format api
|
||||||
|
def test_push_1(self):
|
||||||
|
r = call_api_get( "/api/factory?id=" + id)
|
||||||
|
time.sleep(4)
|
||||||
|
|
||||||
|
# Note: The endpoint test.php does not validate the payload, it only accepts the request and return 200.
|
||||||
|
j = { "id": id, "http-push": "http://www.allerum.net/test.php", "http-push2": "http://www.allerum.net/test.php", "http-push3": "http://www.allerum.net/test.php", "mqtt-push": "192.168.1.16", "mqtt-port": 1883, "mqtt-user": "", "mqtt-pass": "" }
|
||||||
|
r = call_api_post( "/api/config/push", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
def test_push_2(self):
|
||||||
|
r = call_api_get( "/api/test/push?id=" + id + "&format=http-1" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["success"], True)
|
||||||
|
|
||||||
|
def test_push_3(self):
|
||||||
|
r = call_api_get( "/api/test/push?id=" + id + "&format=http-2" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["success"], True)
|
||||||
|
|
||||||
|
def test_push_4(self):
|
||||||
|
r = call_api_get( "/api/test/push?id=" + id + "&format=http-3" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["success"], True)
|
||||||
|
|
||||||
|
def test_push_5(self):
|
||||||
|
r = call_api_get( "/api/test/push?id=" + id + "&format=mqtt" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["success"], True)
|
||||||
|
|
||||||
|
def test_push_6(self):
|
||||||
|
r = call_api_get( "/api/test/push?id=" + id + "&format=influx" )
|
||||||
|
# TODO: Figure out how to test the influx db setup. Create my own mockup ?
|
||||||
|
|
||||||
|
# Check format api
|
||||||
|
def test_format_1(self):
|
||||||
|
j = { "id": id, "http-1": "one" }
|
||||||
|
r = call_api_post( "/api/config/format", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
def test_format_2(self):
|
||||||
|
j = { "id": id, "http-2": "two" }
|
||||||
|
r = call_api_post( "/api/config/format", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
def test_format_3(self):
|
||||||
|
j = { "id": id, "http-3": "five" }
|
||||||
|
r = call_api_post( "/api/config/format", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
def test_format_4(self):
|
||||||
|
j = { "id": id, "influxdb": "three" }
|
||||||
|
r = call_api_post( "/api/config/format", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
def test_format_5(self):
|
||||||
|
j = { "id": id, "mqtt": "four" }
|
||||||
|
r = call_api_post( "/api/config/format", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
def test_format_6(self):
|
||||||
|
r = call_api_get( "/api/config/format" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["id"], id)
|
||||||
|
self.assertEqual(j["http-1"], "one")
|
||||||
|
self.assertEqual(j["http-2"], "two")
|
||||||
|
self.assertEqual(j["http-3"], "five")
|
||||||
|
self.assertEqual(j["influxdb"], "three")
|
||||||
|
self.assertEqual(j["mqtt"], "four")
|
||||||
|
|
||||||
|
def test_format_7(self):
|
||||||
|
j = { "id": id, "http-1": "" }
|
||||||
|
r = call_api_post( "/api/config/format", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
def test_format_8(self):
|
||||||
|
j = { "id": id, "http-2": "" }
|
||||||
|
r = call_api_post( "/api/config/format", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
def test_format_9(self):
|
||||||
|
j = { "id": id, "http-3": "" }
|
||||||
|
r = call_api_post( "/api/config/format", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
def test_format_A(self):
|
||||||
|
j = { "id": id, "influxdb": "" }
|
||||||
|
r = call_api_post( "/api/config/format", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
def test_format_B(self):
|
||||||
|
j = { "id": id, "mqtt": "" }
|
||||||
|
r = call_api_post( "/api/config/format", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
def test_format_C(self):
|
||||||
|
r = call_api_get( "/api/config/format" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
#print(j["http-1"])
|
||||||
|
#print(j["http-2"])
|
||||||
|
#print(j["http-3"])
|
||||||
|
#print(j["influxdb"])
|
||||||
|
#print(j["mqtt"])
|
||||||
|
self.assertEqual(j["http-1"], "%7B%22name%22%20%3A%20%22%24%7Bmdns%7D%22%2C%20%22ID%22%3A%20%22%24%7Bid%7D%22%2C%20%22token%22%20%3A%20%22%24%7Btoken%7D%22%2C%20%22interval%22%3A%20%24%7Bsleep%2Dinterval%7D%2C%20%22temperature%22%3A%20%24%7Btemp%7D%2C%20%22temp%5Funits%22%3A%20%22%24%7Btemp%2Dunit%7D%22%2C%20%22gravity%22%3A%20%24%7Bgravity%7D%2C%20%22angle%22%3A%20%24%7Bangle%7D%2C%20%22battery%22%3A%20%24%7Bbattery%7D%2C%20%22RSSI%22%3A%20%24%7Brssi%7D%2C%20%22corr%2Dgravity%22%3A%20%24%7Bcorr%2Dgravity%7D%2C%20%22gravity%2Dunit%22%3A%20%22%24%7Bgravity%2Dunit%7D%22%2C%20%22run%2Dtime%22%3A%20%24%7Brun%2Dtime%7D%20%7D")
|
||||||
|
self.assertEqual(j["http-2"], "%7B%22name%22%20%3A%20%22%24%7Bmdns%7D%22%2C%20%22ID%22%3A%20%22%24%7Bid%7D%22%2C%20%22token%22%20%3A%20%22%24%7Btoken%7D%22%2C%20%22interval%22%3A%20%24%7Bsleep%2Dinterval%7D%2C%20%22temperature%22%3A%20%24%7Btemp%7D%2C%20%22temp%5Funits%22%3A%20%22%24%7Btemp%2Dunit%7D%22%2C%20%22gravity%22%3A%20%24%7Bgravity%7D%2C%20%22angle%22%3A%20%24%7Bangle%7D%2C%20%22battery%22%3A%20%24%7Bbattery%7D%2C%20%22RSSI%22%3A%20%24%7Brssi%7D%2C%20%22corr%2Dgravity%22%3A%20%24%7Bcorr%2Dgravity%7D%2C%20%22gravity%2Dunit%22%3A%20%22%24%7Bgravity%2Dunit%7D%22%2C%20%22run%2Dtime%22%3A%20%24%7Brun%2Dtime%7D%20%7D")
|
||||||
|
self.assertEqual(j["http-3"], "%3Fname%3D%24%7Bmdns%7D%26id%3D%24%7Bid%7D%26token%3D%24%7Btoken2%7D%26interval%3D%24%7Bsleep%2Dinterval%7D%26temperature%3D%24%7Btemp%7D%26temp%2Dunits%3D%24%7Btemp%2Dunit%7D%26gravity%3D%24%7Bgravity%7D%26angle%3D%24%7Bangle%7D%26battery%3D%24%7Bbattery%7D%26rssi%3D%24%7Brssi%7D%26corr%2Dgravity%3D%24%7Bcorr%2Dgravity%7D%26gravity%2Dunit%3D%24%7Bgravity%2Dunit%7D%26run%2Dtime%3D%24%7Brun%2Dtime%7D")
|
||||||
|
self.assertEqual(j["influxdb"], "measurement%2Chost%3D%24%7Bmdns%7D%2Cdevice%3D%24%7Bid%7D%2Ctemp%2Dformat%3D%24%7Btemp%2Dunit%7D%2Cgravity%2Dformat%3D%24%7Bgravity%2Dunit%7D%20gravity%3D%24%7Bgravity%7D%2Ccorr%2Dgravity%3D%24%7Bcorr%2Dgravity%7D%2Cangle%3D%24%7Bangle%7D%2Ctemp%3D%24%7Btemp%7D%2Cbattery%3D%24%7Bbattery%7D%2Crssi%3D%24%7Brssi%7D%0A")
|
||||||
|
self.assertEqual(j["mqtt"], "ispindel%2F%24%7Bmdns%7D%2Ftilt%3A%24%7Bangle%7D%7Cispindel%2F%24%7Bmdns%7D%2Ftemperature%3A%24%7Btemp%7D%7Cispindel%2F%24%7Bmdns%7D%2Ftemp%5Funits%3A%24%7Btemp%2Dunit%7D%7Cispindel%2F%24%7Bmdns%7D%2Fbattery%3A%24%7Bbattery%7D%7Cispindel%2F%24%7Bmdns%7D%2Fgravity%3A%24%7Bgravity%7D%7Cispindel%2F%24%7Bmdns%7D%2Finterval%3A%24%7Bsleep%2Dinterval%7D%7Cispindel%2F%24%7Bmdns%7D%2FRSSI%3A%24%7Brssi%7D%7C")
|
||||||
|
|
||||||
|
# Toggle sleep mode
|
||||||
|
def toggle_sleepmode_1(self):
|
||||||
|
j = { "id": id, "sleep-mode": "on" }
|
||||||
|
r = call_api_post( "/api/status/sleepmode" )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
r = call_api_get( "/api/status" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["sleep-mode"], True)
|
||||||
|
|
||||||
|
def toggle_sleepmode_2(self):
|
||||||
|
j = { "id": id, "sleep-mode": "off" }
|
||||||
|
r = call_api_post( "/api/status/sleepmode" )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
r = call_api_get( "/api/status" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["sleep-mode"], False)
|
||||||
|
|
||||||
|
# Clear setting
|
||||||
|
def default_settings_1(self):
|
||||||
|
j = { "id": id, "mdns": "gravmon", "temp-format": "C", "sleep-interval": 300 }
|
||||||
|
r = call_api_post( "/api/config/device", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
def default_settings_2(self):
|
||||||
|
j = { "id": id, "token": "", "token2": "", "http-push": "", "http-push2": "", "http-push3": "", "influxdb2-push": "", "influxdb2-org": "", "influxdb2-bucket": "",
|
||||||
|
"influxdb2-auth": "", "mqtt-push": "", "mqtt-port": 1883, "mqtt-user": "", "mqtt-pass": "" }
|
||||||
|
r = call_api_post( "/api/config/push", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
def default_settings_3(self):
|
||||||
|
j = { "id": id, "ota-url": "", "voltage-factor": 1.55, "temp-adjustment-value": -2, "gyro-temp": "off" }
|
||||||
|
r = call_api_post( "/api/config/hardware", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
def default_settings_4(self):
|
||||||
|
j = { "id": id, "gravity-formula": "", "gravity-temp-adjustment": "off", "gravity-format": "G" }
|
||||||
|
r = call_api_post( "/api/config/gravity", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
# Check advanced
|
||||||
|
def test_advanced_config_1(self):
|
||||||
|
r = call_api_get( "/api/status" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["id"], id)
|
||||||
|
r = call_api_get( "/api/factory?id=" + j["id"])
|
||||||
|
time.sleep(4)
|
||||||
|
|
||||||
|
r = call_api_get( "/api/config/advanced" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
#print(j)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["gyro-read-count"], 50)
|
||||||
|
self.assertEqual(j["tempsensor-resolution"], 9)
|
||||||
|
self.assertEqual(j["gyro-moving-threashold"], 500)
|
||||||
|
self.assertEqual(j["formula-max-deviation"], 3)
|
||||||
|
self.assertEqual(j["formula-calibration-temp"], 20)
|
||||||
|
self.assertEqual(j["wifi-portal-timeout"], 120)
|
||||||
|
self.assertEqual(j["wifi-connect-timeout"], 20)
|
||||||
|
self.assertEqual(j["ignore-low-angles"], False)
|
||||||
|
self.assertEqual(j["formula-calibration-temp"], 20)
|
||||||
|
self.assertEqual(j["int-http1"], 0)
|
||||||
|
self.assertEqual(j["int-http2"], 0)
|
||||||
|
self.assertEqual(j["int-http3"], 0)
|
||||||
|
self.assertEqual(j["int-influx"], 0)
|
||||||
|
self.assertEqual(j["int-mqtt"], 0)
|
||||||
|
|
||||||
|
def test_advanced_config_2(self):
|
||||||
|
j = { "id": id, "gyro-read-count": 51, "tempsensor-resolution": 10, "gyro-moving-threashold": 501, "formula-max-deviation": 1.7, "ignore-low-angles": "on",
|
||||||
|
"formula-calibration-temp": 21, "wifi-portal-timeout": 121, "wifi-connect-timeout": 21, "int-http1": 1, "int-http2": 2, "int-http3": 3, "int-influx": 4, "int-mqtt": 5 }
|
||||||
|
r = call_api_post( "/api/config/advanced", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
r = call_api_get( "/api/config/advanced" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["gyro-read-count"], 51)
|
||||||
|
self.assertEqual(j["tempsensor-resolution"], 10)
|
||||||
|
self.assertEqual(j["gyro-moving-threashold"], 501)
|
||||||
|
self.assertEqual(j["formula-max-deviation"], 1.7)
|
||||||
|
self.assertEqual(j["formula-calibration-temp"], 21)
|
||||||
|
self.assertEqual(j["wifi-portal-timeout"], 121)
|
||||||
|
self.assertEqual(j["wifi-connect-timeout"], 21)
|
||||||
|
self.assertEqual(j["ignore-low-angles"], True)
|
||||||
|
self.assertEqual(j["int-http1"], 1)
|
||||||
|
self.assertEqual(j["int-http2"], 2)
|
||||||
|
self.assertEqual(j["int-http3"], 3)
|
||||||
|
self.assertEqual(j["int-influx"], 4)
|
||||||
|
self.assertEqual(j["int-mqtt"], 5)
|
||||||
|
|
||||||
|
def test_advanced_config_3(self):
|
||||||
|
j = { "id": id, "ignore-low-angles": "on" }
|
||||||
|
r = call_api_post( "/api/config/advanced", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
r = call_api_get( "/api/config/advanced" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["ignore-low-angles"], True)
|
||||||
|
|
||||||
|
j = { "id": id } # Skipping checkbox variable should set it to false
|
||||||
|
r = call_api_post( "/api/config/advanced", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
r = call_api_get( "/api/config/advanced" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["ignore-low-angles"], False)
|
||||||
|
|
||||||
|
def test_bug_71(self):
|
||||||
|
format = "gm%3A%7B%22name%22%3A%22%24%7Bmdns%7D%22%2C%20%22ID%22%3A%22%24%7Bid%7D%22%2C%20%22temperature%22%3A%20%24%7Btemp%7D%2C%20%22gravity%22%3A%24%7Bgravity%7D%2C%22angle%22%3A%20%24%7Bangle%7D%2C%20%22battery%22%3A%24%7Bbattery%7D%2C%20%22rssi%22%3A%20%24%7Brssi%7D%7D"
|
||||||
|
j = { "id": id, "mqtt": format }
|
||||||
|
r = call_api_post( "/api/config/format", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
r = call_api_get( "/api/config/format" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["mqtt"], format)
|
||||||
|
|
||||||
|
def test_bug_79(self):
|
||||||
|
j = { "id": id, "formula-max-deviation": 1.7 }
|
||||||
|
r = call_api_post( "/api/config/advanced", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
j = { "id": id, "g1": 1.0, "g2": 1.009, "g3": 1.014, "g4": 1.027, "g5": 1.037, "g6": 1.042, "g7": 1.051, "g8": 1.060, "g9": 1.073, "g10": 1.078, "a1": 23.52, "a2": 26.47, "a3": 29.87, "a4": 33.43, "a5": 38.16, "a6": 40.6, "a7": 45.85, "a8": 50.12, "a9": 56.55, "a10": 59.078, "gravity-formula": "" }
|
||||||
|
r = call_api_post("/api/formula", j)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
r = call_api_get( "/api/formula" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["error"], 'Unable to find an accurate formula based on input, check error log and graph below.')
|
||||||
|
|
||||||
|
j = { "id": id, "formula-max-deviation": 4 }
|
||||||
|
r = call_api_post( "/api/config/advanced", j )
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
j = { "id": id, "g1": 1.0, "g2": 1.009, "g3": 1.014, "g4": 1.027, "g5": 1.037, "g6": 1.042, "g7": 1.051, "g8": 1.060, "g9": 1.073, "g10": 1.078, "a1": 23.52, "a2": 26.47, "a3": 29.87, "a4": 33.43, "a5": 38.16, "a6": 40.6, "a7": 45.85, "a8": 50.12, "a9": 56.55, "a10": 59.078, "gravity-formula": "" }
|
||||||
|
r = call_api_post("/api/formula", j)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
r = call_api_get( "/api/formula" )
|
||||||
|
j = json.loads(r.text)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
self.assertEqual(j["error"], '')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
@ -1,7 +1,9 @@
|
|||||||
{
|
{
|
||||||
|
"wifi-ssid": "ssid 1",
|
||||||
|
"wifi-ssid2": "ssid 2",
|
||||||
"mdns": "gravmon3",
|
"mdns": "gravmon3",
|
||||||
"id": "7376ef",
|
"id": "7376ef",
|
||||||
"ota-url": "http://192.168.1.100:80/firmware/gravmon/",
|
"ota-url": "https://www.gravitymon.com/firmware/",
|
||||||
"temp-format": "C",
|
"temp-format": "C",
|
||||||
"http-push": "http://192.168.1.10:9090/api/v1/ZYfjlUNeiuyu9N/telemetry",
|
"http-push": "http://192.168.1.10:9090/api/v1/ZYfjlUNeiuyu9N/telemetry",
|
||||||
"http-push-h1": "Auth: Basic T7IF9DD9fF3RDddE=",
|
"http-push-h1": "Auth: Basic T7IF9DD9fF3RDddE=",
|
||||||
|
@ -1,91 +0,0 @@
|
|||||||
import requests
|
|
||||||
import json
|
|
||||||
|
|
||||||
host = "192.168.1.1" # IP adress (or name) of the device to send these settings to
|
|
||||||
id = "ee1bfc" # Device ID (shown in serial console during startup or in UI)
|
|
||||||
|
|
||||||
def set_config( url, json ):
|
|
||||||
headers = { "ContentType": "application/json" }
|
|
||||||
print( url )
|
|
||||||
#print( json )
|
|
||||||
resp = requests.post( url, headers=headers, data=json )
|
|
||||||
if resp.status_code != 200 :
|
|
||||||
print ( "Failed " )
|
|
||||||
else :
|
|
||||||
print ( "Success " )
|
|
||||||
|
|
||||||
#
|
|
||||||
# Configure the device settings.
|
|
||||||
#
|
|
||||||
url = "http://" + host + "/api/config/device"
|
|
||||||
json = { "id": id,
|
|
||||||
"mdns": "gravmon", # Name of the device
|
|
||||||
"temp-format": "C", # Temperature format C or F
|
|
||||||
"sleep-interval": 30 # Sleep interval in seconds
|
|
||||||
}
|
|
||||||
set_config( url, json )
|
|
||||||
|
|
||||||
#
|
|
||||||
# Configure the push settings. Blank means that its no used.
|
|
||||||
#
|
|
||||||
url = "http://" + host + "/api/config/push"
|
|
||||||
json = { "id": id,
|
|
||||||
"token": "",
|
|
||||||
"http-push": "http://192.168.1.1/ispindel", # HTTP endpoint
|
|
||||||
"http-push2": "", # HTTP endpoint2
|
|
||||||
"http-push-h1": "Content-Type: application/json",
|
|
||||||
"http-push-h2": "",
|
|
||||||
"http-push2-h1": "Content-Type: application/json",
|
|
||||||
"http-push2-h2": "",
|
|
||||||
"influxdb2-push": "", # InfluxDB2 settings
|
|
||||||
"influxdb2-org": "",
|
|
||||||
"influxdb2-bucket": "",
|
|
||||||
"influxdb2-auth": "" ,
|
|
||||||
"mqtt-push": "",
|
|
||||||
"mqtt-port": 1883,
|
|
||||||
"mqtt-user": "",
|
|
||||||
"mqtt-pass": ""
|
|
||||||
}
|
|
||||||
set_config( url, json )
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Configure the gravity settings.
|
|
||||||
#
|
|
||||||
url = "http://" + host + "/api/config/gravity"
|
|
||||||
json = { "id": id,
|
|
||||||
"gravity-formula": "", # If you want to set the gravity formula
|
|
||||||
"gravity-format": "G",
|
|
||||||
"gravity-temp-adjustment": "off" # on or off
|
|
||||||
}
|
|
||||||
set_config( url, json )
|
|
||||||
|
|
||||||
#
|
|
||||||
# Configure the hardware settings.
|
|
||||||
#
|
|
||||||
url = "http://" + host + "/api/config/hardware"
|
|
||||||
json = { "id": id,
|
|
||||||
"voltage-factor": 1.59, # Default value for voltage calculation
|
|
||||||
"temp-adjustment": 0, # If temp sensor needs to be corrected
|
|
||||||
"gyro-temp": "off", # Use the temp sensor in the gyro
|
|
||||||
"ota-url": "" # if the device should seach for a new update when active
|
|
||||||
}
|
|
||||||
set_config( url, json )
|
|
||||||
|
|
||||||
#
|
|
||||||
# Configure the gravity formula settings. If this is called the formula will be updated based on these measurements (zero angle values will be ignored)
|
|
||||||
#
|
|
||||||
url = "http://" + host + "/api/formula"
|
|
||||||
json = { "id": id,
|
|
||||||
"a1": 22.4,
|
|
||||||
"a2": 54.4,
|
|
||||||
"a3": 58,
|
|
||||||
"a4": 0,
|
|
||||||
"a5": 0,
|
|
||||||
"g1": 1.000,
|
|
||||||
"g2": 1.053,
|
|
||||||
"g3": 1.062,
|
|
||||||
"g4": 1,
|
|
||||||
"g5": 1
|
|
||||||
}
|
|
||||||
set_config( url, json )
|
|
82
test/tests.cpp
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2022 Magnus
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
*/
|
||||||
|
#include <AUnit.h>
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
#include <main.hpp>
|
||||||
|
|
||||||
|
using aunit::Printer;
|
||||||
|
using aunit::TestRunner;
|
||||||
|
using aunit::Verbosity;
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Boolean
|
||||||
|
assertEqual(a, b)
|
||||||
|
assertNotEqual(a, b)
|
||||||
|
assertLess(a, b)
|
||||||
|
assertMore(a, b)
|
||||||
|
assertLessOrEqual(a, b)
|
||||||
|
assertMoreOrEqual(a, b)
|
||||||
|
|
||||||
|
// String
|
||||||
|
assertStringCaseEqual(a, b)
|
||||||
|
assertStringCaseNotEqual(a, b)
|
||||||
|
assertNear(a, b, error)
|
||||||
|
assertNotNear(a, b, error)
|
||||||
|
checkTestDone(name)
|
||||||
|
checkTestNotDone(name)
|
||||||
|
checkTestPass(name)
|
||||||
|
checkTestNotPass(name)
|
||||||
|
checkTestFail(name)
|
||||||
|
checkTestNotFail(name)
|
||||||
|
checkTestSkip(name)
|
||||||
|
checkTestNotSkip(name)
|
||||||
|
checkTestExpire(name) [*]
|
||||||
|
checkTestNotExpire(name) [*]
|
||||||
|
assertTestDone(name)
|
||||||
|
assertTestNotDone(name)
|
||||||
|
assertTestPass(name)
|
||||||
|
assertTestNotPass(name)
|
||||||
|
assertTestFail(name)
|
||||||
|
assertTestNotFail(name)
|
||||||
|
assertTestSkip(name)
|
||||||
|
assertTestNotSkip(name)
|
||||||
|
assertTestExpire(name) [*]
|
||||||
|
assertTestNotExpire(name) [*]
|
||||||
|
*/
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
Serial.println("Gravitymon - Unit Test Build");
|
||||||
|
delay(2000);
|
||||||
|
Printer::setPrinter(&Serial);
|
||||||
|
// TestRunner::setVerbosity(Verbosity::kAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
TestRunner::run();
|
||||||
|
delay(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
// EOF
|
31
test/tests_ble.cpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2022 Magnus
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
*/
|
||||||
|
#include <AUnit.h>
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
#include <main.hpp>
|
||||||
|
|
||||||
|
// No unit testing for the BLE module.
|
||||||
|
|
||||||
|
// EOF
|
67
test/tests_calc.cpp
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2022 Magnus
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
*/
|
||||||
|
#include <AUnit.h>
|
||||||
|
|
||||||
|
#include <calc.hpp>
|
||||||
|
#include <helper.hpp>
|
||||||
|
|
||||||
|
// TODO: Add more test cases to explore formula creation error conditions when
|
||||||
|
// values are out of bounds
|
||||||
|
// TODO: Add more test cases to check order 3 + 4 formula creation as well.
|
||||||
|
|
||||||
|
test(calc_createFormula1) {
|
||||||
|
char buffer[100];
|
||||||
|
RawFormulaData fd = {
|
||||||
|
{0.0, 25.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
|
||||||
|
{0.0, 1.0, 1.02, 1.033, 1.00011, 1.0, 1.0, 1.0, 1.0, 1.0}};
|
||||||
|
int i = createFormula(fd, &buffer[0], sizeof(buffer), 2);
|
||||||
|
assertEqual(i, ERR_FORMULA_NOTENOUGHVALUES);
|
||||||
|
}
|
||||||
|
|
||||||
|
test(calc_createFormula2) {
|
||||||
|
char buffer[100];
|
||||||
|
RawFormulaData fd = {
|
||||||
|
{25.0, 30.0, 35.0, 40.0, 45.0, 50.0, 55.0, 60.0, 65.0, 70.0},
|
||||||
|
{1.0, 1.01, 1.02, 1.03, 1.04, 1.05, 1.06, 1.07, 1.08, 1.1}};
|
||||||
|
int i = createFormula(fd, &buffer[0], sizeof(buffer), 2);
|
||||||
|
assertEqual(i, 0);
|
||||||
|
assertEqual(&buffer[0], "0.00000909*tilt^2+0.00124545*tilt+0.96445455");
|
||||||
|
}
|
||||||
|
|
||||||
|
test(calc_calculateGravity) {
|
||||||
|
const char* formula = "0.00000909*tilt^2+0.00124545*tilt+0.96445455";
|
||||||
|
double g = calculateGravity(30, 20, formula);
|
||||||
|
float v1 = reduceFloatPrecision(g, 2);
|
||||||
|
float v2 = 1.01;
|
||||||
|
assertEqual(v1, v2);
|
||||||
|
}
|
||||||
|
|
||||||
|
test(calc_gravityTemperatureCorrectionC) {
|
||||||
|
double g = gravityTemperatureCorrectionC(1.02, 45.0, 20.0);
|
||||||
|
float v1 = reduceFloatPrecision(g, 2);
|
||||||
|
float v2 = 1.03;
|
||||||
|
assertEqual(v1, v2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// EOF
|