Revert "Revert "System instable""

This reverts commit 1d9ef7e634.
This commit is contained in:
jomjol
2022-11-04 21:59:22 +01:00
parent 1d9ef7e634
commit 7e26744e2e
31 changed files with 126 additions and 1808 deletions

View File

@@ -29,7 +29,7 @@
- [#1143](https://github.com/jomjol/AI-on-the-edge-device/issues/1143) changed postprocess for analog->digit (lowest digit processing)
### Removed
- [#1261](https://github.com/jomjol/AI-on-the-edge-device/issues/1261) removed unused parameter `ErrorMessage`
- n.a.

View File

@@ -89,6 +89,15 @@ Rgb& Rgb::blend( Rgb in ) {
return *this;
}
uint8_t IRAM_ATTR Rgb::getGrb( int idx ) {
switch ( idx ) {
case 0: return g;
case 1: return r;
case 2: return b;
}
__builtin_unreachable();
}
Hsv::Hsv( Rgb r ) {
int min = std::min( r.r, std::min( r.g, r.b ) );
int max = std::max( r.r, std::max( r.g, r.b ) );

View File

@@ -19,21 +19,13 @@ union Rgb {
bool operator==( Rgb in ) const { return in.value == value; }
Rgb& blend( Rgb in );
void swap( Rgb& o ) { value = o.value; }
constexpr Rgb(const Rgb& other) : r(other.r), g(other.g), b(other.b), a(other.a) { }
void linearize() {
r = channelGamma(r);
g = channelGamma(g);
b = channelGamma(b);
}
uint8_t IRAM_ATTR getGrb( int idx ) {
switch ( idx ) {
case 0: return g;
case 1: return r;
case 2: return b;
}
__builtin_unreachable();
}
uint8_t IRAM_ATTR getGrb( int idx );
void stretchChannels( uint8_t maxR, uint8_t maxG, uint8_t maxB ) {
r = stretch( r, maxR );
@@ -62,7 +54,6 @@ private:
}
};
union Hsv {
struct __attribute__ ((packed)) {
uint8_t h, s, v, a;
@@ -75,5 +66,4 @@ union Hsv {
Hsv& operator=( Rgb rgb );
bool operator==( Hsv in ) const { return in.value == value; }
void swap( Hsv& o ) { value = o.value; }
constexpr Hsv(const Hsv& other) : h(other.h), s(other.s), v(other.v), a(other.a) { }
};

View File

@@ -16,16 +16,16 @@ void IRAM_ATTR SmartLed::interruptHandler(void*) {
if ( RMT.int_st.val & (1 << (24 + channel ) ) ) { // tx_thr_event
if ( self )
self->copyRmtHalfBlock();
RMT.int_clr.val = RMT.int_clr.val | 1 << ( 24 + channel );
RMT.int_clr.val |= 1 << ( 24 + channel );
} else if ( RMT.int_st.val & ( 1 << (3 * channel ) ) ) { // tx_end
if ( self )
xSemaphoreGiveFromISR( self->_finishedFlag, nullptr );
RMT.int_clr.val = RMT.int_clr.val | 1 << ( 3 * channel );
RMT.int_clr.val |= 1 << ( 3 * channel );
}
}
}
void SmartLed::copyRmtHalfBlock() {
void IRAM_ATTR SmartLed::copyRmtHalfBlock() {
int offset = detail::MAX_PULSES * _halfIdx;
_halfIdx = !_halfIdx;
int len = 3 - _componentPosition + 3 * ( _count - 1 );

View File

@@ -56,14 +56,10 @@
#include <freertos/semphr.h>
#include <soc/dport_reg.h>
#include <soc/gpio_sig_map.h>
#include <soc/gpio_periph.h>
#include <esp32/rom/gpio.h>
#include <soc/rmt_struct.h>
#include <driver/spi_master.h>
#include <driver/rmt.h>
}
#include <stdio.h>
extern rmt_mem_t RMTMEM;
#endif
#include "Color.h"
@@ -135,7 +131,8 @@ public:
initChannel( _channel );
RMT.tx_lim_ch[ _channel ].limit = detail::MAX_PULSES;
RMT.int_ena.val = RMT.int_ena.val | (1 << ( 24 + _channel )) | (1 << ( 3 * _channel ));
RMT.int_ena.val |= 1 << ( 24 + _channel );
RMT.int_ena.val |= 1 << ( 3 * _channel );
_bitToRmt[ 0 ].level0 = 1;
_bitToRmt[ 0 ].level1 = 0;

View File

@@ -108,7 +108,7 @@ void GpioPin::init()
gpio_config(&io_conf);
// if (_interruptType != GPIO_INTR_DISABLE) { // ohne GPIO_PIN_MODE_EXTERNAL_FLASH_WS281X, wenn das genutzt wird, dann soll auch der Handler hier nicht initialisiert werden, da das dann über SmartLED erfolgt.
if ((_interruptType != GPIO_INTR_DISABLE) && (_mode != GPIO_PIN_MODE_EXTERNAL_FLASH_WS281X)) {
if ((_interruptType != GPIO_INTR_DISABLE) && (_interruptType != GPIO_PIN_MODE_EXTERNAL_FLASH_WS281X)) {
//hook isr handler for specific gpio pin
ESP_LOGD(TAG_SERVERGPIO, "GpioPin::init add isr handler for GPIO %d", _gpio);
gpio_isr_handler_add(_gpio, gpio_isr_handler, (void*)&_gpio);

View File

@@ -5,8 +5,6 @@
#include <esp_http_server.h>
#include <map>
#include "hal/gpio_ll.h"
#include "rom/gpio.h"
#include "driver/gpio.h"
#include "SmartLeds.h"
@@ -111,4 +109,4 @@ GpioHandler* gpio_handler_get();
#endif //SERVER_GPIO_H
#endif //SERVER_GPIO_H

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 esp_timer esp_http_server jomjol_logfile jomjol_image_proc nvs_flash jomjol_fileserver_ota jomjol_controlGPIO)
REQUIRES esp32-camera esp_http_server jomjol_logfile jomjol_image_proc nvs_flash jomjol_fileserver_ota jomjol_controlGPIO)

View File

@@ -70,7 +70,41 @@
static const char *TAGCAMERACLASS = "server_part_camera";
static camera_config_t camera_config;
static camera_config_t camera_config = {
.pin_pwdn = CAM_PIN_PWDN,
.pin_reset = CAM_PIN_RESET,
.pin_xclk = CAM_PIN_XCLK,
.pin_sscb_sda = CAM_PIN_SIOD,
.pin_sscb_scl = CAM_PIN_SIOC,
.pin_d7 = CAM_PIN_D7,
.pin_d6 = CAM_PIN_D6,
.pin_d5 = CAM_PIN_D5,
.pin_d4 = CAM_PIN_D4,
.pin_d3 = CAM_PIN_D3,
.pin_d2 = CAM_PIN_D2,
.pin_d1 = CAM_PIN_D1,
.pin_d0 = CAM_PIN_D0,
.pin_vsync = CAM_PIN_VSYNC,
.pin_href = CAM_PIN_HREF,
.pin_pclk = CAM_PIN_PCLK,
//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 !!!! Hängt in Version 9.2 !!!!
.ledc_timer = LEDC_TIMER_0,
.ledc_channel = LEDC_CHANNEL_0,
.pixel_format = PIXFORMAT_JPEG, //YUV422,GRAYSCALE,RGB565,JPEG
.frame_size = FRAMESIZE_VGA, //QQVGA-UXGA Do not use sizes above QVGA when not JPEG
// .frame_size = FRAMESIZE_UXGA, //QQVGA-UXGA 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
.fb_location = CAMERA_FB_IN_PSRAM, /*!< The location where the frame buffer will be allocated */
// .grab_mode = CAMERA_GRAB_WHEN_EMPTY,
.grab_mode = CAMERA_GRAB_LATEST, // erst ab neuer esp32cam-version
};
#include "driver/ledc.h"
@@ -78,9 +112,6 @@ static camera_config_t camera_config;
CCamera Camera;
#define FLASH_GPIO GPIO_NUM_4
#ifdef BLINK_GPIO
#undef BLINK_GPIO
#endif
#define BLINK_GPIO GPIO_NUM_33
typedef struct {
@@ -502,11 +533,7 @@ esp_err_t CCamera::CaptureToHTTP(httpd_req_t *req, int delay)
esp_camera_fb_return(fb);
int64_t fr_end = esp_timer_get_time();
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0))
ESP_LOGI(TAGCAMERACLASS, "JPG: %luKB %lums", (uint32_t)(fb_len/1024), (uint32_t)((fr_end - fr_start)/1000));
#else
ESP_LOGI(TAGCAMERACLASS, "JPG: %uKB %ums", (uint32_t)(fb_len/1024), (uint32_t)((fr_end - fr_start)/1000));
#endif
if (delay > 0)
{
@@ -645,40 +672,6 @@ CCamera::CCamera()
esp_err_t CCamera::InitCam()
{
ESP_LOGD(TAGCAMERACLASS, "Init Camera");
camera_config.pin_pwdn = CAM_PIN_PWDN;
camera_config.pin_reset = CAM_PIN_RESET;
camera_config.pin_xclk = CAM_PIN_XCLK;
camera_config.pin_sccb_sda = CAM_PIN_SIOD;
camera_config.pin_sccb_scl = CAM_PIN_SIOC;
camera_config.pin_d7 = CAM_PIN_D7;
camera_config.pin_d6 = CAM_PIN_D6;
camera_config.pin_d5 = CAM_PIN_D5;
camera_config.pin_d4 = CAM_PIN_D4;
camera_config.pin_d3 = CAM_PIN_D3;
camera_config.pin_d2 = CAM_PIN_D2;
camera_config.pin_d1 = CAM_PIN_D1;
camera_config.pin_d0 = CAM_PIN_D0;
camera_config.pin_vsync = CAM_PIN_VSYNC;
camera_config.pin_href = CAM_PIN_HREF;
camera_config.pin_pclk = CAM_PIN_PCLK;
//XCLK 20MHz or 10MHz for OV2640 double FPS (Experimental)
camera_config.xclk_freq_hz = 20000000; // Orginalwert
// camera_config.xclk_freq_hz = 5000000; // Test, um die Bildfehler los zu werden !!!! Hängt in Version 9.2 !!!!
camera_config.ledc_timer = LEDC_TIMER_0;
camera_config.ledc_channel = LEDC_CHANNEL_0;
camera_config.pixel_format = PIXFORMAT_JPEG; //YUV422,GRAYSCALE,RGB565,JPEG
camera_config.frame_size = FRAMESIZE_VGA; //QQVGA-UXGA Do not use sizes above QVGA when not JPEG
// camera_config.frame_size = FRAMESIZE_UXGA; //QQVGA-UXGA Do not use sizes above QVGA when not JPEG
camera_config.jpeg_quality = 12; //0-63 lower number means higher quality
camera_config.fb_count = 1; //if more than one, i2s runs in continuous mode. Use only with JPEG
camera_config.fb_location = CAMERA_FB_IN_PSRAM; /*!< The location where the frame buffer will be allocated */
// camera_config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
camera_config.grab_mode = CAMERA_GRAB_LATEST; // erst ab neuer esp32cam-version
ActualQuality = camera_config.jpeg_quality;
ActualResolution = camera_config.frame_size;
//initialize the camera

View File

@@ -2,6 +2,6 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*)
idf_component_register(SRCS ${app_sources}
INCLUDE_DIRS "." "../../include"
REQUIRES tflite-lib esp_http_server bootloader_support app_update esp_http_client vfs nvs_flash jomjol_tfliteclass jomjol_flowcontroll spiffs jomjol_helper jomjol_controlGPIO)
REQUIRES tflite-lib esp_http_server app_update esp_http_client nvs_flash jomjol_tfliteclass jomjol_flowcontroll spiffs jomjol_helper jomjol_controlGPIO)

View File

@@ -3076,9 +3076,7 @@ static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream)
#define MZ_DELETE_FILE remove
#else
#if 0
#pragma message("Using fopen, ftello, fseeko, stat() etc. path for file I/O - this path may not support large files.")
#endif
#ifndef MINIZ_NO_TIME
#include <utime.h>
#endif

View File

@@ -3,6 +3,7 @@
#include <string>
#include "string.h"
#include <esp_int_wdt.h>
#include <esp_task_wdt.h>
@@ -16,9 +17,7 @@
#include <esp_ota_ops.h>
#include "esp_http_client.h"
#include "esp_flash_partitions.h"
#include "esp_vfs.h"
#include "esp_partition.h"
#include "esp_app_format.h"
#include <nvs.h>
#include "nvs_flash.h"
#include "driver/gpio.h"
@@ -79,28 +78,16 @@ static bool ota_update_task(std::string fn)
const esp_partition_t *running = esp_ota_get_running_partition();
if (configured != running) {
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0))
ESP_LOGW(TAGPARTOTA, "Configured OTA boot partition at offset 0x%08lx, but running from offset 0x%08lx",
#else
ESP_LOGW(TAGPARTOTA, "Configured OTA boot partition at offset 0x%08x, but running from offset 0x%08x",
#endif
configured->address, running->address);
ESP_LOGW(TAGPARTOTA, "(This can happen if either the OTA boot data or preferred boot image become somehow corrupted.)");
}
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0))
ESP_LOGI(TAGPARTOTA, "Running partition type %d subtype %d (offset 0x%08lx)",
#else
ESP_LOGI(TAGPARTOTA, "Running partition type %d subtype %d (offset 0x%08x)",
#endif
running->type, running->subtype, running->address);
update_partition = esp_ota_get_next_update_partition(NULL);
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0))
ESP_LOGI(TAGPARTOTA, "Writing to partition subtype %d at offset 0x%lx",
#else
ESP_LOGI(TAGPARTOTA, "Writing to partition subtype %d at offset 0x%x",
#endif
update_partition->subtype, update_partition->address);
// assert(update_partition != NULL);
@@ -487,17 +474,7 @@ esp_err_t handler_ota_update(httpd_req_t *req)
};
void hard_restart() {
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0))
esp_task_wdt_config_t wd_config;
wd_config.timeout_ms = 1000;
wd_config.idle_core_mask = (1 << portNUM_PROCESSORS) - 1; // Bitmask of all cores
wd_config.trigger_panic = true;
esp_task_wdt_init(&wd_config);
#else
esp_task_wdt_init(1,true);
#endif
esp_task_wdt_add(NULL);
while(true);
}

View File

@@ -13,7 +13,7 @@
#define __HIDE_PASSWORD
//static const char *TAG = "class_flow_MQTT";
static const char *TAG = "class_flow_MQTT";
#define LWT_TOPIC "connection"
#define LWT_CONNECTED "connected"
@@ -143,11 +143,7 @@ void publishRuntimeData(std::string maintopic, int SetRetainFlag) {
sprintf(tmp_char, "%ld", (long)getUpTime());
MQTTPublish(maintopic + "/" + "uptime", std::string(tmp_char), SetRetainFlag);
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0))
sprintf(tmp_char, "%lu", esp_get_free_heap_size());
#else
sprintf(tmp_char, "%zu", esp_get_free_heap_size());
#endif
MQTTPublish(maintopic + "/" + "freeMem", std::string(tmp_char), SetRetainFlag);
sprintf(tmp_char, "%d", get_WIFI_RSSI());

View File

@@ -4,9 +4,7 @@
#include <string>
#ifndef BLINK_GPIO
#define BLINK_GPIO GPIO_NUM_4
#endif
#define CAMERA_MODEL_AI_THINKER

View File

@@ -25,7 +25,6 @@ extern "C" {
#include "ClassLogFile.h"
#include "esp_vfs_fat.h"
#include "esp_mac.h"
static const char* TAG = "helper";
@@ -117,11 +116,7 @@ string getSDCardPartitionAllocationSize(){
f_getfree("0:", (DWORD *)&fre_clust, &fs);
allocation_size = fs->ssize;
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0))
printf("SD Card Partition Allocation Size (bytes): %lu)\n", allocation_size);
#else
printf("SD Card Partition Allocation Size (bytes): %zu)\n", allocation_size);
#endif
printf("SD Card Partition Allocation Size (bytes): %d)\n", allocation_size);
return std::to_string(allocation_size);
}

View File

@@ -41,24 +41,19 @@ static esp_err_t http_event_handler(esp_http_client_event_t *evt)
case HTTP_EVENT_DISCONNECTED:
ESP_LOGI(TAG_INTERFACEINFLUXDB, "HTTP Client Disconnected");
break;
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0))
case HTTP_EVENT_REDIRECT:
ESP_LOGI(TAG_INTERFACEINFLUXDB, "HTTP Client Redirect");
break;
#endif
}
return ESP_OK;
}
void InfluxDBPublish(std::string _key, std::string _content, std::string _timestamp) {
char response_buffer[MAX_HTTP_OUTPUT_BUFFER] = {0};
esp_http_client_config_t http_config;
http_config.user_agent = "ESP32 Meter reader";
http_config.method = HTTP_METHOD_POST;
http_config.event_handler = http_event_handler;
http_config.buffer_size = MAX_HTTP_OUTPUT_BUFFER;
http_config.user_data = response_buffer;
esp_http_client_config_t http_config = {
.user_agent = "ESP32 Meter reader",
.method = HTTP_METHOD_POST,
.event_handler = http_event_handler,
.buffer_size = MAX_HTTP_OUTPUT_BUFFER,
.user_data = response_buffer
};
if (_influxDBUser.length() && _influxDBPassword.length()){
http_config.username = _influxDBUser.c_str();

View File

@@ -116,11 +116,7 @@ static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event)
}
static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) {
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0))
ESP_LOGD(TAG_INTERFACEMQTT, "Event dispatched from event loop base=%s, event_id=%ld", base, event_id);
#else
ESP_LOGD(TAG_INTERFACEMQTT, "Event dispatched from event loop base=%s, event_id=%d", base, event_id);
#endif
mqtt_event_handler_cb((esp_mqtt_event_handle_t) event_data);
}
@@ -153,7 +149,6 @@ void MQTT_Configure(std::string _mqttURI, std::string _clientid, std::string _us
}
bool MQTT_Init() {
esp_mqtt_client_config_t mqtt_cfg;
esp_err_t ret;
LogFile.WriteToFile(ESP_LOG_INFO, "MQTT - Init");
@@ -161,33 +156,19 @@ bool MQTT_Init() {
std::string lw = lwt_disconnected;
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0))
mqtt_cfg.broker.address.uri = uri.c_str();
mqtt_cfg.credentials.client_id = client_id.c_str();
mqtt_cfg.session.last_will.topic = lwt_topic.c_str();
mqtt_cfg.session.last_will.msg = lw.c_str();
mqtt_cfg.session.last_will.msg_len = (int)(lw.length());
mqtt_cfg.session.last_will.retain = 1;
mqtt_cfg.session.keepalive = keepalive;
#else
mqtt_cfg.uri = uri.c_str();
mqtt_cfg.client_id = client_id.c_str();
mqtt_cfg.lwt_topic = lwt_topic.c_str();
mqtt_cfg.lwt_msg = lw.c_str();
mqtt_cfg.lwt_retain = 1;
mqtt_cfg.lwt_msg_len = (int)(lw.length());
mqtt_cfg.keepalive = keepalive;
#endif
esp_mqtt_client_config_t mqtt_cfg = {
.uri = uri.c_str(),
.client_id = client_id.c_str(),
.lwt_topic = lwt_topic.c_str(),
.lwt_msg = lw.c_str(),
.lwt_retain = 1,
.lwt_msg_len = (int)(lw.length()),
.keepalive = keepalive
};
if (user.length() && password.length()){
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0))
mqtt_cfg.credentials.username = user.c_str();
mqtt_cfg.credentials.authentication.password = password.c_str();
mqtt_cfg.credentials.authentication.key_password_len = password.length();
#else
mqtt_cfg.username = user.c_str();
mqtt_cfg.password = password.c_str();
#endif
};
client = esp_mqtt_client_init(&mqtt_cfg);

View File

@@ -12,7 +12,6 @@
#include "Helper.h"
#include "esp_camera.h"
#include "esp_timer.h"
#include "time_sntp.h"
#include "ClassControllCamera.h"
@@ -812,17 +811,11 @@ void register_server_tflite_uri(httpd_handle_t server)
camuri.user_ctx = (void*) "Light On";
httpd_register_uri_handler(server, &camuri);
// Legacy API => New: "/setPreValue"
camuri.uri = "/setPreValue.html";
camuri.handler = handler_prevalue;
camuri.user_ctx = (void*) "Prevalue";
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/setPreValue";
camuri.handler = handler_prevalue;
camuri.user_ctx = (void*) "Prevalue";
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/doflow";
camuri.handler = handler_doflow;
camuri.user_ctx = (void*) "Light Off";
@@ -832,51 +825,27 @@ void register_server_tflite_uri(httpd_handle_t server)
camuri.handler = handler_statusflow;
camuri.user_ctx = (void*) "Light Off";
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/statusflow";
camuri.handler = handler_statusflow;
camuri.user_ctx = (void*) "Light Off";
httpd_register_uri_handler(server, &camuri);
// Legacy API => New: "/cpu_temperature"
camuri.uri = "/cputemp.html";
camuri.handler = handler_cputemp;
camuri.user_ctx = (void*) "Light Off";
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/cpu_temperature";
camuri.handler = handler_cputemp;
camuri.user_ctx = (void*) "Light Off";
httpd_register_uri_handler(server, &camuri);
// Legacy API => New: "/rssi"
camuri.uri = "/rssi.html";
camuri.handler = handler_rssi;
camuri.user_ctx = (void*) "Light Off";
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/rssi";
camuri.handler = handler_rssi;
camuri.user_ctx = (void*) "Light Off";
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/editflow.html";
camuri.handler = handler_editflow;
camuri.user_ctx = (void*) "EditFlow";
httpd_register_uri_handler(server, &camuri);
// Legacy API => New: "/value"
camuri.uri = "/value.html";
camuri.handler = handler_wasserzaehler;
camuri.user_ctx = (void*) "Value";
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/value";
camuri.handler = handler_wasserzaehler;
camuri.user_ctx = (void*) "Value";
httpd_register_uri_handler(server, &camuri);
// Legacy API => New: "/value"
camuri.uri = "/wasserzaehler.html";
camuri.handler = handler_wasserzaehler;
camuri.user_ctx = (void*) "Wasserzaehler";

View File

@@ -7,6 +7,7 @@
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_log.h"
#include "esp_attr.h"
#include "esp_sleep.h"
@@ -137,4 +138,4 @@ time_t getUpTime()
time(&now);
return now - bootTime;
}
}

View File

@@ -5,6 +5,7 @@
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_log.h"
#include "esp_attr.h"
#include "esp_sleep.h"

View File

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

View File

@@ -13,8 +13,6 @@
#include "lwip/err.h"
#include "lwip/sys.h"
#include "lwip/ip_addr.h"
#include "lwip/inet.h"
#include <fstream>
#include <string>
@@ -38,14 +36,10 @@ static EventGroupHandle_t s_wifi_event_group;
#define WIFI_FAIL_BIT BIT1
static const char *TAG = "wifi station";
static esp_netif_t *my_sta;
static int s_retry_num = 0;
///////////////////////////////////////////////////////////
#ifdef BLINK_GPIO
#undef BLINK_GPIO
#endif
#define BLINK_GPIO GPIO_NUM_33
int BlinkDauer;
@@ -81,11 +75,7 @@ void task_doBlink(void *pvParameter)
BlinkIsRunning = true;
// Init the GPIO
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0))
esp_rom_gpio_pad_select_gpio(BLINK_GPIO);
#else
gpio_pad_select_gpio(BLINK_GPIO);
#endif
/* Set the GPIO as a push/pull output */
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
@@ -137,9 +127,7 @@ static void event_handler(void* arg, esp_event_base_t event_base,
} 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));
char ip_addr[16];
inet_ntoa_r(event->ip_info.ip.addr, ip_addr, 16);
ipadress = std::string(ip_addr);
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);
@@ -161,7 +149,7 @@ void wifi_init_sta(const char *_ssid, const char *_password, const char *_hostna
ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());
my_sta = esp_netif_create_default_wifi_sta();
esp_netif_t *my_sta = esp_netif_create_default_wifi_sta();
if ((_ipadr != NULL) && (_gw != NULL) && (_netmask != NULL))
{
@@ -237,7 +225,7 @@ void wifi_init_sta(const char *_ssid, const char *_password, const char *_hostna
if (_hostname != NULL)
{
esp_err_t ret = esp_netif_set_hostname(my_sta, _hostname);
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);

View File

@@ -46,9 +46,6 @@ extern const char* BUILD_TIME;
#include "server_GPIO.h"
#ifdef BLINK_GPIO
#undef BLINK_GPIO
#endif
#define BLINK_GPIO GPIO_NUM_33
static const char *TAGMAIN = "main";
@@ -91,10 +88,11 @@ bool Init_NVS_SDCard()
// Options for mounting the filesystem.
// If format_if_mount_failed is set to true, SD card will be partitioned and
// formatted in case when mounting fails.
esp_vfs_fat_sdmmc_mount_config_t mount_config;
mount_config.format_if_mount_failed = false;
mount_config.max_files = 7; // anstatt 5 (2022-09-21)
mount_config.allocation_unit_size = 16 * 1024;
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
.format_if_mount_failed = false,
.max_files = 7, // anstatt 5 (2022-09-21)
.allocation_unit_size = 16 * 1024
};
// Use settings defined above to initialize SD card and mount FAT filesystem.
// Note: esp_vfs_fat_sdmmc_mount is an all-in-one convenience function.
@@ -197,7 +195,7 @@ extern "C" void app_main(void)
ESP_LOGD(TAGMAIN, "No SSID and PASSWORD set!!!");
if (hostname != NULL)
ESP_LOGD(TAGMAIN, "Hostname: %s", hostname);
ESP_LOGD(TAGMAIN, "Hostename: %s", hostname);
else
ESP_LOGD(TAGMAIN, "Hostname not set");

View File

@@ -12,7 +12,6 @@
#include "version.h"
#include "esp_wifi.h"
#include "lwip/inet.h"
#include "server_tflite.h"
#include "esp_log.h"
@@ -360,25 +359,12 @@ esp_err_t sysinfo_handler(httpd_req_t *req)
std::string gitrevision = libfive_git_revision();
std::string htmlversion = getHTMLversion();
char freeheapmem[11];
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0))
sprintf(freeheapmem, "%lu", esp_get_free_heap_size());
#else
sprintf(freeheapmem, "%zu", esp_get_free_heap_size());
#endif
char ipstr[INET_ADDRSTRLEN];
tcpip_adapter_ip_info_t ip_info;
ESP_ERROR_CHECK(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info));
const char *hostname;
esp_netif_t *esp_netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
if (esp_netif != NULL) {
esp_netif_ip_info_t ip_info;
ESP_ERROR_CHECK(esp_netif_get_ip_info(esp_netif, &ip_info));
esp_ip4addr_ntoa(&ip_info.ip, ipstr, INET_ADDRSTRLEN);
ESP_ERROR_CHECK(esp_netif_get_hostname(esp_netif, &hostname));
} else {
ipstr[0] = '\0';
hostname = "n/a";
}
ESP_ERROR_CHECK(tcpip_adapter_get_hostname(TCPIP_ADAPTER_IF_STA, &hostname));
zw = "[\
{\
@@ -390,7 +376,7 @@ esp_err_t sysinfo_handler(httpd_req_t *req)
\"html\" : \"" + htmlversion + "\",\
\"cputemp\" : \"" + cputemp + "\",\
\"hostname\" : \"" + hostname + "\",\
\"IPv4\" : \"" + ipstr + "\",\
\"IPv4\" : \"" + ip4addr_ntoa(&ip_info.ip) + "\",\
\"freeHeapMem\" : \"" + freeheapmem + "\"\
}\
]";

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -1,69 +0,0 @@
##################################################
# Application specific configuration
# Edit this file instead of sdkconfig.esp32cam!
# After editting, make sure to explicitly delete
# sdkconfig.esp32cam to apply your changes!
##################################################
CONFIG_COMPILER_OPTIMIZATION_DEFAULT=n
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_ESP32_REV_MIN_0=y
CONFIG_ESP32_DPORT_WORKAROUND=y
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESPTOOLPY_FLASHSIZE="4MB"
CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
CONFIG_PARTITION_TABLE_OFFSET=0x8000
CONFIG_PARTITION_TABLE_MD5=y
CONFIG_VFS_SUPPORT_IO=y
CONFIG_SPIRAM=y
CONFIG_SPIRAM_SIZE=-1
CONFIG_SPIRAM_SPEED_40M=y
CONFIG_SPIRAM=y
CONFIG_SPIRAM_BOOT_INIT=y
CONFIG_SPIRAM_USE_MALLOC=y
CONFIG_SPIRAM_MEMTEST=y
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768
CONFIG_SPIRAM_CACHE_WORKAROUND=y
CONFIG_ESP_INT_WDT_TIMEOUT_MS=300
CONFIG_HTTPD_MAX_REQ_HDR_LEN=1024
CONFIG_HTTPD_PURGE_BUF_LEN=16
CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=16
CONFIG_ESP32_WIFI_CACHE_TX_BUFFER_NUM=16
CONFIG_FATFS_LFN_HEAP=y
CONFIG_FATFS_MAX_LFN=255
CONFIG_FATFS_API_ENCODING_ANSI_OEM=y
CONFIG_FMB_TIMER_PORT_ENABLED=y
CONFIG_MQTT_SKIP_PUBLISH_IF_DISCONNECTED=y
CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=n
CONFIG_OV7670_SUPPORT=n
CONFIG_OV7725_SUPPORT=n
CONFIG_NT99141_SUPPORT=n
CONFIG_OV3660_SUPPORT=n
CONFIG_OV5640_SUPPORT=n
CONFIG_GC2145_SUPPORT=n
CONFIG_GC032A_SUPPORT=n
CONFIG_GC0308_SUPPORT=n
CONFIG_BF3005_SUPPORT=n
CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y

View File

@@ -407,7 +407,6 @@ textarea {
Set on "false" to ensure, that only positive changes are accepted (typically for counter)
</td>
</tr>
<!--
<tr class="expert" id="ex12">
<td class="indent1">
<input type="checkbox" id="PostProcessing_ErrorMessage_enabled" value="1" onclick = 'InvertEnableItem("PostProcessing", "ErrorMessage")' unchecked >
@@ -423,7 +422,6 @@ textarea {
Do not show error message in return value - in error case, the last valid number will be send out
</td>
</tr>
-->
<tr class="expert" id="ex1dddd">
<td class="indent1">
<input type="checkbox" id="PostProcessing_CheckDigitIncreaseConsistency_enabled" value="1" onclick = 'InvertEnableItem("PostProcessing", "CheckDigitIncreaseConsistency")' unchecked >
@@ -1726,7 +1724,7 @@ function UpdateInput() {
WriteParameter(param, category, "PostProcessing", "PreValueUse", true);
WriteParameter(param, category, "PostProcessing", "PreValueAgeStartup", true);
WriteParameter(param, category, "PostProcessing", "AllowNegativeRates", true);
// WriteParameter(param, category, "PostProcessing", "ErrorMessage", true);
WriteParameter(param, category, "PostProcessing", "ErrorMessage", true);
WriteParameter(param, category, "PostProcessing", "CheckDigitIncreaseConsistency", true);
WriteParameter(param, category, "MQTT", "Uri", true);
@@ -1843,7 +1841,7 @@ function ReadParameterAll()
ReadParameter(param, "PostProcessing", "PreValueUse", true);
ReadParameter(param, "PostProcessing", "PreValueAgeStartup", true);
ReadParameter(param, "PostProcessing", "AllowNegativeRates", true);
// ReadParameter(param, "PostProcessing", "ErrorMessage", true);
ReadParameter(param, "PostProcessing", "ErrorMessage", true);
ReadParameter(param, "PostProcessing", "CheckDigitIncreaseConsistency", true);
ReadParameter(param, "MQTT", "Uri", true);

View File

@@ -84,7 +84,7 @@ function setprevalue() {
inputVal = inputVal.replace(",", ".");
var xhttp = new XMLHttpRequest();
try {
url = basepath + "/setPreValue?value=" + inputVal + "&numbers=" + _number;
url = basepath + "/setPreValue.html?value=" + inputVal + "&numbers=" + _number;
xhttp.open("GET", url, false);
xhttp.send();
response = xhttp.responseText;
@@ -102,7 +102,7 @@ function loadPrevalue(_basepath) {
var xhttp = new XMLHttpRequest();
try {
url = _basepath + '/setPreValue?numbers=' + _number;
url = _basepath + '/setPreValue.html?numbers=' + _number;
xhttp.open("GET", url, false);
xhttp.send();
response = xhttp.responseText;

View File

@@ -172,7 +172,7 @@ function ParseConfig() {
ParamAddValue(param, catname, "MaxRateType", 1, true);
ParamAddValue(param, catname, "ExtendedResolution", 1, true);
ParamAddValue(param, catname, "IgnoreLeadingNaN", 1, true);
// ParamAddValue(param, catname, "ErrorMessage");
ParamAddValue(param, catname, "ErrorMessage");
ParamAddValue(param, catname, "CheckDigitIncreaseConsistency");
var catname = "MQTT";

View File

@@ -111,7 +111,7 @@ function refresh() {
var basepath = "http://192.168.178.22";
function loadStatus() {
url = basepath + '/statusflow';
url = basepath + '/statusflow.html';
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
@@ -125,7 +125,7 @@ function refresh() {
}
function loadCPUTemp() {
url = basepath + '/cpu_temperature';
url = basepath + '/cputemp.html';
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
@@ -138,7 +138,7 @@ function refresh() {
}
function loadRSSI() {
url = basepath + '/rssi';
url = basepath + '/rssi.html';
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {