mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-06 19:46:54 +03:00
Merge for next Bugfix Release (#1616)
* Fix for securing wlan.ini (#1509) * Fix for securing wlan.ini * Fixing error with ' instead of " * Changing to errorcode 403 * maybe strcmp instead of regular == Co-authored-by: Pär Hedberg <par.hedberg@nordicmedtest.se> * Update Web-Installer * solves #1530 (#1531) * Refactor JSON (#1518) * use correct log level * corrected logging * typo * refactored JSON generagion: removed unused parameters, consolidated into singel function, added "pre" * Wrapped 'rate' into double quotes, like all other JSON values Co-authored-by: CaCO3 <caco@ruinelli.ch> * Various corrections (#1519) * use correct log level * corrected logging * typo * add release to webinstaller * changed logs, added INFO log of raw, value, error * . Co-authored-by: CaCO3 <caco@ruinelli.ch> * Prevent auto restart on cam framebuffer init error (#1522) * use correct log level * revert autorestart on camera framebuffer init error * . Co-authored-by: CaCO3 <caco@ruinelli.ch> * #1524 - ensure the recognized digit is less than 10 (#1525) * fix kernel panic (vector out of range) in getReadoutRawString * fix key of caches * fix key of caches * fix key caches * fix cache keys * fix cache keys * move set variables to top * debug * fix key * testing * try fix changelog * test * Update Changelog.md for release * Revert "Update Changelog.md for release" This reverts commit4f51ec7962. * remove testing * fix release creation * testing * Update Changelog.md for release * test * Revert "Merge branch 'master' of https://github.com/haverland/AI-on-the-edge-device" This reverts commitf68695a4c0, reversing changes made toa096cf7182. * Revert "test" This reverts commita096cf7182. * revert testing * #1524 - ensure the result of ZeigerEvalHybridNeu is <10 * Fix late digit transition #1503 Co-authored-by: github-actions <github-actions@github.com> * fix frozen time in datafile on error (#1534) Co-authored-by: CaCO3 <caco@ruinelli.ch> * log NTP server name (#1497) * log NTP server name * . * . * replace calls to /wasserzaehler.html with calls to /value (#1469) Co-authored-by: CaCO3 <caco@ruinelli.ch> * Fix cookie usage, use correct http response codes, add 404 page (#1495) * replaced some HTTP response code with better matching codes * add custom 404 page, add log entry for debugging * fix cookie * replace non-necessary whitespace * . Co-authored-by: CaCO3 <caco@ruinelli.ch> * Don't autofail if NTP server can't be reached during initalization (#1498) This fixes an issue with a restricted network without internet access, where the hardcoded ntp server can't be reached and thus the esp resets, as it's not able to finish initalization. * Update Changelog.md * Update Changelog.md for release * Fix for securing wlan.ini (#1509) * Fix for securing wlan.ini * Fixing error with ' instead of " * Changing to errorcode 403 * maybe strcmp instead of regular == Co-authored-by: Pär Hedberg <par.hedberg@nordicmedtest.se> * Update Web-Installer * solves #1530 (#1531) * Refactor JSON (#1518) * use correct log level * corrected logging * typo * refactored JSON generagion: removed unused parameters, consolidated into singel function, added "pre" * Wrapped 'rate' into double quotes, like all other JSON values Co-authored-by: CaCO3 <caco@ruinelli.ch> * Various corrections (#1519) * use correct log level * corrected logging * typo * add release to webinstaller * changed logs, added INFO log of raw, value, error * . Co-authored-by: CaCO3 <caco@ruinelli.ch> * Prevent auto restart on cam framebuffer init error (#1522) * use correct log level * revert autorestart on camera framebuffer init error * . Co-authored-by: CaCO3 <caco@ruinelli.ch> * #1524 - ensure the recognized digit is less than 10 (#1525) * fix kernel panic (vector out of range) in getReadoutRawString * fix key of caches * fix key of caches * fix key caches * fix cache keys * fix cache keys * move set variables to top * debug * fix key * testing * try fix changelog * test * Update Changelog.md for release * Revert "Update Changelog.md for release" This reverts commit4f51ec7962. * remove testing * fix release creation * testing * Update Changelog.md for release * test * Revert "Merge branch 'master' of https://github.com/haverland/AI-on-the-edge-device" This reverts commitf68695a4c0, reversing changes made toa096cf7182. * Revert "test" This reverts commita096cf7182. * revert testing * #1524 - ensure the result of ZeigerEvalHybridNeu is <10 * Fix late digit transition #1503 Co-authored-by: github-actions <github-actions@github.com> * only use sntp_getservername() after init sntp * set default NTP server on dnew installations Co-authored-by: CaCO3 <caco@ruinelli.ch> Co-authored-by: Ralf Rachinger <git@ralfrachinger.de> Co-authored-by: jomjol <30766535+jomjol@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: parhedberg <par.hedberg@gmail.com> Co-authored-by: Pär Hedberg <par.hedberg@nordicmedtest.se> Co-authored-by: Christopher Fenner <9592452+CFenner@users.noreply.github.com> Co-authored-by: Frank Haverland <fspapaping@googlemail.com> * Renamed variables and added debug log (#1537) * add debug logs * renamed variables * renamed TAGs, added flow status logging * . * . Co-authored-by: CaCO3 <caco@ruinelli.ch> * replaced printf usage in LogFile.WriteToFile() * ENABLE_MQTT c++ macro definition (#1546) * macro * 2 * 2 * delete jomjol_mqtt from CMakeLists * mqtt macro * final * ENABLE_INFLUXDB c++ macro definition (#1547) * macro * 2 * 2 * delete jomjol_mqtt from CMakeLists * mqtt macro * final * ENABLE_INFLUXDB c++ macro definition * Update Changelog.md * Update Changelog.md * Rearange task to CPU (http, camera, mqtt) (#1557) * Streamlined MQTT interlock when not activated & interlock MQTT when WIFI is not connected (#1556) * streamlined mqtt interlock when disabled * Disconnect mqtt client before reboot * Interlock MQTT with WIFI * Update * loglevel to DEBUG * Update * mqtt msg id incremental * new ENABLE_MQTT includes * Loglevel to DEBUG * Loglevel * Update interface_mqtt.cpp * show uptime on overview page, moved labels from firmware to Web UI (#1543) * show uptime on overview page, moved labels from firmware to Web UI * show uptime on info page * also use formated time in log Co-authored-by: CaCO3 <caco@ruinelli.ch> * Continue boot on bad PSRAM (#1558) * add sensor status, show special index/setup page in case of a critical error * continue booting on PSRAM error * Update main.cpp added log messages * init PSRAM and add more log messages * cleanup of init checks * . * . * . Co-authored-by: CaCO3 <caco@ruinelli.ch> * add sensor status, show special index/setup page in case of a critical error (#1560) * add sensor status, show special index/setup page in case of a critical error * Added Reboot * . * added more buttons Co-authored-by: CaCO3 <caco@ruinelli.ch> Co-authored-by: jomjol <30766535+jomjol@users.noreply.github.com> * Update Webinstaller to v13.0.7 * remove html-from-11.3.1 in release (#1565) * fix kernel panic (vector out of range) in getReadoutRawString * fix key of caches * fix key of caches * fix key caches * fix cache keys * fix cache keys * move set variables to top * debug * fix key * testing * try fix changelog * test * Update Changelog.md for release * Revert "Update Changelog.md for release" This reverts commit4f51ec7962. * remove testing * fix release creation * testing * Update Changelog.md for release * test * Revert "Merge branch 'master' of https://github.com/haverland/AI-on-the-edge-device" This reverts commitf68695a4c0, reversing changes made toa096cf7182. * Revert "test" This reverts commita096cf7182. * revert testing * #1524 - ensure the result of ZeigerEvalHybridNeu is <10 * Fix late digit transition #1503 * only initial_esp32_setup and update.zip as artefacts * remove unneeded cache * rename step ota-v2 to ota * rename ota-v2 to ota Co-authored-by: github-actions <github-actions@github.com> * make the sidebar on the overviw page wider and show the round counter (#1570) Co-authored-by: CaCO3 <caco@ruinelli.ch> * Create reply-bot.yml * Update ClassFlowPostProcessing.cpp * Add bot (#1581) * Update reply-bot.yml * Create label-commenter-config.yml * added missing html change * extended instructions (#1583) Co-authored-by: CaCO3 <caco@ruinelli.ch> * Fix Rate Problem * removed redundant "Status:" * Bugfix Double Extract ZIP-Files * Update FeatureRequest.md (#1591) in case of position change between the measurments set this state to true, if there is no change set it back to false. In a defined time window this movement can lead into an alarm state / water leak.. haveing this state in the mqtt broker can trigger functions like closing the ater pipe walve and so on... * Update manifest.json * Delete .gitignore * Delete .gitmodules * Delete firmware.bin * Add files via upload * Block REST API calls till resource is ready (#1609) * Block REST API call till ressource is ready * Update * Update * Update * replace relative include of gethost.js with absolute one. This is needed as that file gets incuded on dynamically generated content which can be on different path levels (#1610) Co-authored-by: CaCO3 <caco@ruinelli.ch> * esp_spiram.h has been replaced by esp32/spiram.h (#1605) * esp_spiram.h has been replaced by esp32/spiram.h * Preparations for next Bugfix Release (#1615) * Merge branch 'rolling' (#1559) * Fix for securing wlan.ini (#1509) * Fix for securing wlan.ini * Fixing error with ' instead of " * Changing to errorcode 403 * maybe strcmp instead of regular == Co-authored-by: Pär Hedberg <par.hedberg@nordicmedtest.se> * Update Web-Installer * solves #1530 (#1531) * Refactor JSON (#1518) * use correct log level * corrected logging * typo * refactored JSON generagion: removed unused parameters, consolidated into singel function, added "pre" * Wrapped 'rate' into double quotes, like all other JSON values Co-authored-by: CaCO3 <caco@ruinelli.ch> * Various corrections (#1519) * use correct log level * corrected logging * typo * add release to webinstaller * changed logs, added INFO log of raw, value, error * . Co-authored-by: CaCO3 <caco@ruinelli.ch> * Prevent auto restart on cam framebuffer init error (#1522) * use correct log level * revert autorestart on camera framebuffer init error * . Co-authored-by: CaCO3 <caco@ruinelli.ch> * #1524 - ensure the recognized digit is less than 10 (#1525) * fix kernel panic (vector out of range) in getReadoutRawString * fix key of caches * fix key of caches * fix key caches * fix cache keys * fix cache keys * move set variables to top * debug * fix key * testing * try fix changelog * test * Update Changelog.md for release * Revert "Update Changelog.md for release" This reverts commit4f51ec7962. * remove testing * fix release creation * testing * Update Changelog.md for release * test * Revert "Merge branch 'master' of https://github.com/haverland/AI-on-the-edge-device" This reverts commitf68695a4c0, reversing changes made toa096cf7182. * Revert "test" This reverts commita096cf7182. * revert testing * #1524 - ensure the result of ZeigerEvalHybridNeu is <10 * Fix late digit transition #1503 Co-authored-by: github-actions <github-actions@github.com> * fix frozen time in datafile on error (#1534) Co-authored-by: CaCO3 <caco@ruinelli.ch> * log NTP server name (#1497) * log NTP server name * . * . * replace calls to /wasserzaehler.html with calls to /value (#1469) Co-authored-by: CaCO3 <caco@ruinelli.ch> * Fix cookie usage, use correct http response codes, add 404 page (#1495) * replaced some HTTP response code with better matching codes * add custom 404 page, add log entry for debugging * fix cookie * replace non-necessary whitespace * . Co-authored-by: CaCO3 <caco@ruinelli.ch> * Don't autofail if NTP server can't be reached during initalization (#1498) This fixes an issue with a restricted network without internet access, where the hardcoded ntp server can't be reached and thus the esp resets, as it's not able to finish initalization. * Update Changelog.md * Update Changelog.md for release * Fix for securing wlan.ini (#1509) * Fix for securing wlan.ini * Fixing error with ' instead of " * Changing to errorcode 403 * maybe strcmp instead of regular == Co-authored-by: Pär Hedberg <par.hedberg@nordicmedtest.se> * Update Web-Installer * solves #1530 (#1531) * Refactor JSON (#1518) * use correct log level * corrected logging * typo * refactored JSON generagion: removed unused parameters, consolidated into singel function, added "pre" * Wrapped 'rate' into double quotes, like all other JSON values Co-authored-by: CaCO3 <caco@ruinelli.ch> * Various corrections (#1519) * use correct log level * corrected logging * typo * add release to webinstaller * changed logs, added INFO log of raw, value, error * . Co-authored-by: CaCO3 <caco@ruinelli.ch> * Prevent auto restart on cam framebuffer init error (#1522) * use correct log level * revert autorestart on camera framebuffer init error * . Co-authored-by: CaCO3 <caco@ruinelli.ch> * #1524 - ensure the recognized digit is less than 10 (#1525) * fix kernel panic (vector out of range) in getReadoutRawString * fix key of caches * fix key of caches * fix key caches * fix cache keys * fix cache keys * move set variables to top * debug * fix key * testing * try fix changelog * test * Update Changelog.md for release * Revert "Update Changelog.md for release" This reverts commit4f51ec7962. * remove testing * fix release creation * testing * Update Changelog.md for release * test * Revert "Merge branch 'master' of https://github.com/haverland/AI-on-the-edge-device" This reverts commitf68695a4c0, reversing changes made toa096cf7182. * Revert "test" This reverts commita096cf7182. * revert testing * #1524 - ensure the result of ZeigerEvalHybridNeu is <10 * Fix late digit transition #1503 Co-authored-by: github-actions <github-actions@github.com> * only use sntp_getservername() after init sntp * set default NTP server on dnew installations Co-authored-by: CaCO3 <caco@ruinelli.ch> Co-authored-by: Ralf Rachinger <git@ralfrachinger.de> Co-authored-by: jomjol <30766535+jomjol@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: parhedberg <par.hedberg@gmail.com> Co-authored-by: Pär Hedberg <par.hedberg@nordicmedtest.se> Co-authored-by: Christopher Fenner <9592452+CFenner@users.noreply.github.com> Co-authored-by: Frank Haverland <fspapaping@googlemail.com> * Renamed variables and added debug log (#1537) * add debug logs * renamed variables * renamed TAGs, added flow status logging * . * . Co-authored-by: CaCO3 <caco@ruinelli.ch> * replaced printf usage in LogFile.WriteToFile() * ENABLE_MQTT c++ macro definition (#1546) * macro * 2 * 2 * delete jomjol_mqtt from CMakeLists * mqtt macro * final * ENABLE_INFLUXDB c++ macro definition (#1547) * macro * 2 * 2 * delete jomjol_mqtt from CMakeLists * mqtt macro * final * ENABLE_INFLUXDB c++ macro definition * Update Changelog.md Co-authored-by: parhedberg <par.hedberg@gmail.com> Co-authored-by: Pär Hedberg <par.hedberg@nordicmedtest.se> Co-authored-by: jomjol <30766535+jomjol@users.noreply.github.com> Co-authored-by: Christopher Fenner <9592452+CFenner@users.noreply.github.com> Co-authored-by: CaCO3 <caco@ruinelli.ch> Co-authored-by: Frank Haverland <fspapaping@googlemail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Ralf Rachinger <git@ralfrachinger.de> Co-authored-by: Nicolas Liaudat <nliaudat@users.noreply.github.com> * Update Changelog.md for release Co-authored-by: parhedberg <par.hedberg@gmail.com> Co-authored-by: Pär Hedberg <par.hedberg@nordicmedtest.se> Co-authored-by: jomjol <30766535+jomjol@users.noreply.github.com> Co-authored-by: Christopher Fenner <9592452+CFenner@users.noreply.github.com> Co-authored-by: CaCO3 <caco@ruinelli.ch> Co-authored-by: Frank Haverland <fspapaping@googlemail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Ralf Rachinger <git@ralfrachinger.de> Co-authored-by: Nicolas Liaudat <nliaudat@users.noreply.github.com> * new model version (#1619) * fix kernel panic (vector out of range) in getReadoutRawString * fix key of caches * fix key of caches * fix key caches * fix cache keys * fix cache keys * move set variables to top * debug * fix key * testing * try fix changelog * test * Update Changelog.md for release * Revert "Update Changelog.md for release" This reverts commit4f51ec7962. * remove testing * fix release creation * testing * Update Changelog.md for release * test * Revert "Merge branch 'master' of https://github.com/haverland/AI-on-the-edge-device" This reverts commitf68695a4c0, reversing changes made toa096cf7182. * Revert "test" This reverts commita096cf7182. * revert testing * #1524 - ensure the result of ZeigerEvalHybridNeu is <10 * Fix late digit transition #1503 * only initial_esp32_setup and update.zip as artefacts * remove unneeded cache * rename step ota-v2 to ota * rename ota-v2 to ota * new models - ana-class100 v1.5.4 - ana-cont-11.0.4 - dig-class100 v1.5.0 Co-authored-by: github-actions <github-actions@github.com> * Update Changelog.md (#1630) * Correct RenameNumber * Update Changelog.md * Fix reloading of data file (#1635) * Update data.html * fixed * show link to graph Co-authored-by: CaCO3 <caco@ruinelli.ch> Co-authored-by: parhedberg <par.hedberg@gmail.com> Co-authored-by: Pär Hedberg <par.hedberg@nordicmedtest.se> Co-authored-by: jomjol <30766535+jomjol@users.noreply.github.com> Co-authored-by: Christopher Fenner <9592452+CFenner@users.noreply.github.com> Co-authored-by: CaCO3 <caco@ruinelli.ch> Co-authored-by: Frank Haverland <fspapaping@googlemail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Ralf Rachinger <git@ralfrachinger.de> Co-authored-by: Nicolas Liaudat <nliaudat@users.noreply.github.com> Co-authored-by: Slider0007 <115730895+Slider0007@users.noreply.github.com> Co-authored-by: smartboart <38385805+smartboart@users.noreply.github.com>
This commit is contained in:
36
.github/label-commenter-config.yml
vendored
Normal file
36
.github/label-commenter-config.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# Reply Bot Configuration
|
||||||
|
# See https://github.com/peaceiris/actions-label-commenter
|
||||||
|
|
||||||
|
labels:
|
||||||
|
#######################################################################
|
||||||
|
# Bot Response: Web Console
|
||||||
|
#######################################################################
|
||||||
|
- name: bot-reply Web Console
|
||||||
|
labeled:
|
||||||
|
issue:
|
||||||
|
body: |
|
||||||
|
You can use the [Web Console](https://jomjol.github.io/AI-on-the-edge-device/index.html) to get USB log from the device.
|
||||||
|
The USB log contains more information about the startup and operation of the device than the normal Web UI log
|
||||||
|
discussion:
|
||||||
|
body: |
|
||||||
|
You can use the [Web Console](https://jomjol.github.io/AI-on-the-edge-device/index.html) to get USB log from the device.
|
||||||
|
The USB log contains more information about the startup and operation of the device than the normal Web UI log
|
||||||
|
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# Bot Response: Rolling Build
|
||||||
|
#######################################################################
|
||||||
|
- name: bot-reply Rolling Build
|
||||||
|
labeled:
|
||||||
|
issue:
|
||||||
|
body: |
|
||||||
|
You can use the latest [Automatic Build](https://github.com/jomjol/AI-on-the-edge-device/actions/workflows/build.yaml?query=branch%3Arolling) of the the `rolling` branch. It might already contain a fix for your issue.
|
||||||
|
Pick the most top passing entry (it has a green circle with a tick in it), then scoll down to the **Artifacts** and download the file named `update_*`.
|
||||||
|
discussion:
|
||||||
|
body: |
|
||||||
|
You can use the latest [Automatic Build](https://github.com/jomjol/AI-on-the-edge-device/actions/workflows/build.yaml?query=branch%3Arolling) of the the `rolling` branch. It might already contain a fix for your issue.
|
||||||
|
Pick the most top passing entry (it has a green circle with a tick in it), then scoll down to the **Artifacts** and download the file named `update_*`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
91
.github/workflows/build.yaml
vendored
91
.github/workflows/build.yaml
vendored
@@ -54,60 +54,10 @@ jobs:
|
|||||||
key: ${{ github.run_number }}
|
key: ${{ github.run_number }}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
## Pack for old OTA (v1)
|
## Pack for new OTA
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
pack-for-OTA-v1:
|
pack-for-OTA:
|
||||||
# Old OTA concept
|
|
||||||
# firmware__*.zip needs to be unpacked before attaching to the release!
|
|
||||||
# The bin filename can contain versioning.
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Get generated files from cache
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
./code/.pio/build/esp32cam/firmware.bin
|
|
||||||
./code/.pio/build/esp32cam/partitions.bin
|
|
||||||
./code/.pio/build/esp32cam/bootloader.bin
|
|
||||||
./sd-card/html/version.txt
|
|
||||||
key: ${{ github.run_number }}
|
|
||||||
|
|
||||||
- name: Set Variables
|
|
||||||
id: vars
|
|
||||||
run: |
|
|
||||||
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
|
||||||
echo "branch=$(echo ${{ github.ref_name }} | tr / __)" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Rename firmware file to contain versioning (old ota)
|
|
||||||
run: |
|
|
||||||
mkdir -p ./dist_old_ota
|
|
||||||
cp "./code/.pio/build/esp32cam/firmware.bin" "./dist_old_ota/firmware__${{ steps.vars.outputs.branch }}_(${{ steps.vars.outputs.sha_short }}).bin"
|
|
||||||
|
|
||||||
- name: Upload Firmware artifact (old OTA concept)
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
# name: "firmware__${{ github.ref_name }}__(${{ steps.vars.outputs.sha_short }})__(extract_before_upload__only_needed_for_migration_from_11.3.1)"
|
|
||||||
name: "firmware__(extract_before_upload)__${{ steps.vars.outputs.branch }}__(${{ steps.vars.outputs.sha_short }})"
|
|
||||||
path: ./dist_old_ota/*
|
|
||||||
|
|
||||||
- name: Upload Web interface artifact (old OTA concept)
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: "html__${{ steps.vars.outputs.branch }}__(${{ steps.vars.outputs.sha_short }})"
|
|
||||||
path: ./sd-card/html/*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#########################################################################################
|
|
||||||
## Pack for new OTA (v2)
|
|
||||||
#########################################################################################
|
|
||||||
pack-for-OTA-v2:
|
|
||||||
# New OTA concept
|
# New OTA concept
|
||||||
# update__version.zip file with following content:
|
# update__version.zip file with following content:
|
||||||
# - /firmware.bin
|
# - /firmware.bin
|
||||||
@@ -140,21 +90,9 @@ jobs:
|
|||||||
mkdir -p ./dist
|
mkdir -p ./dist
|
||||||
cp "./code/.pio/build/esp32cam/firmware.bin" "dist/firmware.bin"
|
cp "./code/.pio/build/esp32cam/firmware.bin" "dist/firmware.bin"
|
||||||
|
|
||||||
# - name: Upload update.zip Artifact (Firmware only)
|
|
||||||
# uses: actions/upload-artifact@v3
|
|
||||||
# with:
|
|
||||||
# name: "update_firmware_only__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }})"
|
|
||||||
# path: ./dist/*
|
|
||||||
|
|
||||||
- name: Add Web UI to dist
|
- name: Add Web UI to dist
|
||||||
run: cp -r ./sd-card/html ./dist/
|
run: cp -r ./sd-card/html ./dist/
|
||||||
|
|
||||||
# - name: Upload update.zip artifact (Firmware + Web UI)
|
|
||||||
# uses: actions/upload-artifact@v3
|
|
||||||
# with:
|
|
||||||
# name: "update_firmware+webinterface__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }})"
|
|
||||||
# path: ./dist/*
|
|
||||||
|
|
||||||
- name: Add CNN to dist
|
- name: Add CNN to dist
|
||||||
run: |
|
run: |
|
||||||
mkdir ./dist/config/
|
mkdir ./dist/config/
|
||||||
@@ -171,7 +109,7 @@ jobs:
|
|||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: dist
|
path: dist
|
||||||
key: ${{ github.run_number }}-pack-for-OTA-v2
|
key: ${{ github.run_number }}-pack-for-OTA
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -235,7 +173,7 @@ jobs:
|
|||||||
#########################################################################################
|
#########################################################################################
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [pack-for-OTA-v2, pack-for-fresh-install]
|
needs: [pack-for-OTA, pack-for-fresh-install]
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -245,22 +183,12 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Get generated files from cache
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
./code/.pio/build/esp32cam/firmware.bin
|
|
||||||
./code/.pio/build/esp32cam/partitions.bin
|
|
||||||
./code/.pio/build/esp32cam/bootloader.bin
|
|
||||||
./sd-card/html/version.txt
|
|
||||||
key: ${{ github.run_number }}
|
|
||||||
|
|
||||||
# import the changes from
|
# import the changes from
|
||||||
- name: Get generated files from cache
|
- name: Get generated files from cache
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: dist
|
path: dist
|
||||||
key: ${{ github.run_number }}-pack-for-OTA-v2
|
key: ${{ github.run_number }}-pack-for-OTA
|
||||||
|
|
||||||
# import cached artifacts from pack-for-fresh-install
|
# import cached artifacts from pack-for-fresh-install
|
||||||
- name: Get generated files from cache
|
- name: Get generated files from cache
|
||||||
@@ -269,23 +197,16 @@ jobs:
|
|||||||
path: firmware
|
path: firmware
|
||||||
key: ${{ github.run_number }}-pack-for-fresh-install
|
key: ${{ github.run_number }}-pack-for-fresh-install
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- name: Prepare artifacts for release
|
- name: Prepare artifacts for release
|
||||||
run: |
|
run: |
|
||||||
mkdir -p release
|
mkdir -p release
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
# create a update.zip like "update__rolling"
|
# create a update.zip like "update__rolling"
|
||||||
pwd
|
pwd
|
||||||
ls ./dist
|
|
||||||
cd ./dist
|
cd ./dist
|
||||||
zip -r ../release/update.zip .
|
zip -r ../release/update.zip .
|
||||||
cd ../firmware
|
cd ../firmware
|
||||||
zip -r ../release/initial_esp32_setup.zip .
|
zip -r ../release/initial_esp32_setup.zip .
|
||||||
cd ../sd-card/html
|
|
||||||
zip -r ../../firmware/html-from-11.3.1.zip .
|
|
||||||
|
|
||||||
|
|
||||||
# extract the version used in next step
|
# extract the version used in next step
|
||||||
- id: get_version
|
- id: get_version
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
@@ -318,8 +239,6 @@ jobs:
|
|||||||
body: ${{ steps.extract-release-notes.outputs.release_notes }}
|
body: ${{ steps.extract-release-notes.outputs.release_notes }}
|
||||||
files: |
|
files: |
|
||||||
release/*
|
release/*
|
||||||
firmware/firmware.bin
|
|
||||||
firmware/html-from-11.3.1.zip
|
|
||||||
|
|
||||||
|
|
||||||
# Commit&Push Changelog to master branch. Must be manually merged back to rolling
|
# Commit&Push Changelog to master branch. Must be manually merged back to rolling
|
||||||
|
|||||||
42
.github/workflows/reply-bot.yml
vendored
Normal file
42
.github/workflows/reply-bot.yml
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# Reply Bot
|
||||||
|
# It uses the configuration in .github/label-commenter-config.yml
|
||||||
|
# See https://github.com/peaceiris/actions-label-commenter
|
||||||
|
|
||||||
|
name: Reply-Bot
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [labeled]
|
||||||
|
discussion:
|
||||||
|
types: [labeled]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
issues: write
|
||||||
|
pull-requests: write
|
||||||
|
discussions: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
comment:
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Remove 'Web Console' label again (issues only)
|
||||||
|
if: github.event.label.name == 'bot-reply Web Console'
|
||||||
|
uses: actions-cool/issues-helper@v2
|
||||||
|
with:
|
||||||
|
actions: 'remove-labels'
|
||||||
|
labels: 'bot-reply Web Console'
|
||||||
|
|
||||||
|
- name: Remove 'Rolling Build' label again (issues only)
|
||||||
|
if: github.event.label.name == 'bot-reply Rolling Build'
|
||||||
|
uses: actions-cool/issues-helper@v2
|
||||||
|
with:
|
||||||
|
actions: 'remove-labels'
|
||||||
|
labels: 'bot-reply Rolling Build'
|
||||||
|
|
||||||
|
- name: Write Response
|
||||||
|
uses: peaceiris/actions-label-commenter@c2d00660c86f2b9ed0fb35b372c451558eba85b3
|
||||||
|
with:
|
||||||
|
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
43
Changelog.md
43
Changelog.md
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
## [13.0.7] - 2022-12-11
|
## [13.0.7] 2022-12-11
|
||||||
|
|
||||||
**Home Assistant MQTT Discovery Support**
|
**Home Assistant MQTT Discovery Support**
|
||||||
|
|
||||||
### Update Procedure
|
### Update Procedure
|
||||||
|
|
||||||
:bangbang: **Make sure to read the instructions below carfully!**.
|
:bangbang: **Make sure to read the instructions below carfully!**
|
||||||
|
|
||||||
1. Backup your configuration (use the `System -> Backup/Restore` page)!
|
1. Backup your configuration (use the `System -> Backup/Restore` page)!
|
||||||
|
|
||||||
@@ -19,13 +19,15 @@
|
|||||||
4. Let it restart and check on the `System -> Info` page that the Firmware as well as the Web UI got updated. If only one got updated, redo the update. If it fails several times, you also can update the Firmware and the Web UI separately.
|
4. Let it restart and check on the `System -> Info` page that the Firmware as well as the Web UI got updated. If only one got updated, redo the update. If it fails several times, you also can update the Firmware and the Web UI separately.
|
||||||
|
|
||||||
5. Safe way:
|
5. Safe way:
|
||||||
1. Update first the `firmware.bin` (extract from zip file) and do the Reboot
|
1. Update first the `firmware.bin` (extract it from one of the provided zip files) and do the Reboot
|
||||||
2. Update with the full zip file (`update-*.zip`, ignore the version warning after the reboot)
|
2. Update with the full zip file (`update-*.zip`, ignore the version warning after the reboot)
|
||||||
|
|
||||||
6. Please go to `Settings -> Configuration` and address the changed parameters:
|
6. Please go to `Settings -> Configuration` and address the changed parameters:
|
||||||
- DataLogging (storing the values for data graph)
|
- DataLogging (storing the values for data graph)
|
||||||
- Debug (extended by different debug reporting levels)
|
- Debug (extended by different debug reporting levels)
|
||||||
|
|
||||||
|
7. Make sure it starts to do the digitalization (check the Error field on the overview page). If it does not start a round within a minute, restart the device.
|
||||||
|
|
||||||
If anything breaks you can try to enforce manual update as following:
|
If anything breaks you can try to enforce manual update as following:
|
||||||
|
|
||||||
**OTA:**
|
**OTA:**
|
||||||
@@ -65,10 +67,17 @@ If anything breaks you can try to enforce manual update as following:
|
|||||||
- NEW v13.0.2: Update Tool "Logfile downloader and combiner" to handle the new csv file format.
|
- NEW v13.0.2: Update Tool "Logfile downloader and combiner" to handle the new csv file format.
|
||||||
- NEW v13.0.2: MQTT: Added MQTT topic `status` (Digitalization Status), Timezone to MQTT topic `timestamp`.#
|
- NEW v13.0.2: MQTT: Added MQTT topic `status` (Digitalization Status), Timezone to MQTT topic `timestamp`.#
|
||||||
- NEW v13.0.2: Logging: Disable heap logs by default, cleanup
|
- NEW v13.0.2: Logging: Disable heap logs by default, cleanup
|
||||||
- **NEW v13.0.5**:
|
- NEW v13.0.7:
|
||||||
- log NTP server name
|
- log NTP server name
|
||||||
- Improved log messages
|
- Improved log messages
|
||||||
- Various preparations for next release
|
- Various preparations for next release
|
||||||
|
- **NEW v13.0.8**:
|
||||||
|
- Continue booting on PSRAM issues, Web UI will show an error
|
||||||
|
- Updated models
|
||||||
|
- Various UI enhancements
|
||||||
|
- Various internal improvements
|
||||||
|
- Show uptime in log
|
||||||
|
- Show uptime and round on overview page
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
@@ -84,13 +93,19 @@ If anything breaks you can try to enforce manual update as following:
|
|||||||
- NEW v13.0.3: Re-updated build environment to v5.2.0 (from accidental downgrad to v4.4.0)
|
- NEW v13.0.3: Re-updated build environment to v5.2.0 (from accidental downgrad to v4.4.0)
|
||||||
- NEW v13.0.4: Fix for reboot in case of MQTT not used
|
- NEW v13.0.4: Fix for reboot in case of MQTT not used
|
||||||
- NEW v13.0.5: No reboot in case of missing NTP-connection
|
- NEW v13.0.5: No reboot in case of missing NTP-connection
|
||||||
- **NEW v13.0.5**:
|
- NEW v13.0.7:
|
||||||
- Prevent autoreboot on cam framebuffer init error
|
- Prevent autoreboot on cam framebuffer init error
|
||||||
- Properly protect `wlan.ini` against deletion
|
- Properly protect `wlan.ini` against deletion
|
||||||
- Fixed various MQTT topic content issues
|
- Fixed various MQTT topic content issues
|
||||||
- Fix Digit detected as 10 (<https://github.com/jomjol/AI-on-the-edge-device/pull/1525>)
|
- Fix Digit detected as 10 (https://github.com/jomjol/AI-on-the-edge-device/pull/1525)
|
||||||
- Fix frozen time in datafile on error
|
- Fix frozen time in datafile on error
|
||||||
- Various minor fixes
|
- Various minor fixes
|
||||||
|
- **NEW v13.0.8**:
|
||||||
|
- Fix Rate Problem ([#1578](https://github.com/jomjol/AI-on-the-edge-device/issues/1578), [#1572](https://github.com/jomjol/AI-on-the-edge-device/issues/1572))
|
||||||
|
- Stabilized MQTT
|
||||||
|
- Fixed redundant calls in OTA
|
||||||
|
- Block REST API calls till resource is ready
|
||||||
|
- Fixed number renaming ([#1635](https://github.com/jomjol/AI-on-the-edge-device/issues/1635))
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,14 @@
|
|||||||
|
|
||||||
|
|
||||||
____
|
____
|
||||||
|
#### #34 implement state and Roi for water leak detection
|
||||||
|
for example see Roi on the next picture..
|
||||||
|

|
||||||
|
in case of position change between the measurments set this state to true, if there is no change set it back to false.
|
||||||
|
In a defined time window this movement can lead into an alarm state / water leak..
|
||||||
|
haveing this state in the mqtt broker can trigger functions like closing the ater pipe walve and so on...
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### #33 Implement MATTER protocoll
|
#### #33 Implement MATTER protocoll
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,9 @@ There are different ways to flash your ESP32:
|
|||||||
|
|
||||||
See the [Wiki](https://github.com/jomjol/AI-on-the-edge-device/wiki/Installation) for more information.
|
See the [Wiki](https://github.com/jomjol/AI-on-the-edge-device/wiki/Installation) for more information.
|
||||||
|
|
||||||
|
### Flashing the SD-Card
|
||||||
|
The SD-Card must be flashed separately, see the [Wiki](https://github.com/jomjol/AI-on-the-edge-device/wiki/Installation) for details.
|
||||||
|
|
||||||
## Casing
|
## Casing
|
||||||
|
|
||||||
A 3d-printable housing can be found here:
|
A 3d-printable housing can be found here:
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ static size_t jpg_encode_stream(void * arg, size_t index, const void* data, size
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CCamera::SetBrightnessContrastSaturation(int _brightness, int _contrast, int _saturation)
|
bool CCamera::SetBrightnessContrastSaturation(int _brightness, int _contrast, int _saturation)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
@@ -281,7 +282,6 @@ void CCamera::EnableAutoExposure(int flashdauer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay)
|
esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay)
|
||||||
{
|
{
|
||||||
string ftype;
|
string ftype;
|
||||||
@@ -543,6 +543,7 @@ esp_err_t CCamera::CaptureToHTTP(httpd_req_t *req, int delay)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CCamera::LightOnOff(bool status)
|
void CCamera::LightOnOff(bool status)
|
||||||
{
|
{
|
||||||
GpioHandler* gpioHandler = gpio_handler_get();
|
GpioHandler* gpioHandler = gpio_handler_get();
|
||||||
@@ -578,6 +579,7 @@ void CCamera::LightOnOff(bool status)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CCamera::LEDOnOff(bool status)
|
void CCamera::LEDOnOff(bool status)
|
||||||
{
|
{
|
||||||
// Init the GPIO
|
// Init the GPIO
|
||||||
@@ -638,6 +640,7 @@ void CCamera::GetCameraParameter(httpd_req_t *req, int &qual, framesize_t &resol
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
framesize_t CCamera::TextToFramesize(const char * _size)
|
framesize_t CCamera::TextToFramesize(const char * _size)
|
||||||
{
|
{
|
||||||
if (strcmp(_size, "QVGA") == 0)
|
if (strcmp(_size, "QVGA") == 0)
|
||||||
@@ -669,6 +672,7 @@ CCamera::CCamera()
|
|||||||
ledc_init();
|
ledc_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t CCamera::InitCam()
|
esp_err_t CCamera::InitCam()
|
||||||
{
|
{
|
||||||
ESP_LOGD(TAG, "Init Camera");
|
ESP_LOGD(TAG, "Init Camera");
|
||||||
@@ -682,9 +686,11 @@ esp_err_t CCamera::InitCam()
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CameraInitSuccessful = true;
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CCamera::SetLEDIntensity(float _intrel)
|
void CCamera::SetLEDIntensity(float _intrel)
|
||||||
{
|
{
|
||||||
_intrel = min(_intrel, (float) 100);
|
_intrel = min(_intrel, (float) 100);
|
||||||
@@ -694,3 +700,9 @@ void CCamera::SetLEDIntensity(float _intrel)
|
|||||||
ESP_LOGD(TAG, "Set led_intensity to %d of 8191", led_intensity);
|
ESP_LOGD(TAG, "Set led_intensity to %d of 8191", led_intensity);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool CCamera::getCameraInitSuccessful()
|
||||||
|
{
|
||||||
|
return CameraInitSuccessful;
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class CCamera {
|
|||||||
int led_intensity = 4095;
|
int led_intensity = 4095;
|
||||||
|
|
||||||
void ledc_init(void);
|
void ledc_init(void);
|
||||||
|
bool CameraInitSuccessful = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int image_height, image_width;
|
int image_height, image_width;
|
||||||
@@ -42,6 +43,7 @@ class CCamera {
|
|||||||
void SetLEDIntensity(float _intrel);
|
void SetLEDIntensity(float _intrel);
|
||||||
|
|
||||||
void EnableAutoExposure(int flashdauer);
|
void EnableAutoExposure(int flashdauer);
|
||||||
|
bool getCameraInitSuccessful();
|
||||||
|
|
||||||
|
|
||||||
framesize_t TextToFramesize(const char * text);
|
framesize_t TextToFramesize(const char * text);
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ char scratch2[SCRATCH_BUFSIZE2];
|
|||||||
//#define DEBUG_DETAIL_ON
|
//#define DEBUG_DETAIL_ON
|
||||||
|
|
||||||
|
|
||||||
void PowerResetCamera(){
|
void PowerResetCamera()
|
||||||
|
{
|
||||||
ESP_LOGD(TAG, "Resetting camera by power down line");
|
ESP_LOGD(TAG, "Resetting camera by power down line");
|
||||||
gpio_config_t conf;
|
gpio_config_t conf;
|
||||||
conf.intr_type = GPIO_INTR_DISABLE;
|
conf.intr_type = GPIO_INTR_DISABLE;
|
||||||
@@ -37,182 +38,223 @@ void PowerResetCamera(){
|
|||||||
|
|
||||||
esp_err_t handler_lightOn(httpd_req_t *req)
|
esp_err_t handler_lightOn(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_lightOn - Start");
|
LogFile.WriteHeapInfo("handler_lightOn - Start");
|
||||||
ESP_LOGD(TAG, "handler_lightOn uri: %s", req->uri);
|
ESP_LOGD(TAG, "handler_lightOn uri: %s", req->uri);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Camera.LightOnOff(true);
|
if (Camera.getCameraInitSuccessful())
|
||||||
const char* resp_str = (const char*) req->user_ctx;
|
{
|
||||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
Camera.LightOnOff(true);
|
||||||
|
const char* resp_str = (const char*) req->user_ctx;
|
||||||
|
httpd_resp_send(req, resp_str, strlen(resp_str));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
httpd_resp_send_err(req, HTTPD_403_FORBIDDEN, "Camera Light On API not yet initialized. Please retry later...");
|
||||||
|
return ESP_ERR_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_lightOn - Done");
|
LogFile.WriteHeapInfo("handler_lightOn - Done");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_lightOff(httpd_req_t *req)
|
esp_err_t handler_lightOff(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_lightOff - Start");
|
LogFile.WriteHeapInfo("handler_lightOff - Start");
|
||||||
ESP_LOGD(TAG, "handler_lightOff uri: %s", req->uri);
|
ESP_LOGD(TAG, "handler_lightOff uri: %s", req->uri);
|
||||||
#endif
|
#endif
|
||||||
Camera.LightOnOff(false);
|
|
||||||
const char* resp_str = (const char*) req->user_ctx;
|
|
||||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
if (Camera.getCameraInitSuccessful())
|
||||||
LogFile.WriteHeapInfo("handler_lightOff - Done");
|
{
|
||||||
#endif
|
Camera.LightOnOff(false);
|
||||||
|
const char* resp_str = (const char*) req->user_ctx;
|
||||||
|
httpd_resp_send(req, resp_str, strlen(resp_str));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
httpd_resp_send_err(req, HTTPD_403_FORBIDDEN, "Camera Light Off API not yet initialized. Please retry later...");
|
||||||
|
return ESP_ERR_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_lightOff - Done");
|
||||||
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_capture(httpd_req_t *req)
|
esp_err_t handler_capture(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_capture - Start");
|
LogFile.WriteHeapInfo("handler_capture - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int quality;
|
if (Camera.getCameraInitSuccessful())
|
||||||
framesize_t res;
|
{
|
||||||
|
int quality;
|
||||||
|
framesize_t res;
|
||||||
|
|
||||||
Camera.GetCameraParameter(req, quality, res);
|
Camera.GetCameraParameter(req, quality, res);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "Size: %d, Quality: %d", res, quality);
|
ESP_LOGD(TAG, "Size: %d, Quality: %d", res, quality);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Camera.SetQualitySize(quality, res);
|
Camera.SetQualitySize(quality, res);
|
||||||
|
|
||||||
esp_err_t ressult;
|
esp_err_t result;
|
||||||
ressult = Camera.CaptureToHTTP(req);
|
result = Camera.CaptureToHTTP(req);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_capture - Done");
|
LogFile.WriteHeapInfo("handler_capture - Done");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ressult;
|
return result;
|
||||||
};
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
httpd_resp_send_err(req, HTTPD_403_FORBIDDEN, "Camera Capture API not yet initialized. Please retry later...");
|
||||||
|
return ESP_ERR_NOT_FOUND;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_capture_with_ligth(httpd_req_t *req)
|
esp_err_t handler_capture_with_ligth(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_capture_with_ligth - Start");
|
LogFile.WriteHeapInfo("handler_capture_with_ligth - Start");
|
||||||
#endif
|
#endif
|
||||||
char _query[100];
|
|
||||||
char _delay[10];
|
|
||||||
|
|
||||||
int quality;
|
if (Camera.getCameraInitSuccessful())
|
||||||
framesize_t res;
|
|
||||||
int delay = 2500;
|
|
||||||
|
|
||||||
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
|
||||||
{
|
{
|
||||||
ESP_LOGD(TAG, "Query: %s", _query);
|
char _query[100];
|
||||||
if (httpd_query_key_value(_query, "delay", _delay, 10) == ESP_OK)
|
char _delay[10];
|
||||||
|
|
||||||
|
int quality;
|
||||||
|
framesize_t res;
|
||||||
|
int delay = 2500;
|
||||||
|
|
||||||
|
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
ESP_LOGD(TAG, "Query: %s", _query);
|
||||||
ESP_LOGD(TAG, "Delay: %s", _delay);
|
if (httpd_query_key_value(_query, "delay", _delay, 10) == ESP_OK)
|
||||||
#endif
|
{
|
||||||
delay = atoi(_delay);
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
ESP_LOGD(TAG, "Delay: %s", _delay);
|
||||||
|
#endif
|
||||||
|
delay = atoi(_delay);
|
||||||
|
|
||||||
if (delay < 0)
|
if (delay < 0)
|
||||||
delay = 0;
|
delay = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
Camera.GetCameraParameter(req, quality, res);
|
Camera.GetCameraParameter(req, quality, res);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "Size: %d, Quality: %d", res, quality);
|
ESP_LOGD(TAG, "Size: %d, Quality: %d", res, quality);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Camera.SetQualitySize(quality, res);
|
Camera.SetQualitySize(quality, res);
|
||||||
Camera.LightOnOff(true);
|
Camera.LightOnOff(true);
|
||||||
const TickType_t xDelay = delay / portTICK_PERIOD_MS;
|
const TickType_t xDelay = delay / portTICK_PERIOD_MS;
|
||||||
vTaskDelay( xDelay );
|
vTaskDelay( xDelay );
|
||||||
|
|
||||||
esp_err_t ressult;
|
esp_err_t result;
|
||||||
ressult = Camera.CaptureToHTTP(req);
|
result = Camera.CaptureToHTTP(req);
|
||||||
|
|
||||||
Camera.LightOnOff(false);
|
Camera.LightOnOff(false);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_capture_with_ligth - Done");
|
LogFile.WriteHeapInfo("handler_capture_with_ligth - Done");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ressult;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
httpd_resp_send_err(req, HTTPD_403_FORBIDDEN, "Camera Capture + flashlight API not yet initialized. Please retry later...");
|
||||||
|
return ESP_ERR_NOT_FOUND;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_capture_save_to_file(httpd_req_t *req)
|
esp_err_t handler_capture_save_to_file(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_capture_save_to_file - Start");
|
LogFile.WriteHeapInfo("handler_capture_save_to_file - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char _query[100];
|
if (Camera.getCameraInitSuccessful())
|
||||||
char _delay[10];
|
|
||||||
int delay = 0;
|
|
||||||
char filename[100];
|
|
||||||
std::string fn = "/sdcard/";
|
|
||||||
|
|
||||||
|
|
||||||
int quality;
|
|
||||||
framesize_t res;
|
|
||||||
|
|
||||||
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
|
||||||
{
|
{
|
||||||
ESP_LOGD(TAG, "Query: %s", _query);
|
char _query[100];
|
||||||
if (httpd_query_key_value(_query, "filename", filename, 100) == ESP_OK)
|
char _delay[10];
|
||||||
|
int delay = 0;
|
||||||
|
char filename[100];
|
||||||
|
std::string fn = "/sdcard/";
|
||||||
|
|
||||||
|
|
||||||
|
int quality;
|
||||||
|
framesize_t res;
|
||||||
|
|
||||||
|
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
||||||
{
|
{
|
||||||
fn.append(filename);
|
ESP_LOGD(TAG, "Query: %s", _query);
|
||||||
#ifdef DEBUG_DETAIL_ON
|
if (httpd_query_key_value(_query, "filename", filename, 100) == ESP_OK)
|
||||||
ESP_LOGD(TAG, "Filename: %s", fn.c_str());
|
{
|
||||||
#endif
|
fn.append(filename);
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
ESP_LOGD(TAG, "Filename: %s", fn.c_str());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fn.append("noname.jpg");
|
||||||
|
|
||||||
|
if (httpd_query_key_value(_query, "delay", _delay, 10) == ESP_OK)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
ESP_LOGD(TAG, "Delay: %s", _delay);
|
||||||
|
#endif
|
||||||
|
delay = atoi(_delay);
|
||||||
|
|
||||||
|
if (delay < 0)
|
||||||
|
delay = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fn.append("noname.jpg");
|
fn.append("noname.jpg");
|
||||||
|
|
||||||
if (httpd_query_key_value(_query, "delay", _delay, 10) == ESP_OK)
|
Camera.GetCameraParameter(req, quality, res);
|
||||||
{
|
#ifdef DEBUG_DETAIL_ON
|
||||||
#ifdef DEBUG_DETAIL_ON
|
ESP_LOGD(TAG, "Size: %d, Quality: %d", res, quality);
|
||||||
ESP_LOGD(TAG, "Delay: %s", _delay);
|
#endif
|
||||||
#endif
|
Camera.SetQualitySize(quality, res);
|
||||||
delay = atoi(_delay);
|
|
||||||
|
|
||||||
if (delay < 0)
|
esp_err_t result;
|
||||||
delay = 0;
|
result = Camera.CaptureToFile(fn, delay);
|
||||||
}
|
|
||||||
|
|
||||||
|
const char* resp_str = (const char*) fn.c_str();
|
||||||
|
httpd_resp_send(req, resp_str, strlen(resp_str));
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_capture_save_to_file - Done");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fn.append("noname.jpg");
|
{
|
||||||
|
httpd_resp_send_err(req, HTTPD_403_FORBIDDEN, "Camera Capture + save API not yet initialized. Please retry later...");
|
||||||
Camera.GetCameraParameter(req, quality, res);
|
return ESP_ERR_NOT_FOUND;
|
||||||
#ifdef DEBUG_DETAIL_ON
|
}
|
||||||
ESP_LOGD(TAG, "Size: %d, Quality: %d", res, quality);
|
}
|
||||||
#endif
|
|
||||||
Camera.SetQualitySize(quality, res);
|
|
||||||
|
|
||||||
esp_err_t ressult;
|
|
||||||
ressult = Camera.CaptureToFile(fn, delay);
|
|
||||||
|
|
||||||
const char* resp_str = (const char*) fn.c_str();
|
|
||||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
|
||||||
LogFile.WriteHeapInfo("handler_capture_save_to_file - Done");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ressult;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void register_server_camera_uri(httpd_handle_t server)
|
void register_server_camera_uri(httpd_handle_t server)
|
||||||
|
|||||||
@@ -935,7 +935,11 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st
|
|||||||
|
|
||||||
// Get and print information about each file in the archive.
|
// Get and print information about each file in the archive.
|
||||||
int numberoffiles = (int)mz_zip_reader_get_num_files(&zip_archive);
|
int numberoffiles = (int)mz_zip_reader_get_num_files(&zip_archive);
|
||||||
for (sort_iter = 0; sort_iter < 2; sort_iter++)
|
ESP_LOGI(TAG, "Numbers of files to be extrated: %d", numberoffiles);
|
||||||
|
|
||||||
|
|
||||||
|
sort_iter = 0;
|
||||||
|
// for (sort_iter = 0; sort_iter < 2; sort_iter++)
|
||||||
{
|
{
|
||||||
memset(&zip_archive, 0, sizeof(zip_archive));
|
memset(&zip_archive, 0, sizeof(zip_archive));
|
||||||
status = mz_zip_reader_init_file(&zip_archive, _in_zip_file.c_str(), sort_iter ? MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY : 0);
|
status = mz_zip_reader_init_file(&zip_archive, _in_zip_file.c_str(), sort_iter ? MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY : 0);
|
||||||
|
|||||||
@@ -29,6 +29,9 @@
|
|||||||
#include "server_tflite.h"
|
#include "server_tflite.h"
|
||||||
#include "server_file.h"
|
#include "server_file.h"
|
||||||
#include "server_GPIO.h"
|
#include "server_GPIO.h"
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
|
#include "interface_mqtt.h"
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
|
|
||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
@@ -55,6 +58,18 @@ esp_err_t handler_reboot(httpd_req_t *req);
|
|||||||
std::string _file_name_update;
|
std::string _file_name_update;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void infinite_loop(void)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
ESP_LOGI(TAG, "When a new firmware is available on the server, press the reset button to download it");
|
||||||
|
while(1) {
|
||||||
|
ESP_LOGI(TAG, "Waiting for a new firmware... %d", ++i);
|
||||||
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void task_do_Update_ZIP(void *pvParameter)
|
void task_do_Update_ZIP(void *pvParameter)
|
||||||
{
|
{
|
||||||
std::string filetype = toUpper(getFileType(_file_name_update));
|
std::string filetype = toUpper(getFileType(_file_name_update));
|
||||||
@@ -107,26 +122,14 @@ void CheckUpdate()
|
|||||||
BaseType_t xReturned;
|
BaseType_t xReturned;
|
||||||
int _i = configMINIMAL_STACK_SIZE;
|
int _i = configMINIMAL_STACK_SIZE;
|
||||||
xReturned = xTaskCreate(&task_do_Update_ZIP, "task_do_Update_ZIP", configMINIMAL_STACK_SIZE * 35, NULL, tskIDLE_PRIORITY+1, NULL);
|
xReturned = xTaskCreate(&task_do_Update_ZIP, "task_do_Update_ZIP", configMINIMAL_STACK_SIZE * 35, NULL, tskIDLE_PRIORITY+1, NULL);
|
||||||
TickType_t xDelay;
|
while(1) { // wait until reboot within task_do_Update_ZIP
|
||||||
xDelay = 2000000 / portTICK_PERIOD_MS;
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
ESP_LOGD(TAG, "Wait for Update to be finished: sleep for: %ldms", (long) xDelay);
|
|
||||||
vTaskDelay( xDelay );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void infinite_loop(void)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
ESP_LOGI(TAG, "When a new firmware is available on the server, press the reset button to download it");
|
|
||||||
while(1) {
|
|
||||||
ESP_LOGI(TAG, "Waiting for a new firmware... %d", ++i);
|
|
||||||
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static bool ota_update_task(std::string fn)
|
static bool ota_update_task(std::string fn)
|
||||||
{
|
{
|
||||||
esp_err_t err;
|
esp_err_t err;
|
||||||
@@ -601,6 +604,9 @@ void doReboot(){
|
|||||||
xTaskCreate(&task_reboot, "reboot", configMINIMAL_STACK_SIZE * 64, NULL, 10, NULL);
|
xTaskCreate(&task_reboot, "reboot", configMINIMAL_STACK_SIZE * 64, NULL, 10, NULL);
|
||||||
// KillTFliteTasks(); // kills itself
|
// KillTFliteTasks(); // kills itself
|
||||||
gpio_handler_destroy();
|
gpio_handler_destroy();
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
|
MQTTdestroy_client();
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
vTaskDelay(5000 / portTICK_PERIOD_MS);
|
vTaskDelay(5000 / portTICK_PERIOD_MS);
|
||||||
esp_restart();
|
esp_restart();
|
||||||
hard_restart();
|
hard_restart();
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ void ClassFlowImage::RemoveOldLogs()
|
|||||||
if (!isLogImage)
|
if (!isLogImage)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ESP_LOGI(TAG, "remove old images");
|
ESP_LOGD(TAG, "remove old images");
|
||||||
if (logfileRetentionInDays == 0) {
|
if (logfileRetentionInDays == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ void ClassFlowImage::RemoveOldLogs()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ESP_LOGI(TAG, "Image folder deleted: %d | Image folder not deleted: %d", deleted, notDeleted);
|
ESP_LOGD(TAG, "Image folder deleted: %d | Image folder not deleted: %d", deleted, notDeleted);
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -189,36 +189,26 @@ string ClassFlowMQTT::GetMQTTMainTopic()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ClassFlowMQTT::Start(float AutoIntervall) {
|
bool ClassFlowMQTT::Start(float AutoIntervall)
|
||||||
|
{
|
||||||
// printf("URI: %s, MAINTOPIC: %s", uri.c_str(), maintopic.c_str());
|
|
||||||
|
|
||||||
if ((uri.length() == 0) || (maintopic.length() == 0))
|
|
||||||
{
|
|
||||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "MQTT not started because URI or Maintopic is not set. MQTT will be disabled.");
|
|
||||||
MQTTdisable();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
roundInterval = AutoIntervall; // Minutes
|
roundInterval = AutoIntervall; // Minutes
|
||||||
keepAlive = roundInterval * 60 * 2.5; // Seconds, make sure it is greater thatn 2 rounds!
|
keepAlive = roundInterval * 60 * 2.5; // Seconds, make sure it is greater thatn 2 rounds!
|
||||||
|
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
stream << std::fixed << std::setprecision(1) << "Digitizer interval is " << roundInterval <<
|
stream << std::fixed << std::setprecision(1) << "Digitizer interval is " << roundInterval <<
|
||||||
" minutes => setting MQTT LWT timeout to " << ((float)keepAlive/60) << " minutes.";
|
" minutes => setting MQTT LWT timeout to " << ((float)keepAlive/60) << " minutes.";
|
||||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, stream.str());
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, stream.str());
|
||||||
|
|
||||||
mqttServer_setParameter(flowpostprocessing->GetNumbers(), keepAlive, roundInterval);
|
mqttServer_setParameter(flowpostprocessing->GetNumbers(), keepAlive, roundInterval);
|
||||||
|
|
||||||
MQTT_Configure(uri, clientname, user, password, maintopic, LWT_TOPIC, LWT_CONNECTED, LWT_DISCONNECTED,
|
bool MQTTConfigCheck = MQTT_Configure(uri, clientname, user, password, maintopic, LWT_TOPIC, LWT_CONNECTED,
|
||||||
keepAlive, SetRetainFlag, (void *)&GotConnected);
|
LWT_DISCONNECTED, keepAlive, SetRetainFlag, (void *)&GotConnected);
|
||||||
|
|
||||||
if (!MQTT_Init()) {
|
if (!MQTTConfigCheck) {
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Init at startup failed! Retry with next publish call");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return (MQTT_Init() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -237,7 +227,7 @@ bool ClassFlowMQTT::doFlow(string zwtime)
|
|||||||
|
|
||||||
publishSystemData();
|
publishSystemData();
|
||||||
|
|
||||||
if (flowpostprocessing)
|
if (flowpostprocessing && getMQTTisConnected())
|
||||||
{
|
{
|
||||||
std::vector<NumberPost*>* NUMBERS = flowpostprocessing->GetNumbers();
|
std::vector<NumberPost*>* NUMBERS = flowpostprocessing->GetNumbers();
|
||||||
|
|
||||||
|
|||||||
@@ -707,6 +707,8 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
NUMBERS[j]->ReturnValue = "";
|
NUMBERS[j]->ReturnValue = "";
|
||||||
NUMBERS[j]->ErrorMessageText = "";
|
NUMBERS[j]->ErrorMessageText = "";
|
||||||
NUMBERS[j]->Value = -1;
|
NUMBERS[j]->Value = -1;
|
||||||
|
/* TODO to be discussed, see https://github.com/jomjol/AI-on-the-edge-device/issues/1617 */
|
||||||
|
// NUMBERS[j]->lastvalue = imagetime; // must only be set in case of good value !!! --> move to the end
|
||||||
NUMBERS[j]->lastvalue = imagetime;
|
NUMBERS[j]->lastvalue = imagetime;
|
||||||
|
|
||||||
UpdateNachkommaDecimalShift();
|
UpdateNachkommaDecimalShift();
|
||||||
@@ -764,6 +766,9 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
{
|
{
|
||||||
string _zw = NUMBERS[j]->name + ": Raw: " + NUMBERS[j]->ReturnRawValue + ", Value: " + NUMBERS[j]->ReturnValue + ", Status: " + NUMBERS[j]->ErrorMessageText;
|
string _zw = NUMBERS[j]->name + ": Raw: " + NUMBERS[j]->ReturnRawValue + ", Value: " + NUMBERS[j]->ReturnValue + ", Status: " + NUMBERS[j]->ErrorMessageText;
|
||||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, _zw);
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, _zw);
|
||||||
|
/* TODO to be discussed, see https://github.com/jomjol/AI-on-the-edge-device/issues/1617 */
|
||||||
|
NUMBERS[j]->lastvalue = imagetime;
|
||||||
|
|
||||||
WriteDataLog(j);
|
WriteDataLog(j);
|
||||||
continue; // es gibt keinen Zahl, da noch ein N vorhanden ist.
|
continue; // es gibt keinen Zahl, da noch ein N vorhanden ist.
|
||||||
}
|
}
|
||||||
@@ -848,7 +853,9 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
|
|
||||||
if (abs(_ratedifference) > abs(NUMBERS[j]->MaxRateValue))
|
if (abs(_ratedifference) > abs(NUMBERS[j]->MaxRateValue))
|
||||||
{
|
{
|
||||||
NUMBERS[j]->ErrorMessageText = NUMBERS[j]->ErrorMessageText + "Rate too high - Read: " + RundeOutput(NUMBERS[j]->Value, NUMBERS[j]->Nachkomma) + " - Pre: " + RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma);
|
WriteDataLog(j);
|
||||||
|
|
||||||
|
NUMBERS[j]->ErrorMessageText = NUMBERS[j]->ErrorMessageText + "Rate too high - Read: " + RundeOutput(NUMBERS[j]->Value, NUMBERS[j]->Nachkomma) + " - Pre: " + RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma) + " - Rate: " + RundeOutput(_ratedifference, NUMBERS[j]->Nachkomma);
|
||||||
NUMBERS[j]->Value = NUMBERS[j]->PreValue;
|
NUMBERS[j]->Value = NUMBERS[j]->PreValue;
|
||||||
NUMBERS[j]->ReturnValue = "";
|
NUMBERS[j]->ReturnValue = "";
|
||||||
NUMBERS[j]->ReturnRateValue = "";
|
NUMBERS[j]->ReturnRateValue = "";
|
||||||
@@ -865,6 +872,8 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
NUMBERS[j]->ReturnChangeAbsolute = RundeOutput(NUMBERS[j]->Value - NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma);
|
NUMBERS[j]->ReturnChangeAbsolute = RundeOutput(NUMBERS[j]->Value - NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma);
|
||||||
NUMBERS[j]->PreValue = NUMBERS[j]->Value;
|
NUMBERS[j]->PreValue = NUMBERS[j]->Value;
|
||||||
NUMBERS[j]->PreValueOkay = true;
|
NUMBERS[j]->PreValueOkay = true;
|
||||||
|
NUMBERS[j]->lastvalue = imagetime;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NUMBERS[j]->ReturnValue = RundeOutput(NUMBERS[j]->Value, NUMBERS[j]->Nachkomma);
|
NUMBERS[j]->ReturnValue = RundeOutput(NUMBERS[j]->Value, NUMBERS[j]->Nachkomma);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -35,6 +36,8 @@ static const char* TAG = "HELPER";
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
unsigned int systemStatus = 0;
|
||||||
|
|
||||||
sdmmc_cid_t SDCardCid;
|
sdmmc_cid_t SDCardCid;
|
||||||
sdmmc_csd_t SDCardCsd;
|
sdmmc_csd_t SDCardCsd;
|
||||||
|
|
||||||
@@ -770,6 +773,38 @@ string getMac(void) {
|
|||||||
return macFormated;
|
return macFormated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void setSystemStatusFlag(SystemStatusFlag_t flag) {
|
||||||
|
systemStatus = systemStatus | flag; // set bit
|
||||||
|
|
||||||
|
char buf[20];
|
||||||
|
snprintf(buf, sizeof(buf), "0x%08X", getSystemStatus());
|
||||||
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "New System Status: " + std::string(buf));
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearSystemStatusFlag(SystemStatusFlag_t flag) {
|
||||||
|
systemStatus = systemStatus | ~flag; // clear bit
|
||||||
|
|
||||||
|
char buf[20];
|
||||||
|
snprintf(buf, sizeof(buf), "0x%08X", getSystemStatus());
|
||||||
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "New System Status: " + std::string(buf));
|
||||||
|
}
|
||||||
|
|
||||||
|
int getSystemStatus(void) {
|
||||||
|
return systemStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isSetSystemStatusFlag(SystemStatusFlag_t flag) {
|
||||||
|
//ESP_LOGE(TAG, "Flag (0x%08X) is set (0x%08X): %d", flag, systemStatus , ((systemStatus & flag) == flag));
|
||||||
|
|
||||||
|
if ((systemStatus & flag) == flag) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
string getResetReason(void) {
|
string getResetReason(void) {
|
||||||
std::string reasonText;
|
std::string reasonText;
|
||||||
|
|
||||||
@@ -792,6 +827,30 @@ string getResetReason(void) {
|
|||||||
return reasonText;
|
return reasonText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current uptime formated ad xxf xxh xxm [xxs]
|
||||||
|
*/
|
||||||
|
std::string getFormatedUptime(bool compact) {
|
||||||
|
char buf[20];
|
||||||
|
#pragma GCC diagnostic ignored "-Wformat-truncation"
|
||||||
|
|
||||||
|
int uptime = (uint32_t)(esp_timer_get_time()/1000/1000); // in seconds
|
||||||
|
|
||||||
|
int days = int(floor(uptime / (3600*24)));
|
||||||
|
int hours = int(floor((uptime - days * 3600*24) / (3600)));
|
||||||
|
int minutes = int(floor((uptime - days * 3600*24 - hours * 3600) / (60)));
|
||||||
|
int seconds = uptime - days * 3600*24 - hours * 3600 - minutes * 60;
|
||||||
|
|
||||||
|
if (compact) {
|
||||||
|
snprintf(buf, sizeof(buf), "%dd%02dh%02dm%02ds", days, hours, minutes, seconds);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
snprintf(buf, sizeof(buf), "%3dd %02dh %02dm %02ds", days, hours, minutes, seconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(buf);
|
||||||
|
}
|
||||||
|
|
||||||
const char* get404(void) {
|
const char* get404(void) {
|
||||||
return
|
return
|
||||||
"<pre>\n\n\n\n"
|
"<pre>\n\n\n\n"
|
||||||
|
|||||||
@@ -63,6 +63,28 @@ string getSDCardCapacity();
|
|||||||
string getSDCardSectorSize();
|
string getSDCardSectorSize();
|
||||||
|
|
||||||
string getMac(void);
|
string getMac(void);
|
||||||
|
|
||||||
|
|
||||||
|
/* Error bit fields
|
||||||
|
One bit per error
|
||||||
|
Make sure it matches https://github.com/jomjol/AI-on-the-edge-device/wiki/Error-Codes */
|
||||||
|
enum SystemStatusFlag_t { // One bit per error
|
||||||
|
// First Byte
|
||||||
|
SYSTEM_STATUS_PSRAM_BAD = 1 << 0, // 1, Critical Error
|
||||||
|
SYSTEM_STATUS_HEAP_TOO_SMALL = 1 << 1, // 2, Critical Error
|
||||||
|
SYSTEM_STATUS_CAM_BAD = 1 << 2, // 4, Critical Error
|
||||||
|
|
||||||
|
// Second Byte
|
||||||
|
SYSTEM_STATUS_CAM_FB_BAD = 1 << (0+8), // 8, Flow still might work
|
||||||
|
SYSTEM_STATUS_NTP_BAD = 1 << (1+8), // 9, Flow will work but time will be wrong
|
||||||
|
};
|
||||||
|
|
||||||
|
void setSystemStatusFlag(SystemStatusFlag_t flag);
|
||||||
|
void clearSystemStatusFlag(SystemStatusFlag_t flag);
|
||||||
|
int getSystemStatus(void);
|
||||||
|
bool isSetSystemStatusFlag(SystemStatusFlag_t flag);
|
||||||
|
|
||||||
string getResetReason(void);
|
string getResetReason(void);
|
||||||
|
std::string getFormatedUptime(bool compact);
|
||||||
|
|
||||||
const char* get404(void);
|
const char* get404(void);
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ void ClassLogFile::WriteToDedicatedFile(std::string _fn, esp_log_level_t level,
|
|||||||
{
|
{
|
||||||
FILE* pFile;
|
FILE* pFile;
|
||||||
std::string zwtime;
|
std::string zwtime;
|
||||||
std::string logline = "";
|
std::string ntpTime = "";
|
||||||
|
|
||||||
if (level > loglevel) {// Only write to file if loglevel is below threshold
|
if (level > loglevel) {// Only write to file if loglevel is below threshold
|
||||||
return;
|
return;
|
||||||
@@ -138,7 +138,7 @@ void ClassLogFile::WriteToDedicatedFile(std::string _fn, esp_log_level_t level,
|
|||||||
strftime(buffer, 80, "%Y-%m-%dT%H:%M:%S", timeinfo);
|
strftime(buffer, 80, "%Y-%m-%dT%H:%M:%S", timeinfo);
|
||||||
|
|
||||||
zwtime = std::string(buffer);
|
zwtime = std::string(buffer);
|
||||||
logline = zwtime;
|
ntpTime = zwtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string loglevelString;
|
std::string loglevelString;
|
||||||
@@ -164,10 +164,10 @@ void ClassLogFile::WriteToDedicatedFile(std::string _fn, esp_log_level_t level,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
char uptime[20];
|
std::string formatedUptime = getFormatedUptime(true);
|
||||||
snprintf(uptime, sizeof(uptime), "%8d", (uint32_t)(esp_timer_get_time()/1000/1000)); // in seconds
|
|
||||||
logline = "[" + std::string(uptime) + "] " + logline + "\t<" + loglevelString + ">\t" + message + "\n";
|
ntpTime = "[" + formatedUptime + "] " + ntpTime + "\t<" + loglevelString + ">\t" + message + "\n";
|
||||||
fputs(logline.c_str(), pFile);
|
fputs(ntpTime.c_str(), pFile);
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGE(TAG, "Can't open log file %s", _fn.c_str());
|
ESP_LOGE(TAG, "Can't open log file %s", _fn.c_str());
|
||||||
@@ -298,7 +298,7 @@ void ClassLogFile::RemoveOldLogFile()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Remove old log files");
|
ESP_LOGD(TAG, "Remove old log files");
|
||||||
|
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
struct tm* timeinfo;
|
struct tm* timeinfo;
|
||||||
@@ -350,7 +350,7 @@ void ClassLogFile::RemoveOldDataLog()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Remove old data files");
|
ESP_LOGD(TAG, "Remove old data files");
|
||||||
|
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
struct tm* timeinfo;
|
struct tm* timeinfo;
|
||||||
|
|||||||
@@ -2,4 +2,4 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*)
|
|||||||
|
|
||||||
idf_component_register(SRCS ${app_sources}
|
idf_component_register(SRCS ${app_sources}
|
||||||
INCLUDE_DIRS "."
|
INCLUDE_DIRS "."
|
||||||
REQUIRES tflite-lib mqtt jomjol_tfliteclass jomjol_helper jomjol_mqtt jomjol_wlan)
|
REQUIRES tflite-lib mqtt jomjol_tfliteclass jomjol_helper jomjol_mqtt jomjol_wlan)
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
#include "interface_mqtt.h"
|
#include "interface_mqtt.h"
|
||||||
|
|
||||||
//#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
|
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
#include "connect_wlan.h"
|
||||||
#include "mqtt_client.h"
|
#include "mqtt_client.h"
|
||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
#include "server_tflite.h"
|
#include "server_tflite.h"
|
||||||
@@ -19,85 +19,92 @@ std::map<std::string, std::function<bool(std::string, char*, int)>>* subscribeFu
|
|||||||
|
|
||||||
int failedOnRound = -1;
|
int failedOnRound = -1;
|
||||||
|
|
||||||
bool MQTT_Enabled = true;
|
esp_mqtt_event_id_t esp_mqtt_ID = MQTT_EVENT_ANY;
|
||||||
|
|
||||||
esp_mqtt_event_id_t esp_mmqtt_ID = MQTT_EVENT_ANY;
|
|
||||||
// ESP_EVENT_ANY_ID
|
// ESP_EVENT_ANY_ID
|
||||||
|
|
||||||
|
bool mqtt_enabled = false;
|
||||||
|
bool mqtt_configOK = false;
|
||||||
bool mqtt_initialized = false;
|
bool mqtt_initialized = false;
|
||||||
bool mqtt_connected = false;
|
bool mqtt_connected = false;
|
||||||
|
|
||||||
esp_mqtt_client_handle_t client = NULL;
|
esp_mqtt_client_handle_t client = NULL;
|
||||||
std::string uri, client_id, lwt_topic, lwt_connected, lwt_disconnected, user, password, maintopic;
|
std::string uri, client_id, lwt_topic, lwt_connected, lwt_disconnected, user, password, maintopic;
|
||||||
int keepalive, SetRetainFlag;
|
int keepalive, SetRetainFlag;
|
||||||
void (*callbackOnConnected)(std::string, int) = NULL;
|
void (*callbackOnConnected)(std::string, int) = NULL;
|
||||||
|
|
||||||
|
|
||||||
void MQTTdisable()
|
bool MQTTPublish(std::string _key, std::string _content, int retained_flag)
|
||||||
{
|
{
|
||||||
MQTT_Enabled = false;
|
if (!mqtt_enabled) { // MQTT sevice not started / configured (MQTT_Init not called before)
|
||||||
}
|
return false;
|
||||||
|
|
||||||
bool MQTTPublish(std::string _key, std::string _content, int retained_flag) {
|
|
||||||
int msg_id;
|
|
||||||
std::string zw;
|
|
||||||
|
|
||||||
if (failedOnRound == getCountFlowRounds()) { // we already failed in this round, do not retry until the next round
|
|
||||||
return true; // Fail quietly
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (failedOnRound == getCountFlowRounds()) { // we already failed in this round, do not retry until the next round
|
||||||
|
return true; // Fail quietly
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("MQTT Publish");
|
LogFile.WriteHeapInfo("MQTT Publish");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!mqtt_initialized) {
|
MQTT_Init(); // Re-Init client if not initialized yet/anymore
|
||||||
if (!MQTT_Init()) {
|
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Init failed, skipping all MQTT publishings in this round!");
|
if (mqtt_initialized && mqtt_connected) {
|
||||||
failedOnRound = getCountFlowRounds();
|
#ifdef DEBUG_DETAIL_ON
|
||||||
return false;
|
long long int starttime = esp_timer_get_time();
|
||||||
|
#endif
|
||||||
|
int msg_id = esp_mqtt_client_publish(client, _key.c_str(), _content.c_str(), 0, 1, retained_flag);
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
ESP_LOGD(TAG, "Publish msg_id %d in %lld ms", msg_id, (esp_timer_get_time() - starttime)/1000);
|
||||||
|
#endif
|
||||||
|
if (msg_id == -1) {
|
||||||
|
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Failed to publish topic '" + _key + "', re-trying...");
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
starttime = esp_timer_get_time();
|
||||||
|
#endif
|
||||||
|
msg_id = esp_mqtt_client_publish(client, _key.c_str(), _content.c_str(), 0, 1, retained_flag);
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
ESP_LOGD(TAG, "Publish msg_id %d in %lld ms", msg_id, (esp_timer_get_time() - starttime)/1000);
|
||||||
|
#endif
|
||||||
|
if (msg_id == -1) {
|
||||||
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to publish topic '" + _key + "', skipping all MQTT publishings in this round!");
|
||||||
|
failedOnRound = getCountFlowRounds();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
msg_id = esp_mqtt_client_publish(client, _key.c_str(), _content.c_str(), 0, 1, retained_flag);
|
if (_content.length() > 80) { // Truncate message if too long
|
||||||
if (msg_id < 0) {
|
_content.resize(80);
|
||||||
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Failed to publish topic '" + _key + "', re-trying...");
|
_content.append("..");
|
||||||
esp_mqtt_client_reconnect(client);
|
|
||||||
|
|
||||||
msg_id = esp_mqtt_client_publish(client, _key.c_str(), _content.c_str(), 0, 1, retained_flag);
|
|
||||||
if (msg_id < 0) {
|
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to publish topic '" + _key + "', skipping all MQTT publishings in this round!");
|
|
||||||
failedOnRound = getCountFlowRounds();
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Published topic: " + _key + ", content: " + _content + " (msg_id=" + std::to_string(msg_id) + ")");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
if (_content.length() > 80) { // Truncate message if too long
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Publish skipped. Client not initalized or not connected. (topic: " + _key + ")");
|
||||||
_content.resize(80);
|
return false;
|
||||||
_content.append("..");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
zw = "Published topic: " + _key + ", content: " + _content + " (msg_id=" + std::to_string(msg_id) + ")";
|
|
||||||
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, zw);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event)
|
static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event) {
|
||||||
{
|
|
||||||
int msg_id;
|
int msg_id;
|
||||||
std::string topic = "";
|
std::string topic = "";
|
||||||
switch (event->event_id) {
|
switch (event->event_id) {
|
||||||
case MQTT_EVENT_BEFORE_CONNECT:
|
case MQTT_EVENT_BEFORE_CONNECT:
|
||||||
ESP_LOGD(TAG, "MQTT_EVENT_BEFORE_CONNECT");
|
ESP_LOGD(TAG, "MQTT_EVENT_BEFORE_CONNECT");
|
||||||
|
mqtt_initialized = true;
|
||||||
break;
|
break;
|
||||||
case MQTT_EVENT_CONNECTED:
|
case MQTT_EVENT_CONNECTED:
|
||||||
ESP_LOGD(TAG, "MQTT_EVENT_CONNECTED");
|
ESP_LOGD(TAG, "MQTT_EVENT_CONNECTED");
|
||||||
|
mqtt_initialized = true;
|
||||||
mqtt_connected = true;
|
mqtt_connected = true;
|
||||||
MQTTconnected();
|
MQTTconnected();
|
||||||
break;
|
break;
|
||||||
case MQTT_EVENT_DISCONNECTED:
|
case MQTT_EVENT_DISCONNECTED:
|
||||||
ESP_LOGD(TAG, "MQTT_EVENT_DISCONNECTED");
|
ESP_LOGD(TAG, "MQTT_EVENT_DISCONNECTED");
|
||||||
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Disconnected from broker");
|
||||||
mqtt_connected = false;
|
mqtt_connected = false;
|
||||||
break;
|
break;
|
||||||
case MQTT_EVENT_SUBSCRIBED:
|
case MQTT_EVENT_SUBSCRIBED:
|
||||||
@@ -126,8 +133,15 @@ static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MQTT_EVENT_ERROR:
|
case MQTT_EVENT_ERROR:
|
||||||
ESP_LOGD(TAG, "MQTT_EVENT_ERROR");
|
#ifdef DEBUG_DETAIL_ON
|
||||||
mqtt_initialized = false; // Force re-init on next publish call
|
ESP_LOGD(TAG, "MQTT_EVENT_ERROR - esp_mqtt_error_codes:");
|
||||||
|
ESP_LOGD(TAG, "error_type:%d", event->error_handle->error_type);
|
||||||
|
ESP_LOGD(TAG, "connect_return_code:%d", event->error_handle->connect_return_code);
|
||||||
|
ESP_LOGD(TAG, "esp_transport_sock_errno:%d", event->error_handle->esp_transport_sock_errno);
|
||||||
|
ESP_LOGD(TAG, "esp_tls_last_esp_err:%d", event->error_handle->esp_tls_last_esp_err);
|
||||||
|
ESP_LOGD(TAG, "esp_tls_stack_err:%d", event->error_handle->esp_tls_stack_err);
|
||||||
|
ESP_LOGD(TAG, "esp_tls_cert_verify_flags:%d", event->error_handle->esp_tls_cert_verify_flags);
|
||||||
|
#endif
|
||||||
mqtt_connected = false;
|
mqtt_connected = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -143,16 +157,14 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MQTT_Configure(std::string _mqttURI, std::string _clientid, std::string _user, std::string _password,
|
bool MQTT_Configure(std::string _mqttURI, std::string _clientid, std::string _user, std::string _password,
|
||||||
std::string _maintopic, std::string _lwt, std::string _lwt_connected, std::string _lwt_disconnected,
|
std::string _maintopic, std::string _lwt, std::string _lwt_connected, std::string _lwt_disconnected,
|
||||||
int _keepalive, int _SetRetainFlag, void *_callbackOnConnected){
|
int _keepalive, int _SetRetainFlag, void *_callbackOnConnected) {
|
||||||
#ifdef __HIDE_PASSWORD
|
if ((_mqttURI.length() == 0) || (_maintopic.length() == 0) || (_clientid.length() == 0))
|
||||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "URI: " + _mqttURI + ", clientname: " + _clientid +
|
{
|
||||||
", user: " + _user + ", password: XXXXXXXX, maintopic: " + _maintopic + ", last-will-topic: " + _maintopic + "/" + _lwt + ", keepAlive: " + std::to_string(_keepalive));
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Init aborted! Config error (URI, MainTopic or ClientID missing)");
|
||||||
#else
|
return false;
|
||||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "URI: " + _mqttURI + ", clientname: " + _clientid +
|
}
|
||||||
", user: " + _user + ", password: " + _password + ", maintopic: " + _maintopic + ", last-will-topic: " + _maintopic + "/" + _lwt + ", keepAlive: " + std::to_string(_keepalive));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uri = _mqttURI;
|
uri = _mqttURI;
|
||||||
client_id = _clientid;
|
client_id = _clientid;
|
||||||
@@ -168,42 +180,60 @@ void MQTT_Configure(std::string _mqttURI, std::string _clientid, std::string _us
|
|||||||
user = _user;
|
user = _user;
|
||||||
password = _password;
|
password = _password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __HIDE_PASSWORD
|
||||||
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "URI: " + uri + ", clientname: " + client_id + ", user: " + user + ", password: XXXXXXXX, maintopic: "
|
||||||
|
+ maintopic + ", last-will-topic: " + lwt_topic + ", keepAlive: " + std::to_string(keepalive) + ", RetainFlag: " + std::to_string(SetRetainFlag));
|
||||||
|
#else
|
||||||
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "URI: " + uri + ", clientname: " + client_id + ", user: " + user + ", password: " + password + ", maintopic: "
|
||||||
|
+ maintopic + ", last-will-topic: " + lwt_topic + ", keepAlive: " + std::to_string(keepalive) + ", RetainFlag: " + std::to_string(SetRetainFlag));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
mqtt_configOK = true;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MQTT_Init() {
|
|
||||||
|
|
||||||
if (MQTT_Enabled == false)
|
int MQTT_Init() {
|
||||||
return false;
|
if (mqtt_initialized) {
|
||||||
|
return 0;
|
||||||
if ((client_id.length() == 0) || (lwt_topic.length() == 0))
|
|
||||||
{
|
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, std::string("Init with no Client_ID (" + client_id + ") or Last Will Topic (" + lwt_topic + "). Abort Init!"));
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t ret;
|
if (mqtt_configOK) {
|
||||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, std::string("Init"));
|
mqtt_enabled = true;
|
||||||
|
} else {
|
||||||
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Init called, but client is not yet configured.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!getWIFIisConnected()) {
|
||||||
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Init called, but WIFI is not yet connected.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Init");
|
||||||
MQTTdestroy_client();
|
MQTTdestroy_client();
|
||||||
|
|
||||||
std::string lw = lwt_disconnected;
|
|
||||||
|
|
||||||
esp_mqtt_client_config_t mqtt_cfg = {
|
esp_mqtt_client_config_t mqtt_cfg = {
|
||||||
.uri = uri.c_str(),
|
.uri = uri.c_str(),
|
||||||
.client_id = client_id.c_str(),
|
.client_id = client_id.c_str(),
|
||||||
.lwt_topic = lwt_topic.c_str(),
|
.lwt_topic = lwt_topic.c_str(),
|
||||||
.lwt_msg = lw.c_str(),
|
.lwt_msg = lwt_disconnected.c_str(),
|
||||||
.lwt_retain = 1,
|
.lwt_retain = 1,
|
||||||
.lwt_msg_len = (int)(lw.length()),
|
.lwt_msg_len = (int)(lwt_disconnected.length()),
|
||||||
.keepalive = keepalive,
|
.keepalive = keepalive,
|
||||||
.disable_auto_reconnect = false, // Reconnection routine active
|
.disable_auto_reconnect = false, // Reconnection routine active (Default: false)
|
||||||
.reconnect_timeout_ms = 10000 // Try to reconnect to broker every 10s
|
.buffer_size = 1536, // size of MQTT send/receive buffer (Default: 1024)
|
||||||
|
.reconnect_timeout_ms = 15000, // Try to reconnect to broker (Default: 10000ms)
|
||||||
|
.network_timeout_ms = 20000, // Network Timeout (Default: 10000ms)
|
||||||
|
.message_retransmit_timeout = 3000 // Tiem after message resent when broker not acknowledged (QoS1, QoS2)
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (user.length() && password.length()){
|
if (user.length() && password.length()){
|
||||||
mqtt_cfg.username = user.c_str();
|
mqtt_cfg.username = user.c_str();
|
||||||
mqtt_cfg.password = password.c_str();
|
mqtt_cfg.password = password.c_str();
|
||||||
};
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("MQTT Client Init");
|
LogFile.WriteHeapInfo("MQTT Client Init");
|
||||||
@@ -212,12 +242,12 @@ bool MQTT_Init() {
|
|||||||
client = esp_mqtt_client_init(&mqtt_cfg);
|
client = esp_mqtt_client_init(&mqtt_cfg);
|
||||||
if (client)
|
if (client)
|
||||||
{
|
{
|
||||||
ret = esp_mqtt_client_register_event(client, esp_mmqtt_ID, mqtt_event_handler, client);
|
esp_err_t ret = esp_mqtt_client_register_event(client, esp_mqtt_ID, mqtt_event_handler, client);
|
||||||
if (ret != ESP_OK)
|
if (ret != ESP_OK)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Could not register event (ret=" + std::to_string(ret) + ")!");
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Could not register event (ret=" + std::to_string(ret) + ")!");
|
||||||
mqtt_initialized = false;
|
mqtt_initialized = false;
|
||||||
return false;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
@@ -226,40 +256,44 @@ bool MQTT_Init() {
|
|||||||
ret = esp_mqtt_client_start(client);
|
ret = esp_mqtt_client_start(client);
|
||||||
if (ret != ESP_OK)
|
if (ret != ESP_OK)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Could not start client (ret=" + std::to_string(ret) + "), retrying...");
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Client start failed (retval=" + std::to_string(ret) + ")!");
|
||||||
ret = esp_mqtt_client_start(client);
|
mqtt_initialized = false;
|
||||||
if (ret != ESP_OK)
|
return -1;
|
||||||
{
|
}
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Could not start client (ret=" + std::to_string(ret) + ")!");
|
else {
|
||||||
mqtt_initialized = false;
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Client started, waiting for established connection...");
|
||||||
return false;
|
mqtt_initialized = true;
|
||||||
}
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Init failed, no handle created!");
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Init failed, no handle created!");
|
||||||
mqtt_initialized = false;
|
mqtt_initialized = false;
|
||||||
return false;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Client started, waiting for established connection...");
|
|
||||||
mqtt_initialized = true;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MQTTdestroy_client() {
|
void MQTTdestroy_client() {
|
||||||
if (client) {
|
if (client) {
|
||||||
|
if (mqtt_connected) {
|
||||||
|
esp_mqtt_client_disconnect(client);
|
||||||
|
mqtt_connected = false;
|
||||||
|
}
|
||||||
esp_mqtt_client_stop(client);
|
esp_mqtt_client_stop(client);
|
||||||
esp_mqtt_client_destroy(client);
|
esp_mqtt_client_destroy(client);
|
||||||
client = NULL;
|
client = NULL;
|
||||||
mqtt_initialized = false;
|
mqtt_initialized = false;
|
||||||
mqtt_connected = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MQTTisConnected() {
|
bool getMQTTisEnabled() {
|
||||||
|
return mqtt_enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool getMQTTisConnected() {
|
||||||
return mqtt_connected;
|
return mqtt_connected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,15 +6,16 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
void MQTT_Configure(std::string _mqttURI, std::string _clientid, std::string _user, std::string _password,
|
bool MQTT_Configure(std::string _mqttURI, std::string _clientid, std::string _user, std::string _password,
|
||||||
std::string _maintopic, std::string _lwt, std::string _lwt_connected, std::string _lwt_disconnected,
|
std::string _maintopic, std::string _lwt, std::string _lwt_connected, std::string _lwt_disconnected,
|
||||||
int _keepalive, int SetRetainFlag, void *callbackOnConnected);
|
int _keepalive, int SetRetainFlag, void *callbackOnConnected);
|
||||||
bool MQTT_Init();
|
int MQTT_Init();
|
||||||
void MQTTdestroy_client();
|
void MQTTdestroy_client();
|
||||||
|
|
||||||
bool MQTTPublish(std::string _key, std::string _content, int retained_flag = 1); // retained Flag as Standart
|
bool MQTTPublish(std::string _key, std::string _content, int retained_flag = 1); // retained Flag as Standart
|
||||||
|
|
||||||
bool MQTTisConnected();
|
bool getMQTTisEnabled();
|
||||||
|
bool getMQTTisConnected();
|
||||||
|
|
||||||
void MQTTregisterConnectFunction(std::string name, std::function<void()> func);
|
void MQTTregisterConnectFunction(std::string name, std::function<void()> func);
|
||||||
void MQTTunregisterConnectFunction(std::string name);
|
void MQTTunregisterConnectFunction(std::string name);
|
||||||
|
|||||||
@@ -129,6 +129,9 @@ void sendHomeAssistantDiscoveryTopic(std::string group, std::string field,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MQTThomeassistantDiscovery() {
|
void MQTThomeassistantDiscovery() {
|
||||||
|
if (!getMQTTisConnected())
|
||||||
|
return;
|
||||||
|
|
||||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "MQTT - Sending Homeassistant Discovery Topics (Meter Type: " + meterType + ", Value Unit: " + valueUnit + " , Rate Unit: " + rateUnit + ")...");
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "MQTT - Sending Homeassistant Discovery Topics (Meter Type: " + meterType + ", Value Unit: " + valueUnit + " , Rate Unit: " + rateUnit + ")...");
|
||||||
|
|
||||||
// Group | Field | User Friendly Name | Icon | Unit | Device Class | State Class | Entity Category
|
// Group | Field | User Friendly Name | Icon | Unit | Device Class | State Class | Entity Category
|
||||||
@@ -161,6 +164,9 @@ void MQTThomeassistantDiscovery() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void publishSystemData() {
|
void publishSystemData() {
|
||||||
|
if (!getMQTTisConnected())
|
||||||
|
return;
|
||||||
|
|
||||||
char tmp_char[50];
|
char tmp_char[50];
|
||||||
|
|
||||||
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Publishing system MQTT topics...");
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Publishing system MQTT topics...");
|
||||||
@@ -180,6 +186,9 @@ void publishSystemData() {
|
|||||||
|
|
||||||
|
|
||||||
void publishStaticData() {
|
void publishStaticData() {
|
||||||
|
if (!getMQTTisConnected())
|
||||||
|
return;
|
||||||
|
|
||||||
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Publishing static MQTT topics...");
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Publishing static MQTT topics...");
|
||||||
MQTTPublish(maintopic + "/" + "MAC", getMac(), retainFlag);
|
MQTTPublish(maintopic + "/" + "MAC", getMac(), retainFlag);
|
||||||
MQTTPublish(maintopic + "/" + "IP", *getIPAddress(), retainFlag);
|
MQTTPublish(maintopic + "/" + "IP", *getIPAddress(), retainFlag);
|
||||||
@@ -204,6 +213,7 @@ esp_err_t sendDiscovery_and_static_Topics(httpd_req_t *req) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GotConnected(std::string maintopic, int retainFlag) {
|
void GotConnected(std::string maintopic, int retainFlag) {
|
||||||
|
vTaskDelay(10000 / portTICK_PERIOD_MS); // Delay execution by 10s after connection got established
|
||||||
if (HomeassistantDiscovery) {
|
if (HomeassistantDiscovery) {
|
||||||
MQTThomeassistantDiscovery();
|
MQTThomeassistantDiscovery();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ ClassFlowControll tfliteflow;
|
|||||||
TaskHandle_t xHandleblink_task_doFlow = NULL;
|
TaskHandle_t xHandleblink_task_doFlow = NULL;
|
||||||
TaskHandle_t xHandletask_autodoFlow = NULL;
|
TaskHandle_t xHandletask_autodoFlow = NULL;
|
||||||
|
|
||||||
|
bool FlowInitDone = false;
|
||||||
bool flowisrunning = false;
|
bool flowisrunning = false;
|
||||||
|
|
||||||
long auto_intervall = 0;
|
long auto_intervall = 0;
|
||||||
@@ -47,17 +48,18 @@ int getCountFlowRounds() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
esp_err_t GetJPG(std::string _filename, httpd_req_t *req)
|
esp_err_t GetJPG(std::string _filename, httpd_req_t *req)
|
||||||
{
|
{
|
||||||
return tfliteflow.GetJPGStream(_filename, req);
|
return tfliteflow.GetJPGStream(_filename, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t GetRawJPG(httpd_req_t *req)
|
esp_err_t GetRawJPG(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
return tfliteflow.SendRawJPG(req);
|
return tfliteflow.SendRawJPG(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool isSetupModusActive() {
|
bool isSetupModusActive() {
|
||||||
return tfliteflow.getStatusSetupModus();
|
return tfliteflow.getStatusSetupModus();
|
||||||
return false;
|
return false;
|
||||||
@@ -66,70 +68,72 @@ bool isSetupModusActive() {
|
|||||||
|
|
||||||
void KillTFliteTasks()
|
void KillTFliteTasks()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "Handle: xHandleblink_task_doFlow: %ld", (long) xHandleblink_task_doFlow);
|
ESP_LOGD(TAG, "Handle: xHandleblink_task_doFlow: %ld", (long) xHandleblink_task_doFlow);
|
||||||
#endif
|
#endif
|
||||||
if (xHandleblink_task_doFlow != NULL)
|
if (xHandleblink_task_doFlow != NULL)
|
||||||
{
|
{
|
||||||
TaskHandle_t xHandleblink_task_doFlowTmp = xHandleblink_task_doFlow;
|
TaskHandle_t xHandleblink_task_doFlowTmp = xHandleblink_task_doFlow;
|
||||||
xHandleblink_task_doFlow = NULL;
|
xHandleblink_task_doFlow = NULL;
|
||||||
vTaskDelete(xHandleblink_task_doFlowTmp);
|
vTaskDelete(xHandleblink_task_doFlowTmp);
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "Killed: xHandleblink_task_doFlow");
|
ESP_LOGD(TAG, "Killed: xHandleblink_task_doFlow");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "Handle: xHandletask_autodoFlow: %ld", (long) xHandletask_autodoFlow);
|
ESP_LOGD(TAG, "Handle: xHandletask_autodoFlow: %ld", (long) xHandletask_autodoFlow);
|
||||||
#endif
|
#endif
|
||||||
if (xHandletask_autodoFlow != NULL)
|
if (xHandletask_autodoFlow != NULL)
|
||||||
{
|
{
|
||||||
TaskHandle_t xHandletask_autodoFlowTmp = xHandletask_autodoFlow;
|
TaskHandle_t xHandletask_autodoFlowTmp = xHandletask_autodoFlow;
|
||||||
xHandletask_autodoFlow = NULL;
|
xHandletask_autodoFlow = NULL;
|
||||||
vTaskDelete(xHandletask_autodoFlowTmp);
|
vTaskDelete(xHandletask_autodoFlowTmp);
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "Killed: xHandletask_autodoFlow");
|
ESP_LOGD(TAG, "Killed: xHandletask_autodoFlow");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void doInit(void)
|
void doInit(void)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "Start tfliteflow.InitFlow(config);");
|
ESP_LOGD(TAG, "Start tfliteflow.InitFlow(config);");
|
||||||
#endif
|
#endif
|
||||||
tfliteflow.InitFlow(CONFIG_FILE);
|
tfliteflow.InitFlow(CONFIG_FILE);
|
||||||
#ifdef DEBUG_DETAIL_ON
|
FlowInitDone = true;
|
||||||
ESP_LOGD(TAG, "Finished tfliteflow.InitFlow(config);");
|
#ifdef DEBUG_DETAIL_ON
|
||||||
#endif
|
ESP_LOGD(TAG, "Finished tfliteflow.InitFlow(config);");
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
tfliteflow.StartMQTTService();
|
tfliteflow.StartMQTTService();
|
||||||
#endif //ENABLE_MQTT
|
#endif //ENABLE_MQTT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool doflow(void)
|
bool doflow(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string zw_time = gettimestring(LOGFILE_TIME_FORMAT);
|
std::string zw_time = gettimestring(LOGFILE_TIME_FORMAT);
|
||||||
ESP_LOGD(TAG, "doflow - start %s", zw_time.c_str());
|
ESP_LOGD(TAG, "doflow - start %s", zw_time.c_str());
|
||||||
flowisrunning = true;
|
flowisrunning = true;
|
||||||
tfliteflow.doFlow(zw_time);
|
tfliteflow.doFlow(zw_time);
|
||||||
flowisrunning = false;
|
flowisrunning = false;
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "doflow - end %s", zw_time.c_str());
|
ESP_LOGD(TAG, "doflow - end %s", zw_time.c_str());
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void blink_task_doFlow(void *pvParameter)
|
void blink_task_doFlow(void *pvParameter)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "blink_task_doFlow");
|
ESP_LOGD(TAG, "blink_task_doFlow");
|
||||||
#endif
|
#endif
|
||||||
if (!flowisrunning)
|
if (!flowisrunning)
|
||||||
{
|
{
|
||||||
flowisrunning = true;
|
flowisrunning = true;
|
||||||
@@ -143,10 +147,10 @@ void blink_task_doFlow(void *pvParameter)
|
|||||||
|
|
||||||
esp_err_t handler_init(httpd_req_t *req)
|
esp_err_t handler_init(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_init - Start");
|
LogFile.WriteHeapInfo("handler_init - Start");
|
||||||
ESP_LOGD(TAG, "handler_doinit uri: %s", req->uri);
|
ESP_LOGD(TAG, "handler_doinit uri: %s", req->uri);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char* resp_str = "Init started<br>";
|
const char* resp_str = "Init started<br>";
|
||||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
httpd_resp_send(req, resp_str, strlen(resp_str));
|
||||||
@@ -158,18 +162,19 @@ esp_err_t handler_init(httpd_req_t *req)
|
|||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
httpd_resp_send_chunk(req, NULL, 0);
|
httpd_resp_send_chunk(req, NULL, 0);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_init - Done");
|
LogFile.WriteHeapInfo("handler_init - Done");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_doflow(httpd_req_t *req)
|
esp_err_t handler_doflow(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_doflow - Start");
|
LogFile.WriteHeapInfo("handler_doflow - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ESP_LOGD(TAG, "handler_doFlow uri: %s", req->uri);
|
ESP_LOGD(TAG, "handler_doFlow uri: %s", req->uri);
|
||||||
|
|
||||||
@@ -188,199 +193,208 @@ esp_err_t handler_doflow(httpd_req_t *req)
|
|||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
httpd_resp_send_chunk(req, NULL, 0);
|
httpd_resp_send_chunk(req, NULL, 0);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_doflow - Done");
|
LogFile.WriteHeapInfo("handler_doflow - Done");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_json(httpd_req_t *req)
|
esp_err_t handler_json(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_json - Start");
|
LogFile.WriteHeapInfo("handler_json - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
ESP_LOGD(TAG, "handler_JSON uri: %s", req->uri);
|
ESP_LOGD(TAG, "handler_JSON uri: %s", req->uri);
|
||||||
|
|
||||||
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
if (FlowInitDone)
|
||||||
httpd_resp_set_type(req, "application/json");
|
|
||||||
|
|
||||||
std::string zw = tfliteflow.getJSON();
|
|
||||||
if (zw.length() > 0)
|
|
||||||
{
|
{
|
||||||
httpd_resp_send(req, zw.c_str(), zw.length());
|
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
||||||
|
httpd_resp_set_type(req, "application/json");
|
||||||
|
|
||||||
|
std::string zw = tfliteflow.getJSON();
|
||||||
|
if (zw.length() > 0)
|
||||||
|
{
|
||||||
|
httpd_resp_send(req, zw.c_str(), zw.length());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
httpd_resp_send(req, NULL, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
httpd_resp_send(req, NULL, 0);
|
httpd_resp_send_err(req, HTTPD_403_FORBIDDEN, "JSON API not yet initialized. Please retry later...");
|
||||||
|
return ESP_ERR_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_JSON - Done");
|
LogFile.WriteHeapInfo("handler_JSON - Done");
|
||||||
#endif
|
#endif
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_wasserzaehler(httpd_req_t *req)
|
esp_err_t handler_wasserzaehler(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_wasserzaehler - Start");
|
LogFile.WriteHeapInfo("handler_wasserzaehler - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool _rawValue = false;
|
if (FlowInitDone)
|
||||||
bool _noerror = false;
|
|
||||||
bool _all = false;
|
|
||||||
std::string _type = "value";
|
|
||||||
string zw;
|
|
||||||
|
|
||||||
ESP_LOGD(TAG, "handler_wasserzaehler uri: %s", req->uri);
|
|
||||||
|
|
||||||
char _query[100];
|
|
||||||
char _size[10];
|
|
||||||
|
|
||||||
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
|
||||||
{
|
{
|
||||||
// ESP_LOGD(TAG, "Query: %s", _query);
|
bool _rawValue = false;
|
||||||
if (httpd_query_key_value(_query, "all", _size, 10) == ESP_OK)
|
bool _noerror = false;
|
||||||
|
bool _all = false;
|
||||||
|
std::string _type = "value";
|
||||||
|
string zw;
|
||||||
|
|
||||||
|
ESP_LOGD(TAG, "handler_wasserzaehler uri: %s", req->uri);
|
||||||
|
|
||||||
|
char _query[100];
|
||||||
|
char _size[10];
|
||||||
|
|
||||||
|
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
// ESP_LOGD(TAG, "Query: %s", _query);
|
||||||
ESP_LOGD(TAG, "all is found%s", _size);
|
if (httpd_query_key_value(_query, "all", _size, 10) == ESP_OK)
|
||||||
#endif
|
{
|
||||||
_all = true;
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
ESP_LOGD(TAG, "all is found%s", _size);
|
||||||
|
#endif
|
||||||
|
_all = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (httpd_query_key_value(_query, "type", _size, 10) == ESP_OK)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
ESP_LOGD(TAG, "all is found: %s", _size);
|
||||||
|
#endif
|
||||||
|
_type = std::string(_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (httpd_query_key_value(_query, "rawvalue", _size, 10) == ESP_OK)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
ESP_LOGD(TAG, "rawvalue is found: %s", _size);
|
||||||
|
#endif
|
||||||
|
_rawValue = true;
|
||||||
|
}
|
||||||
|
if (httpd_query_key_value(_query, "noerror", _size, 10) == ESP_OK)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
ESP_LOGD(TAG, "noerror is found: %s", _size);
|
||||||
|
#endif
|
||||||
|
_noerror = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (httpd_query_key_value(_query, "type", _size, 10) == ESP_OK)
|
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
||||||
|
|
||||||
|
if (_all)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
httpd_resp_set_type(req, "text/plain");
|
||||||
ESP_LOGD(TAG, "all is found: %s", _size);
|
ESP_LOGD(TAG, "TYPE: %s", _type.c_str());
|
||||||
#endif
|
int _intype = READOUT_TYPE_VALUE;
|
||||||
_type = std::string(_size);
|
if (_type == "prevalue")
|
||||||
|
_intype = READOUT_TYPE_PREVALUE;
|
||||||
|
if (_type == "raw")
|
||||||
|
_intype = READOUT_TYPE_RAWVALUE;
|
||||||
|
if (_type == "error")
|
||||||
|
_intype = READOUT_TYPE_ERROR;
|
||||||
|
|
||||||
|
|
||||||
|
zw = tfliteflow.getReadoutAll(_intype);
|
||||||
|
ESP_LOGD(TAG, "ZW: %s", zw.c_str());
|
||||||
|
if (zw.length() > 0)
|
||||||
|
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||||
|
httpd_resp_sendstr_chunk(req, NULL);
|
||||||
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (httpd_query_key_value(_query, "rawvalue", _size, 10) == ESP_OK)
|
zw = tfliteflow.getReadout(_rawValue, _noerror);
|
||||||
{
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
|
||||||
ESP_LOGD(TAG, "rawvalue is found: %s", _size);
|
|
||||||
#endif
|
|
||||||
_rawValue = true;
|
|
||||||
}
|
|
||||||
if (httpd_query_key_value(_query, "noerror", _size, 10) == ESP_OK)
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
|
||||||
ESP_LOGD(TAG, "noerror is found: %s", _size);
|
|
||||||
#endif
|
|
||||||
_noerror = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
|
||||||
|
|
||||||
if (_all)
|
|
||||||
{
|
|
||||||
httpd_resp_set_type(req, "text/plain");
|
|
||||||
ESP_LOGD(TAG, "TYPE: %s", _type.c_str());
|
|
||||||
int _intype = READOUT_TYPE_VALUE;
|
|
||||||
if (_type == "prevalue")
|
|
||||||
_intype = READOUT_TYPE_PREVALUE;
|
|
||||||
if (_type == "raw")
|
|
||||||
_intype = READOUT_TYPE_RAWVALUE;
|
|
||||||
if (_type == "error")
|
|
||||||
_intype = READOUT_TYPE_ERROR;
|
|
||||||
|
|
||||||
|
|
||||||
zw = tfliteflow.getReadoutAll(_intype);
|
|
||||||
ESP_LOGD(TAG, "ZW: %s", zw.c_str());
|
|
||||||
if (zw.length() > 0)
|
if (zw.length() > 0)
|
||||||
httpd_resp_sendstr_chunk(req, zw.c_str());
|
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||||
httpd_resp_sendstr_chunk(req, NULL);
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
zw = tfliteflow.getReadout(_rawValue, _noerror);
|
string query = std::string(_query);
|
||||||
if (zw.length() > 0)
|
// ESP_LOGD(TAG, "Query: %s, query.c_str());
|
||||||
httpd_resp_sendstr_chunk(req, zw.c_str());
|
if (query.find("full") != std::string::npos)
|
||||||
|
|
||||||
string query = std::string(_query);
|
|
||||||
// ESP_LOGD(TAG, "Query: %s, query.c_str());
|
|
||||||
if (query.find("full") != std::string::npos)
|
|
||||||
{
|
|
||||||
string txt, zw;
|
|
||||||
|
|
||||||
txt = "<p>Aligned Image: <p><img src=\"/img_tmp/alg_roi.jpg\"> <p>\n";
|
|
||||||
txt = txt + "Digital Counter: <p> ";
|
|
||||||
httpd_resp_sendstr_chunk(req, txt.c_str());
|
|
||||||
|
|
||||||
std::vector<HTMLInfo*> htmlinfodig;
|
|
||||||
htmlinfodig = tfliteflow.GetAllDigital();
|
|
||||||
|
|
||||||
for (int i = 0; i < htmlinfodig.size(); ++i)
|
|
||||||
{
|
{
|
||||||
if (tfliteflow.GetTypeDigital() == Digital)
|
string txt, zw;
|
||||||
{
|
|
||||||
if (htmlinfodig[i]->val == 10)
|
|
||||||
zw = "NaN";
|
|
||||||
else
|
|
||||||
zw = to_string((int) htmlinfodig[i]->val);
|
|
||||||
|
|
||||||
txt = "<img src=\"/img_tmp/" + htmlinfodig[i]->filename + "\"> " + zw;
|
txt = "<p>Aligned Image: <p><img src=\"/img_tmp/alg_roi.jpg\"> <p>\n";
|
||||||
|
txt = txt + "Digital Counter: <p> ";
|
||||||
|
httpd_resp_sendstr_chunk(req, txt.c_str());
|
||||||
|
|
||||||
|
std::vector<HTMLInfo*> htmlinfodig;
|
||||||
|
htmlinfodig = tfliteflow.GetAllDigital();
|
||||||
|
|
||||||
|
for (int i = 0; i < htmlinfodig.size(); ++i)
|
||||||
|
{
|
||||||
|
if (tfliteflow.GetTypeDigital() == Digital)
|
||||||
|
{
|
||||||
|
if (htmlinfodig[i]->val == 10)
|
||||||
|
zw = "NaN";
|
||||||
|
else
|
||||||
|
zw = to_string((int) htmlinfodig[i]->val);
|
||||||
|
|
||||||
|
txt = "<img src=\"/img_tmp/" + htmlinfodig[i]->filename + "\"> " + zw;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::stringstream stream;
|
||||||
|
stream << std::fixed << std::setprecision(1) << htmlinfodig[i]->val;
|
||||||
|
zw = stream.str();
|
||||||
|
|
||||||
|
txt = "<img src=\"/img_tmp/" + htmlinfodig[i]->filename + "\"> " + zw;
|
||||||
|
}
|
||||||
|
httpd_resp_sendstr_chunk(req, txt.c_str());
|
||||||
|
delete htmlinfodig[i];
|
||||||
}
|
}
|
||||||
else
|
htmlinfodig.clear();
|
||||||
|
|
||||||
|
txt = " <p> Analog Meter: <p> ";
|
||||||
|
httpd_resp_sendstr_chunk(req, txt.c_str());
|
||||||
|
|
||||||
|
std::vector<HTMLInfo*> htmlinfoana;
|
||||||
|
htmlinfoana = tfliteflow.GetAllAnalog();
|
||||||
|
for (int i = 0; i < htmlinfoana.size(); ++i)
|
||||||
{
|
{
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
stream << std::fixed << std::setprecision(1) << htmlinfodig[i]->val;
|
stream << std::fixed << std::setprecision(1) << htmlinfoana[i]->val;
|
||||||
zw = stream.str();
|
zw = stream.str();
|
||||||
|
|
||||||
txt = "<img src=\"/img_tmp/" + htmlinfodig[i]->filename + "\"> " + zw;
|
txt = "<img src=\"/img_tmp/" + htmlinfoana[i]->filename + "\"> " + zw;
|
||||||
|
httpd_resp_sendstr_chunk(req, txt.c_str());
|
||||||
|
delete htmlinfoana[i];
|
||||||
}
|
}
|
||||||
httpd_resp_sendstr_chunk(req, txt.c_str());
|
htmlinfoana.clear();
|
||||||
delete htmlinfodig[i];
|
|
||||||
}
|
}
|
||||||
htmlinfodig.clear();
|
|
||||||
|
|
||||||
txt = " <p> Analog Meter: <p> ";
|
|
||||||
httpd_resp_sendstr_chunk(req, txt.c_str());
|
|
||||||
|
|
||||||
std::vector<HTMLInfo*> htmlinfoana;
|
|
||||||
htmlinfoana = tfliteflow.GetAllAnalog();
|
|
||||||
for (int i = 0; i < htmlinfoana.size(); ++i)
|
|
||||||
{
|
|
||||||
std::stringstream stream;
|
|
||||||
stream << std::fixed << std::setprecision(1) << htmlinfoana[i]->val;
|
|
||||||
zw = stream.str();
|
|
||||||
|
|
||||||
txt = "<img src=\"/img_tmp/" + htmlinfoana[i]->filename + "\"> " + zw;
|
|
||||||
httpd_resp_sendstr_chunk(req, txt.c_str());
|
|
||||||
delete htmlinfoana[i];
|
|
||||||
}
|
|
||||||
htmlinfoana.clear();
|
|
||||||
|
|
||||||
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
|
httpd_resp_sendstr_chunk(req, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
httpd_resp_send_err(req, HTTPD_403_FORBIDDEN, "Value API not yet initialized. Please retry later...");
|
||||||
|
return ESP_ERR_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_wasserzaehler - Done");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
|
||||||
httpd_resp_sendstr_chunk(req, NULL);
|
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
|
||||||
LogFile.WriteHeapInfo("handler_wasserzaehler - Done");
|
|
||||||
#endif
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_editflow(httpd_req_t *req)
|
esp_err_t handler_editflow(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_editflow - Start");
|
LogFile.WriteHeapInfo("handler_editflow - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ESP_LOGD(TAG, "handler_editflow uri: %s", req->uri);
|
ESP_LOGD(TAG, "handler_editflow uri: %s", req->uri);
|
||||||
|
|
||||||
@@ -392,9 +406,9 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
|||||||
{
|
{
|
||||||
if (httpd_query_key_value(_query, "task", _valuechar, 30) == ESP_OK)
|
if (httpd_query_key_value(_query, "task", _valuechar, 30) == ESP_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "task is found: %s", _valuechar);
|
ESP_LOGD(TAG, "task is found: %s", _valuechar);
|
||||||
#endif
|
#endif
|
||||||
_task = string(_valuechar);
|
_task = string(_valuechar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -427,10 +441,10 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
|||||||
httpd_query_key_value(_query, "out", _valuechar, 30);
|
httpd_query_key_value(_query, "out", _valuechar, 30);
|
||||||
out = string(_valuechar);
|
out = string(_valuechar);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "in: %s", in.c_str());
|
ESP_LOGD(TAG, "in: %s", in.c_str());
|
||||||
ESP_LOGD(TAG, "out: %s", out.c_str());
|
ESP_LOGD(TAG, "out: %s", out.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
in = "/sdcard" + in;
|
in = "/sdcard" + in;
|
||||||
out = "/sdcard" + out;
|
out = "/sdcard" + out;
|
||||||
@@ -469,14 +483,14 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
|||||||
zw = string(_valuechar);
|
zw = string(_valuechar);
|
||||||
dy = stoi(zw);
|
dy = stoi(zw);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "in: %s", in.c_str());
|
ESP_LOGD(TAG, "in: %s", in.c_str());
|
||||||
ESP_LOGD(TAG, "out: %s", out.c_str());
|
ESP_LOGD(TAG, "out: %s", out.c_str());
|
||||||
ESP_LOGD(TAG, "x: %s", zw.c_str());
|
ESP_LOGD(TAG, "x: %s", zw.c_str());
|
||||||
ESP_LOGD(TAG, "y: %s", zw.c_str());
|
ESP_LOGD(TAG, "y: %s", zw.c_str());
|
||||||
ESP_LOGD(TAG, "dx: %s", zw.c_str());
|
ESP_LOGD(TAG, "dx: %s", zw.c_str());
|
||||||
ESP_LOGD(TAG, "dy: %s", zw.c_str());
|
ESP_LOGD(TAG, "dy: %s", zw.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (httpd_query_key_value(_query, "enhance", _valuechar, 10) == ESP_OK)
|
if (httpd_query_key_value(_query, "enhance", _valuechar, 10) == ESP_OK)
|
||||||
{
|
{
|
||||||
@@ -570,51 +584,60 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
|||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
httpd_resp_sendstr_chunk(req, NULL);
|
httpd_resp_sendstr_chunk(req, NULL);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_editflow - Done");
|
LogFile.WriteHeapInfo("handler_editflow - Done");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_statusflow(httpd_req_t *req)
|
esp_err_t handler_statusflow(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_prevalue - Start");
|
LogFile.WriteHeapInfo("handler_prevalue - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char* resp_str;
|
if (FlowInitDone)
|
||||||
|
{
|
||||||
|
const char* resp_str;
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "handler_prevalue: %s", req->uri);
|
ESP_LOGD(TAG, "handler_prevalue: %s", req->uri);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
string* zw = tfliteflow.getActStatus();
|
string* zw = tfliteflow.getActStatus();
|
||||||
resp_str = zw->c_str();
|
resp_str = zw->c_str();
|
||||||
|
|
||||||
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
||||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
httpd_resp_send(req, resp_str, strlen(resp_str));
|
||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
httpd_resp_send_chunk(req, NULL, 0);
|
httpd_resp_send_chunk(req, NULL, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
httpd_resp_send_err(req, HTTPD_403_FORBIDDEN, "Flowstatus API not yet initialized. Please retry later...");
|
||||||
|
return ESP_ERR_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_prevalue - Start");
|
LogFile.WriteHeapInfo("handler_prevalue - Done");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_cputemp(httpd_req_t *req)
|
esp_err_t handler_cputemp(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_cputemp - Start");
|
LogFile.WriteHeapInfo("handler_cputemp - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char* resp_str;
|
const char* resp_str;
|
||||||
char cputemp[20];
|
char cputemp[20];
|
||||||
|
|
||||||
sprintf(cputemp, "CPU Temp: %4.1f°C", temperatureRead());
|
sprintf(cputemp, "%4.1f°C", temperatureRead());
|
||||||
|
|
||||||
resp_str = cputemp;
|
resp_str = cputemp;
|
||||||
|
|
||||||
@@ -623,50 +646,82 @@ esp_err_t handler_cputemp(httpd_req_t *req)
|
|||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
httpd_resp_send_chunk(req, NULL, 0);
|
httpd_resp_send_chunk(req, NULL, 0);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_cputemp - End");
|
LogFile.WriteHeapInfo("handler_cputemp - End");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_rssi(httpd_req_t *req)
|
esp_err_t handler_rssi(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_rssi - Start");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (getWIFIisConnected())
|
||||||
|
{
|
||||||
|
const char* resp_str;
|
||||||
|
char rssi[20];
|
||||||
|
|
||||||
|
sprintf(rssi, "%idBm", get_WIFI_RSSI());
|
||||||
|
|
||||||
|
resp_str = rssi;
|
||||||
|
|
||||||
|
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
||||||
|
httpd_resp_send(req, resp_str, strlen(resp_str));
|
||||||
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
|
httpd_resp_send_chunk(req, NULL, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
httpd_resp_send_err(req, HTTPD_403_FORBIDDEN, "RSSI API not yet initialized. Please retry later...");
|
||||||
|
return ESP_ERR_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_rssi - End");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
esp_err_t handler_uptime(httpd_req_t *req)
|
||||||
|
{
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_rssi - Start");
|
LogFile.WriteHeapInfo("handler_uptime - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char* resp_str;
|
std::string formatedUptime = getFormatedUptime(false);
|
||||||
char rssi[20];
|
|
||||||
|
|
||||||
sprintf(rssi, "RSSI: %idBm", get_WIFI_RSSI());
|
|
||||||
|
|
||||||
resp_str = rssi;
|
|
||||||
|
|
||||||
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
||||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
httpd_resp_send(req, formatedUptime.c_str(), strlen(formatedUptime.c_str()));
|
||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
httpd_resp_send_chunk(req, NULL, 0);
|
httpd_resp_send_chunk(req, NULL, 0);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_rssi - End");
|
LogFile.WriteHeapInfo("handler_uptime - End");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_prevalue(httpd_req_t *req)
|
esp_err_t handler_prevalue(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_prevalue - Start");
|
LogFile.WriteHeapInfo("handler_prevalue - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char* resp_str;
|
const char* resp_str;
|
||||||
string zw;
|
string zw;
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "handler_prevalue: %s", req->uri);
|
ESP_LOGD(TAG, "handler_prevalue: %s", req->uri);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char _query[100];
|
char _query[100];
|
||||||
char _size[10] = "";
|
char _size[10] = "";
|
||||||
@@ -674,15 +729,15 @@ esp_err_t handler_prevalue(httpd_req_t *req)
|
|||||||
|
|
||||||
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "Query: %s", _query);
|
ESP_LOGD(TAG, "Query: %s", _query);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (httpd_query_key_value(_query, "value", _size, 10) == ESP_OK)
|
if (httpd_query_key_value(_query, "value", _size, 10) == ESP_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "Value: %s", _size);
|
ESP_LOGD(TAG, "Value: %s", _size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
httpd_query_key_value(_query, "numbers", _numbers, 50);
|
httpd_query_key_value(_query, "numbers", _numbers, 50);
|
||||||
@@ -706,12 +761,13 @@ esp_err_t handler_prevalue(httpd_req_t *req)
|
|||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
httpd_resp_send_chunk(req, NULL, 0);
|
httpd_resp_send_chunk(req, NULL, 0);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_prevalue - End");
|
LogFile.WriteHeapInfo("handler_prevalue - End");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
void task_autodoFlow(void *pvParameter)
|
void task_autodoFlow(void *pvParameter)
|
||||||
{
|
{
|
||||||
@@ -721,6 +777,7 @@ void task_autodoFlow(void *pvParameter)
|
|||||||
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Restarted due to an Exception/panic! Postponing first round start by 5 minutes to allow for an OTA or to fetch the log!");
|
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Restarted due to an Exception/panic! Postponing first round start by 5 minutes to allow for an OTA or to fetch the log!");
|
||||||
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Setting logfile level to DEBUG until the next reboot!");
|
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Setting logfile level to DEBUG until the next reboot!");
|
||||||
LogFile.setLogLevel(ESP_LOG_DEBUG);
|
LogFile.setLogLevel(ESP_LOG_DEBUG);
|
||||||
|
//MQTTPublish(GetMQTTMainTopic() + "/" + "status", "Postponing first round", false);
|
||||||
vTaskDelay(60*5000 / portTICK_RATE_MS); // Wait 5 minutes to give time to do an OTA or fetch the log
|
vTaskDelay(60*5000 / portTICK_RATE_MS); // Wait 5 minutes to give time to do an OTA or fetch the log
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -744,20 +801,20 @@ void task_autodoFlow(void *pvParameter)
|
|||||||
|
|
||||||
if (flowisrunning)
|
if (flowisrunning)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "Autoflow: doFlow is already running!");
|
ESP_LOGD(TAG, "Autoflow: doFlow is already running!");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "Autoflow: doFlow is started");
|
ESP_LOGD(TAG, "Autoflow: doFlow is started");
|
||||||
#endif
|
#endif
|
||||||
flowisrunning = true;
|
flowisrunning = true;
|
||||||
doflow();
|
doflow();
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "Remove older log files");
|
ESP_LOGD(TAG, "Remove older log files");
|
||||||
#endif
|
#endif
|
||||||
LogFile.RemoveOldLogFile();
|
LogFile.RemoveOldLogFile();
|
||||||
LogFile.RemoveOldDataLog();
|
LogFile.RemoveOldDataLog();
|
||||||
}
|
}
|
||||||
@@ -784,6 +841,7 @@ void task_autodoFlow(void *pvParameter)
|
|||||||
ESP_LOGD(TAG, "task_autodoFlow: end");
|
ESP_LOGD(TAG, "task_autodoFlow: end");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TFliteDoAutoStart()
|
void TFliteDoAutoStart()
|
||||||
{
|
{
|
||||||
BaseType_t xReturned;
|
BaseType_t xReturned;
|
||||||
@@ -801,10 +859,9 @@ void TFliteDoAutoStart()
|
|||||||
ESP_LOGD(TAG, "ERROR task_autodoFlow konnte nicht erzeugt werden!");
|
ESP_LOGD(TAG, "ERROR task_autodoFlow konnte nicht erzeugt werden!");
|
||||||
}
|
}
|
||||||
ESP_LOGD(TAG, "getESPHeapInfo: %s", getESPHeapInfo().c_str());
|
ESP_LOGD(TAG, "getESPHeapInfo: %s", getESPHeapInfo().c_str());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
std::string GetMQTTMainTopic()
|
std::string GetMQTTMainTopic()
|
||||||
{
|
{
|
||||||
@@ -873,6 +930,11 @@ void register_server_tflite_uri(httpd_handle_t server)
|
|||||||
camuri.user_ctx = (void*) "Light Off";
|
camuri.user_ctx = (void*) "Light Off";
|
||||||
httpd_register_uri_handler(server, &camuri);
|
httpd_register_uri_handler(server, &camuri);
|
||||||
|
|
||||||
|
camuri.uri = "/uptime";
|
||||||
|
camuri.handler = handler_uptime;
|
||||||
|
camuri.user_ctx = (void*) "Light Off";
|
||||||
|
httpd_register_uri_handler(server, &camuri);
|
||||||
|
|
||||||
camuri.uri = "/editflow";
|
camuri.uri = "/editflow";
|
||||||
camuri.handler = handler_editflow;
|
camuri.handler = handler_editflow;
|
||||||
camuri.user_ctx = (void*) "EditFlow";
|
camuri.user_ctx = (void*) "EditFlow";
|
||||||
|
|||||||
@@ -2,6 +2,6 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*)
|
|||||||
|
|
||||||
idf_component_register(SRCS ${app_sources}
|
idf_component_register(SRCS ${app_sources}
|
||||||
INCLUDE_DIRS "."
|
INCLUDE_DIRS "."
|
||||||
REQUIRES nvs_flash jomjol_helper)
|
REQUIRES nvs_flash jomjol_helper jomjol_mqtt)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,9 @@
|
|||||||
|
|
||||||
#include "lwip/err.h"
|
#include "lwip/err.h"
|
||||||
#include "lwip/sys.h"
|
#include "lwip/sys.h"
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
|
#include "interface_mqtt.h"
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -38,6 +41,7 @@ static EventGroupHandle_t s_wifi_event_group;
|
|||||||
static const char *TAG = "WIFI";
|
static const char *TAG = "WIFI";
|
||||||
|
|
||||||
static int s_retry_num = 0;
|
static int s_retry_num = 0;
|
||||||
|
bool WIFIConnected = false;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
#define BLINK_GPIO GPIO_NUM_33
|
#define BLINK_GPIO GPIO_NUM_33
|
||||||
@@ -113,9 +117,11 @@ static void event_handler(void* arg, esp_event_base_t event_base,
|
|||||||
int32_t event_id, void* event_data)
|
int32_t event_id, void* event_data)
|
||||||
{
|
{
|
||||||
if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
|
if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
|
||||||
|
WIFIConnected = false;
|
||||||
LEDBlinkTask(200, 1, true);
|
LEDBlinkTask(200, 1, true);
|
||||||
esp_wifi_connect();
|
esp_wifi_connect();
|
||||||
} else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
|
} else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
|
||||||
|
WIFIConnected = false;
|
||||||
// if (s_retry_num < EXAMPLE_ESP_MAXIMUM_RETRY) {
|
// if (s_retry_num < EXAMPLE_ESP_MAXIMUM_RETRY) {
|
||||||
esp_wifi_connect();
|
esp_wifi_connect();
|
||||||
s_retry_num++;
|
s_retry_num++;
|
||||||
@@ -131,6 +137,14 @@ static void event_handler(void* arg, esp_event_base_t event_base,
|
|||||||
s_retry_num = 0;
|
s_retry_num = 0;
|
||||||
xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
|
xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
|
||||||
LEDBlinkTask(1000, 5, true);
|
LEDBlinkTask(1000, 5, true);
|
||||||
|
|
||||||
|
WIFIConnected = true;
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
|
if (getMQTTisEnabled()) {
|
||||||
|
vTaskDelay(5000 / portTICK_PERIOD_MS);
|
||||||
|
MQTT_Init(); // Init when WIFI is getting connected
|
||||||
|
}
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,17 +263,17 @@ void wifi_init_sta(const char *_ssid, const char *_password, const char *_hostna
|
|||||||
/* xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually
|
/* xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually
|
||||||
* happened. */
|
* happened. */
|
||||||
if (bits & WIFI_CONNECTED_BIT) {
|
if (bits & WIFI_CONNECTED_BIT) {
|
||||||
#ifdef __HIDE_PASSWORD
|
#ifdef __HIDE_PASSWORD
|
||||||
ESP_LOGI(TAG, "connected to ap SSID: %s, password: XXXXXXX", _ssid);
|
ESP_LOGI(TAG, "connected to ap SSID: %s, password: XXXXXXX", _ssid);
|
||||||
#else
|
#else
|
||||||
ESP_LOGI(TAG, "connected to ap SSID: %s, password: %s", _ssid, _password);
|
ESP_LOGI(TAG, "connected to ap SSID: %s, password: %s", _ssid, _password);
|
||||||
#endif
|
#endif
|
||||||
} else if (bits & WIFI_FAIL_BIT) {
|
} else if (bits & WIFI_FAIL_BIT) {
|
||||||
#ifdef __HIDE_PASSWORD
|
#ifdef __HIDE_PASSWORD
|
||||||
ESP_LOGI(TAG, "Failed to connect to SSID: %s, password: XXXXXXXX", _ssid);
|
ESP_LOGI(TAG, "Failed to connect to SSID: %s, password: XXXXXXXX", _ssid);
|
||||||
#else
|
#else
|
||||||
ESP_LOGI(TAG, "Failed to connect to SSID: %s, password: %s", _ssid, _password);
|
ESP_LOGI(TAG, "Failed to connect to SSID: %s, password: %s", _ssid, _password);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGE(TAG, "UNEXPECTED EVENT");
|
ESP_LOGE(TAG, "UNEXPECTED EVENT");
|
||||||
}
|
}
|
||||||
@@ -289,3 +303,7 @@ void wifi_init_sta(const char *_ssid, const char *_password)
|
|||||||
wifi_init_sta(_ssid, _password, NULL, NULL, NULL, NULL, NULL);
|
wifi_init_sta(_ssid, _password, NULL, NULL, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool getWIFIisConnected() {
|
||||||
|
return WIFIConnected;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ void wifi_init_sta(const char *_ssid, const char *_password);
|
|||||||
std::string* getIPAddress();
|
std::string* getIPAddress();
|
||||||
std::string* getSSID();
|
std::string* getSSID();
|
||||||
int get_WIFI_RSSI();
|
int get_WIFI_RSSI();
|
||||||
|
bool getWIFIisConnected();
|
||||||
|
|
||||||
extern std::string hostname;
|
extern std::string hostname;
|
||||||
extern std::string std_hostname;
|
extern std::string std_hostname;
|
||||||
|
|||||||
@@ -65,5 +65,6 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/main/*.*)
|
|||||||
# idf_component_register(SRCS ${app_sources})
|
# idf_component_register(SRCS ${app_sources})
|
||||||
|
|
||||||
idf_component_register(SRCS ${app_sources}
|
idf_component_register(SRCS ${app_sources}
|
||||||
INCLUDE_DIRS ".")
|
INCLUDE_DIRS "."
|
||||||
|
# REQUIRES esp_psram) # comming in IDF 5.0
|
||||||
|
)
|
||||||
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
//#include "esp_psram.h" // Comming in IDF 5.0, see https://docs.espressif.com/projects/esp-idf/en/v5.0-beta1/esp32/migration-guides/release-5.x/system.html?highlight=esp_psram_get_size
|
||||||
|
#include "esp32/spiram.h"
|
||||||
|
|
||||||
// SD-Card ////////////////////
|
// SD-Card ////////////////////
|
||||||
#include "nvs_flash.h"
|
#include "nvs_flash.h"
|
||||||
@@ -122,7 +124,7 @@ bool Init_NVS_SDCard()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void task_NoSDBlink(void *pvParameter)
|
void task_MainInitError_blink(void *pvParameter)
|
||||||
{
|
{
|
||||||
gpio_pad_select_gpio(BLINK_GPIO);
|
gpio_pad_select_gpio(BLINK_GPIO);
|
||||||
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
|
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
|
||||||
@@ -147,7 +149,6 @@ void task_NoSDBlink(void *pvParameter)
|
|||||||
extern "C" void app_main(void)
|
extern "C" void app_main(void)
|
||||||
{
|
{
|
||||||
TickType_t xDelay;
|
TickType_t xDelay;
|
||||||
bool initSucessful = true;
|
|
||||||
|
|
||||||
ESP_LOGI(TAG, "\n\n\n\n\n"); // Add mark on log to see when it restarted
|
ESP_LOGI(TAG, "\n\n\n\n\n"); // Add mark on log to see when it restarted
|
||||||
|
|
||||||
@@ -160,9 +161,9 @@ extern "C" void app_main(void)
|
|||||||
|
|
||||||
if (!Init_NVS_SDCard())
|
if (!Init_NVS_SDCard())
|
||||||
{
|
{
|
||||||
xTaskCreate(&task_NoSDBlink, "task_NoSDBlink", configMINIMAL_STACK_SIZE * 64, NULL, tskIDLE_PRIORITY+1, NULL);
|
xTaskCreate(&task_MainInitError_blink, "task_MainInitError_blink", configMINIMAL_STACK_SIZE * 64, NULL, tskIDLE_PRIORITY+1, NULL);
|
||||||
return;
|
return; // No way to continue without SD-Card!
|
||||||
};
|
}
|
||||||
|
|
||||||
string versionFormated = "Branch: '" + std::string(GIT_BRANCH) + \
|
string versionFormated = "Branch: '" + std::string(GIT_BRANCH) + \
|
||||||
"', Revision: " + std::string(GIT_REV) +", Date/Time: " + std::string(BUILD_TIME) + \
|
"', Revision: " + std::string(GIT_REV) +", Date/Time: " + std::string(BUILD_TIME) + \
|
||||||
@@ -216,6 +217,7 @@ extern "C" void app_main(void)
|
|||||||
|
|
||||||
if (!setup_time()) {
|
if (!setup_time()) {
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "NTP Initialization failed!");
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "NTP Initialization failed!");
|
||||||
|
setSystemStatusFlag(SYSTEM_STATUS_NTP_BAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
setBootTime();
|
setBootTime();
|
||||||
@@ -231,13 +233,32 @@ extern "C" void app_main(void)
|
|||||||
std::string zw = gettimestring("%Y%m%d-%H%M%S");
|
std::string zw = gettimestring("%Y%m%d-%H%M%S");
|
||||||
ESP_LOGD(TAG, "time %s", zw.c_str());
|
ESP_LOGD(TAG, "time %s", zw.c_str());
|
||||||
|
|
||||||
|
/* Check if PSRAM can be initalized */
|
||||||
|
esp_err_t ret;
|
||||||
|
ret = esp_spiram_init();
|
||||||
|
if (ret == ESP_FAIL) { // Failed to init PSRAM, most likely not available or broken
|
||||||
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to initialize PSRAM (" + std::to_string(ret) + ")!");
|
||||||
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Either your device misses the PSRAM chip or it is broken!");
|
||||||
|
setSystemStatusFlag(SYSTEM_STATUS_PSRAM_BAD);
|
||||||
|
}
|
||||||
|
else { // PSRAM init ok
|
||||||
|
/* Check if PSRAM provides at least 4 MB */
|
||||||
|
size_t psram_size = esp_spiram_get_size();
|
||||||
|
// size_t psram_size = esp_psram_get_size(); // comming in IDF 5.0
|
||||||
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "The device has " + std::to_string(psram_size/1024/1024) + " MBytes of PSRAM");
|
||||||
|
if (psram_size < (4*1024*1024)) { // PSRAM is below 4 MBytes
|
||||||
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "At least 4 MBytes are required!");
|
||||||
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Does the device really have a 4 Mbytes PSRAM?");
|
||||||
|
setSystemStatusFlag(SYSTEM_STATUS_PSRAM_BAD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check available Heap memory */
|
||||||
size_t _hsize = getESPHeapSize();
|
size_t _hsize = getESPHeapSize();
|
||||||
if (_hsize < 4000000) // Check for a bit less than 4 MB (but clearly over 2 MB)
|
if (_hsize < 4000000) { // Check available Heap memory for a bit less than 4 MB (a test on a good device showed 4187558 bytes to be available)
|
||||||
{
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Not enough Heap memory available. Expected around 4 MBytes, but only " + std::to_string(_hsize) + " Bytes are available! That is not enough for this firmware!");
|
||||||
std::string _zws = "Not enough PSRAM available. Expected around 4 MBytes - available: " + std::to_string((float)_hsize/1024/1024) + " MBytes!";
|
setSystemStatusFlag(SYSTEM_STATUS_HEAP_TOO_SMALL);
|
||||||
_zws = _zws + "\nEither not initialized, too small (2 MByte only) or not present at all. Firmware cannot start!!";
|
} else { // Heap memory is ok
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, _zws);
|
|
||||||
} else { // Bad Camera Status, retry init
|
|
||||||
if (camStatus != ESP_OK) {
|
if (camStatus != ESP_OK) {
|
||||||
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Failed to initialize camera module, retrying...");
|
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Failed to initialize camera module, retrying...");
|
||||||
|
|
||||||
@@ -251,7 +272,7 @@ extern "C" void app_main(void)
|
|||||||
if (camStatus != ESP_OK) {
|
if (camStatus != ESP_OK) {
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to initialize camera module!");
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to initialize camera module!");
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Check that your camera module is working and connected properly!");
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Check that your camera module is working and connected properly!");
|
||||||
initSucessful = false;
|
setSystemStatusFlag(SYSTEM_STATUS_CAM_BAD);
|
||||||
}
|
}
|
||||||
} else { // Test Camera
|
} else { // Test Camera
|
||||||
camera_fb_t * fb = esp_camera_fb_get();
|
camera_fb_t * fb = esp_camera_fb_get();
|
||||||
@@ -259,8 +280,8 @@ extern "C" void app_main(void)
|
|||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Camera Framebuffer cannot be initialized!");
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Camera Framebuffer cannot be initialized!");
|
||||||
/* Easiest would be to simply restart here and try again,
|
/* Easiest would be to simply restart here and try again,
|
||||||
how ever there seem to be systems where it fails at startup but still work corectly later.
|
how ever there seem to be systems where it fails at startup but still work corectly later.
|
||||||
Therefore we treat it still as successed!
|
Therefore we treat it still as successed! */
|
||||||
//initSucessful = false; */
|
setSystemStatusFlag(SYSTEM_STATUS_CAM_FB_BAD);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
esp_camera_fb_return(fb);
|
esp_camera_fb_return(fb);
|
||||||
@@ -269,8 +290,6 @@ extern "C" void app_main(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
xDelay = 2000 / portTICK_PERIOD_MS;
|
xDelay = 2000 / portTICK_PERIOD_MS;
|
||||||
ESP_LOGD(TAG, "main: sleep for: %ldms", (long) xDelay*10);
|
ESP_LOGD(TAG, "main: sleep for: %ldms", (long) xDelay*10);
|
||||||
vTaskDelay( xDelay );
|
vTaskDelay( xDelay );
|
||||||
@@ -291,17 +310,24 @@ extern "C" void app_main(void)
|
|||||||
ESP_LOGD(TAG, "vor reg server main");
|
ESP_LOGD(TAG, "vor reg server main");
|
||||||
register_server_main_uri(server, "/sdcard");
|
register_server_main_uri(server, "/sdcard");
|
||||||
|
|
||||||
if (initSucessful) {
|
|
||||||
|
/* Testing */
|
||||||
|
//setSystemStatusFlag(SYSTEM_STATUS_CAM_FB_BAD);
|
||||||
|
//setSystemStatusFlag(SYSTEM_STATUS_PSRAM_BAD);
|
||||||
|
|
||||||
|
/* Main Init has successed or only an error which allows to continue operation */
|
||||||
|
if (getSystemStatus() == 0) { // No error flag is set
|
||||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Initialization completed successfully!");
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Initialization completed successfully!");
|
||||||
ESP_LOGD(TAG, "vor do autostart");
|
ESP_LOGD(TAG, "vor do autostart");
|
||||||
TFliteDoAutoStart();
|
TFliteDoAutoStart();
|
||||||
}
|
}
|
||||||
else { // Initialization failed
|
else if (isSetSystemStatusFlag(SYSTEM_STATUS_CAM_FB_BAD) || // Non critical errors occured, we try to continue...
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Initialization failed. Will restart in 5 minutes!");
|
isSetSystemStatusFlag(SYSTEM_STATUS_NTP_BAD)) {
|
||||||
vTaskDelay(60*4000 / portTICK_RATE_MS); // Wait 4 minutes to give time to do an OTA or fetch the log
|
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Initialization completed with errors, but trying to continue...");
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Initialization failed. Will restart in 1 minute!");
|
ESP_LOGD(TAG, "vor do autostart");
|
||||||
vTaskDelay(60*1000 / portTICK_RATE_MS); // Wait 1 minute to give time to do an OTA or fetch the log
|
TFliteDoAutoStart();
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Initialization failed. Will restart now!");
|
}
|
||||||
doReboot();
|
else { // Any other error is critical and makes running the flow impossible.
|
||||||
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Initialization failed. Not starting flows!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,6 +128,14 @@ esp_err_t info_get_handler(httpd_req_t *req)
|
|||||||
httpd_resp_sendstr_chunk(req, NULL);
|
httpd_resp_sendstr_chunk(req, NULL);
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
else if (_task.compare("Round") == 0)
|
||||||
|
{
|
||||||
|
char formated[10] = "";
|
||||||
|
snprintf(formated, sizeof(formated), "%d", getCountFlowRounds());
|
||||||
|
httpd_resp_sendstr_chunk(req, formated);
|
||||||
|
httpd_resp_sendstr_chunk(req, NULL);
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
else if (_task.compare("SDCardPartitionSize") == 0)
|
else if (_task.compare("SDCardPartitionSize") == 0)
|
||||||
{
|
{
|
||||||
std::string zw;
|
std::string zw;
|
||||||
@@ -230,9 +238,33 @@ esp_err_t hello_main_handler(httpd_req_t *req)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filetosend == "/sdcard/html/index.html" && isSetupModusActive()) {
|
if (filetosend == "/sdcard/html/index.html") {
|
||||||
ESP_LOGD(TAG, "System is in setup mode --> index.html --> setup.html");
|
if (isSetSystemStatusFlag(SYSTEM_STATUS_PSRAM_BAD) || // Initialization failed with crritical errors!
|
||||||
filetosend = "/sdcard/html/setup.html";
|
isSetSystemStatusFlag(SYSTEM_STATUS_CAM_BAD)) {
|
||||||
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "We have a critical error, not serving main page!");
|
||||||
|
|
||||||
|
char buf[20];
|
||||||
|
std::string message = "<h1>AI on the Edge Device</h1><b>We have one or more critical errors:</b><br>";
|
||||||
|
|
||||||
|
for (int i = 0; i < 32; i++) {
|
||||||
|
if (isSetSystemStatusFlag((SystemStatusFlag_t)(1<<i))) {
|
||||||
|
snprintf(buf, sizeof(buf), "0x%08X", 1<<i);
|
||||||
|
message += std::string(buf) + "<br>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message += "<br>Please check <a href=\"https://github.com/jomjol/AI-on-the-edge-device/wiki/Error-Codes\" target=_blank>github.com/jomjol/AI-on-the-edge-device/wiki/Error-Codes</a> for more information!";
|
||||||
|
message += "<br><br><button onclick=\"window.location.href='/reboot';\">Reboot</button>";
|
||||||
|
message += " <button onclick=\"window.open('/ota_page.html');\">OTA Update</button>";
|
||||||
|
message += " <button onclick=\"window.open('/log.html');\">Log Viewer</button>";
|
||||||
|
message += " <button onclick=\"window.open('/info.html');\">Show System Info</button>";
|
||||||
|
httpd_resp_send_err(req, HTTPD_500_INTERNAL_SERVER_ERROR, message.c_str());
|
||||||
|
return ESP_FAIL;
|
||||||
|
}
|
||||||
|
else if (isSetupModusActive()) {
|
||||||
|
ESP_LOGD(TAG, "System is in setup mode --> index.html --> setup.html");
|
||||||
|
filetosend = "/sdcard/html/setup.html";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGD(TAG, "Filename: %s", filename);
|
ESP_LOGD(TAG, "Filename: %s", filename);
|
||||||
@@ -427,9 +459,9 @@ httpd_handle_t start_webserver(void)
|
|||||||
httpd_handle_t server = NULL;
|
httpd_handle_t server = NULL;
|
||||||
httpd_config_t config = { };
|
httpd_config_t config = { };
|
||||||
|
|
||||||
config.task_priority = tskIDLE_PRIORITY+1; // 20210924 --> vorher +5
|
config.task_priority = tskIDLE_PRIORITY+3; //20221211: before: tskIDLE_PRIORITY+1; // 20210924 --> vorher +5
|
||||||
config.stack_size = 32768; //20210921 --> vorher 32768 // bei 32k stürzt das Programm beim Bilderaufnehmen ab
|
config.stack_size = 32768; //20210921 --> vorher 32768 // bei 32k stürzt das Programm beim Bilderaufnehmen ab
|
||||||
config.core_id = tskNO_AFFINITY;
|
config.core_id = 0; //20221211 --> force all not flow related tasks to CPU0, before: tskNO_AFFINITY;
|
||||||
config.server_port = 80;
|
config.server_port = 80;
|
||||||
config.ctrl_port = 32768;
|
config.ctrl_port = 32768;
|
||||||
config.max_open_sockets = 5; //20210921 --> vorher 7
|
config.max_open_sockets = 5; //20210921 --> vorher 7
|
||||||
@@ -437,8 +469,8 @@ httpd_handle_t start_webserver(void)
|
|||||||
config.max_resp_headers = 8;
|
config.max_resp_headers = 8;
|
||||||
config.backlog_conn = 5;
|
config.backlog_conn = 5;
|
||||||
config.lru_purge_enable = true; // dadurch werden alte Verbindungen gekappt, falls neue benögt werden.
|
config.lru_purge_enable = true; // dadurch werden alte Verbindungen gekappt, falls neue benögt werden.
|
||||||
config.recv_wait_timeout = 5; // default: 5 20210924 --> vorher 30
|
config.recv_wait_timeout = 5; // default: 5 20210924 --> vorher 30
|
||||||
config.send_wait_timeout = 5; // default: 5 20210924 --> vorher 30
|
config.send_wait_timeout = 5; // default: 5 20210924 --> vorher 30
|
||||||
config.global_user_ctx = NULL;
|
config.global_user_ctx = NULL;
|
||||||
config.global_user_ctx_free_fn = NULL;
|
config.global_user_ctx_free_fn = NULL;
|
||||||
config.global_transport_ctx = NULL;
|
config.global_transport_ctx = NULL;
|
||||||
|
|||||||
@@ -36,28 +36,31 @@ CONFIG_SPIRAM_MEMTEST=y
|
|||||||
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384
|
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384
|
||||||
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=40960
|
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=40960
|
||||||
CONFIG_SPIRAM_CACHE_WORKAROUND=y
|
CONFIG_SPIRAM_CACHE_WORKAROUND=y
|
||||||
|
CONFIG_SPIRAM_IGNORE_NOTFOUND=y
|
||||||
|
|
||||||
CONFIG_ESP_INT_WDT_TIMEOUT_MS=300
|
CONFIG_ESP_INT_WDT_TIMEOUT_MS=300
|
||||||
|
|
||||||
CONFIG_HTTPD_MAX_REQ_HDR_LEN=1024
|
CONFIG_HTTPD_MAX_REQ_HDR_LEN=1024
|
||||||
|
|
||||||
CONFIG_HTTPD_PURGE_BUF_LEN=16
|
CONFIG_HTTPD_PURGE_BUF_LEN=16
|
||||||
|
|
||||||
CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=16
|
CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=16
|
||||||
|
|
||||||
CONFIG_ESP32_WIFI_CACHE_TX_BUFFER_NUM=16
|
CONFIG_ESP32_WIFI_CACHE_TX_BUFFER_NUM=16
|
||||||
|
|
||||||
CONFIG_FATFS_LFN_HEAP=y
|
CONFIG_FATFS_LFN_HEAP=y
|
||||||
|
|
||||||
CONFIG_FATFS_MAX_LFN=255
|
CONFIG_FATFS_MAX_LFN=255
|
||||||
CONFIG_FATFS_API_ENCODING_ANSI_OEM=y
|
CONFIG_FATFS_API_ENCODING_ANSI_OEM=y
|
||||||
|
|
||||||
CONFIG_FMB_TIMER_PORT_ENABLED=y
|
CONFIG_FMB_TIMER_PORT_ENABLED=y
|
||||||
|
|
||||||
|
CONFIG_MQTT_MSG_ID_INCREMENTAL=y
|
||||||
CONFIG_MQTT_SKIP_PUBLISH_IF_DISCONNECTED=y
|
CONFIG_MQTT_SKIP_PUBLISH_IF_DISCONNECTED=y
|
||||||
|
CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED=y
|
||||||
|
CONFIG_MQTT_USE_CORE_0=y
|
||||||
|
|
||||||
CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=n
|
CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=n
|
||||||
|
|
||||||
|
CONFIG_CAMERA_CORE0=n
|
||||||
|
CONFIG_CAMERA_CORE1=y
|
||||||
CONFIG_OV7670_SUPPORT=n
|
CONFIG_OV7670_SUPPORT=n
|
||||||
CONFIG_OV7725_SUPPORT=n
|
CONFIG_OV7725_SUPPORT=n
|
||||||
CONFIG_NT99141_SUPPORT=n
|
CONFIG_NT99141_SUPPORT=n
|
||||||
|
|||||||
25
docs/.gitignore
vendored
25
docs/.gitignore
vendored
@@ -1,25 +0,0 @@
|
|||||||
# Remove if certain files are committed on purpose
|
|
||||||
.pio/
|
|
||||||
.vscode/
|
|
||||||
.code-workspace
|
|
||||||
/sd-card/htm./.vscode/
|
|
||||||
/code/build
|
|
||||||
/code/.helper
|
|
||||||
/sd-card/html/debug/
|
|
||||||
/firmware/
|
|
||||||
version.txt
|
|
||||||
/dist/
|
|
||||||
/dist_release/
|
|
||||||
/dist_old_ota
|
|
||||||
CMakeLists.txt.user
|
|
||||||
CMakeCache.txt
|
|
||||||
CMakeFiles
|
|
||||||
CMakeScripts
|
|
||||||
Makefile
|
|
||||||
cmake_install.cmake
|
|
||||||
install_manifest.txt
|
|
||||||
compile_commands.json
|
|
||||||
CTestTestfile.cmake
|
|
||||||
_deps
|
|
||||||
code/edgeAI.code-workspace
|
|
||||||
.DS_Store
|
|
||||||
9
docs/.gitmodules
vendored
9
docs/.gitmodules
vendored
@@ -1,9 +0,0 @@
|
|||||||
[submodule "code/components/esp32-camera"]
|
|
||||||
path = code/components/esp32-camera
|
|
||||||
url = https://github.com/espressif/esp32-camera.git
|
|
||||||
[submodule "code/components/esp-nn"]
|
|
||||||
path = code/components/esp-nn
|
|
||||||
url = https://github.com/espressif/esp-nn.git
|
|
||||||
[submodule "code/components/tflite-micro-esp-examples"]
|
|
||||||
path = code/components/tflite-micro-esp-examples
|
|
||||||
url = https://github.com/espressif/tflite-micro-esp-examples.git
|
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
<p>Notes:</p>
|
<p>Notes:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>For the installation, make sure to switch the ESP32 to Bootloader mode!</li>
|
<li>For the installation, make sure to switch the ESP32 to Bootloader mode!</li>
|
||||||
|
<li>The SD-Card still must be flashed separately on a PC (See in the <a href=https://github.com/jomjol/AI-on-the-edge-device/wiki/Installation>Wiki</a>)!</li>
|
||||||
<li>After the installation, a manual reset might be required!</li>
|
<li>After the installation, a manual reset might be required!</li>
|
||||||
<li>Please note that not all webbrowsers and operating systems support the needed access to USB!</li>
|
<li>Please note that not all webbrowsers and operating systems support the needed access to USB!</li>
|
||||||
<li>Check the <a href=https://github.com/jomjol/AI-on-the-edge-device/wiki/Installation>Wiki</a> for additional information.</li>
|
<li>Check the <a href=https://github.com/jomjol/AI-on-the-edge-device/wiki/Installation>Wiki</a> for additional information.</li>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "AI-on-the-edge",
|
"name": "AI-on-the-edge",
|
||||||
"version": "13.0.5",
|
"version": "13.0.7",
|
||||||
"funding_url": "https://www.paypal.com/donate?hosted_button_id=8TRSVYNYKDSWL",
|
"funding_url": "https://www.paypal.com/donate?hosted_button_id=8TRSVYNYKDSWL",
|
||||||
"new_install_prompt_erase": false,
|
"new_install_prompt_erase": false,
|
||||||
"builds": [
|
"builds": [
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
"offset": 32768
|
"offset": 32768
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "releases/download/v13.0.5/firmware.bin",
|
"path": "releases/download/v13.0.7/firmware.bin",
|
||||||
"offset": 65536
|
"offset": 65536
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
BIN
docs/releases/download/v13.0.7/firmware.bin
Normal file
BIN
docs/releases/download/v13.0.7/firmware.bin
Normal file
Binary file not shown.
BIN
sd-card/config/ana-class100_0154_s1_q.tflite
Normal file
BIN
sd-card/config/ana-class100_0154_s1_q.tflite
Normal file
Binary file not shown.
BIN
sd-card/config/ana-cont_1104_s2_q.tflite
Normal file
BIN
sd-card/config/ana-cont_1104_s2_q.tflite
Normal file
Binary file not shown.
BIN
sd-card/config/dig-class100-0150_s2_q.tflite
Normal file
BIN
sd-card/config/dig-class100-0150_s2_q.tflite
Normal file
Binary file not shown.
@@ -25,7 +25,7 @@
|
|||||||
flex: 0 1 auto;
|
flex: 0 1 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
#log {
|
#data {
|
||||||
font-family: 'Courier New', Courier, monospace;
|
font-family: 'Courier New', Courier, monospace;
|
||||||
font-size: small;
|
font-size: small;
|
||||||
}
|
}
|
||||||
@@ -37,54 +37,36 @@
|
|||||||
<button onClick="reload();">Reload</button>
|
<button onClick="reload();">Reload</button>
|
||||||
<button onClick="window.open('datafileact');">Show full data</button>
|
<button onClick="window.open('datafileact');">Show full data</button>
|
||||||
<button onClick="window.location.href = 'fileserver/log/data/'">Show older data files</button>
|
<button onClick="window.location.href = 'fileserver/log/data/'">Show older data files</button>
|
||||||
|
<a href="graph.html" target="_self">Show graph</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="row content" id="log"><br><br><br><b>Loading Logfile, please wait...</b></div>
|
<div class="row content" id="data"><br><br><br><b>Loading Data file, please wait...</b></div>
|
||||||
<div class="row footer">
|
<div class="row footer">
|
||||||
<button onClick="reload();">Reload</button>
|
<button onClick="reload();">Reload</button>
|
||||||
<button onClick="window.open('datafileact');">Show full data</button>
|
<button onClick="window.open('datafileact');">Show full data</button>
|
||||||
<button onClick="window.location.href = 'fileserver/log/data/'">Show older data files</button>
|
<button onClick="window.location.href = 'fileserver/log/data/'">Show older data files</button>
|
||||||
|
<a href="graph.html" target="_self">Show graph</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function reload() {
|
function reload() {
|
||||||
// document.getElementById('log').innerHTML += "<br><b>Reloading...<b><br><br>";
|
document.getElementById('data').innerHTML += "<br><b>Reloading...<b><br><br>";
|
||||||
document.getElementById('log').innerHTML += "<b>Reloading...</b>";
|
|
||||||
window.scrollBy(0,document.body.scrollHeight);
|
window.scrollBy(0,document.body.scrollHeight);
|
||||||
funcRequest('log');
|
funcRequest('data');
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function processLogLine(line, index, arr) {
|
|
||||||
if (line.includes("<WRN>")) {
|
|
||||||
arr[index] = "<span style=\"color:#e83c00\">" + line + "</span>";
|
|
||||||
}
|
|
||||||
else if (line.includes("<ERR>")) {
|
|
||||||
arr[index] = "<span style=\"color:red\"><b>" + line + "</b></span>";
|
|
||||||
}
|
|
||||||
else if (line.includes("<DBG>")) {
|
|
||||||
arr[index] = "<span style=\"color:gray\">" + line + "</span>";
|
|
||||||
}
|
|
||||||
|
|
||||||
arr[index] += "<br>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function funcRequest(url){
|
async function funcRequest(url){
|
||||||
await fetch(url)
|
await fetch(url)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
document.getElementById("log").innerHTML = "HTTP error " + res.status;
|
document.getElementById("data").innerHTML = "HTTP error " + res.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.text();
|
return res.text();
|
||||||
})
|
})
|
||||||
.then((log) => {
|
.then((data) => {
|
||||||
log = log.replace(/</g, "<").replace(/>/g, ">");
|
document.getElementById('data').innerHTML = "<br>" + data.split("\n").join("\n<br>") + " ";
|
||||||
logArr = log.split("\n");
|
|
||||||
logArr.forEach(processLogLine);
|
|
||||||
|
|
||||||
document.getElementById('log').innerHTML = "<br>" + logArr.join("\n") + " ";
|
|
||||||
|
|
||||||
window.scrollBy(0,document.body.scrollHeight);
|
window.scrollBy(0,document.body.scrollHeight);
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ function getbasepath(){
|
|||||||
{
|
{
|
||||||
// host = "http://192.168.2.219"; // jomjol interner test
|
// host = "http://192.168.2.219"; // jomjol interner test
|
||||||
// host = "http://192.168.178.46"; // jomjol interner test
|
// host = "http://192.168.178.46"; // jomjol interner test
|
||||||
host = "http://192.168.178.44"; // jomjol interner Real
|
host = "http://192.168.178.46"; // jomjol interner Real
|
||||||
// host = "http://192.168.43.191";
|
// host = "http://192.168.43.191";
|
||||||
// host = "."; // jomjol interner localhost
|
// host = "."; // jomjol interner localhost
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,16 @@ div {
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
Uptime:
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div id="uptime">
|
||||||
|
<object data="/uptime"></object>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h3>Build Info</h3>
|
<h3>Build Info</h3>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
.tg {border-collapse:collapse;border-spacing:0;width:100%;color: darkslategray;border: inset;height:585px;}
|
.tg {border-collapse:collapse;border-spacing:0;width:100%;color: darkslategray;border: inset;height:585px;}
|
||||||
.tg td{font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;}
|
.tg td{font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;}
|
||||||
.tg th{height: 50px;font-size:24px;font-weight:bold;text-align:left;padding:0px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#f0f0f0}
|
.tg th{height: 50px;font-size:24px;font-weight:bold;text-align:left;padding:0px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#f0f0f0}
|
||||||
.tg .tg-1{width:77%;font-size:20px;font-family:Arial, Helvetica, sans-serif !important;border: inset;}
|
.tg .tg-1{width:700px;font-size:20px;font-family:Arial, Helvetica, sans-serif !important;border: inset;}
|
||||||
.tg .tg-2{font-size:20px;font-family:Arial, Helvetica, sans-serif !important;border: inset;}
|
.tg .tg-2{font-size:20px;font-family:Arial, Helvetica, sans-serif !important;border: inset;}
|
||||||
.tg .tg-3{height: 15px;font-size:14px;font-family:Arial, Helvetica, sans-serif !important;border: inset;}
|
.tg .tg-3{height: 15px;font-size:14px;font-family:Arial, Helvetica, sans-serif !important;border: inset;}
|
||||||
</style>
|
</style>
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="th">Error:</th>
|
<th class="th">Status:</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="tg-2">
|
<td class="tg-2">
|
||||||
@@ -59,6 +59,10 @@
|
|||||||
<div id="statusflow" ></div>
|
<div id="statusflow" ></div>
|
||||||
<div id="cputemp" ></div>
|
<div id="cputemp" ></div>
|
||||||
<div id="rssi" ></div>
|
<div id="rssi" ></div>
|
||||||
|
<div>
|
||||||
|
<span id="uptime" ></span>
|
||||||
|
<span id="round" ></span>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -87,6 +91,8 @@ function addZero(i) {
|
|||||||
loadStatus();
|
loadStatus();
|
||||||
loadCPUTemp();
|
loadCPUTemp();
|
||||||
loadRSSI();
|
loadRSSI();
|
||||||
|
loadUptime();
|
||||||
|
loadRoundCounter();
|
||||||
refresh();
|
refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -116,8 +122,7 @@ function refresh() {
|
|||||||
xhttp.onreadystatechange = function() {
|
xhttp.onreadystatechange = function() {
|
||||||
if (this.readyState == 4 && this.status == 200) {
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
var _rsp = xhttp.responseText;
|
var _rsp = xhttp.responseText;
|
||||||
_rsp = "Status: " + _rsp;
|
$('#statusflow').html("Status: " + _rsp);
|
||||||
$('#statusflow').html(_rsp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xhttp.open("GET", url, true);
|
xhttp.open("GET", url, true);
|
||||||
@@ -130,7 +135,7 @@ function refresh() {
|
|||||||
xhttp.onreadystatechange = function() {
|
xhttp.onreadystatechange = function() {
|
||||||
if (this.readyState == 4 && this.status == 200) {
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
var _rsp = xhttp.responseText;
|
var _rsp = xhttp.responseText;
|
||||||
$('#cputemp').html(_rsp);
|
$('#cputemp').html("CPU Temperature: " +_rsp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xhttp.open("GET", url, true);
|
xhttp.open("GET", url, true);
|
||||||
@@ -143,7 +148,33 @@ function refresh() {
|
|||||||
xhttp.onreadystatechange = function() {
|
xhttp.onreadystatechange = function() {
|
||||||
if (this.readyState == 4 && this.status == 200) {
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
var _rsp = xhttp.responseText;
|
var _rsp = xhttp.responseText;
|
||||||
$('#rssi').html(_rsp);
|
$('#rssi').html("RSSI: " + _rsp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhttp.open("GET", url, true);
|
||||||
|
xhttp.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadUptime() {
|
||||||
|
url = basepath + '/uptime';
|
||||||
|
var xhttp = new XMLHttpRequest();
|
||||||
|
xhttp.onreadystatechange = function() {
|
||||||
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
|
var _rsp = xhttp.responseText;
|
||||||
|
$('#uptime').html("Uptime: " + _rsp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhttp.open("GET", url, true);
|
||||||
|
xhttp.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadRoundCounter() {
|
||||||
|
url = basepath + '/info?type=Round';
|
||||||
|
var xhttp = new XMLHttpRequest();
|
||||||
|
xhttp.onreadystatechange = function() {
|
||||||
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
|
var _rsp = xhttp.responseText;
|
||||||
|
$('#round').html("(Round: " + _rsp + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xhttp.open("GET", url, true);
|
xhttp.open("GET", url, true);
|
||||||
@@ -199,6 +230,8 @@ function refresh() {
|
|||||||
loadStatus();
|
loadStatus();
|
||||||
loadCPUTemp();
|
loadCPUTemp();
|
||||||
loadRSSI();
|
loadRSSI();
|
||||||
|
loadUptime();
|
||||||
|
loadRoundCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|||||||
@@ -706,7 +706,7 @@ function getNUMBERInfo(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function RenameNUMBER(_alt, _neu){
|
function RenameNUMBER(_alt, _neu){
|
||||||
if ((_neu.search(".") >= 0) || (_neu.search(",") >= 0) || (_neu.search(" ") >= 0) || (_neu.search("\"") >= 0))
|
if ((_neu.indexOf(".") >= 0) || (_neu.indexOf(",") >= 0) || (_neu.indexOf(" ") >= 0) || (_neu.indexOf("\"") >= 0))
|
||||||
{
|
{
|
||||||
return "Name must not contain ',', '.', ' ' or '\"' - please change name";
|
return "Name must not contain ',', '.', ' ' or '\"' - please change name";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,8 +30,7 @@
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<script type="text/javascript" src="./html/gethost.js">
|
<script type="text/javascript" src="/fileserver/html/gethost.js">
|
||||||
// Achtung dieses Script wird mit /fileserver aufgerufen, daher muss hier /html/gethost.js verwendet werden!
|
|
||||||
</script>
|
</script>
|
||||||
<script language="JavaScript">
|
<script language="JavaScript">
|
||||||
function setpath() {
|
function setpath() {
|
||||||
|
|||||||
Reference in New Issue
Block a user