Compare commits

...

31 Commits

Author SHA1 Message Date
jomjol
21a59fbd35 Update README.md 2021-05-30 21:52:52 +02:00
jomjol
cdcf940d12 v7.1.1 2021-05-30 21:49:50 +02:00
jomjol
6cefc44fb6 Update README.md 2021-05-28 20:56:24 +02:00
jomjol
e5ff8f2164 Update Firmware 2021-05-28 19:56:10 +02:00
jomjol
a000252c8a Merge pull request #236 from jomjol/rolling
Update to v7.1.0
2021-05-28 19:53:08 +02:00
jomjol
9a42c580cf v7.1.0 2021-05-28 19:52:26 +02:00
jomjol
6e0a7a742e Rolling 210527 2021-05-27 19:22:27 +02:00
jomjol
026bac121f Rolling 20210522-v2 2021-05-22 11:37:46 +02:00
jomjol
8a26b817f7 Rolling 20210522 2021-05-22 07:39:10 +02:00
jomjol
528a4435a9 Rolling 20210520 2021-05-20 21:58:37 +02:00
jomjol
9b791bb7a7 rolling 20210520 2021-05-20 07:00:09 +02:00
jomjol
58eb0b1292 rolling 20210517 2021-05-17 19:35:38 +02:00
jomjol
39eda4a4be Merge pull request #224 from jomjol/master
sync rolling
2021-05-13 08:23:03 +02:00
jomjol
87a6445ff6 Update version in firmware 2021-05-13 08:22:20 +02:00
jomjol
b7e6d33d48 Merge pull request #223 from jomjol/rolling
Update v7.0.1
2021-05-13 08:17:03 +02:00
jomjol
52e9cd20ee Update v7.0.1 2021-05-13 08:16:01 +02:00
jomjol
b34bd5d988 Merge pull request #217 from jomjol/master
Synch rolling
2021-05-08 18:23:54 +02:00
jomjol
58d5e7bc58 v7.0.0 2021-05-08 18:23:10 +02:00
jomjol
1e09bfbb80 Merge pull request #216 from jomjol/rolling
Update to v7.0.0
2021-05-08 18:20:11 +02:00
jomjol
91fa1c066c Vorbereitung v7.0.0 2021-05-08 18:16:58 +02:00
jomjol
10d49b55d1 Rolling 20210507 2021-05-07 21:33:16 +02:00
jomjol
67d0bf6a27 Update config.ini 2021-05-06 21:54:38 +02:00
jomjol
d36cbde7aa Rolling 20210506v2 2021-05-06 21:50:14 +02:00
jomjol
016f4088d4 Rolling 20210506 2021-05-06 20:28:27 +02:00
jomjol
c2d1bbb4be Merge pull request #205 from jomjol/rolling
v6.7.2
2021-05-01 19:53:26 +02:00
jomjol
bc6a01444a v6.7.2 2021-05-01 19:52:10 +02:00
jomjol
24f0902194 Merge pull request #204 from jomjol/master
Sync Rolling
2021-05-01 17:47:08 +02:00
jomjol
19fd6a10dd v6.7.1 2021-05-01 17:44:56 +02:00
jomjol
a45a5296e4 Merge branch 'rolling' into master 2021-05-01 17:40:31 +02:00
jomjol
1459bb15c1 Prepare v6.7.1 2021-05-01 17:32:22 +02:00
jomjol
ce5f3c463b Rolling 2021-05-01 08:15:11 +02:00
66 changed files with 1652 additions and 800 deletions

View File

@@ -1,5 +1,83 @@
# Versions
##### 6.7.2 Image Processing in Memory - (2021-05-01)
* NEW 6.7.2: Updated html for setup modus - remove reboot on edit configuration)
* NEW 6.7.1: Improved stability of camera (back to v6.6.1) - remove black strips and areas
* Upgrade digital CNN to v8.3.0 (added new type of digits)
* Internal update: TFlite (v2.5), esp32cam, startup sequence
* Rollback to espressif v2.1.0, as v3.2.0 shows unstable reboot
* Bugfix: WLan-passwords, reset of hostname
##### 6.6.1 Image Processing in Memory - (2021-04-05)
* NEW 6.6.1: failed SD card initialization indicated by fast blinking LED at startup
* Improved SD-card handling (increase compatibility with more type of cards)
##### 6.5.0 Image Processing in Memory - (2021-03-25)
* Upgrade digital CNN to v8.2.0 (added new type of digits)
* Supporting alignment structures in ROI definition
* Bug fixing: definition of hostname in `config.ini`
##### 6.4.0 Image Processing in Memory - (2021-03-20)
* Additional alignment marks for settings the ROIs (analog and digit)
* Upgrade analog CNN to v7.0.0 (added new type of pointer)
##### 6.3.1 Image Processing in Memory - (2021-03-16)
* NEW: 6.3.1: bug fixing in initial edit reference image and `config.ini` (Spelling error in `InitialRotate`)
* Initial setup mode: bug fixing, error correction
* Bug-fixing
##### 6.2.2 Image Processing in Memory - (2021-03-10)
* NEW 6.2.2: bug fixing
* NEW 6.2.1: Changed brightness and contrast to default if not enabled (resolves to bright images)
* Determination of fixed illumination settings during startup - speed up of 5s in each run
* Update digital CNN to v8.1.1 (additional digital images trained)
* Extended error message in MQTT error message
* Image brightness is now adjustable
* Bug fixing: minor topics
##### 6.1.0 Image Processing in Memory - (2021-01-20)
* Disabling of analog / digital counters in configuration
* Improved Alignment Algorithm (`AlignmentAlgo` = `Default`, `Accurate` , `Fast`)
* Analog counters: `ExtendedResolution` (last digit is extended by sub comma value of CNN)
* `config.ini`: additional parameter `hostname` (additional to wlan.ini)
* Switching of GPIO12/13 via http-interface: `/GPIO?GPIO=12&Status=high/low`
* Bug fixing: html configuration page, wlan password ("=" now possible)
##### 6.0.0 Image Processing in Memory - (2021-01-02)
* **Major change**: image processing fully in memory - no need of SD card buffer anymore
* Need to limit camera resolution to VGA (due to memory limits)
* MQTT: Last Will Testament (LWT) implemented: "connection lost" in case of connection lost to `TopicError`
* Disabled `CheckDigitIncreaseConsistency` in default configuration - must now be explicit enabled if needed
* Update digital CNN to v7.2.1 (additional digital images trained)
* Setting of arbitrary time server in `config.ini`
* Option for fixed IP-, DNS-Settings in `wlan.ini`
* Increased stability (internal image and camera handling)
* Bug fixing: edit digits, handling PreValue, html-bugs
##### 5.0.0 Setup Modus - (2020-12-06)
* Implementation of initial setup modus for fresh installation
@@ -127,4 +205,4 @@
##### 0.1.0 (2020-08-07)
* Initial Version
* Initial Version

View File

@@ -45,77 +45,30 @@ In other cases you can contact the developer via email: <img src="https://raw.gi
##### 6.7.0 Image Processing in Memory - (2021-04-23)
* Upgrade digital CNN to v8.3.0 (added new type of digits)
* Internal update: TFlite (v2.5), esp32cam, startup sequence
* Rollback to espressif v2.1.0, as v3.2.0 shows unstable reboot
##### 7.1.1 MQTT-Update - (2021-05-30)
* Bugfix: WLan-passwords, reset of hostname
* NEW: 7.1.1: bug fix wlan password with "=" (again)
* MQTT error message: changes "no error", send retain flag
* Update wlan handling to esp-idf 4.1
* Upgrade digital CNN to v8.7.0 (added new images)
* Bug fix: MQTT, WLAN, LED-Controll, GPIO usage, fixed IP, calculation flow rate
##### 7.0.1 MQTT-Update - (2021-05-13)
* NEW: 7.0.1: bug fix wlan password with "="
* Upgrade digital CNN to v8.5.0 (added new images)
* New MQTT topics: flow rate (units/minute), time stamp (last correct read readout)
* Update MQTT/Error topic to " " in case no error (instead of empty string)
* Portrait or landscape image orientation in rotated image (avoid cropping)
##### 6.6.1 Image Processing in Memory - (2021-04-05)
* NEW 6.6.1: failed SD card initialization indicated by fast blinking LED at startup
* Improved SD-card handling (increase compatibility with more type of cards)
##### 6.5.0 Image Processing in Memory - (2021-03-25)
* Upgrade digital CNN to v8.2.0 (added new type of digits)
* Supporting alignment structures in ROI definition
* Bug fixing: definition of hostname in `config.ini`
##### 6.4.0 Image Processing in Memory - (2021-03-20)
* Additional alignment marks for settings the ROIs (analog and digit)
* Upgrade analog CNN to v7.0.0 (added new type of pointer)
##### 6.3.1 Image Processing in Memory - (2021-03-16)
* NEW: 6.3.1: bug fixing in initial edit reference image and `config.ini` (Spelling error in `InitialRotate`)
* Initial setup mode: bug fixing, error correction
* Bug-fixing
##### 6.2.2 Image Processing in Memory - (2021-03-10)
* NEW 6.2.2: bug fixing
* NEW 6.2.1: Changed brightness and contrast to default if not enabled (resolves to bright images)
* Determination of fixed illumination settings during startup - speed up of 5s in each run
* Update digital CNN to v8.1.1 (additional digital images trained)
* Extended error message in MQTT error message
* Image brightness is now adjustable
* Bug fixing: minor topics
##### 6.1.0 Image Processing in Memory - (2021-01-20)
* Disabling of analog / digital counters in configuration
* Improved Alignment Algorithm (`AlignmentAlgo` = `Default`, `Accurate` , `Fast`)
* Analog counters: `ExtendedResolution` (last digit is extended by sub comma value of CNN)
* `config.ini`: additional parameter `hostname` (additional to wlan.ini)
* Switching of GPIO12/13 via http-interface: `/GPIO?GPIO=12&Status=high/low`
* Bug fixing: html configuration page, wlan password ("=" now possible)
##### 6.0.0 Image Processing in Memory - (2021-01-02)
* **Major change**: image processing fully in memory - no need of SD card buffer anymore
* Need to limit camera resolution to VGA (due to memory limits)
* MQTT: Last Will Testament (LWT) implemented: "connection lost" in case of connection lost to `TopicError`
* Disabled `CheckDigitIncreaseConsistency` in default configuration - must now be explicit enabled if needed
* Update digital CNN to v7.2.1 (additional digital images trained)
* Setting of arbitrary time server in `config.ini`
* Option for fixed IP-, DNS-Settings in `wlan.ini`
* Increased stability (internal image and camera handling)
* Bug fixing: edit digits, handling PreValue, html-bugs
## Additional ideas
@@ -127,6 +80,8 @@ There are some ideas and feature request, which are not followed currently - mai
## History
##### 6.7.2 Image Processing in Memory - (2021-05-01)
##### 5.0.0 Setup Modus - (2020-12-06)
##### 4.1.1 Configuration editor - (2020-12-02)

Binary file not shown.

View File

@@ -1,492 +0,0 @@
#include "connect_wlan.h"
#include <string.h>
#include "esp_wifi.h"
#include "esp_event_loop.h"
#include "freertos/event_groups.h"
#include "esp_log.h"
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <arpa/inet.h>
#include "Helper.h"
static const char *MAIN_TAG = "connect_wlan";
std::string ssid = "";
std::string passphrase = "";
std::string hostname = "";
std::string ipaddress = "";
std::string gw = "";
std::string netmask = "";
std::string dns = "";
std::string std_hostname = "watermeter";
static EventGroupHandle_t wifi_event_group;
#define BLINK_GPIO GPIO_NUM_33
std::vector<string> ZerlegeZeile(std::string input, std::string _delimiter = "")
{
std::vector<string> Output;
std::string delimiter = " =,";
if (_delimiter.length() > 0){
delimiter = _delimiter;
}
input = trim(input, delimiter);
size_t pos = findDelimiterPos(input, delimiter);
std::string token;
while (pos != std::string::npos) {
token = input.substr(0, pos);
token = trim(token, delimiter);
Output.push_back(token);
input.erase(0, pos + 1);
input = trim(input, delimiter);
pos = findDelimiterPos(input, delimiter);
}
Output.push_back(input);
return Output;
}
void wifi_connect(){
wifi_config_t cfg = { };
strcpy((char*)cfg.sta.ssid, (const char*)ssid.c_str());
strcpy((char*)cfg.sta.password, (const char*)passphrase.c_str());
ESP_ERROR_CHECK( esp_wifi_disconnect() );
ESP_ERROR_CHECK( esp_wifi_set_config(ESP_IF_WIFI_STA, &cfg) );
ESP_ERROR_CHECK( esp_wifi_connect() );
}
void blinkstatus(int dauer, int _anzahl)
{
gpio_reset_pin(BLINK_GPIO);
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
for (int i = 0; i < _anzahl; ++i)
{
gpio_set_level(BLINK_GPIO, 0);
vTaskDelay(dauer / portTICK_PERIOD_MS);
gpio_set_level(BLINK_GPIO, 1);
vTaskDelay(dauer / portTICK_PERIOD_MS);
}
}
static esp_err_t event_handler(void *ctx, system_event_t *event)
{
switch(event->event_id) {
case SYSTEM_EVENT_STA_START:
blinkstatus(200, 1);
wifi_connect();
break;
case SYSTEM_EVENT_STA_GOT_IP:
xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
blinkstatus(1000, 3);
break;
case SYSTEM_EVENT_STA_DISCONNECTED:
blinkstatus(200, 5);
esp_wifi_connect();
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
break;
default:
break;
}
return ESP_OK;
}
void initialise_wifi()
{
ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL) );
wifi_event_group = xEventGroupCreate();
esp_log_level_set("wifi", ESP_LOG_NONE); // disable wifi driver logging
tcpip_adapter_init();
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
ESP_ERROR_CHECK( esp_wifi_start() );
esp_err_t ret = tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA , hostname.c_str());
if(ret != ESP_OK ){
ESP_LOGE(MAIN_TAG,"failed to set hostname:%d",ret);
}
xEventGroupWaitBits(wifi_event_group,CONNECTED_BIT,true,true,portMAX_DELAY);
tcpip_adapter_ip_info_t ip_info;
ESP_ERROR_CHECK(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info));
ipaddress = std::string(ip4addr_ntoa(&ip_info.ip));
netmask = std::string(ip4addr_ntoa(&ip_info.netmask));
gw = std::string(ip4addr_ntoa(&ip_info.gw));
printf("IPv4 : %s\n", ip4addr_ntoa(&ip_info.ip));
printf("HostName : %s\n", hostname.c_str());
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
void strinttoip4(std::string ip, int &a, int &b, int &c, int &d) {
std::stringstream s(ip);
char ch; //to temporarily store the '.'
s >> a >> ch >> b >> ch >> c >> ch >> d;
}
void initialise_wifi_fixed_ip()
{
wifi_event_group = xEventGroupCreate();
ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());
esp_netif_t *my_sta = esp_netif_create_default_wifi_sta();
esp_netif_dhcpc_stop(my_sta);
esp_netif_ip_info_t ip_info;
int a, b, c, d;
strinttoip4(ipaddress, a, b, c, d);
IP4_ADDR(&ip_info.ip, a, b, c, d);
strinttoip4(gw, a, b, c, d);
IP4_ADDR(&ip_info.gw, a, b, c, d);
strinttoip4(netmask, a, b, c, d);
IP4_ADDR(&ip_info.netmask, a, b, c, d);
esp_netif_set_ip_info(my_sta, &ip_info);
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
if (dns.length() > 0) {
esp_netif_dns_info_t dns_info;
ip4_addr_t ip;
ip.addr = esp_ip4addr_aton(dns.c_str());
ip_addr_set_ip4_u32(&dns_info.ip, ip.addr);
ESP_ERROR_CHECK(esp_netif_set_dns_info(my_sta, ESP_NETIF_DNS_MAIN, &dns_info));
}
ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL) );
wifi_config_t wifi_config = { };
strcpy((char*)wifi_config.sta.ssid, (const char*)ssid.c_str());
strcpy((char*)wifi_config.sta.password, (const char*)passphrase.c_str());
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) );
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) );
ESP_ERROR_CHECK(esp_wifi_start() );
ESP_LOGI(MAIN_TAG, "wifi_init_sta finished.");
EventBits_t bits = xEventGroupWaitBits(wifi_event_group,CONNECTED_BIT,true,true,portMAX_DELAY);
if (bits & CONNECTED_BIT) {
ESP_LOGI(MAIN_TAG, "connected to ap SSID:%s password:%s",
ssid.c_str(), passphrase.c_str());
} else {
ESP_LOGI(MAIN_TAG, "Failed to connect to SSID:%s, password:%s",
ssid.c_str(), passphrase.c_str());
}
tcpip_adapter_ip_info_t ip_info2;
ESP_ERROR_CHECK(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info2));
ipaddress = std::string(ip4addr_ntoa(&ip_info2.ip));
netmask = std::string(ip4addr_ntoa(&ip_info2.netmask));
gw = std::string(ip4addr_ntoa(&ip_info2.gw));
// vEventGroupDelete(wifi_event_group);
}
void ConnectToWLAN()
{
if (ipaddress.length() == 0 || gw.length() == 0 || netmask.length() == 0)
{
printf("Connect to WLAN with dyn. IP\n");
initialise_wifi();
}
else
{
printf("Connect to WLAN with fixed IP\n");
initialise_wifi_fixed_ip();
}
}
bool ChangeHostName(std::string fn, std::string _newhostname)
{
if (_newhostname == hostname)
return false;
string line = "";
std::vector<string> zerlegt;
bool found = false;
std::vector<string> neuesfile;
FILE* pFile;
fn = FormatFileName(fn);
pFile = OpenFileAndWait(fn.c_str(), "r");
printf("file loaded\n");
if (pFile == NULL)
return false;
char zw[1024];
fgets(zw, 1024, pFile);
line = std::string(zw);
while ((line.size() > 0) || !(feof(pFile)))
{
printf("%s", line.c_str());
zerlegt = ZerlegeZeile(line, "=");
zerlegt[0] = trim(zerlegt[0], " ");
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "HOSTNAME")){
line = "hostname = \"" + _newhostname + "\"\n";
found = true;
}
neuesfile.push_back(line);
if (fgets(zw, 1024, pFile) == NULL)
{
line = "";
}
else
{
line = std::string(zw);
}
}
if (!found)
{
line = "\nhostname = \"" + _newhostname + "\"\n";
neuesfile.push_back(line);
}
fclose(pFile);
pFile = OpenFileAndWait(fn.c_str(), "w+");
for (int i = 0; i < neuesfile.size(); ++i)
{
printf(neuesfile[i].c_str());
fputs(neuesfile[i].c_str(), pFile);
}
fclose(pFile);
printf("*** Update hostname done ***\n");
return true;
}
void LoadWlanFromFile(std::string fn)
{
string line = "";
std::vector<string> zerlegt;
hostname = std_hostname;
FILE* pFile;
fn = FormatFileName(fn);
pFile = OpenFileAndWait(fn.c_str(), "r");
printf("file loaded\n");
if (pFile == NULL)
return;
char zw[1024];
fgets(zw, 1024, pFile);
line = std::string(zw);
while ((line.size() > 0) || !(feof(pFile)))
{
printf("%s", line.c_str());
zerlegt = ZerlegeZeile(line, "=");
zerlegt[0] = trim(zerlegt[0], " ");
for (int i = 2; i < zerlegt.size(); ++i)
zerlegt[1] = zerlegt[1] + zerlegt[i];
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "HOSTNAME")){
hostname = trim(zerlegt[1]);
if ((hostname[0] == '"') && (hostname[hostname.length()-1] == '"')){
hostname = hostname.substr(1, hostname.length()-2);
}
}
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "SSID")){
ssid = trim(zerlegt[1]);
if ((ssid[0] == '"') && (ssid[ssid.length()-1] == '"')){
ssid = ssid.substr(1, ssid.length()-2);
}
}
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "PASSWORD")){
passphrase = zerlegt[1];
if ((passphrase[0] == '"') && (passphrase[passphrase.length()-1] == '"')){
passphrase = passphrase.substr(1, passphrase.length()-2);
}
}
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "IP")){
ipaddress = zerlegt[1];
if ((ipaddress[0] == '"') && (ipaddress[ipaddress.length()-1] == '"')){
ipaddress = ipaddress.substr(1, ipaddress.length()-2);
}
}
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "GATEWAY")){
gw = zerlegt[1];
if ((gw[0] == '"') && (gw[gw.length()-1] == '"')){
gw = gw.substr(1, gw.length()-2);
}
}
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "NETMASK")){
netmask = zerlegt[1];
if ((netmask[0] == '"') && (netmask[netmask.length()-1] == '"')){
netmask = netmask.substr(1, netmask.length()-2);
}
}
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "DNS")){
dns = zerlegt[1];
if ((dns[0] == '"') && (dns[dns.length()-1] == '"')){
dns = dns.substr(1, dns.length()-2);
}
}
if (fgets(zw, 1024, pFile) == NULL)
{
line = "";
}
else
{
line = std::string(zw);
}
}
fclose(pFile);
// Check if Hostname was empty in .ini if yes set to std_hostname
if(hostname.length() <= 0){
hostname = std_hostname;
}
printf("\nWLan: %s, %s\n", ssid.c_str(), passphrase.c_str());
printf("Hostename: %s\n", hostname.c_str());
printf("Fixed IP: %s, Gateway %s, Netmask %s, DNS %s\n", ipaddress.c_str(), gw.c_str(), netmask.c_str(), dns.c_str());
}
void LoadNetConfigFromFile(std::string fn, std::string &_ip, std::string &_gw, std::string &_netmask, std::string &_dns)
{
string line = "";
std::vector<string> zerlegt;
FILE* pFile;
fn = FormatFileName(fn);
pFile = OpenFileAndWait(fn.c_str(), "r");
printf("file loaded\n");
if (pFile == NULL)
return;
char zw[1024];
fgets(zw, 1024, pFile);
line = std::string(zw);
while ((line.size() > 0) || !(feof(pFile)))
{
printf("%s", line.c_str());
zerlegt = ZerlegeZeile(line, "=");
zerlegt[0] = trim(zerlegt[0], " ");
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "IP")){
_ip = zerlegt[1];
if ((_ip[0] == '"') && (_ip[_ip.length()-1] == '"')){
_ip = _ip.substr(1, _ip.length()-2);
}
}
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "GATEWAY")){
_gw = zerlegt[1];
if ((_gw[0] == '"') && (_gw[_gw.length()-1] == '"')){
_gw = _gw.substr(1, _gw.length()-2);
}
}
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "NETMASK")){
_netmask = zerlegt[1];
if ((_netmask[0] == '"') && (_netmask[_netmask.length()-1] == '"')){
_netmask = _netmask.substr(1, _netmask.length()-2);
}
}
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "DNS")){
_dns = zerlegt[1];
if ((_dns[0] == '"') && (_dns[_dns.length()-1] == '"')){
_dns = _dns.substr(1, _dns.length()-2);
}
}
if (fgets(zw, 1024, pFile) == NULL)
{
line = "";
}
else
{
line = std::string(zw);
}
}
fclose(pFile);
}
std::string getHostname(){
return hostname;
}
std::string getIPAddress(){
return ipaddress;
}
std::string getSSID(){
return ssid;
}
std::string getNetMask(){
return netmask;
}
std::string getGW(){
return gw;
}

View File

@@ -1,20 +0,0 @@
#ifndef CONNECT_WLAN_H
#define CONNECT_WLAN_H
#include <string>
#include "driver/gpio.h"
const int CONNECTED_BIT = BIT0;
void ConnectToWLAN();
void LoadWlanFromFile(std::string fn);
bool ChangeHostName(std::string fn, std::string _newhostname);
std::string getHostname();
std::string getIPAddress();
std::string getSSID();
std::string getNetMask();
std::string getGW();
#endif

View File

@@ -4,6 +4,6 @@ list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/proto
idf_component_register(SRCS ${app_sources}
INCLUDE_DIRS "."
REQUIRES esp32-camera-master esp_http_server jomjol_logfile jomjol_image_proc jomjol_fileserver_ota nvs_flash)
REQUIRES esp32-camera-master esp_http_server jomjol_logfile jomjol_image_proc nvs_flash jomjol_fileserver_ota)

View File

@@ -8,7 +8,8 @@
#include "Helper.h"
#include "CImageBasis.h"
#include "server_ota.h"
#include "server_ota.h"
#define BOARD_ESP32CAM_AITHINKER
@@ -72,7 +73,7 @@ static camera_config_t camera_config = {
//XCLK 20MHz or 10MHz for OV2640 double FPS (Experimental)
// .xclk_freq_hz = 20000000, // Orginalwert
.xclk_freq_hz = 5000000, // Test, um die Bildfehler los zu werden !!!! ging mal mit 5000000
.xclk_freq_hz = 5000000, // Test, um die Bildfehler los zu werden !!!!
.ledc_timer = LEDC_TIMER_0,
.ledc_channel = LEDC_CHANNEL_0,
@@ -83,7 +84,7 @@ static camera_config_t camera_config = {
.jpeg_quality = 5, //0-63 lower number means higher quality
.fb_count = 2 //if more than one, i2s runs in continuous mode. Use only with JPEG
.fb_count = 1 //if more than one, i2s runs in continuous mode. Use only with JPEG
};
@@ -221,14 +222,23 @@ void CCamera::SetQualitySize(int qual, framesize_t resol)
void CCamera::EnableAutoExposure(int flashdauer)
{
LEDOnOff(true);
LightOnOff(true);
if (flashdauer > 0)
LightOnOff(true);
const TickType_t xDelay = flashdauer / portTICK_PERIOD_MS;
vTaskDelay( xDelay );
camera_fb_t * fb = esp_camera_fb_get();
if (!fb) {
ESP_LOGE(TAGCAMERACLASS, "Camera Capture Failed");
doReboot();
}
esp_camera_fb_return(fb);
sensor_t * s = esp_camera_sensor_get();
s->set_gain_ctrl(s, 0);
s->set_exposure_ctrl(s, 0);
LEDOnOff(false);
LightOnOff(false);
isFixedExposure = true;
@@ -264,10 +274,9 @@ esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay)
camera_fb_t * fb = esp_camera_fb_get();
if (!fb) {
ESP_LOGE(TAGCAMERACLASS, "Camera Capture Failed");
LightOnOff(false);
LogFile.WriteHeapInfo("Camera Capture Failed - Reinit Camera");
Camera.InitCam();
LEDOnOff(false);
doReboot();
return ESP_FAIL;
}
@@ -351,10 +360,11 @@ esp_err_t CCamera::CaptureToFile(std::string nm, int delay)
camera_fb_t * fb = esp_camera_fb_get();
if (!fb) {
ESP_LOGE(TAGCAMERACLASS, "Camera Capture Failed");
ESP_LOGE(TAGCAMERACLASS, "Reboot ?????");
LEDOnOff(false);
LogFile.WriteHeapInfo("Camera Capture Failed - Reinit Camera");
Camera.InitCam();
LightOnOff(false);
doReboot();
return ESP_FAIL;
}
LEDOnOff(false);
@@ -439,14 +449,14 @@ esp_err_t CCamera::CaptureToHTTP(httpd_req_t *req, int delay)
vTaskDelay( xDelay );
}
fb = esp_camera_fb_get();
if (!fb) {
ESP_LOGE(TAGCAMERACLASS, "Camera capture failed");
LightOnOff(false);
LogFile.WriteHeapInfo("Camera Capture Failed - Reinit Camera");
Camera.InitCam();
doReboot();
httpd_resp_send_500(req);
// doReboot();
return ESP_FAIL;
}
@@ -581,16 +591,10 @@ CCamera::CCamera()
contrast = -5;
saturation = -5;
isFixedExposure = false;
ActualQuality = camera_config.jpeg_quality;
ActualResolution = camera_config.frame_size;
}
esp_err_t CCamera::InitCam()
{
esp_camera_deinit();
PowerResetCamera();
if(CAM_PIN_PWDN != -1){
// Init the GPIO
gpio_pad_select_gpio(CAM_PIN_PWDN);
@@ -600,6 +604,8 @@ esp_err_t CCamera::InitCam()
}
printf("Init Camera\n");
ActualQuality = camera_config.jpeg_quality;
ActualResolution = camera_config.frame_size;
//initialize the camera
esp_err_t err = esp_camera_init(&camera_config);
if (err != ESP_OK) {
@@ -607,42 +613,5 @@ esp_err_t CCamera::InitCam()
return err;
}
SetBrightnessContrastSaturation(brightness, contrast, saturation);
SetQualitySize(ActualQuality, ActualResolution);
if (isFixedExposure)
EnableAutoExposure(waitbeforepicture_org);
LightOnOff(false);
return ESP_OK;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
void PowerResetCamera(){
printf("Resetting camera by power down line.\n");
/*
gpio_config_t conf = { 0 };
conf.pin_bit_mask = 1LL << GPIO_NUM_32;
conf.mode = GPIO_MODE_OUTPUT;
gpio_config(&conf);
*/
gpio_pad_select_gpio(GPIO_NUM_32);
/* Set the GPIO as a push/pull output */
gpio_set_direction(GPIO_NUM_32, GPIO_MODE_OUTPUT);
// carefull, logic is inverted compared to reset pin
gpio_set_level(GPIO_NUM_32, 0); // ehemals 1 !!!!!!!!!!!!!!!!!!!!
vTaskDelay(1000 / portTICK_PERIOD_MS);
gpio_set_level(GPIO_NUM_32, 1); // ehemals 0 !!!!!!!!!!!!!!!!!!!!
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}

View File

@@ -25,7 +25,6 @@ class CCamera {
framesize_t ActualResolution;
int brightness, contrast, saturation;
bool isFixedExposure;
int waitbeforepicture_org;
public:
@@ -50,7 +49,6 @@ class CCamera {
esp_err_t CaptureToBasisImage(CImageBasis *_Image, int delay = 0);
};
void PowerResetCamera();
extern CCamera Camera;

View File

@@ -0,0 +1,246 @@
#include "server_camera.h"
#include <string>
#include "string.h"
#include "esp_camera.h"
#include "ClassControllCamera.h"
#include "ClassLogFile.h"
#define SCRATCH_BUFSIZE2 8192
char scratch2[SCRATCH_BUFSIZE2];
//#define DEBUG_DETAIL_ON
void PowerResetCamera(){
ESP_LOGD(TAGPARTCAMERA, "Resetting camera by power down line");
gpio_config_t conf = { 0 };
conf.pin_bit_mask = 1LL << GPIO_NUM_32;
conf.mode = GPIO_MODE_OUTPUT;
gpio_config(&conf);
// carefull, logic is inverted compared to reset pin
gpio_set_level(GPIO_NUM_32, 1);
vTaskDelay(1000 / portTICK_PERIOD_MS);
gpio_set_level(GPIO_NUM_32, 0);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
esp_err_t handler_lightOn(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_lightOn - Start");
printf("handler_lightOn uri:\n"); printf(req->uri); printf("\n");
#endif
Camera.LightOnOff(true);
const char* resp_str = (const char*) req->user_ctx;
httpd_resp_send(req, resp_str, strlen(resp_str));
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_lightOn - Done");
#endif
return ESP_OK;
};
esp_err_t handler_lightOff(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_lightOff - Start");
printf("handler_lightOff uri:\n"); printf(req->uri); printf("\n");
#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
LogFile.WriteHeapInfo("handler_lightOff - Done");
#endif
return ESP_OK;
};
esp_err_t handler_capture(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_capture - Start");
#endif
int quality;
framesize_t res;
Camera.GetCameraParameter(req, quality, res);
#ifdef DEBUG_DETAIL_ON
printf("Size: %d", res); printf(" Quality: %d\n", quality);
#endif
Camera.SetQualitySize(quality, res);
esp_err_t ressult;
ressult = Camera.CaptureToHTTP(req);
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_capture - Done");
#endif
return ressult;
};
esp_err_t handler_capture_with_ligth(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_capture_with_ligth - Start");
#endif
char _query[100];
char _delay[10];
int quality;
framesize_t res;
int delay = 2500;
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
{
printf("Query: "); printf(_query); printf("\n");
if (httpd_query_key_value(_query, "delay", _delay, 10) == ESP_OK)
{
#ifdef DEBUG_DETAIL_ON
printf("Delay: "); printf(_delay); printf("\n");
#endif
delay = atoi(_delay);
if (delay < 0)
delay = 0;
}
};
Camera.GetCameraParameter(req, quality, res);
#ifdef DEBUG_DETAIL_ON
printf("Size: %d", res); printf(" Quality: %d\n", quality);
#endif
Camera.SetQualitySize(quality, res);
Camera.LightOnOff(true);
const TickType_t xDelay = delay / portTICK_PERIOD_MS;
vTaskDelay( xDelay );
esp_err_t ressult;
ressult = Camera.CaptureToHTTP(req);
Camera.LightOnOff(false);
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_capture_with_ligth - Done");
#endif
return ressult;
};
esp_err_t handler_capture_save_to_file(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_capture_save_to_file - Start");
#endif
char _query[100];
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)
{
printf("Query: "); printf(_query); printf("\n");
if (httpd_query_key_value(_query, "filename", filename, 100) == ESP_OK)
{
fn.append(filename);
#ifdef DEBUG_DETAIL_ON
printf("Filename: "); printf(fn.c_str()); printf("\n");
#endif
}
else
fn.append("noname.jpg");
if (httpd_query_key_value(_query, "delay", _delay, 10) == ESP_OK)
{
#ifdef DEBUG_DETAIL_ON
printf("Delay: "); printf(_delay); printf("\n");
#endif
delay = atoi(_delay);
if (delay < 0)
delay = 0;
}
}
else
fn.append("noname.jpg");
Camera.GetCameraParameter(req, quality, res);
#ifdef DEBUG_DETAIL_ON
printf("Size: %d", res); printf(" Quality: %d\n", 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)
{
#ifdef DEBUG_DETAIL_ON
ESP_LOGI(TAGPARTCAMERA, "server_part_camera - Registering URI handlers");
#endif
httpd_uri_t camuri = { };
camuri.method = HTTP_GET;
camuri.uri = "/lighton";
camuri.handler = handler_lightOn;
camuri.user_ctx = (void*) "Light On";
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/lightoff";
camuri.handler = handler_lightOff;
camuri.user_ctx = (void*) "Light Off";
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/capture";
camuri.handler = handler_capture;
camuri.user_ctx = NULL;
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/capture_with_flashlight";
camuri.handler = handler_capture_with_ligth;
camuri.user_ctx = NULL;
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/save";
camuri.handler = handler_capture_save_to_file;
camuri.user_ctx = NULL;
httpd_register_uri_handler(server, &camuri);
}

View File

@@ -0,0 +1,16 @@
#ifndef JOMJOL_CONTROLCAMERA_H
#define JOMJOL_CONTROLCAMERA_H
#include <esp_log.h>
#include <esp_http_server.h>
//#include "ClassControllCamera.h"
static const char *TAGPARTCAMERA = "server_camera";
void register_server_camera_uri(httpd_handle_t server);
void PowerResetCamera();
#endif

View File

@@ -721,21 +721,33 @@ void register_server_file_uri(httpd_handle_t server, const char *base_path)
/* Validate file storage base path */
if (!base_path) {
// if (!base_path || strcmp(base_path, "/spiffs") != 0) {
ESP_LOGE(TAG, "File server base_path not set");
// return ESP_ERR_INVALID_ARG;
}
if (server_data) {
ESP_LOGE(TAG, "File server already started");
// return ESP_ERR_INVALID_STATE;
}
/* Allocate memory for server data */
server_data = (file_server_data *) calloc(1, sizeof(struct file_server_data));
if (!server_data) {
ESP_LOGE(TAG, "Failed to allocate memory for server data");
// return ESP_ERR_NO_MEM;
}
strlcpy(server_data->base_path, base_path,
sizeof(server_data->base_path));
/* URI handler for getting uploaded files */
// char zw[sizeof(serverprefix)+1];
// strcpy(zw, serverprefix);
// zw[strlen(serverprefix)] = '*';
// zw[strlen(serverprefix)+1] = '\0';
// printf("zw: %s\n", zw);
httpd_uri_t file_download = {
.uri = "/fileserver*", // Match all URIs of type /path/to/file
.method = HTTP_GET,
@@ -744,6 +756,8 @@ void register_server_file_uri(httpd_handle_t server, const char *base_path)
};
httpd_register_uri_handler(server, &file_download);
httpd_uri_t file_logfileact = {
.uri = "/logfileact", // Match all URIs of type /path/to/file
.method = HTTP_GET,
@@ -770,4 +784,5 @@ void register_server_file_uri(httpd_handle_t server, const char *base_path)
.user_ctx = server_data // Pass server data as context
};
httpd_register_uri_handler(server, &file_delete);
}

View File

@@ -412,26 +412,11 @@ void task_reboot(void *pvParameter)
vTaskDelete(NULL); //Delete this task if it exits from the loop above
}
inline void invoke_abort(void)
{
while (1) {
if (esp_cpu_in_ocd_debug_mode()) {
__asm__ ("break 0,0");
}
*((int *) 0) = 0;
}
}
void doReboot(){
LogFile.WriteToFile("Reboot - now");
xTaskCreate(&task_reboot, "reboot", configMINIMAL_STACK_SIZE * 64, NULL, 10, NULL);
KillTFliteTasks();
// xTaskCreate(&task_reboot, "reboot", configMINIMAL_STACK_SIZE * 64, NULL, 10, NULL);
xTaskCreate(&task_reboot, "reboot", configMINIMAL_STACK_SIZE * 64, NULL, 10, NULL);
vTaskDelay(5000 / portTICK_PERIOD_MS);
invoke_abort();
esp_restart();
hard_restart();
}

View File

@@ -2,6 +2,6 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*)
idf_component_register(SRCS ${app_sources}
INCLUDE_DIRS "."
REQUIRES jomjol_tfliteclass jomjol_helper jomjol_controlcamera jomjol_mqtt jomjol_fileserver_ota jomjol_image_proc connect_wlan)
REQUIRES jomjol_tfliteclass jomjol_helper jomjol_controlcamera jomjol_mqtt jomjol_fileserver_ota jomjol_image_proc jomjol_wlan)

View File

@@ -19,6 +19,7 @@ void ClassFlowAlignment::SetInitialParameter(void)
initalrotate = 0;
anz_ref = 0;
initialmirror = false;
initialflip = false;
SaveAllFiles = false;
namerawimage = "/sdcard/img_tmp/raw.jpg";
FileStoreRefAlignment = "/sdcard/config/align.txt";
@@ -72,6 +73,11 @@ bool ClassFlowAlignment::ReadParameter(FILE* pfile, string& aktparamgraph)
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
{
zerlegt = ZerlegeZeile(aktparamgraph);
if ((toUpper(zerlegt[0]) == "FLIPIMAGESIZE") && (zerlegt.size() > 1))
{
if (toUpper(zerlegt[1]) == "TRUE")
initialflip = true;
}
if ((toUpper(zerlegt[0]) == "INITIALMIRROR") && (zerlegt.size() > 1))
{
if (toUpper(zerlegt[1]) == "TRUE")
@@ -153,7 +159,13 @@ bool ClassFlowAlignment::doFlow(string time)
delete AlignAndCutImage;
AlignAndCutImage = new CAlignAndCutImage(ImageBasis, ImageTMP);
CRotateImage rt(AlignAndCutImage, ImageTMP);
CRotateImage rt(AlignAndCutImage, ImageTMP, initialflip);
if (initialflip)
{
int _zw = ImageBasis->height;
ImageBasis->height = ImageBasis->width;
ImageBasis->width = _zw;
}
if (initialmirror){
printf("do mirror\n");
@@ -161,7 +173,7 @@ bool ClassFlowAlignment::doFlow(string time)
if (SaveAllFiles) AlignAndCutImage->SaveToFile(FormatFileName("/sdcard/img_tmp/mirror.jpg"));
}
if (initalrotate != 0)
if ((initalrotate != 0) || initialflip)
{
rt.Rotate(initalrotate);
if (SaveAllFiles) AlignAndCutImage->SaveToFile(FormatFileName("/sdcard/img_tmp/rot.jpg"));
@@ -176,6 +188,12 @@ bool ClassFlowAlignment::doFlow(string time)
if (SaveAllFiles)
{
if (initialflip)
{
int _zw = ImageTMP->width;
ImageTMP->width = ImageTMP->height;
ImageTMP->height = _zw;
}
DrawRef(ImageTMP);
ImageTMP->SaveToFile(FormatFileName("/sdcard/img_tmp/alg_roi.jpg"));
}
@@ -209,7 +227,7 @@ void ClassFlowAlignment::SaveReferenceAlignmentValues()
time(&rawtime);
timeinfo = localtime(&rawtime);
strftime(buffer, 80, "%Y-%m-%d_%H-%M-%S", timeinfo);
strftime(buffer, 80, "%Y-%m-%dT%H:%M:%S", timeinfo);
zwtime = std::string(buffer);
}

View File

@@ -15,6 +15,7 @@ class ClassFlowAlignment :
protected:
float initalrotate;
bool initialmirror;
bool initialflip;
RefInfo References[2];
int anz_ref;
string namerawimage;

View File

@@ -285,7 +285,7 @@ bool ClassFlowAnalog::doNeuralNetwork(string time)
zwcnn = FormatFileName(zwcnn);
printf(zwcnn.c_str());printf("\n");
tflite->LoadModel(zwcnn);
// tflite->MakeAllocate();
tflite->MakeAllocate();
#endif
for (int i = 0; i < ROI.size(); ++i)

View File

@@ -1,6 +1,7 @@
#include "ClassFlowControll.h"
#include "connect_wlan.h"
#include "read_wlanini.h"
#include "freertos/task.h"
@@ -21,13 +22,16 @@ static const char* TAG = "flow_controll";
std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
std::string _classname = "";
std::string result = "";
// printf("_stepname: %s\n", _stepname.c_str());
if ((_stepname.compare("[MakeImage]") == 0) || (_stepname.compare(";[MakeImage]") == 0)){
_classname = "ClassFlowMakeImage";
}
if ((_stepname.compare("[Alignment]") == 0) || (_stepname.compare(";[Alignment]") == 0)){
_classname = "ClassFlowAlignment";
}
if ((_stepname.compare("[Digits]") == 0) || (_stepname.compare(";[Digits]") == 0)){
if ((_stepname.compare(0, 7, "[Digits") == 0) || (_stepname.compare(0, 8, ";[Digits") == 0)) {
// if ((_stepname.compare("[Digits]") == 0) || (_stepname.compare(";[Digits]") == 0)){
// printf("Digits!!!\n");
_classname = "ClassFlowDigit";
}
if ((_stepname.compare("[Analog]") == 0) || (_stepname.compare(";[Analog]") == 0)){
@@ -109,7 +113,7 @@ ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type)
cfc = new ClassFlowAnalog(&FlowControll);
flowanalog = (ClassFlowAnalog*) cfc;
}
if (toUpper(_type).compare("[DIGITS]") == 0)
if (toUpper(_type).compare(0, 7, "[DIGITS") == 0)
{
cfc = new ClassFlowDigit(&FlowControll);
flowdigit = (ClassFlowDigit*) cfc;

View File

@@ -26,7 +26,8 @@ void ClassFlowDigit::SetInitialParameter(void)
previousElement = NULL;
SaveAllFiles = false;
disabled = false;
DecimalShift = 0;
DecimalShiftEnabled = false;
}
ClassFlowDigit::ClassFlowDigit() : ClassFlowImage(TAG)
@@ -88,8 +89,25 @@ bool ClassFlowDigit::ReadParameter(FILE* pfile, string& aktparamgraph)
if (!this->GetNextParagraph(pfile, aktparamgraph))
return false;
printf("aktparamgraph: %s\n", aktparamgraph.c_str());
/*
if ((aktparamgraph.compare("[Digits]") != 0) && (aktparamgraph.compare(";[Digits]") != 0)) // Paragraph passt nich zu MakeImage
return false;
*/
if ((aktparamgraph.compare(0, 7, "[Digits") != 0) && (aktparamgraph.compare(0, 8, ";[Digits") != 0)) // Paragraph passt nich zu MakeImage
return false;
int _pospkt = aktparamgraph.find_first_of(".");
int _posklammerzu = aktparamgraph.find_first_of("]");
// printf("Pos: %d, %d\n", _pospkt, _posklammerzu);
if (_pospkt > -1)
NameDigit = aktparamgraph.substr(_pospkt+1, _posklammerzu - _pospkt-1);
else
NameDigit = "";
printf("Name Digit: %s\n", NameDigit.c_str());
if (aktparamgraph[0] == ';')
{
@@ -224,7 +242,7 @@ bool ClassFlowDigit::doNeuralNetwork(string time)
string zwcnn = FormatFileName("/sdcard" + cnnmodelfile);
printf(zwcnn.c_str());printf("\n");
tflite->LoadModel(zwcnn);
// tflite->MakeAllocate();
tflite->MakeAllocate();
#endif
for (int i = 0; i < ROI.size(); ++i)

View File

@@ -21,6 +21,10 @@ protected:
string cnnmodelfile;
int modelxsize, modelysize;
bool SaveAllFiles;
string NameDigit;
int DecimalShift;
bool DecimalShiftEnabled;
ClassFlowAlignment* flowpostalignment;

View File

@@ -11,6 +11,8 @@ void ClassFlowMQTT::SetInitialParameter(void)
uri = "";
topic = "";
topicError = "";
topicRate = "";
topicTimeStamp = "";
clientname = "watermeter";
OldValue = "";
flowpostprocessing = NULL;
@@ -94,6 +96,15 @@ bool ClassFlowMQTT::ReadParameter(FILE* pfile, string& aktparamgraph)
{
this->topicError = zerlegt[1];
}
if ((toUpper(zerlegt[0]) == "TOPICRATE") && (zerlegt.size() > 1))
{
this->topicRate = zerlegt[1];
}
if ((toUpper(zerlegt[0]) == "TOPICTIMESTAMP") && (zerlegt.size() > 1))
{
this->topicTimeStamp = zerlegt[1];
}
if ((toUpper(zerlegt[0]) == "CLIENTID") && (zerlegt.size() > 1))
{
this->clientname = zerlegt[1];
@@ -114,12 +125,16 @@ bool ClassFlowMQTT::doFlow(string zwtime)
{
std::string result;
std::string resulterror = "";
std::string resultrate = "";
std::string resulttimestamp = "";
string zw = "";
if (flowpostprocessing)
{
result = flowpostprocessing->getReadoutParam(false, true);
resulterror = flowpostprocessing->getReadoutError();
resultrate = flowpostprocessing->getReadoutRate();
resulttimestamp = flowpostprocessing->getReadoutTimeStamp();
}
else
{
@@ -139,7 +154,19 @@ bool ClassFlowMQTT::doFlow(string zwtime)
MQTTPublish(topic, result);
if (topicError.length() > 0) {
MQTTPublish(topicError, resulterror);
if (resulterror.length() == 0)
{
resulterror = " ";
}
MQTTPublish(topicError, resulterror, 1);
}
if (topicRate.length() > 0) {
MQTTPublish(topicRate, resultrate);
}
if (topicTimeStamp.length() > 0) {
MQTTPublish(topicTimeStamp, resulttimestamp);
}
OldValue = result;

View File

@@ -9,7 +9,7 @@ class ClassFlowMQTT :
public ClassFlow
{
protected:
std::string uri, topic, topicError, clientname;
std::string uri, topic, topicError, clientname, topicRate, topicTimeStamp;
std::string OldValue;
ClassFlowPostProcessing* flowpostprocessing;
std::string user, password;

View File

@@ -14,12 +14,23 @@ static const char* TAG = "flow_make_image";
esp_err_t ClassFlowMakeImage::camera_capture(){
string nm = namerawimage;
Camera.CaptureToFile(nm);
time(&TimeImageTaken);
localtime(&TimeImageTaken);
return ESP_OK;
}
void ClassFlowMakeImage::takePictureWithFlash(int flashdauer)
{
// für den Fall, dass das Bild geflippt wird, muss es hier zurück gesetzt werden ////
rawImage->width = image_width;
rawImage->height = image_height;
/////////////////////////////////////////////////////////////////////////////////////
printf("Flashdauer: %d\n", flashdauer);
Camera.CaptureToBasisImage(rawImage, flashdauer);
time(&TimeImageTaken);
localtime(&TimeImageTaken);
if (SaveAllFiles) rawImage->SaveToFile(namerawimage);
}
@@ -82,6 +93,12 @@ bool ClassFlowMakeImage::ReadParameter(FILE* pfile, string& aktparamgraph)
if (toUpper(zerlegt[1]) == "TRUE")
SaveAllFiles = true;
}
if ((toUpper(zerlegt[0]) == "WAITBEFORETAKINGPICTURE") && (zerlegt.size() > 1))
{
waitbeforepicture = stoi(zerlegt[1]);
}
if ((toUpper(zerlegt[0]) == "BRIGHTNESS") && (zerlegt.size() > 1))
{
@@ -114,9 +131,9 @@ bool ClassFlowMakeImage::ReadParameter(FILE* pfile, string& aktparamgraph)
rawImage->CreateEmptyImage(image_width, image_height, 3);
waitbeforepicture_store = waitbeforepicture;
if (FixedExposure)
if (FixedExposure && (waitbeforepicture > 0))
{
printf("Fixed Exposure enabled!\n");
// printf("Fixed Exposure enabled!\n");
int flashdauer = (int) (waitbeforepicture * 1000);
Camera.EnableAutoExposure(flashdauer);
waitbeforepicture = 0.2;
@@ -165,6 +182,9 @@ bool ClassFlowMakeImage::doFlow(string zwtime)
esp_err_t ClassFlowMakeImage::SendRawJPG(httpd_req_t *req)
{
int flashdauer = (int) (waitbeforepicture * 1000);
time(&TimeImageTaken);
localtime(&TimeImageTaken);
return Camera.CaptureToHTTP(req, flashdauer);
}
@@ -175,6 +195,9 @@ ImageData* ClassFlowMakeImage::SendRawImage()
ImageData *id;
int flashdauer = (int) (waitbeforepicture * 1000);
Camera.CaptureToBasisImage(zw, flashdauer);
time(&TimeImageTaken);
localtime(&TimeImageTaken);
id = zw->writeToMemoryAsJPG();
delete zw;
return id;

View File

@@ -11,6 +11,13 @@
#include <time.h>
#include "time_sntp.h"
#define PREVALUE_TIME_FORMAT_OUTPUT "%Y-%m-%dT%H:%M:%S"
#define PREVALUE_TIME_FORMAT_INPUT "%d-%d-%dT%d:%d:%d"
string ClassFlowPostProcessing::GetPreValue()
{
std::string result;
@@ -63,7 +70,7 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
int yy, month, dd, hh, mm, ss;
struct tm whenStart;
sscanf(zwtime.c_str(), "%d-%d-%d_%d-%d-%d", &yy, &month, &dd, &hh, &mm, &ss);
sscanf(zwtime.c_str(), PREVALUE_TIME_FORMAT_INPUT, &yy, &month, &dd, &hh, &mm, &ss);
whenStart.tm_year = yy - 1900;
whenStart.tm_mon = month - 1;
whenStart.tm_mday = dd;
@@ -72,12 +79,11 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
whenStart.tm_sec = ss;
whenStart.tm_isdst = -1;
tStart = mktime(&whenStart);
lastvalue = mktime(&whenStart);
time_t now;
time(&now);
localtime(&now);
double difference = difftime(now, tStart);
time(&tStart);
localtime(&tStart);
double difference = difftime(tStart, lastvalue);
difference /= 60;
if (difference > PreValueAgeStartup)
return false;
@@ -122,13 +128,17 @@ void ClassFlowPostProcessing::SavePreValue(float value, string zwtime)
time(&rawtime);
timeinfo = localtime(&rawtime);
strftime(buffer, 80, "%Y-%m-%d_%H-%M-%S", timeinfo);
zwtime = std::string(buffer);
strftime(buffer, 80, PREVALUE_TIME_FORMAT_OUTPUT, timeinfo);
timeStamp = std::string(buffer);
}
else
{
timeStamp = zwtime;
}
PreValue = value;
fputs(zwtime.c_str(), pFile);
fputs(timeStamp.c_str(), pFile);
fputs("\n", pFile);
fputs(to_string(value).c_str(), pFile);
fputs("\n", pFile);
@@ -139,6 +149,7 @@ void ClassFlowPostProcessing::SavePreValue(float value, string zwtime)
ClassFlowPostProcessing::ClassFlowPostProcessing(std::vector<ClassFlow*>* lfc)
{
FlowRateAct = 0;
PreValueUse = false;
PreValueAgeStartup = 30;
AllowNegativeRates = false;
@@ -150,8 +161,18 @@ ClassFlowPostProcessing::ClassFlowPostProcessing(std::vector<ClassFlow*>* lfc)
checkDigitIncreaseConsistency = false;
DecimalShift = 0;
ErrorMessageText = "";
timeStamp = "";
FilePreValue = FormatFileName("/sdcard/config/prevalue.ini");
ListFlowControll = lfc;
flowMakeImage = NULL;
for (int i = 0; i < ListFlowControll->size(); ++i)
{
if (((*ListFlowControll)[i])->name().compare("ClassFlowMakeImage") == 0)
{
flowMakeImage = (ClassFlowMakeImage*) (*ListFlowControll)[i];
}
}
}
@@ -300,7 +321,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
timeinfo = localtime(&imagetime);
char strftime_buf[64];
strftime(strftime_buf, sizeof(strftime_buf), "%Y-%m-%d_%H-%M-%S", timeinfo);
strftime(strftime_buf, sizeof(strftime_buf), "%Y-%m-%dT%H:%M:%S", timeinfo);
zwtime = std::string(strftime_buf);
@@ -343,12 +364,23 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
PreValueOkay = true;
PreValue = Value;
if (flowMakeImage)
{
lastvalue = flowMakeImage->getTimeImageTaken();
zwtime = ConvertTimeToString(lastvalue, PREVALUE_TIME_FORMAT_OUTPUT);
}
else
{
time(&lastvalue);
localtime(&lastvalue);
}
SavePreValue(Value, zwtime);
}
return true;
}
zw = ErsetzteN(ReturnRawValue);
Value = std::stof(zw);
@@ -373,17 +405,37 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
}
ReturnValueNoError = zwvalue;
ReturnValue = zwvalue;
if (ErrorMessage && (ErrorMessageText.length() > 0))
ReturnValue = ReturnValue + "\t" + ErrorMessageText;
time_t currenttime;
if (flowMakeImage)
{
currenttime = flowMakeImage->getTimeImageTaken();
zwtime = ConvertTimeToString(currenttime, PREVALUE_TIME_FORMAT_OUTPUT);
}
else
{
time(&currenttime);
localtime(&currenttime);
}
double difference = difftime(currenttime, lastvalue); // in Sekunden
difference /= 60; // in Minuten
FlowRateAct = (Value - PreValue) / difference;
lastvalue = currenttime;
// std::string _zw = "CalcRate: " + std::to_string(FlowRateAct) + " TimeDifference[min]: " + std::to_string(difference);
// _zw = _zw + " Value: " + std::to_string(Value) + " PreValue: " + std::to_string(PreValue);
// LogFile.WriteToFile(_zw);
if (ErrorMessageText.length() == 0)
{
PreValue = Value;
ErrorMessageText = "no error";
SavePreValue(Value, zwtime);
}
return true;
}
@@ -506,6 +558,16 @@ float ClassFlowPostProcessing::checkDigitConsistency(float input, int _decilamsh
return input;
}
string ClassFlowPostProcessing::getReadoutRate()
{
return std::to_string(FlowRateAct);
}
string ClassFlowPostProcessing::getReadoutTimeStamp()
{
return timeStamp;
}
string ClassFlowPostProcessing::getReadoutError()
{

View File

@@ -1,9 +1,12 @@
#pragma once
#include "ClassFlow.h"
#include "ClassFlowMakeImage.h"
#include <string>
class ClassFlowPostProcessing :
public ClassFlow
{
@@ -17,6 +20,9 @@ protected:
bool PreValueOkay;
bool checkDigitIncreaseConsistency;
int DecimalShift;
time_t lastvalue;
float FlowRateAct; // m3 / min
string FilePreValue;
float PreValue; // letzter Wert, der gut ausgelesen wurde
@@ -25,6 +31,9 @@ protected:
string ReturnValue; // korrigierter Rückgabewert, ggf. mit Fehlermeldung
string ReturnValueNoError; // korrigierter Rückgabewert ohne Fehlermeldung
string ErrorMessageText; // Fehlermeldung bei Consistency Check
string timeStamp;
ClassFlowMakeImage *flowMakeImage;
bool LoadPreValue(void);
string ShiftDecimal(string in, int _decShift);
@@ -40,6 +49,8 @@ public:
string getReadout();
string getReadoutParam(bool _rawValue, bool _noerror);
string getReadoutError();
string getReadoutRate();
string getReadoutTimeStamp();
void SavePreValue(float value, string time = "");
string GetPreValue();

View File

@@ -0,0 +1,101 @@
#ifndef CAMERADEFINED
#define CAMERADEFINED
#if defined(CAMERA_MODEL_WROVER_KIT)
#define PWDN_GPIO_NUM -1
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 21
#define SIOD_GPIO_NUM 26
#define SIOC_GPIO_NUM 27
#define Y9_GPIO_NUM 35
#define Y8_GPIO_NUM 34
#define Y7_GPIO_NUM 39
#define Y6_GPIO_NUM 36
#define Y5_GPIO_NUM 19
#define Y4_GPIO_NUM 18
#define Y3_GPIO_NUM 5
#define Y2_GPIO_NUM 4
#define VSYNC_GPIO_NUM 25
#define HREF_GPIO_NUM 23
#define PCLK_GPIO_NUM 22
#elif defined(CAMERA_MODEL_M5STACK_PSRAM)
#define PWDN_GPIO_NUM -1
#define RESET_GPIO_NUM 15
#define XCLK_GPIO_NUM 27
#define SIOD_GPIO_NUM 25
#define SIOC_GPIO_NUM 23
#define Y9_GPIO_NUM 19
#define Y8_GPIO_NUM 36
#define Y7_GPIO_NUM 18
#define Y6_GPIO_NUM 39
#define Y5_GPIO_NUM 5
#define Y4_GPIO_NUM 34
#define Y3_GPIO_NUM 35
#define Y2_GPIO_NUM 32
#define VSYNC_GPIO_NUM 22
#define HREF_GPIO_NUM 26
#define PCLK_GPIO_NUM 21
#elif defined(CAMERA_MODEL_AI_THINKER)
#define PWDN_GPIO_NUM GPIO_NUM_32
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM GPIO_NUM_0
#define SIOD_GPIO_NUM GPIO_NUM_26
#define SIOC_GPIO_NUM GPIO_NUM_27
#define Y9_GPIO_NUM GPIO_NUM_35
#define Y8_GPIO_NUM GPIO_NUM_34
#define Y7_GPIO_NUM GPIO_NUM_39
#define Y6_GPIO_NUM GPIO_NUM_36
#define Y5_GPIO_NUM GPIO_NUM_21
#define Y4_GPIO_NUM GPIO_NUM_19
#define Y3_GPIO_NUM GPIO_NUM_18
#define Y2_GPIO_NUM GPIO_NUM_5
#define VSYNC_GPIO_NUM GPIO_NUM_25
#define HREF_GPIO_NUM GPIO_NUM_23
#define PCLK_GPIO_NUM GPIO_NUM_22
#else
#error "Camera model not selected"
#endif
static camera_config_t camera_config = {
.pin_pwdn = PWDN_GPIO_NUM,
.pin_reset = RESET_GPIO_NUM,
.pin_xclk = XCLK_GPIO_NUM,
.pin_sscb_sda = SIOD_GPIO_NUM,
.pin_sscb_scl = SIOC_GPIO_NUM,
.pin_d7 = Y9_GPIO_NUM,
.pin_d6 = Y8_GPIO_NUM,
.pin_d5 = Y7_GPIO_NUM,
.pin_d4 = Y6_GPIO_NUM,
.pin_d3 = Y5_GPIO_NUM,
.pin_d2 = Y4_GPIO_NUM,
.pin_d1 = Y3_GPIO_NUM,
.pin_d0 = Y2_GPIO_NUM,
.pin_vsync = VSYNC_GPIO_NUM,
.pin_href = HREF_GPIO_NUM,
.pin_pclk = PCLK_GPIO_NUM,
//XCLK 20MHz or 10MHz for OV2640 double FPS (Experimental)
.xclk_freq_hz = 20000000,
.ledc_timer = LEDC_TIMER_0,
.ledc_channel = LEDC_CHANNEL_0,
.pixel_format = PIXFORMAT_JPEG,//YUV422,GRAYSCALE,RGB565,JPEG
// .pixel_format = PIXFORMAT_RGB888,//YUV422,GRAYSCALE,RGB565,JPEG
// .frame_size = FRAMESIZE_QVGA,//QQVGA-QXGA Do not use sizes above QVGA when not JPEG
.frame_size = FRAMESIZE_SVGA,//QQVGA-QXGA Do not use sizes above QVGA when not JPEG
.jpeg_quality = 12, //0-63 lower number means higher quality
.fb_count = 1 //if more than one, i2s runs in continuous mode. Use only with JPEG
};
#endif

View File

@@ -1,7 +1,7 @@
#include "CRotateImage.h"
CRotateImage::CRotateImage(CImageBasis *_org, CImageBasis *_temp)
CRotateImage::CRotateImage(CImageBasis *_org, CImageBasis *_temp, bool _flip)
{
rgb_image = _org->rgb_image;
channels = _org->channels;
@@ -9,8 +9,10 @@ CRotateImage::CRotateImage(CImageBasis *_org, CImageBasis *_temp)
height = _org->height;
bpp = _org->bpp;
externalImage = true;
ImageTMP = _temp;
ImageTMP = _temp;
ImageOrg = _org;
islocked = false;
doflip = _flip;
}
void CRotateImage::Mirror(){
@@ -58,12 +60,33 @@ void CRotateImage::Mirror(){
void CRotateImage::Rotate(float _angle, int _centerx, int _centery)
{
int org_width, org_height;
float m[2][3];
float x_center = _centerx;
float y_center = _centery;
_angle = _angle / 180 * M_PI;
if (doflip)
{
org_width = width;
org_height = height;
height = org_width;
width = org_height;
x_center = x_center - (org_width/2) + (org_height/2);
y_center = y_center + (org_width/2) - (org_height/2);
if (ImageOrg)
{
ImageOrg->height = height;
ImageOrg->width = width;
}
}
else
{
org_width = width;
org_height = height;
}
m[0][0] = cos(_angle);
m[0][1] = sin(_angle);
m[0][2] = (1 - m[0][0]) * x_center - m[0][1] * y_center;
@@ -72,6 +95,12 @@ void CRotateImage::Rotate(float _angle, int _centerx, int _centery)
m[1][1] = m[0][0];
m[1][2] = m[0][1] * x_center + (1 - m[0][0]) * y_center;
if (doflip)
{
m[0][2] = m[0][2] + (org_width/2) - (org_height/2);
m[1][2] = m[1][2] - (org_width/2) + (org_height/2);
}
int memsize = width * height * channels;
uint8_t* odata;
if (ImageTMP)
@@ -101,9 +130,9 @@ void CRotateImage::Rotate(float _angle, int _centerx, int _centery)
x_source += int(m[0][2]);
y_source += int(m[1][2]);
if ((x_source >= 0) && (x_source < width) && (y_source >= 0) && (y_source < height))
if ((x_source >= 0) && (x_source < org_width) && (y_source >= 0) && (y_source < org_height))
{
p_source = rgb_image + (channels * (y_source * width + x_source));
p_source = rgb_image + (channels * (y_source * org_width + x_source));
for (int _channels = 0; _channels < channels; ++_channels)
p_target[_channels] = p_source[_channels];
}

View File

@@ -4,10 +4,11 @@
class CRotateImage: public CImageBasis
{
public:
CImageBasis *ImageTMP;
CRotateImage(std::string _image) : CImageBasis(_image) {ImageTMP = NULL;};
CRotateImage(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp) : CImageBasis(_rgb_image, _channels, _width, _height, _bpp) {ImageTMP = NULL;};
CRotateImage(CImageBasis *_org, CImageBasis *_temp);
CImageBasis *ImageTMP, *ImageOrg;
bool doflip;
CRotateImage(std::string _image, bool _flip = false) : CImageBasis(_image) {ImageTMP = NULL; ImageOrg = NULL; doflip = _flip;};
CRotateImage(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp, bool _flip = false) : CImageBasis(_rgb_image, _channels, _width, _height, _bpp) {ImageTMP = NULL; ImageOrg = NULL; doflip = _flip;};
CRotateImage(CImageBasis *_org, CImageBasis *_temp, bool _flip = false);
void Rotate(float _angle);
void Rotate(float _angle, int _centerx, int _centery);

View File

@@ -77,7 +77,7 @@ void ClassLogFile::WriteToDedicatedFile(std::string _fn, std::string info, bool
time(&rawtime);
timeinfo = localtime(&rawtime);
strftime(buffer, 80, "%Y-%m-%d_%H-%M-%S", timeinfo);
strftime(buffer, 80, "%Y-%m-%dT%H:%M:%S", timeinfo);
zwtime = std::string(buffer);
info = zwtime + ": " + info;

View File

@@ -16,11 +16,11 @@ esp_mqtt_event_id_t esp_mmqtt_ID = MQTT_EVENT_ANY;
bool mqtt_connected = false;
esp_mqtt_client_handle_t client = NULL;
void MQTTPublish(std::string _key, std::string _content){
void MQTTPublish(std::string _key, std::string _content, int retained_flag){
if (client && mqtt_connected) {
int msg_id;
std::string zw;
msg_id = esp_mqtt_client_publish(client, _key.c_str(), _content.c_str(), 0, 1, 0);
msg_id = esp_mqtt_client_publish(client, _key.c_str(), _content.c_str(), 0, 1, retained_flag);
zw = "sent publish successful in MQTTPublish, msg_id=" + std::to_string(msg_id) + ", " + _key + ", " + _content;
if (debugdetail) LogFile.WriteToFile(zw);
ESP_LOGI(TAG, "sent publish successful in MQTTPublish, msg_id=%d, %s, %s", msg_id, _key.c_str(), _content.c_str());
@@ -74,6 +74,7 @@ void MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user, st
.client_id = _clientid.c_str(),
.lwt_topic = _LWTContext.c_str(),
.lwt_msg = _zwmessage.c_str(),
.lwt_retain = 1,
.lwt_msg_len = _lzw,
.keepalive = _keepalive
};
@@ -88,5 +89,5 @@ void MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user, st
esp_mqtt_client_register_event(client, esp_mmqtt_ID, mqtt_event_handler, client);
esp_mqtt_client_start(client);
MQTTPublish(_LWTContext, "");
MQTTPublish(_LWTContext, "", 1);
}

View File

@@ -4,4 +4,4 @@ void MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user, st
//void MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user = "", std::string _password = "");
void MQTTPublish(std::string _key, std::string _content);
void MQTTPublish(std::string _key, std::string _content, int retained_flag = 0);

View File

@@ -6,13 +6,9 @@
// #define DEBUG_DETAIL_ON
//#define GET_MEMORY(X) malloc(X)
#define GET_MEMORY(X) heap_caps_malloc(X, MALLOC_CAP_SPIRAM)
float CTfLiteClass::GetOutputValue(int nr)
{
TfLiteTensor* output2 = interpreter->output(0);
TfLiteTensor* output2 = this->interpreter->output(0);
int numeroutput = output2->dims->data[1];
if ((nr+1) > numeroutput)
@@ -57,7 +53,7 @@ int CTfLiteClass::GetOutClassification()
void CTfLiteClass::GetInputDimension(bool silent = false)
{
TfLiteTensor* input2 = interpreter->input(0);
TfLiteTensor* input2 = this->interpreter->input(0);
int numdim = input2->dims->size;
if (!silent) printf("NumDimension: %d\n", numdim);
@@ -76,7 +72,7 @@ void CTfLiteClass::GetInputDimension(bool silent = false)
void CTfLiteClass::GetOutPut()
{
TfLiteTensor* output2 = interpreter->output(0);
TfLiteTensor* output2 = this->interpreter->output(0);
int numdim = output2->dims->size;
printf("NumDimension: %d\n", numdim);
@@ -146,20 +142,20 @@ void CTfLiteClass::MakeAllocate()
static tflite::AllOpsResolver resolver;
// printf(LogFile.getESPHeapInfo().c_str()); printf("\n");
interpreter = new tflite::MicroInterpreter(model, resolver, tensor_arena, kTensorArenaSize, error_reporter);
this->interpreter = new tflite::MicroInterpreter(this->model, resolver, this->tensor_arena, this->kTensorArenaSize, this->error_reporter);
// printf(LogFile.getESPHeapInfo().c_str()); printf("\n");
TfLiteStatus allocate_status = interpreter->AllocateTensors();
TfLiteStatus allocate_status = this->interpreter->AllocateTensors();
if (allocate_status != kTfLiteOk) {
TF_LITE_REPORT_ERROR(error_reporter, "AllocateTensors() failed");
GetInputDimension();
this->GetInputDimension();
return;
}
// printf("Allocate Done.\n");
}
void CTfLiteClass::GetInputTensorSize(){
float *zw = input;
float *zw = this->input;
int test = sizeof(zw);
#ifdef DEBUG_DETAIL_ON
printf("Input Tensor Dimension: %d\n", test);
@@ -215,39 +211,36 @@ unsigned char* CTfLiteClass::ReadFileToCharArray(std::string _fn)
void CTfLiteClass::LoadModel(std::string _fn){
#ifdef SUPRESS_TFLITE_ERRORS
error_reporter = new tflite::OwnMicroErrorReporter;
this->error_reporter = new tflite::OwnMicroErrorReporter;
#else
error_reporter = new tflite::MicroErrorReporter;
this->error_reporter = new tflite::MicroErrorReporter;
#endif
unsigned char *rd;
rd = ReadFileToCharArray(_fn.c_str());
model = tflite::GetModel(rd);
this->model = tflite::GetModel(rd);
free(rd);
TFLITE_MINIMAL_CHECK(model != nullptr);
MakeAllocate();
}
CTfLiteClass::CTfLiteClass()
{
model = nullptr;
interpreter = nullptr;
input = nullptr;
output = nullptr;
kTensorArenaSize = 200 * 1024; /// laut testfile: 108000 - bisher 600
tensor_arena = (uint8_t*) GET_MEMORY(kTensorArenaSize);
// tensor_arena = new uint8_t[kTensorArenaSize];
this->model = nullptr;
this->interpreter = nullptr;
this->input = nullptr;
this->output = nullptr;
this->kTensorArenaSize = 200 * 1024; /// laut testfile: 108000 - bisher 600
this->tensor_arena = new uint8_t[kTensorArenaSize];
}
CTfLiteClass::~CTfLiteClass()
{
delete tensor_arena;
delete interpreter;
delete error_reporter;
delete this->tensor_arena;
delete this->interpreter;
delete this->error_reporter;
}

View File

@@ -41,7 +41,7 @@ class CTfLiteClass
const tflite::Model* model;
tflite::MicroInterpreter* interpreter;
TfLiteTensor* output = nullptr;
tflite::AllOpsResolver resolver;
static tflite::AllOpsResolver resolver;
int kTensorArenaSize;
uint8_t *tensor_arena;
@@ -52,12 +52,12 @@ class CTfLiteClass
long GetFileSize(std::string filename);
unsigned char* ReadFileToCharArray(std::string _fn);
void MakeAllocate();
public:
CTfLiteClass();
~CTfLiteClass();
void LoadModel(std::string _fn);
void MakeAllocate();
void GetInputTensorSize();
bool LoadInputImageBasis(CImageBasis *rs);
void Invoke();

View File

@@ -128,6 +128,31 @@ void blink_task_doFlow(void *pvParameter)
xHandleblink_task_doFlow = NULL;
}
esp_err_t handler_init(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_init - Start");
printf("handler_doinit uri:\n"); printf(req->uri); printf("\n");
#endif
char* resp_str = "Init started<br>";
httpd_resp_send(req, resp_str, strlen(resp_str));
doInit();
resp_str = "Init done<br>";
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);
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_init - Done");
#endif
return ESP_OK;
};
esp_err_t handler_doflow(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
@@ -409,6 +434,44 @@ esp_err_t handler_editflow(httpd_req_t *req)
httpd_resp_sendstr_chunk(req, zw.c_str());
}
if (_task.compare("test_align") == 0)
{
std::string _host = "";
if (httpd_query_key_value(_query, "host", _valuechar, 30) == ESP_OK) {
_host = std::string(_valuechar);
}
// printf("Parameter host: "); printf(_host.c_str()); printf("\n");
// string zwzw = "Do " + _task + " start\n"; printf(zwzw.c_str());
std::string zw = tfliteflow.doSingleStep("[Alignment]", _host);
httpd_resp_sendstr_chunk(req, zw.c_str());
}
if (_task.compare("test_analog") == 0)
{
std::string _host = "";
if (httpd_query_key_value(_query, "host", _valuechar, 30) == ESP_OK) {
_host = std::string(_valuechar);
}
// printf("Parameter host: "); printf(_host.c_str()); printf("\n");
// string zwzw = "Do " + _task + " start\n"; printf(zwzw.c_str());
std::string zw = tfliteflow.doSingleStep("[Analog]", _host);
httpd_resp_sendstr_chunk(req, zw.c_str());
}
if (_task.compare("test_digits") == 0)
{
std::string _host = "";
if (httpd_query_key_value(_query, "host", _valuechar, 30) == ESP_OK) {
_host = std::string(_valuechar);
}
// printf("Parameter host: "); printf(_host.c_str()); printf("\n");
// string zwzw = "Do " + _task + " start\n"; printf(zwzw.c_str());
std::string zw = tfliteflow.doSingleStep("[Digits]", _host);
httpd_resp_sendstr_chunk(req, zw.c_str());
}
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_sendstr_chunk(req, NULL);
@@ -543,6 +606,11 @@ void register_server_tflite_uri(httpd_handle_t server)
httpd_uri_t camuri = { };
camuri.method = HTTP_GET;
camuri.uri = "/doinit";
camuri.handler = handler_init;
camuri.user_ctx = (void*) "Light On";
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/setPreValue.html";
camuri.handler = handler_prevalue;
camuri.user_ctx = (void*) "Prevalue";
@@ -552,6 +620,7 @@ void register_server_tflite_uri(httpd_handle_t server)
camuri.handler = handler_doflow;
camuri.user_ctx = (void*) "Light Off";
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/editflow.html";
camuri.handler = handler_editflow;

View File

@@ -27,6 +27,17 @@ void time_sync_notification_cb(struct timeval *tv)
ESP_LOGI(TAG, "Notification of a time synchronization event");
}
std::string ConvertTimeToString(time_t _time, const char * frm)
{
struct tm timeinfo;
char strftime_buf[64];
localtime_r(&_time, &timeinfo);
strftime(strftime_buf, sizeof(strftime_buf), frm, &timeinfo);
std::string result(strftime_buf);
return result;
}
std::string gettimestring(const char * frm)
{
time_t now;

View File

@@ -9,10 +9,13 @@
#include "esp_log.h"
#include "esp_attr.h"
#include "esp_sleep.h"
// #include "nvs_flash.h"
#include "esp_sntp.h"
void setup_time(void);
std::string gettimestring(const char * frm);
std::string ConvertTimeToString(time_t _time, const char * frm);
void setTimeZone(std::string _tzstring);
void reset_servername(std::string _servername);

View File

@@ -2,6 +2,6 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*)
idf_component_register(SRCS ${app_sources}
INCLUDE_DIRS "."
REQUIRES jomjol_helper)
REQUIRES nvs_flash jomjol_helper)

View File

@@ -0,0 +1,293 @@
#include "connect_wlan.h"
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "driver/gpio.h"
#include "esp_system.h"
#include "esp_wifi.h"
#include "esp_event.h"
#include "esp_log.h"
#include "nvs_flash.h"
#include "lwip/err.h"
#include "lwip/sys.h"
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#define EXAMPLE_ESP_MAXIMUM_RETRY 1000
/* FreeRTOS event group to signal when we are connected*/
static EventGroupHandle_t s_wifi_event_group;
/* The event group allows multiple bits for each event, but we only care about two events:
* - we are connected to the AP with an IP
* - we failed to connect after the maximum amount of retries */
#define WIFI_CONNECTED_BIT BIT0
#define WIFI_FAIL_BIT BIT1
static const char *TAG = "wifi station";
static int s_retry_num = 0;
///////////////////////////////////////////////////////////
#define BLINK_GPIO GPIO_NUM_33
int BlinkDauer;
int BlinkAnzahl;
bool BlinkOff;
bool BlinkIsRunning = false;
std::string hostname = "";
std::string std_hostname = "watermeter";
std::string ipadress = "";
std::string ssid = "";
std::string getIPAddress()
{
return ipadress;
}
std::string getSSID()
{
return ssid;
}
void task_doBlink(void *pvParameter)
{
ESP_LOGI("BLINK", "Blinken - start");
while (BlinkIsRunning)
{
// ESP_LOGI("BLINK", "Blinken - wait");
vTaskDelay(100 / portTICK_PERIOD_MS);
}
BlinkIsRunning = true;
// Init the GPIO
gpio_pad_select_gpio(BLINK_GPIO);
/* Set the GPIO as a push/pull output */
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
for (int i = 0; i < BlinkAnzahl; ++i)
{
if (BlinkAnzahl > 1)
{
gpio_set_level(BLINK_GPIO, 1);
vTaskDelay(BlinkDauer / portTICK_PERIOD_MS);
}
gpio_set_level(BLINK_GPIO, 0);
vTaskDelay(BlinkDauer / portTICK_PERIOD_MS);
}
if (BlinkOff)
gpio_set_level(BLINK_GPIO, 1);
ESP_LOGI("BLINK", "Blinken - done");
BlinkIsRunning = false;
vTaskDelete(NULL); //Delete this task if it exits from the loop above
}
void LEDBlinkTask(int _dauer, int _anz, bool _off)
{
BlinkDauer = _dauer;
BlinkAnzahl = _anz;
BlinkOff = _off;
xTaskCreate(&task_doBlink, "task_doBlink", configMINIMAL_STACK_SIZE * 8, NULL, tskIDLE_PRIORITY+1, NULL);
}
/////////////////////////////////////////////////////////
static void event_handler(void* arg, esp_event_base_t event_base,
int32_t event_id, void* event_data)
{
if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
LEDBlinkTask(200, 1, true);
esp_wifi_connect();
} else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
if (s_retry_num < EXAMPLE_ESP_MAXIMUM_RETRY) {
// LEDBlinkTask(200, 1, true);
esp_wifi_connect();
s_retry_num++;
ESP_LOGI(TAG, "retry to connect to the AP");
} else {
xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT);
}
ESP_LOGI(TAG,"connect to the AP fail");
} else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data;
ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip));
ipadress = std::string(ip4addr_ntoa((const ip4_addr*) &event->ip_info.ip));
s_retry_num = 0;
xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
LEDBlinkTask(1000, 5, true);
}
}
void strinttoip4(const char *ip, int &a, int &b, int &c, int &d) {
std::string zw = std::string(ip);
std::stringstream s(zw);
char ch; //to temporarily store the '.'
s >> a >> ch >> b >> ch >> c >> ch >> d;
}
void wifi_init_sta(const char *_ssid, const char *_password, const char *_hostname, const char *_ipadr, const char *_gw, const char *_netmask, const char *_dns)
{
ssid = std::string(_ssid);
s_wifi_event_group = xEventGroupCreate();
ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());
/////////////////////////////////////////////////////////////////
esp_netif_t *my_sta = esp_netif_create_default_wifi_sta();
if ((_ipadr != NULL) && (_gw != NULL) && (_netmask != NULL))
{
ESP_LOGI(TAG, "set IP %s, GW %s, Netmask %s manual", _ipadr, _gw, _netmask);
esp_netif_dhcpc_stop(my_sta);
esp_netif_ip_info_t ip_info;
int a, b, c, d;
strinttoip4(_ipadr, a, b, c, d);
IP4_ADDR(&ip_info.ip, a, b, c, d);
strinttoip4(_gw, a, b, c, d);
IP4_ADDR(&ip_info.gw, a, b, c, d);
strinttoip4(_netmask, a, b, c, d);
IP4_ADDR(&ip_info.netmask, a, b, c, d);
esp_netif_set_ip_info(my_sta, &ip_info);
}
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
if ((_ipadr != NULL) && (_gw != NULL) && (_netmask != NULL))
{
if (_dns == NULL)
_dns = _gw;
ESP_LOGI(TAG, "set DNS manual");
esp_netif_dns_info_t dns_info;
ip4_addr_t ip;
ip.addr = esp_ip4addr_aton(_dns);
ip_addr_set_ip4_u32(&dns_info.ip, ip.addr);
ESP_ERROR_CHECK(esp_netif_set_dns_info(my_sta, ESP_NETIF_DNS_MAIN, &dns_info));
}
/////////////////////////////////////////////////////////////////
// esp_netif_create_default_wifi_sta();
// wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
// ESP_ERROR_CHECK(esp_wifi_init(&cfg));
/*
////////////////////////////// esp-idf 4.2 //////////////////////////
esp_event_handler_instance_t instance_any_id;
esp_event_handler_instance_t instance_got_ip;
ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,
ESP_EVENT_ANY_ID,
&event_handler,
NULL,
&instance_any_id));
ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT,
IP_EVENT_STA_GOT_IP,
&event_handler,
NULL,
&instance_got_ip));
////////////////////////// ENDE esp-idf 4.2 ///////////////////////////
*/
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL));
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler, NULL));
wifi_config_t wifi_config = { };
strcpy((char*)wifi_config.sta.ssid, (const char*)_ssid);
strcpy((char*)wifi_config.sta.password, (const char*)_password);
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) );
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config) );
ESP_ERROR_CHECK(esp_wifi_start() );
if (_hostname != NULL)
{
esp_err_t ret = tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA , _hostname);
hostname = std::string(_hostname);
if(ret != ESP_OK ){
ESP_LOGE(TAG,"failed to set hostname:%d",ret);
}
}
ESP_LOGI(TAG, "wifi_init_sta finished.");
/* Waiting until either the connection is established (WIFI_CONNECTED_BIT) or connection failed for the maximum
* number of re-tries (WIFI_FAIL_BIT). The bits are set by event_handler() (see above) */
EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group,
WIFI_CONNECTED_BIT | WIFI_FAIL_BIT,
pdFALSE,
pdFALSE,
portMAX_DELAY);
/* xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually
* happened. */
if (bits & WIFI_CONNECTED_BIT) {
ESP_LOGI(TAG, "connected to ap SSID:%s password:%s",
_ssid, _password);
} else if (bits & WIFI_FAIL_BIT) {
ESP_LOGI(TAG, "Failed to connect to SSID:%s, password:%s",
_ssid, _password);
} else {
ESP_LOGE(TAG, "UNEXPECTED EVENT");
}
/* The event will not be processed after unregister */
/*
////////////////////////////// esp-idf 4.2 //////////////////////////
ESP_ERROR_CHECK(esp_event_handler_instance_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, instance_got_ip));
ESP_ERROR_CHECK(esp_event_handler_instance_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, instance_any_id));
////////////////////////// ENDE esp-idf 4.2 ///////////////////////////
*/
/* Deaktiveren, damit bei einen Verbindungsabbruch neu aufgebaut wird
ESP_ERROR_CHECK(esp_event_handler_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler));
ESP_ERROR_CHECK(esp_event_handler_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler));
vEventGroupDelete(s_wifi_event_group);
*/
/*
while (BlinkIsRunning)
{
vTaskDelay(100 / portTICK_PERIOD_MS);
}
*/
}
void wifi_init_sta(const char *_ssid, const char *_password, const char *_hostname)
{
wifi_init_sta(_ssid, _password, _hostname, NULL, NULL, NULL, NULL);
}
void wifi_init_sta(const char *_ssid, const char *_password)
{
wifi_init_sta(_ssid, _password, NULL, NULL, NULL, NULL, NULL);
}

View File

@@ -0,0 +1,16 @@
#ifndef CONNECT_WLAN_H
#define CONNECT_WLAN_H
#include <string>
void wifi_init_sta(const char *_ssid, const char *_password, const char *_hostname, const char *_ipadr, const char *_gw, const char *_netmask, const char *_dns);
void wifi_init_sta(const char *_ssid, const char *_password, const char *_hostname);
void wifi_init_sta(const char *_ssid, const char *_password);
std::string getIPAddress();
std::string getSSID();
extern std::string hostname;
extern std::string std_hostname;
#endif

View File

@@ -0,0 +1,257 @@
#include "read_wlanini.h"
#include "Helper.h"
#include "connect_wlan.h"
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <string.h>
std::vector<string> ZerlegeZeile(std::string input, std::string _delimiter = "")
{
std::vector<string> Output;
std::string delimiter = " =,";
if (_delimiter.length() > 0){
delimiter = _delimiter;
}
input = trim(input, delimiter);
size_t pos = findDelimiterPos(input, delimiter);
std::string token;
while (pos != std::string::npos) {
token = input.substr(0, pos);
token = trim(token, delimiter);
Output.push_back(token);
input.erase(0, pos + 1);
input = trim(input, delimiter);
pos = findDelimiterPos(input, delimiter);
}
Output.push_back(input);
return Output;
}
void LoadWlanFromFile(std::string fn, char *&_ssid, char *&_password, char *&_hostname, char *&_ipadr, char *&_gw, char *&_netmask, char *&_dns)
{
std::string ssid = "";
std::string passphrase = "";
std::string ipaddress = "";
std::string gw = "";
std::string netmask = "";
std::string dns = "";
std::string line = "";
std::vector<string> zerlegt;
hostname = std_hostname;
FILE* pFile;
fn = FormatFileName(fn);
pFile = OpenFileAndWait(fn.c_str(), "r");
printf("file loaded\n");
if (pFile == NULL)
return;
char zw[1024];
fgets(zw, 1024, pFile);
line = std::string(zw);
while ((line.size() > 0) || !(feof(pFile)))
{
// printf("%s", line.c_str());
zerlegt = ZerlegeZeile(line, "=");
zerlegt[0] = trim(zerlegt[0], " ");
for (int i = 2; i < zerlegt.size(); ++i)
zerlegt[1] = zerlegt[1] + "=" + zerlegt[i];
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "HOSTNAME")){
hostname = trim(zerlegt[1]);
if ((hostname[0] == '"') && (hostname[hostname.length()-1] == '"')){
hostname = hostname.substr(1, hostname.length()-2);
}
}
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "SSID")){
ssid = trim(zerlegt[1]);
if ((ssid[0] == '"') && (ssid[ssid.length()-1] == '"')){
ssid = ssid.substr(1, ssid.length()-2);
}
}
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "PASSWORD")){
passphrase = zerlegt[1];
if ((passphrase[0] == '"') && (passphrase[passphrase.length()-1] == '"')){
passphrase = passphrase.substr(1, passphrase.length()-2);
}
}
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "IP")){
ipaddress = zerlegt[1];
if ((ipaddress[0] == '"') && (ipaddress[ipaddress.length()-1] == '"')){
ipaddress = ipaddress.substr(1, ipaddress.length()-2);
}
}
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "GATEWAY")){
gw = zerlegt[1];
if ((gw[0] == '"') && (gw[gw.length()-1] == '"')){
gw = gw.substr(1, gw.length()-2);
}
}
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "NETMASK")){
netmask = zerlegt[1];
if ((netmask[0] == '"') && (netmask[netmask.length()-1] == '"')){
netmask = netmask.substr(1, netmask.length()-2);
}
}
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "DNS")){
dns = zerlegt[1];
if ((dns[0] == '"') && (dns[dns.length()-1] == '"')){
dns = dns.substr(1, dns.length()-2);
}
}
if (fgets(zw, 1024, pFile) == NULL)
{
line = "";
}
else
{
line = std::string(zw);
}
}
fclose(pFile);
// Check if Hostname was empty in .ini if yes set to std_hostname
if(hostname.length() >= 0){
hostname = std_hostname;
}
_hostname = new char[hostname.length() + 1];
strcpy(_hostname, hostname.c_str());
_ssid = new char[ssid.length() + 1];
strcpy(_ssid, ssid.c_str());
_password = new char[passphrase.length() + 1];
strcpy(_password, passphrase.c_str());
if (ipaddress.length() > 0)
{
_ipadr = new char[ipaddress.length() + 1];
strcpy(_ipadr, ipaddress.c_str());
}
else
_ipadr = NULL;
if (gw.length() > 0)
{
_gw = new char[gw.length() + 1];
strcpy(_gw, gw.c_str());
}
else
_gw = NULL;
if (netmask.length() > 0)
{
_netmask = new char[netmask.length() + 1];
strcpy(_netmask, netmask.c_str());
}
else
_netmask = NULL;
if (dns.length() > 0)
{
_dns = new char[dns.length() + 1];
strcpy(_dns, dns.c_str());
}
else
_dns = NULL;
}
bool ChangeHostName(std::string fn, std::string _newhostname)
{
if (_newhostname == hostname)
return false;
string line = "";
std::vector<string> zerlegt;
bool found = false;
std::vector<string> neuesfile;
FILE* pFile;
fn = FormatFileName(fn);
pFile = OpenFileAndWait(fn.c_str(), "r");
printf("file loaded\n");
if (pFile == NULL)
return false;
char zw[1024];
fgets(zw, 1024, pFile);
line = std::string(zw);
while ((line.size() > 0) || !(feof(pFile)))
{
printf("%s", line.c_str());
zerlegt = ZerlegeZeile(line, "=");
zerlegt[0] = trim(zerlegt[0], " ");
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "HOSTNAME")){
line = "hostname = \"" + _newhostname + "\"\n";
found = true;
}
neuesfile.push_back(line);
if (fgets(zw, 1024, pFile) == NULL)
{
line = "";
}
else
{
line = std::string(zw);
}
}
if (!found)
{
line = "\nhostname = \"" + _newhostname + "\"\n";
neuesfile.push_back(line);
}
fclose(pFile);
pFile = OpenFileAndWait(fn.c_str(), "w+");
for (int i = 0; i < neuesfile.size(); ++i)
{
printf(neuesfile[i].c_str());
fputs(neuesfile[i].c_str(), pFile);
}
fclose(pFile);
printf("*** Update hostname done ***\n");
return true;
}

View File

@@ -0,0 +1,11 @@
#ifndef READ_WLANINI_H
#define READ_WLANINI_H
#include <string>
void LoadWlanFromFile(std::string fn, char *&_ssid, char *&_password, char *&_hostname, char *&_ipadr, char *&_gw, char *&_netmask, char *&_dns);
bool ChangeHostName(std::string fn, std::string _newhostname);
#endif

2
code/dependencies.lock Normal file
View File

@@ -0,0 +1,2 @@
manifest_hash: 45994dbfed009907994c31f6d279c5861a1eacbf219ce8b58e74e39b3393816a
version: 1.0.0

View File

@@ -17,6 +17,7 @@
#include "ClassLogFile.h"
#include "connect_wlan.h"
#include "read_wlanini.h"
#include "server_tflite.h"
#include "server_file.h"
@@ -24,6 +25,8 @@
#include "time_sntp.h"
#include "ClassControllCamera.h"
#include "server_main.h"
#include "server_camera.h"
#define __SD_USE_ONE_LINE_MODE__
@@ -65,8 +68,10 @@ bool Init_NVS_SDCard()
// does make a difference some boards, so we do that here.
gpio_set_pull_mode(GPIO_NUM_15, GPIO_PULLUP_ONLY); // CMD, needed in 4- and 1- line modes
gpio_set_pull_mode(GPIO_NUM_2, GPIO_PULLUP_ONLY); // D0, needed in 4- and 1-line modes
#ifndef __SD_USE_ONE_LINE_MODE__
gpio_set_pull_mode(GPIO_NUM_4, GPIO_PULLUP_ONLY); // D1, needed in 4-line mode only
gpio_set_pull_mode(GPIO_NUM_12, GPIO_PULLUP_ONLY); // D2, needed in 4-line mode only
#endif
gpio_set_pull_mode(GPIO_NUM_13, GPIO_PULLUP_ONLY); // D3, needed in 4- and 1-line modes
// Options for mounting the filesystem.
@@ -102,6 +107,7 @@ bool Init_NVS_SDCard()
// Init the GPIO
// Flash ausschalten
gpio_pad_select_gpio(FLASH_GPIO);
gpio_set_direction(FLASH_GPIO, GPIO_MODE_OUTPUT);
gpio_set_level(FLASH_GPIO, 0);
@@ -113,6 +119,7 @@ void task_NoSDBlink(void *pvParameter)
{
gpio_pad_select_gpio(BLINK_GPIO);
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
TickType_t xDelay;
xDelay = 100 / portTICK_PERIOD_MS;
@@ -124,28 +131,50 @@ void task_NoSDBlink(void *pvParameter)
vTaskDelay( xDelay );
gpio_set_level(BLINK_GPIO, 0);
vTaskDelay( xDelay );
}
vTaskDelete(NULL); //Delete this task if it exits from the loop above
}
extern "C" void app_main(void)
{
printf("Do Reset Camera\n");
PowerResetCamera();
Camera.InitCam();
Camera.LightOnOff(false);
if (!Init_NVS_SDCard())
{
xTaskCreate(&task_NoSDBlink, "task_NoSDBlink", configMINIMAL_STACK_SIZE * 64, NULL, tskIDLE_PRIORITY+1, NULL);
return;
};
CheckOTAUpdate();
Camera.InitCam();
char *ssid = NULL, *passwd = NULL, *hostname = NULL, *ip = NULL, *gateway = NULL, *netmask = NULL, *dns = NULL;
LoadWlanFromFile("/sdcard/wlan.ini", ssid, passwd, hostname, ip, gateway, netmask, dns);
LoadWlanFromFile("/sdcard/wlan.ini");
ConnectToWLAN();
printf("\nNetparameter: IP: %s - GW: %s - NetMask %s\n", getIPAddress().c_str(), getGW().c_str(), getNetMask().c_str());
if (ssid != NULL && passwd != NULL)
printf("\nWLan: %s, %s\n", ssid, passwd);
else
printf("No SSID and PASSWORD set!!!");
if (hostname != NULL)
printf("Hostename: %s\n", hostname);
else
printf("Hostname not set.\n");
if (ip != NULL && gateway != NULL && netmask != NULL)
printf("Fixed IP: %s, Gateway %s, Netmask %s\n", ip, gateway, netmask);
if (dns != NULL)
printf("DNS IP: %s\n", dns);
wifi_init_sta(ssid, passwd, hostname, ip, gateway, netmask, dns);
TickType_t xDelay;
xDelay = 2000 / portTICK_PERIOD_MS;
// printf("Autoflow: sleep for : %ldms\n", (long) xDelay);
printf("Autoflow: sleep for : %ldms\n", (long) xDelay);
// LogFile.WriteToFile("Startsequence 06");
vTaskDelay( xDelay );
// LogFile.WriteToFile("Startsequence 07");
@@ -155,14 +184,17 @@ extern "C" void app_main(void)
LogFile.WriteToFile("=============================================================================================");
LogFile.SwitchOnOff(false);
// std::string zw = gettimestring("%Y%m%d-%H%M%S");
// printf("time %s\n", zw.c_str());
std::string zw = gettimestring("%Y%m%d-%H%M%S");
printf("time %s\n", zw.c_str());
// Camera.InitCam();
// Camera.LightOnOff(false);
xDelay = 2000 / portTICK_PERIOD_MS;
printf("Autoflow: sleep for : %ldms\n", (long) xDelay);
vTaskDelay( xDelay );
server = start_webserver();
register_server_camera_uri(server);
register_server_tflite_uri(server);
register_server_file_uri(server, "/sdcard");
register_server_ota_sdcard_uri(server);
@@ -170,8 +202,10 @@ extern "C" void app_main(void)
#ifdef __SD_USE_ONE_LINE_MODE__
register_server_GPIO_uri(server);
#endif
printf("vor reg server main\n");
register_server_main_uri(server, "/sdcard");
printf("vor dotautostart\n");
TFliteDoAutoStart();
}
}

View File

@@ -107,7 +107,7 @@ esp_err_t info_get_handler(httpd_req_t *req)
if (_task.compare("Hostname") == 0)
{
std::string zw;
zw = std::string(getHostname());
zw = std::string(hostname);
httpd_resp_sendstr_chunk(req, zw.c_str());
httpd_resp_sendstr_chunk(req, NULL);
return ESP_OK;
@@ -387,7 +387,7 @@ httpd_handle_t start_webserver(void)
httpd_config_t config = { };
config.task_priority = tskIDLE_PRIORITY+5;
config.stack_size = 16384; // bei 32k stürzt das Programm beim Bilderaufnehmen ab
config.stack_size = 32384; // bei 32k stürzt das Programm beim Bilderaufnehmen ab
config.core_id = tskNO_AFFINITY;
config.server_port = 80;
config.ctrl_port = 32768;

View File

@@ -9,7 +9,7 @@
#include <sys/param.h>
#include "nvs_flash.h"
#include "tcpip_adapter.h"
//#include "esp_eth.h"
#include "esp_eth.h"
#include <esp_http_server.h>

View File

@@ -1,4 +1,4 @@
const char* GIT_REV="ec96b7f";
const char* GIT_TAG="";
const char* GIT_REV="6cefc44";
const char* GIT_TAG="v7.1.0";
const char* GIT_BRANCH="master";
const char* BUILD_TIME="2021-04-23 07:11";
const char* BUILD_TIME="2021-05-30 21:47";

View File

@@ -13,7 +13,7 @@ extern "C"
#include "Helper.h"
#include <fstream>
const char* GIT_BASE_BRANCH = "master - v6.7.0 - 2020-04-23";
const char* GIT_BASE_BRANCH = "master - v7.1.1 - 2020-05-30";
const char* git_base_branch(void)

View File

@@ -24,7 +24,7 @@ board_build.partitions = partitions.csv
lib_deps =
jomjol_helper
connect_wlan
jomjol_wlan
jomjol_image_proc
jomjol_controlcamera
jomjol_flowcontroll

View File

@@ -135,11 +135,10 @@ CONFIG_EXAMPLE_CONNECT_IPV6=y
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
# CONFIG_COMPILER_OPTIMIZATION_PERF is not set
# CONFIG_COMPILER_OPTIMIZATION_NONE is not set
# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE is not set
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y
# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set
# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set
CONFIG_COMPILER_CXX_EXCEPTIONS=y
CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE=0
# CONFIG_COMPILER_CXX_EXCEPTIONS is not set
# CONFIG_COMPILER_CXX_RTTI is not set
CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y
# CONFIG_COMPILER_STACK_CHECK_MODE_NORM is not set
@@ -247,9 +246,9 @@ CONFIG_ESP32_REV_MIN_0=y
CONFIG_ESP32_REV_MIN=0
CONFIG_ESP32_DPORT_WORKAROUND=y
# CONFIG_ESP32_DEFAULT_CPU_FREQ_80 is not set
# CONFIG_ESP32_DEFAULT_CPU_FREQ_160 is not set
CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=240
CONFIG_ESP32_DEFAULT_CPU_FREQ_160=y
# CONFIG_ESP32_DEFAULT_CPU_FREQ_240 is not set
CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=160
CONFIG_ESP32_SPIRAM_SUPPORT=y
#
@@ -398,8 +397,18 @@ CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=y
#
# Ethernet
#
# CONFIG_ETH_USE_ESP32_EMAC is not set
# CONFIG_ETH_USE_SPI_ETHERNET is not set
CONFIG_ETH_ENABLED=y
CONFIG_ETH_USE_ESP32_EMAC=y
CONFIG_ETH_PHY_INTERFACE_RMII=y
# CONFIG_ETH_PHY_INTERFACE_MII is not set
CONFIG_ETH_RMII_CLK_INPUT=y
# CONFIG_ETH_RMII_CLK_OUTPUT is not set
CONFIG_ETH_RMII_CLK_IN_GPIO=0
CONFIG_ETH_DMA_BUFFER_SIZE=512
CONFIG_ETH_DMA_RX_BUFFER_NUM=10
CONFIG_ETH_DMA_TX_BUFFER_NUM=10
CONFIG_ETH_USE_SPI_ETHERNET=y
CONFIG_ETH_SPI_ETHERNET_DM9051=y
# CONFIG_ETH_USE_OPENETH is not set
# end of Ethernet
@@ -419,7 +428,7 @@ CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y
#
# ESP HTTP client
#
# CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS is not set
CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y
# CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH is not set
# end of ESP HTTP client
@@ -538,12 +547,14 @@ CONFIG_FATFS_ALLOC_PREFER_EXTRAM=y
# Modbus configuration
#
CONFIG_FMB_COMM_MODE_RTU_EN=y
# CONFIG_FMB_COMM_MODE_ASCII_EN is not set
CONFIG_FMB_COMM_MODE_ASCII_EN=y
CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND=150
CONFIG_FMB_MASTER_DELAY_MS_CONVERT=200
CONFIG_FMB_QUEUE_LENGTH=20
CONFIG_FMB_SERIAL_TASK_STACK_SIZE=2048
CONFIG_FMB_SERIAL_BUF_SIZE=256
CONFIG_FMB_SERIAL_ASCII_BITS_PER_SYMB=8
CONFIG_FMB_SERIAL_ASCII_TIMEOUT_RESPOND_MS=1000
CONFIG_FMB_SERIAL_TASK_PRIO=10
# CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT is not set
CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT=20
@@ -982,24 +993,24 @@ CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30
#
# Supplicant
#
# CONFIG_WPA_MBEDTLS_CRYPTO is not set
CONFIG_WPA_MBEDTLS_CRYPTO=y
# CONFIG_WPA_TLS_V12 is not set
# end of Supplicant
#
# Camera configuration
#
# CONFIG_OV7670_SUPPORT is not set
CONFIG_OV7670_SUPPORT=y
# CONFIG_OV7725_SUPPORT is not set
# CONFIG_NT99141_SUPPORT is not set
CONFIG_NT99141_SUPPORT=y
CONFIG_OV2640_SUPPORT=y
# CONFIG_OV3660_SUPPORT is not set
# CONFIG_OV5640_SUPPORT is not set
CONFIG_OV3660_SUPPORT=y
CONFIG_OV5640_SUPPORT=y
# CONFIG_SCCB_HARDWARE_I2C_PORT0 is not set
CONFIG_SCCB_HARDWARE_I2C_PORT1=y
# CONFIG_CAMERA_CORE0 is not set
CONFIG_CAMERA_CORE0=y
# CONFIG_CAMERA_CORE1 is not set
CONFIG_CAMERA_NO_AFFINITY=y
# CONFIG_CAMERA_NO_AFFINITY is not set
# end of Camera configuration
# end of Component config
@@ -1035,11 +1046,10 @@ CONFIG_MONITOR_BAUD_OTHER_VAL=115200
CONFIG_MONITOR_BAUD=115200
# CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG is not set
CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE=y
# CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED is not set
CONFIG_OPTIMIZATION_ASSERTIONS_SILENT=y
CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y
# CONFIG_OPTIMIZATION_ASSERTIONS_SILENT is not set
# CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED is not set
CONFIG_CXX_EXCEPTIONS=y
CONFIG_CXX_EXCEPTIONS_EMG_POOL_SIZE=0
# CONFIG_CXX_EXCEPTIONS is not set
CONFIG_STACK_CHECK_NONE=y
# CONFIG_STACK_CHECK_NORM is not set
# CONFIG_STACK_CHECK_STRONG is not set

View File

@@ -131,15 +131,14 @@ CONFIG_EXAMPLE_CONNECT_IPV6=y
#
# Compiler options
#
# CONFIG_COMPILER_OPTIMIZATION_DEFAULT is not set
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y
# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set
# CONFIG_COMPILER_OPTIMIZATION_PERF is not set
# CONFIG_COMPILER_OPTIMIZATION_NONE is not set
# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE is not set
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y
# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set
# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set
CONFIG_COMPILER_CXX_EXCEPTIONS=y
CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE=0
# CONFIG_COMPILER_CXX_EXCEPTIONS is not set
# CONFIG_COMPILER_CXX_RTTI is not set
CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y
# CONFIG_COMPILER_STACK_CHECK_MODE_NORM is not set
@@ -398,8 +397,18 @@ CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=y
#
# Ethernet
#
# CONFIG_ETH_USE_ESP32_EMAC is not set
# CONFIG_ETH_USE_SPI_ETHERNET is not set
CONFIG_ETH_ENABLED=y
CONFIG_ETH_USE_ESP32_EMAC=y
CONFIG_ETH_PHY_INTERFACE_RMII=y
# CONFIG_ETH_PHY_INTERFACE_MII is not set
CONFIG_ETH_RMII_CLK_INPUT=y
# CONFIG_ETH_RMII_CLK_OUTPUT is not set
CONFIG_ETH_RMII_CLK_IN_GPIO=0
CONFIG_ETH_DMA_BUFFER_SIZE=512
CONFIG_ETH_DMA_RX_BUFFER_NUM=10
CONFIG_ETH_DMA_TX_BUFFER_NUM=10
CONFIG_ETH_USE_SPI_ETHERNET=y
CONFIG_ETH_SPI_ETHERNET_DM9051=y
# CONFIG_ETH_USE_OPENETH is not set
# end of Ethernet
@@ -419,7 +428,7 @@ CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y
#
# ESP HTTP client
#
# CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS is not set
CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y
# CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH is not set
# end of ESP HTTP client
@@ -538,12 +547,14 @@ CONFIG_FATFS_ALLOC_PREFER_EXTRAM=y
# Modbus configuration
#
CONFIG_FMB_COMM_MODE_RTU_EN=y
# CONFIG_FMB_COMM_MODE_ASCII_EN is not set
CONFIG_FMB_COMM_MODE_ASCII_EN=y
CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND=150
CONFIG_FMB_MASTER_DELAY_MS_CONVERT=200
CONFIG_FMB_QUEUE_LENGTH=20
CONFIG_FMB_SERIAL_TASK_STACK_SIZE=2048
CONFIG_FMB_SERIAL_BUF_SIZE=256
CONFIG_FMB_SERIAL_ASCII_BITS_PER_SYMB=8
CONFIG_FMB_SERIAL_ASCII_TIMEOUT_RESPOND_MS=1000
CONFIG_FMB_SERIAL_TASK_PRIO=10
# CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT is not set
CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT=20
@@ -587,6 +598,7 @@ CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0
# CONFIG_FREERTOS_USE_TRACE_FACILITY is not set
# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set
# CONFIG_FREERTOS_DEBUG_INTERNALS is not set
CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y
CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y
# CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set
CONFIG_FREERTOS_DEBUG_OCDAWARE=y
@@ -982,24 +994,24 @@ CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30
#
# Supplicant
#
# CONFIG_WPA_MBEDTLS_CRYPTO is not set
CONFIG_WPA_MBEDTLS_CRYPTO=y
# CONFIG_WPA_TLS_V12 is not set
# end of Supplicant
#
# Camera configuration
#
# CONFIG_OV7670_SUPPORT is not set
CONFIG_OV7670_SUPPORT=y
# CONFIG_OV7725_SUPPORT is not set
# CONFIG_NT99141_SUPPORT is not set
CONFIG_NT99141_SUPPORT=y
CONFIG_OV2640_SUPPORT=y
# CONFIG_OV3660_SUPPORT is not set
# CONFIG_OV5640_SUPPORT is not set
CONFIG_OV3660_SUPPORT=y
CONFIG_OV5640_SUPPORT=y
# CONFIG_SCCB_HARDWARE_I2C_PORT0 is not set
CONFIG_SCCB_HARDWARE_I2C_PORT1=y
# CONFIG_CAMERA_CORE0 is not set
CONFIG_CAMERA_CORE0=y
# CONFIG_CAMERA_CORE1 is not set
CONFIG_CAMERA_NO_AFFINITY=y
# CONFIG_CAMERA_NO_AFFINITY is not set
# end of Camera configuration
# end of Component config

View File

@@ -1,4 +1,4 @@
const char* GIT_REV="ec96b7f";
const char* GIT_TAG="";
const char* GIT_REV="6cefc44";
const char* GIT_TAG="v7.1.0";
const char* GIT_BRANCH="master";
const char* BUILD_TIME="2021-04-23 07:11";
const char* BUILD_TIME="2021-05-30 21:47";

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -9,6 +9,7 @@ FixedExposure = false
[Alignment]
InitialRotate=180
FlipImageSize = false
/config/ref0.jpg 119 273
/config/ref1.jpg 456 138
SearchFieldX = 20
@@ -17,7 +18,7 @@ InitialMirror= false
AlignmentAlgo = Default
[Digits]
Model = /config/dig0840s1q.tflite
Model = /config/dig0870s3q.tflite
;LogImageLocation = /log/digit
;LogfileRetentionInDays = 3
ModelInputSize = 20 32
@@ -49,6 +50,8 @@ CheckDigitIncreaseConsistency = false
;Uri = mqtt://IP-ADRESS:1883
;Topic = wasserzaehler/zaehlerstand
;TopicError = wasserzaehler/error
;TopicRate = wasserzaehler/rate
;TopicTimeStamp = wasserzaehler/timestamp
;ClientID = wasser
;user = USERNAME
;password = PASSWORD

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -518,6 +518,34 @@ textarea {
MQTT topic, in which the error status is reported (empty = no error)
</td>
</tr>
<tr>
<td width="20px" style="padding-left: 40px;">
<input type="checkbox" id="MQTT_TopicRate_enabled" value="1" onclick = 'InvertEnableItem("MQTT", "TopicRate")' unchecked >
</td>
<td width="200px">
<class id="MQTT_TopicRate_text" style="color:black;">TopicRate</class>
</td>
<td>
<input type="text" id="MQTT_TopicRate_value1">
</td>
<td style="font-size: 80%;">
MQTT topic, in which the flow rate [units / minute] is reported
</td>
</tr>
<tr>
<td width="20px" style="padding-left: 40px;">
<input type="checkbox" id="MQTT_TopicTimeStamp_enabled" value="1" onclick = 'InvertEnableItem("MQTT", "TopicTimeStamp")' unchecked >
</td>
<td width="200px">
<class id="MQTT_TopicTimeStamp_text" style="color:black;">TopicTimeStamp</class>
</td>
<td>
<input type="text" id="MQTT_TopicTimeStamp_value1">
</td>
<td style="font-size: 80%;">
MQTT topic, reporting the last correct readout
</td>
</tr>
<tr>
<td width="20px" style="padding-left: 40px;">
<input type="checkbox" id="MQTT_ClientID_enabled" value="1" onclick = 'InvertEnableItem("MQTT", "ClientID")' unchecked >
@@ -683,9 +711,13 @@ textarea {
<p>
</p>
<p>
<button class="button" id="reboot" type="button" onclick="doReboot()">Reboot to activate updates</button>
</p>
<div id="doreboot">
<p>
<button class="button" id="Edit_Config_Direct" onclick="editConfigDirect()" style="display:none">Edit Config.ini direct</button>
<button class="button" id="reboot" type="button" onclick="doReboot()">Reboot to activate updates</button>
</p>
</div>
</div>
@@ -701,6 +733,14 @@ textarea {
function LoadConfigNeu() {
var isInitialSetup = getParameterByName('InitialSetup');
if (isInitialSetup === 'true')
{
document.getElementById("reboot").style.display = "none";
}
basepath = getbasepath();
if (!loadConfig(basepath)) {
alert("Config.ini could not be loaded!\nPlease reload the page.");
@@ -715,6 +755,16 @@ function LoadConfigNeu() {
document.getElementById("divall").style.display = '';
}
function getParameterByName(name, url = window.location.href) {
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
function WriteParameter(_param, _category, _cat, _name, _optional, _select = false, _anzpara = 1){
if (_param[_cat][_name]["found"]){
if (_optional) {
@@ -885,6 +935,8 @@ function UpdateInput() {
WriteParameter(param, category, "MQTT", "Uri", true);
WriteParameter(param, category, "MQTT", "Topic", true);
WriteParameter(param, category, "MQTT", "TopicError", true);
WriteParameter(param, category, "MQTT", "TopicRate", true);
WriteParameter(param, category, "MQTT", "TopicTimeStamp", true);
WriteParameter(param, category, "MQTT", "ClientID", true);
WriteParameter(param, category, "MQTT", "user", true);
WriteParameter(param, category, "MQTT", "password", true);
@@ -942,6 +994,8 @@ function ReadParameterAll()
ReadParameter(param, "MQTT", "Uri", true);
ReadParameter(param, "MQTT", "Topic", true);
ReadParameter(param, "MQTT", "TopicError", true);
ReadParameter(param, "MQTT", "TopicRate", true);
ReadParameter(param, "MQTT", "TopicTimeStamp", true);
ReadParameter(param, "MQTT", "ClientID", true);
ReadParameter(param, "MQTT", "user", true);
ReadParameter(param, "MQTT", "password", true);

View File

@@ -44,6 +44,11 @@ table {
<tr>
<td style="padding-top: 10px"><label for="mirror" id="labelmirror">Mirror Image:</label></td>
<td style="padding-top: 10px"><input type="checkbox" id="mirror" name="mirror" value="1" onchange="drawRotated()"></td>
</tr>
<tr>
<td><label for="flip" id="labelflip">Flip Image Size:</label></td>
<td><input type="checkbox" id="flip" name="flip" value="1" onchange="drawRotated()"></td>
</tr>
<tr>
@@ -129,6 +134,13 @@ table {
document.getElementById("labelmirror").style = "color:lightgrey;";
}
if (param["Alignment"]["FlipImageSize"].found)
document.getElementById("flip").disabled = false;
else
{
document.getElementById("labelflip").style = "color:lightgrey;";
}
if (param["MakeImage"]["Brightness"].found && param["MakeImage"]["Brightness"].enabled)
document.getElementById("MakeImage_Brightness_value1").disabled = false;
else
@@ -156,6 +168,9 @@ table {
if (_param["Alignment"]["InitialMirror"].found && (_param["Alignment"]["InitialMirror"].value1 == "true"))
document.getElementById("mirror").checked = true;
if (_param["Alignment"]["FlipImageSize"].found && (_param["Alignment"]["FlipImageSize"].value1 == "true"))
document.getElementById("flip").checked = true;
document.getElementById("finerotate").disabled = true;
document.getElementById("prerotateangle").disabled = true;
document.getElementById("updatereferenceimage").disabled = true;
@@ -164,6 +179,7 @@ table {
// document.getElementById("MakeImage_Saturation_value1").disabled = true;
// document.getElementById("MakeImage_Contrast_value1").disabled = true;
document.getElementById("mirror").disabled = false;
document.getElementById("flip").disabled = false;
if (!(param["MakeImage"]["Brightness"].found))
{
document.getElementById("MakeImage_Brightness_value1").type = "hidden";
@@ -172,6 +188,7 @@ table {
document.getElementById("mirror").disabled = true;
document.getElementById("flip").disabled = true;
isActReference = true;
loadCanvas(url);
@@ -190,11 +207,17 @@ table {
function SaveReference(){
if (confirm("Are you sure you want to update the reference image?")) {
param["Alignment"]["InitialRotate"].value1 = document.getElementById("prerotateangle").value;
if ((param["Alignment"]["InitialMirror"].found == true) && (document.getElementById("mirror").checked))
param["Alignment"]["InitialMirror"].value1 = "true";
else
param["Alignment"]["InitialMirror"].value1 = "false";
if ((param["Alignment"]["FlipImageSize"].found == true) && (document.getElementById("flip").checked))
param["Alignment"]["FlipImageSize"].value1 = "true";
else
param["Alignment"]["FlipImageSize"].value1 = "false";
if (param["MakeImage"]["Brightness"].found && param["MakeImage"]["Brightness"].enabled)
{
ReadParameter(param, "MakeImage", "Brightness", false);
@@ -319,6 +342,7 @@ table {
finerot= parseFloat(document.getElementById("finerotate").value);
prerot = parseFloat(document.getElementById("prerotateangle").value);
mirror = document.getElementById("mirror").checked;
flip = document.getElementById("flip").checked;
if (finerot == 1) {
prerot+=1
@@ -332,10 +356,22 @@ table {
document.getElementById("finerotate").value = finerot;
document.getElementById("prerotateangle").value = prerot;
var canvas = document.getElementById('canvas');
if (flip == 1)
{
canvas.width = imageObj.height;
canvas.height = imageObj.width;
}
else
{
canvas.width = imageObj.width;
canvas.height = imageObj.height;
}
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
context.clearRect(0,0,imageObj.width,imageObj.height);
context.clearRect(0,0,canvas.width,canvas.height);
context.save();
if (isActReference)
@@ -344,17 +380,12 @@ table {
}
else
{
context.translate(canvas.width/2,canvas.height/2);
context.rotate(degrees*Math.PI/180);
if (mirror) {
context.scale(-1, 1);
context.translate(-imageObj.width/2,imageObj.height/2);
context.rotate(-degrees*Math.PI/180);
context.drawImage(imageObj, imageObj.width/2,-imageObj.height/2, -imageObj.width, imageObj.height);
}
else {
context.translate(imageObj.width/2,imageObj.height/2);
context.rotate(degrees*Math.PI/180);
context.drawImage(imageObj,-imageObj.width/2,-imageObj.height/2);
}
context.drawImage(imageObj,-imageObj.width/2,-imageObj.height/2);
}

View File

@@ -9,7 +9,7 @@ function getbasepath(){
{
// host = "http://192.168.2.118"; // jomjol interner test
// host = "http://192.168.178.26"; // jomjol interner test
host = "http://192.168.178.26"; // jomjol interner Real
host = "http://192.168.178.22"; // jomjol interner Real
// host = "."; // jomjol interner localhost
}

View File

@@ -39,7 +39,8 @@ function ParseConfig() {
ParamAddValue(param, catname, "InitialMirror");
ParamAddValue(param, catname, "SearchFieldX");
ParamAddValue(param, catname, "SearchFieldY");
ParamAddValue(param, catname, "AlignmentAlgo");
ParamAddValue(param, catname, "AlignmentAlgo");
ParamAddValue(param, catname, "FlipImageSize");
var catname = "Digits";
category[catname] = new Object();
@@ -83,6 +84,8 @@ function ParseConfig() {
ParamAddValue(param, catname, "Uri");
ParamAddValue(param, catname, "Topic");
ParamAddValue(param, catname, "TopicError");
ParamAddValue(param, catname, "TopicRate");
ParamAddValue(param, catname, "TopicTimeStamp");
ParamAddValue(param, catname, "ClientID");
ParamAddValue(param, catname, "user");
ParamAddValue(param, catname, "password");

Binary file not shown.

View File

@@ -111,7 +111,7 @@ function LoadStep(){
break;
case 5:
document.getElementById('maincontent').src = '/edit_config_param.html';
document.getElementById('maincontent').src = '/edit_config_param.html?InitialSetup=true';
document.getElementById('explaincontent').src = '/explain_5.html';
document.getElementById('h_iframe_explain').style.display = "";
document.getElementById("previous").disabled = false;

View File

@@ -1 +1 @@
6.4.1
6.8.0

View File

@@ -31,7 +31,7 @@
var m = addZero(d.getMinutes());
var s = addZero(d.getSeconds());
$('#img').html('<img src="/img_tmp/alg_roi.jpg" style="width:100%; max-height:555px;"></img>');
$('#img').html('<img src="/img_tmp/alg_roi.jpg" style="max-height:555px; display:block; margin-left:auto; margin-right:auto;"></img>');
$("#raw").load("/wasserzaehler.html?rawvalue=true");
$("#corrected").load("/wasserzaehler.html");
$("#checked").load("/setPreValue.html");
@@ -49,7 +49,7 @@
var m = addZero(d.getMinutes());
var s = addZero(d.getSeconds());
// reassign the url to be like alg_roi.jpg?timestamp=456784512 based on timestamp
$('#img').html('<img src="/img_tmp/alg_roi.jpg?timestamp='+ timestamp +'" style="width:100%; max-height:555px;"></img>');
$('#img').html('<img src="/img_tmp/alg_roi.jpg?timestamp='+ timestamp +'"max-height:555px; display:block; margin-left:auto; margin-right:auto;"></img>');
$("#raw").load("/wasserzaehler.html?rawvalue=true");
$("#corrected").load("/wasserzaehler.html");
$("#checked").load("/setPreValue.html");