Merge branch 'rolling'

This commit is contained in:
jomjol
2022-11-27 18:43:31 +01:00
5 changed files with 123 additions and 33 deletions

View File

@@ -170,9 +170,8 @@ jobs:
- name: Store generated files in cache
uses: actions/cache@v3
with:
path: |
./dist
key: ${{ steps.vars.outputs.branch }}-pack-for-OTA-v2
path: dist
key: ${{ github.run_number }}-pack-for-OTA-v2
@@ -225,8 +224,7 @@ jobs:
- name: Store generated files in cache
uses: actions/cache@v3
with:
path: |
./firmware
path: firmware
key: ${{ github.run_number }}-pack-for-fresh-install
@@ -242,6 +240,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Set Variables
id: vars
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Get generated files from cache
uses: actions/cache@v3
@@ -251,34 +253,31 @@ jobs:
./code/.pio/build/esp32cam/partitions.bin
./code/.pio/build/esp32cam/bootloader.bin
./sd-card/html/version.txt
key: ${{ github.run_number }}
key: ${{ steps.vars.outputs.branch }}
# import the changes from
- name: Get generated files from cache
uses: actions/cache@v3
with:
path: |
./dist
path: dist
key: ${{ github.run_number }}-pack-for-OTA-v2
# import cached artifacts from pack-for-fresh-install
- name: Get generated files from cache
uses: actions/cache@v3
with:
path: |
./firmware
path: firmware
key: ${{ github.run_number }}-pack-for-fresh-install
- name: Set Variables
id: vars
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Prepare artifacts for release
run: |
mkdir -p release
mkdir -p dist
# create a update.zip like "update__rolling"
pwd
ls ./dist
cd ./dist
zip -r ../release/update.zip .
cd ../firmware

View File

@@ -2,44 +2,52 @@
## [Unreleased]
Home Assistant Discovery Support
**Home Assistant MQTT Discovery Support**
**Make sure to read the instructions below carfully!**.
### Update Procedure
:bangbang: **Make sure to read the instructions below carfully!**.
1. Backup your configuration (use the `System -> Backup/Restore` page)!
1. You should update to `12.0.1` before you update to this release. All other migrations are not tested.
1. You should update to `12.0.1` before you update to this release. All other migrations are untested.
1. Upload and update the `update-*.zip` file from this release.
1. 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.
1. Please go to `Settings -> Configuration` and address the changed parameters.
1. Please go to `Settings -> Configuration` and address the changed parameters:
* DataLogging (storing the values for data graph)
* Debug (extended by different debug reporting levels)
If anything breaks you can try to
1. Call `http://<IP>/ota?task=update&file=firmware.bin` resp. `http://<IP>/ota?task=update&file=update-*.zip` if the upload successed but the extraction failed (`update-*.zip` is the name of the uploaded file).
1. Use the initial_esp32_setup.zip ( <https://github.com/jomjol/AI-on-the-edge-device/wiki/Installation> ) as alternative to have a clean install.
If anything breaks you can try to enforce manual update as following:
**OTA:**
1. Make sure the last run of the update completed the **Uploading** step.
1. Call `http://<IP>/ota?task=update&file=<UPLOAD_FILENAME>` to enforce the extraction/flashing.
**Initial Setup:**
1. Use the initial_esp32_setup.zip ( <https://github.com/jomjol/AI-on-the-edge-device/wiki/Installation> ) as alternative to have a clean install.
### Added
- Implementation of [Home Assistant MQTT Discovery](https://www.home-assistant.io/integrations/mqtt/#mqtt-discovery)
- Improved ROIs configuration: locked ROI geometry, equidistant delta x
- `/graph.html` to fetch measurements from the debug log and display them as a graph. Activate debug logging for this feature to work.
- PreValue is now contained in `/json` ([#1154](https://github.com/jomjol/AI-on-the-edge-device/issues/1154))
- Show graph of values direct in the user interface (thanks to [@rdmueller](https://github.com/rdmueller))
- Using new data logging (see below)
- Possibility to choose different values and switch between different numbers (if present)
- SD card info into the `System>Info` menu (thanks to [@Slider007]( https://github.com/Slider0007))
- Added a logging of the values in a text table in `/log/data` - each measurement is on one line
- Improved OTA Update mechanism (only working after installation for next update)
- Added data logging in `/log/data` - One day per file and each measurement is on one line
- Format: csv - comma separated
- Content: `time`, `name-of-number`, `raw-value`, `return-value`, `pre-value`, `change-rate`, `change-absolute`, `error-text`, `cnn-digital`, `cnn-analog`
- Show graph of values direct in the user interface (thanks to [@rdmueller](https://github.com/rdmueller))
- Using new data logging (see above)
- Possibility to choose different values and switch between different numbers (if present)
Note: You need to activate data logging for this feature to work, see above!
- PreValue is now contained in `/json` ([#1154](https://github.com/jomjol/AI-on-the-edge-device/issues/1154))
- SD card info into the `System>Info` menu (thanks to [@Slider007]( https://github.com/Slider0007))
- Version check (Firmware vs. Web UI)
- Various minor new features
### Changed
- Updated tflite (`dig-cont_0600_s3.tflite`)
- Update mode (more robust, not fully bullet prove yet)
- Updated OTA functionality (more robust, but not fully bullet prove yet)
- Updated Espressif library to `espressif32@v5.2.0`
- [#1176](https://github.com/jomjol/AI-on-the-edge-device/discussions/1176) accept minor negative values (-0.2) if extended resolution is enabled
- [#1143](https://github.com/jomjol/AI-on-the-edge-device/issues/1143) added config parameter `AnalogDigitalTransitionStart`. It can setup very early and very late digit transition starts.

View File

@@ -52,6 +52,68 @@ static const char *TAG = "OTA";
esp_err_t handler_reboot(httpd_req_t *req);
std::string _file_name_update;
void task_do_Update_ZIP(void *pvParameter)
{
std::string filetype = toUpper(getFileType(_file_name_update));
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "File: " + _file_name_update + " Filetype: " + filetype);
if (filetype == "ZIP")
{
std::string in, out, outbin, zw, retfirmware;
out = "/sdcard/html";
outbin = "/sdcard/firmware";
retfirmware = unzip_new(_file_name_update, out+"/", outbin+"/");
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Files unzipped.");
if (retfirmware.length() > 0)
{
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Found firmware.bin");
ota_update_task(retfirmware);
}
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Trigger reboot due to firmware update.");
doReboot();
}
else
{
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Only ZIP-Files support for update during startup!");
}
}
void CheckUpdate()
{
FILE *pfile;
if ((pfile = fopen("/sdcard/update.txt", "r")) == NULL)
{
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "No update triggered.");
return;
}
char zw[1024] = "";
fgets(zw, 1024, pfile);
_file_name_update = std::string(zw);
fclose(pfile);
DeleteFile("/sdcard/update.txt"); // Prevent Boot Loop!!!
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Update during boot triggered - Update File: " + _file_name_update);
BaseType_t xReturned;
int _i = configMINIMAL_STACK_SIZE;
xReturned = xTaskCreate(&task_do_Update_ZIP, "task_do_Update_ZIP", configMINIMAL_STACK_SIZE * 35, NULL, tskIDLE_PRIORITY+1, NULL);
TickType_t xDelay;
xDelay = 2000000 / portTICK_PERIOD_MS;
ESP_LOGD(TAG, "Wait for Update to be finished: sleep for: %ldms", (long) xDelay);
vTaskDelay( xDelay );
}
static void infinite_loop(void)
{
@@ -373,6 +435,21 @@ esp_err_t handler_ota_update(httpd_req_t *req)
if (filetype == "ZIP")
{
FILE *pfile;
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Update for reboot.");
pfile = fopen("/sdcard/update.txt", "w");
fwrite(fn.c_str(), fn.length(), 1, pfile);
fclose(pfile);
std::string zw = "reboot\n";
httpd_resp_sendstr_chunk(req, zw.c_str());
httpd_resp_sendstr_chunk(req, NULL);
ESP_LOGD(TAG, "Send reboot");
return ESP_OK;
/*
std::string in, out, outbin, zw, retfirmware;
out = "/sdcard/html";
@@ -392,6 +469,7 @@ esp_err_t handler_ota_update(httpd_req_t *req)
httpd_resp_sendstr_chunk(req, NULL);
return ESP_OK;
}
*/
}
@@ -537,7 +615,7 @@ esp_err_t handler_reboot(httpd_req_t *req)
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "handler_reboot");
ESP_LOGI(TAG, "!!! System will restart within 5 sec!!!");
const char* resp_str = "<body style='font-family: arial'> <h3 id=t></h3></body><script>var h='Rebooting!<br>The page will automatically reload in around 25..60s.<br>'; document.getElementById('t').innerHTML=h; setInterval(function (){h +='.'; document.getElementById('t').innerHTML=h; fetch(window.location.hostname,{mode: 'no-cors'}).then(r=>{parent.location.href=('/index.html');})}, 1000);</script>";
const char* resp_str = "<body style='font-family: arial'> <h3 id=t></h3></body><script>var h='Rebooting!<br>The page will automatically reload in around 25..60s - in case of firmware update up to 180s.<br>'; document.getElementById('t').innerHTML=h; setInterval(function (){h +='.'; document.getElementById('t').innerHTML=h; fetch(window.location.hostname,{mode: 'no-cors'}).then(r=>{parent.location.href=('/index.html');})}, 1000);</script>";
httpd_resp_send(req, resp_str, strlen(resp_str));
doReboot();

View File

@@ -2,10 +2,12 @@
#include <esp_http_server.h>
//#include "ClassControllCamera.h"
#include <string>
void register_server_ota_sdcard_uri(httpd_handle_t server);
void CheckOTAUpdate();
void doReboot();
void hard_restart();
void CheckUpdate();
static bool ota_update_task(std::string fn);

View File

@@ -174,9 +174,12 @@ extern "C" void app_main(void)
ESP_LOGD(TAG, "=============================================================================================");
ESP_LOGD(TAG, "Reset reason: %s", getResetReason().c_str());
CheckOTAUpdate();
LogFile.CreateLogDirectories();
CheckUpdate();
/*
int mk_ret = mkdir("/sdcard/new_fd_mkdir", 0775);
ESP_LOGI(TAG, "mkdir ret %d", mk_ret);