aboutsummaryrefslogtreecommitdiff
path: root/software
diff options
context:
space:
mode:
authorMDC Service <michael.schmid@mdc-service.de>2022-05-23 11:17:34 +0200
committerGitHub <noreply@github.com>2022-05-23 11:17:34 +0200
commit74a0003fea4087de8e9f03b6f828c45d255bcd4a (patch)
tree1b4615232dcac918fcc47cbd3c6ed54014fb38b7 /software
parentd2f3c7c9e17895ae43caed761f941a30e4e5eed6 (diff)
initial check in firmware files
Diffstat (limited to 'software')
-rw-r--r--software/CMakeLists.txt8
-rw-r--r--software/Makefile8
-rw-r--r--software/buffer-dump.odtbin0 -> 23290 bytes
-rw-r--r--software/esp2
-rw-r--r--software/esp32.sh3
-rw-r--r--software/export.sh2
-rw-r--r--software/main/CMakeLists.txt2
-rw-r--r--software/main/HMI.cpp176
-rw-r--r--software/main/HMI.h114
-rw-r--r--software/main/Kconfig.projbuild183
-rw-r--r--software/main/MU80X.cpp429
-rw-r--r--software/main/MU80X.h101
-rw-r--r--software/main/PCF8575.cpp474
-rw-r--r--software/main/PCF8575.h208
-rw-r--r--software/main/SimplePgSQL.cpp900
-rw-r--r--software/main/SimplePgSQL.h209
-rw-r--r--software/main/build/CMakeFiles/3.16.3/CMakeCCompiler.cmake76
-rw-r--r--software/main/build/CMakeFiles/3.16.3/CMakeCXXCompiler.cmake88
-rw-r--r--software/main/build/CMakeFiles/3.16.3/CMakeDetermineCompilerABI_C.binbin0 -> 16552 bytes
-rw-r--r--software/main/build/CMakeFiles/3.16.3/CMakeDetermineCompilerABI_CXX.binbin0 -> 16560 bytes
-rw-r--r--software/main/build/CMakeFiles/3.16.3/CMakeSystem.cmake15
-rw-r--r--software/main/build/CMakeFiles/3.16.3/CompilerIdC/CMakeCCompilerId.c671
-rw-r--r--software/main/build/CMakeFiles/3.16.3/CompilerIdC/a.outbin0 -> 16712 bytes
-rw-r--r--software/main/build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp660
-rw-r--r--software/main/build/CMakeFiles/3.16.3/CompilerIdCXX/a.outbin0 -> 16720 bytes
-rw-r--r--software/main/build/CMakeFiles/CMakeOutput.log429
-rw-r--r--software/main/build/CMakeFiles/cmake.check_cache1
-rw-r--r--software/main/component.mk4
-rw-r--r--software/main/config.cpp265
-rw-r--r--software/main/config.h33
-rw-r--r--software/main/etc.cpp17
-rw-r--r--software/main/etc.h14
-rw-r--r--software/main/iic.cpp174
-rw-r--r--software/main/iic.h25
-rw-r--r--software/main/main.cpp413
-rw-r--r--software/main/main.h130
-rw-r--r--software/main/uart.cpp57
-rw-r--r--software/main/uart.h22
-rw-r--r--software/michi_funcs/AW9523B.cpp225
-rw-r--r--software/michi_funcs/AW9523B.hpp151
-rw-r--r--software/michi_funcs/SimplePgSQL.cpp1278
-rw-r--r--software/michi_funcs/SimplePgSQL.h278
-rw-r--r--software/michi_funcs/SimplePgSQL_cpp.old900
-rw-r--r--software/michi_funcs/SimplePgSQL_h.old209
-rw-r--r--software/michi_funcs/board_rev_A.cpp38
-rw-r--r--software/michi_funcs/board_rev_A.hpp49
-rw-r--r--software/michi_funcs/board_rev_B.cpp102
-rw-r--r--software/michi_funcs/board_rev_B.hpp63
-rw-r--r--software/michi_funcs/component.mk4
-rw-r--r--software/michi_funcs/db_funcs.cpp404
-rw-r--r--software/michi_funcs/db_funcs.h66
-rw-r--r--software/michi_funcs/sdcard_funcs.cpp153
-rw-r--r--software/michi_funcs/sdcard_funcs.hpp6
-rw-r--r--software/partitions.csv9
-rw-r--r--software/rcbuf.txt54
-rw-r--r--software/sdkconfig1382
-rw-r--r--software/sdkconfig.defaults1
-rw-r--r--software/sdkconfig.old1221
-rw-r--r--software/spiffs_image/parameter.dat8
59 files changed, 12514 insertions, 0 deletions
diff --git a/software/CMakeLists.txt b/software/CMakeLists.txt
new file mode 100644
index 0000000..da45c64
--- /dev/null
+++ b/software/CMakeLists.txt
@@ -0,0 +1,8 @@
+# The following lines of boilerplate have to be in your project's CMakeLists
+# in this exact order for cmake to work correctly
+cmake_minimum_required(VERSION 3.5)
+
+include($ENV{IDF_PATH}/tools/cmake/project.cmake)
+#project(ethernet_basic)
+project(waescheschrank)
+spiffs_create_partition_image(storage spiffs_image FLASH_IN_PROJECT)
diff --git a/software/Makefile b/software/Makefile
new file mode 100644
index 0000000..9169fd8
--- /dev/null
+++ b/software/Makefile
@@ -0,0 +1,8 @@
+#
+# This is a project Makefile. It is assumed the directory this Makefile resides in is a
+# project subdirectory.
+#
+
+PROJECT_NAME := scaladis
+
+include $(IDF_PATH)/make/project.mk
diff --git a/software/buffer-dump.odt b/software/buffer-dump.odt
new file mode 100644
index 0000000..0dcaaf8
--- /dev/null
+++ b/software/buffer-dump.odt
Binary files differ
diff --git a/software/esp b/software/esp
new file mode 100644
index 0000000..8f75f3e
--- /dev/null
+++ b/software/esp
@@ -0,0 +1,2 @@
+#!/bin/sh
+/home/steffen/esp/esp-idf/tools/idf.py -b 115200 -p /dev/ttyUSB0 $1 $2 $3
diff --git a/software/esp32.sh b/software/esp32.sh
new file mode 100644
index 0000000..988d674
--- /dev/null
+++ b/software/esp32.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+/home/steffen/esp/esp-idf/tools/idf.py -b 115200 -p /dev/ttyUSB0 build flash monitor
+
diff --git a/software/export.sh b/software/export.sh
new file mode 100644
index 0000000..adf35ae
--- /dev/null
+++ b/software/export.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+. ../esp-idf/export.sh
diff --git a/software/main/CMakeLists.txt b/software/main/CMakeLists.txt
new file mode 100644
index 0000000..dc2a20b
--- /dev/null
+++ b/software/main/CMakeLists.txt
@@ -0,0 +1,2 @@
+idf_component_register(SRCS "main.cpp" "SimplePgSQL.cpp" "MU80X.cpp" "HMI.cpp" "etc.cpp" "uart.cpp" "iic.cpp" "config.cpp"
+ INCLUDE_DIRS ".")
diff --git a/software/main/HMI.cpp b/software/main/HMI.cpp
new file mode 100644
index 0000000..8ed8cda
--- /dev/null
+++ b/software/main/HMI.cpp
@@ -0,0 +1,176 @@
+/*
+ * HMI.cpp
+ *
+ * Created on: 17.08.2021
+ * Author: steffen
+ */
+#include "HMI.h"
+
+#ifdef ESP32
+HMI::HMI(int fh) {
+ _devh = fh;
+}
+#else
+HMI::HMI(const char *dev, const uint16_t baud) {
+ struct termios t1, t2;
+
+ int bd = B115200;
+ if (baud == 57600)
+ bd = B57600;
+
+ _devh = open(dev, O_RDWR | O_NONBLOCK);
+ if (_devh < 0) {
+ fprintf(stderr, "Unable to open serial device %s", dev);
+ } else {
+
+ tcgetattr(_devh, &t1);
+ tcgetattr(_devh, &t2);
+ cfmakeraw(&t1);
+
+ t1.c_cflag = (CLOCAL | CS8 | CREAD);
+ cfsetspeed(&t1, bd);
+ t1.c_cc[VMIN] = 0;
+ t1.c_cc[VTIME] = 0;
+ tcsetattr(_devh, TCSADRAIN, &t1);
+ }
+
+}
+#endif
+
+
+int HMI::serial_read(int fh, char *buf) {
+#ifdef ESP32
+ return (uart_read_bytes(fh, buf, 1, 1));
+#else
+ return (read(fh,buf,1));
+#endif
+}
+
+int HMI::serial_write(int fh, char *buf, int len) {
+#ifdef ESP32
+ return (uart_write_bytes(fh, buf, len));
+#else
+ return(write(fh,buf,len));
+#endif
+}
+
+int HMI::iReadProt(int ms) {
+ int cnt = ms;
+ int ec = 0; // end counter (3 x 0xFF)
+ char rc;
+ int i=0;
+ int res;
+ printf("CNT:%d\n",cnt);fflush(stdout);
+ while (cnt > 0) {
+ if ((res=serial_read(_devh, &rc)) == 1) {
+#ifdef DEBUG
+ printf(" <%02X> ", rc);
+ fflush (stdout);
+#endif
+ RecvBuf[i++]=rc;
+ if (rc==0xFF) {
+ ec++;
+ if (ec==3) {
+ i-=3;
+ RecvBuf[i]=0;
+#ifdef DEBUG
+ idumpbuf(RecvBuf,i);
+ printf("OK Received:%d\n", i);
+ fflush(stdout);
+#endif
+ return HMIResultOK;
+ }
+ }
+ cnt = ms;
+ } else {
+ cnt--;
+#ifdef DEBUG
+ printf(" - ");
+ fflush (stdout);
+#endif
+#ifdef ESP32
+ vTaskDelay(1);
+#else
+ usleep(1000);
+#endif
+ }
+ }
+ if (i==0) return HMIResultReadErr;
+ RecvBuf[i]=0;
+#ifdef DEBUG
+ printf("ERR Received:%d:%s\n", i,RecvBuf);
+ fflush(stdout);
+#endif
+ return HMIResultReadErr;
+}
+
+int HMI::iReadValue(char *name,int *result) {
+ char cmd[64];
+ int res;
+ sprintf(cmd,"get %s.txt",name);
+ res=iSendProt((int)strlen(cmd),cmd);
+ return res;
+}
+int HMI::iReadValue(char *name, char *result) {
+ char cmd[64];
+ int res;
+ sprintf(cmd,"get %s.txt",name);
+ res=iSendProt((int)strlen(cmd),cmd,10);
+// printf(">%s:%d<\n",cmd,res);fflush(stdout);
+ if (res==HMIResultOK) {
+// idumpbuf((void *)RecvBuf, (int)strlen((char *)RecvBuf));
+ strncpy(result,(char *)&RecvBuf[1],16);
+ }
+ return res;
+}
+int HMI::iWriteValue(char *name,int value) {
+ char cmd[64];
+ int res;
+ sprintf(cmd,"%s.txt=\"%d\"",name,value);
+#ifdef DEBUG
+// printf(">%s<\n",cmd);fflush(stdout);
+#endif
+ res=iSendProt((int)strlen(cmd),cmd);
+ return res;
+}
+int HMI::iWriteValue(char *name,char * value) {
+ char cmd[64];
+ int res;
+ sprintf(cmd,"%s.txt=\"%s\"",name,value);
+#ifdef DEBUG
+// printf(">%s<\n",cmd);fflush(stdout);
+#endif
+ res=iSendProt((int)strlen(cmd),cmd);
+ return res;
+}
+int HMI::iSendProt(int len, char *data) {
+ int res = 0;
+ int res2=0;
+ char lbuf[]={0xFF,0xFF,0xFF};
+ res = serial_write(_devh, (char *)data, (int)len);
+ if (res>0) res2=serial_write(_devh, lbuf, 3);
+ else return HMIResultWriteErr;
+ if (res2<0) return HMIResultWriteErr;
+ return HMIResultOK;;
+}
+int HMI::iSendProt(int len, char *data, int wait) {
+ int res = 0;
+ int res2=0;
+ char lbuf[]={0xFF,0xFF,0xFF};
+ res = serial_write(_devh, (char *)data, (int)len);
+ if (res>0) res2=serial_write(_devh, (char *)lbuf, 3);
+ else return HMIResultWriteErr;
+ if (res2<0) return HMIResultWriteErr;
+ if (wait==0) return res;
+ res = iReadProt(wait);
+ return res;
+}
+void HMI::idumpbuf(void *buf, int len) {
+ int i, c;
+ char *lb = (char*) buf;
+ for (i = 0; i < len; i++) {
+ c = (char) *lb++;
+ printf("%02X ", c);
+ }
+ printf("\n");
+}
diff --git a/software/main/HMI.h b/software/main/HMI.h
new file mode 100644
index 0000000..d377ccb
--- /dev/null
+++ b/software/main/HMI.h
@@ -0,0 +1,114 @@
+/*
+ * LCD.h
+ *
+ * Created on: 17.08.2021
+ * Author: steffen
+ */
+
+#ifndef HMI_H_
+#define HMI_H_
+#include "main.h"
+
+#define DEBUG
+#define ESP32
+#define ProtBufLen 260
+
+#define ERR_NOERR 0
+#define ERR_CRC -1
+#define ERR_WRITE -2
+#define ERR_NOANSWER -3
+#define ERR_DECODE -4
+
+
+#define BAUD_9600 0
+#define BAUD_19200 1
+#define BAUD_38400 2
+#define BAUD_57600 5
+#define BAUD_115200 6
+
+#define PIC_WELCOME 0
+#define PIC_OPENDOOR 1
+#define PIC_EMPTY 2
+#define PIC_KAS_OK 3
+#define PIC_KAS_DIS 4
+#define PIC_TRS_OK 5
+#define PIC_TRS_DIS 6
+
+#define BUT0 p0
+#define TXT0 t0
+#define BUT1 p1
+#define TXT1 t1
+#define BUT2 p2
+#define TXT2 t2
+#define BUT3 p3
+#define TXT3 t3
+#define BUT4 p4
+#define TXT4 t4
+#define BUT5 p5
+#define TXT5 t5
+
+#ifdef ESP32
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "esp_event.h"
+#include "esp_log.h"
+#include "driver/uart.h"
+#else
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <termios.h>
+#endif
+
+#define ESP32
+#define HMIResultOK 0
+#define HMIResultWriteErr -1
+#define HMIResultReadErr -2
+#define HMIResultProtErr -3
+
+typedef struct {
+ int page;
+ int id;
+ int state;
+} HMI_t;
+
+class HMI {
+public:
+
+#ifdef ESP32
+ HMI(const int fh);
+#else
+ HMI(const char *dev = "/dev/ttyUSB0", const uint16_t baud = 57600);
+#endif
+ ~HMI(void);
+
+ int iReadProt(int ms);
+ int iReadValue(char *name, int *res);
+ int iReadValue(char *name,char *res);
+ int iWriteValue(char *name,int value);
+ int iWriteValue(char *name,char *value);
+ int iSendProt(int len, char *data); // done
+ int iSendProt(int len, char *data, int wait); // done
+
+private:
+ int _devh;
+ unsigned char SendBuf[ProtBufLen];
+ unsigned char RecvBuf[ProtBufLen];
+ int serial_read(int fh, char *buf);
+ int serial_write(int fh, char * buf,int len);
+ void idumpbuf(void *buf, int len);
+
+};
+#endif /* HMI_H_ */
diff --git a/software/main/Kconfig.projbuild b/software/main/Kconfig.projbuild
new file mode 100644
index 0000000..be15538
--- /dev/null
+++ b/software/main/Kconfig.projbuild
@@ -0,0 +1,183 @@
+menu "Example Configuration"
+
+ config EXAMPLE_USE_SPI_ETHERNET
+ bool
+
+ choice EXAMPLE_ETHERNET_TYPE
+ prompt "Ethernet Type"
+ default EXAMPLE_USE_INTERNAL_ETHERNET if IDF_TARGET_ESP32
+ default EXAMPLE_USE_W5500
+ help
+ Select which kind of Ethernet will be used in the example.
+
+ config EXAMPLE_USE_INTERNAL_ETHERNET
+ depends on IDF_TARGET_ESP32
+ select ETH_USE_ESP32_EMAC
+ bool "Internal EMAC"
+ help
+ Select internal Ethernet MAC controller.
+
+ config EXAMPLE_USE_DM9051
+ bool "DM9051 Module"
+ select EXAMPLE_USE_SPI_ETHERNET
+ select ETH_USE_SPI_ETHERNET
+ select ETH_SPI_ETHERNET_DM9051
+ help
+ Select external SPI-Ethernet module (DM9051).
+
+ config EXAMPLE_USE_W5500
+ bool "W5500 Module"
+ select EXAMPLE_USE_SPI_ETHERNET
+ select ETH_USE_SPI_ETHERNET
+ select ETH_SPI_ETHERNET_W5500
+ help
+ Select external SPI-Ethernet module (W5500).
+
+ config EXAMPLE_USE_KSZ8851SNL
+ bool "KSZ8851SNL Module"
+ select EXAMPLE_USE_SPI_ETHERNET
+ select ETH_USE_SPI_ETHERNET
+ select ETH_SPI_ETHERNET_KSZ8851SNL
+ help
+ Select external SPI-Ethernet module (KSZ8851SNL).
+ endchoice # EXAMPLE_ETHERNET_TYPE
+
+ if EXAMPLE_USE_INTERNAL_ETHERNET
+ choice EXAMPLE_ETH_PHY_MODEL
+ prompt "Ethernet PHY Device"
+ default EXAMPLE_ETH_PHY_IP101
+ help
+ Select the Ethernet PHY device to use in the example.
+
+ config EXAMPLE_ETH_PHY_IP101
+ bool "IP101"
+ help
+ IP101 is a single port 10/100 MII/RMII/TP/Fiber Fast Ethernet Transceiver.
+ Goto http://www.icplus.com.tw/pp-IP101G.html for more information about it.
+
+ config EXAMPLE_ETH_PHY_RTL8201
+ bool "RTL8201/SR8201"
+ help
+ RTL8201F/SR8201F is a single port 10/100Mb Ethernet Transceiver with auto MDIX.
+ Goto http://www.corechip-sz.com/productsview.asp?id=22 for more information about it.
+
+ config EXAMPLE_ETH_PHY_LAN8720
+ bool "LAN8720"
+ help
+ LAN8720A is a small footprint RMII 10/100 Ethernet Transceiver with HP Auto-MDIX Support.
+ Goto https://www.microchip.com/LAN8720A for more information about it.
+
+ config EXAMPLE_ETH_PHY_DP83848
+ bool "DP83848"
+ help
+ DP83848 is a single port 10/100Mb/s Ethernet Physical Layer Transceiver.
+ Goto http://www.ti.com/product/DP83848J for more information about it.
+
+ config EXAMPLE_ETH_PHY_KSZ8041
+ bool "KSZ8041"
+ help
+ The KSZ8041 is a single supply 10Base-T/100Base-TX Physical Layer Transceiver.
+ Goto https://www.microchip.com/wwwproducts/en/KSZ8041 for more information about it.
+
+ config EXAMPLE_ETH_PHY_KSZ8081
+ bool "KSZ8081"
+ help
+ The KSZ8081 is a single supply 10Base-T/100Base-TX Physical Layer Transceiver.
+ Goto https://www.microchip.com/wwwproducts/en/KSZ8081 for more information about it.
+ endchoice # EXAMPLE_ETH_PHY_MODEL
+
+ config EXAMPLE_ETH_MDC_GPIO
+ int "SMI MDC GPIO number"
+ default 23
+ help
+ Set the GPIO number used by SMI MDC.
+
+ config EXAMPLE_ETH_MDIO_GPIO
+ int "SMI MDIO GPIO number"
+ default 18
+ help
+ Set the GPIO number used by SMI MDIO.
+ endif # EXAMPLE_USE_INTERNAL_ETHERNET
+
+ if EXAMPLE_USE_SPI_ETHERNET
+ config EXAMPLE_ETH_SPI_HOST
+ int "SPI Host Number"
+ range 0 2
+ default 1
+ help
+ Set the SPI host used to communicate with the SPI Ethernet Controller.
+
+ config EXAMPLE_ETH_SPI_SCLK_GPIO
+ int "SPI SCLK GPIO number"
+ range 0 34 if IDF_TARGET_ESP32
+ range 0 46 if IDF_TARGET_ESP32S2
+ range 0 19 if IDF_TARGET_ESP32C3
+ default 18 if IDF_TARGET_ESP32
+ default 20 if IDF_TARGET_ESP32S2
+ default 6 if IDF_TARGET_ESP32C3
+ help
+ Set the GPIO number used by SPI SCLK.
+
+ config EXAMPLE_ETH_SPI_MOSI_GPIO
+ int "SPI MOSI GPIO number"
+ range 0 34 if IDF_TARGET_ESP32
+ range 0 46 if IDF_TARGET_ESP32S2
+ range 0 19 if IDF_TARGET_ESP32C3
+ default 23 if IDF_TARGET_ESP32
+ default 19 if IDF_TARGET_ESP32S2
+ default 7 if IDF_TARGET_ESP32C3
+ help
+ Set the GPIO number used by SPI MOSI.
+
+ config EXAMPLE_ETH_SPI_MISO_GPIO
+ int "SPI MISO GPIO number"
+ range 0 34 if IDF_TARGET_ESP32
+ range 0 46 if IDF_TARGET_ESP32S2
+ range 0 19 if IDF_TARGET_ESP32C3
+ default 19 if IDF_TARGET_ESP32
+ default 18 if IDF_TARGET_ESP32S2
+ default 2 if IDF_TARGET_ESP32C3
+ help
+ Set the GPIO number used by SPI MISO.
+
+ config EXAMPLE_ETH_SPI_CS_GPIO
+ int "SPI CS GPIO number"
+ range 0 34 if IDF_TARGET_ESP32
+ range 0 46 if IDF_TARGET_ESP32S2
+ range 0 19 if IDF_TARGET_ESP32C3
+ default 16 if IDF_TARGET_ESP32
+ default 21 if IDF_TARGET_ESP32S2
+ default 10 if IDF_TARGET_ESP32C3
+ help
+ Set the GPIO number used by SPI CS.
+
+ config EXAMPLE_ETH_SPI_CLOCK_MHZ
+ int "SPI clock speed (MHz)"
+ range 5 80
+ default 12 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32C3
+ default 36 if IDF_TARGET_ESP32S2
+ help
+ Set the clock speed (MHz) of SPI interface.
+
+ config EXAMPLE_ETH_SPI_INT_GPIO
+ int "Interrupt GPIO number"
+ default 17 if IDF_TARGET_ESP32
+ default 4 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32C3
+ help
+ Set the GPIO number used by the SPI Ethernet module interrupt line.
+ endif # EXAMPLE_USE_SPI_ETHERNET
+
+ config EXAMPLE_ETH_PHY_RST_GPIO
+ int "PHY Reset GPIO number"
+ default 5
+ help
+ Set the GPIO number used to reset PHY chip.
+ Set to -1 to disable PHY chip hardware reset.
+
+ config EXAMPLE_ETH_PHY_ADDR
+ int "PHY Address"
+ range 0 31
+ default 1
+ help
+ Set PHY address according your board schematic.
+endmenu
diff --git a/software/main/MU80X.cpp b/software/main/MU80X.cpp
new file mode 100644
index 0000000..c50ac07
--- /dev/null
+++ b/software/main/MU80X.cpp
@@ -0,0 +1,429 @@
+/*
+ * clou.cpp
+ *
+ * Created on: 15.07.2021
+ * Author: steffen
+ */
+#include "MU80X.h"
+
+//#define DEBUG
+#ifdef ESP32
+MU80X::MU80X(int fh) {
+ ProtStatus = 0;
+ ConnectionStatus=0;
+ TagsInBuffer=0;
+ TagsSeen=0;
+ _devid = 0xFF;
+
+ _devh = fh;
+
+ int res = iGetReaderInformation(_devid);
+ if (res >= 0) {
+// printf("RDR Info:%d\n",res);
+// DumpBuffer(RecvBuf,res);
+// fflush (stdout);
+ _devid = RecvBuf[1];
+ }
+}
+#else
+MU80X::MU80X(const char *dev, const uint16_t baud) {
+ struct termios t1, t2;
+
+ ProtStatus = 0;
+ _devid = 0xFF;
+
+ int bd = B115200;
+ if (baud == 57600)
+ bd = B57600;
+
+ _devh = open(dev, O_RDWR | O_NONBLOCK);
+ if (_devh < 0) {
+ fprintf(stderr, "Unable to open serial device %s", dev);
+ } else {
+
+ tcgetattr(_devh, &t1);
+ tcgetattr(_devh, &t2);
+ cfmakeraw(&t1);
+
+ t1.c_cflag = (CLOCAL | CS8 | CREAD);
+ cfsetspeed(&t1, bd);
+ t1.c_cc[VMIN] = 0;
+ t1.c_cc[VTIME] = 0;
+ tcsetattr(_devh, TCSADRAIN, &t1);
+
+ int res = iGetReaderInformation(_devid);
+ if (res >= 0) {
+ fflush (stdout);
+ _devid = RecvBuf[1];
+ }
+ }
+
+}
+#endif
+
+MU80X::~MU80X(void) {
+#ifdef ESP32
+
+#else
+ if (_devh > 0)
+ close(_devh);
+#endif
+}
+// internal
+void MU80X::DumpBuffer(unsigned char *buf, int len) {
+ int i, c;
+ char *lb = (char*) buf;
+ for (i = 0; i < len; i++) {
+ if (i % 32 == 0)
+ printf("\n");
+ c = (char) *lb++;
+ printf("%02X ", (unsigned char) c);
+ if (c > 32)
+ printf(" %c ", c);
+ else
+ printf(" ");
+
+ }
+ printf("\n");
+}
+
+void MU80X::PrintTag(Tag_t tag) {
+ int i;
+ for (i = 0; i < 12; i++) {
+ printf("%02X ", tag.b[i]);
+ }
+ printf("Ant:%d RSSI:%d Count:%d ", tag.ant, tag.rssi, tag.count);
+ printf("\n");
+}
+
+int MU80X::_DecodeBuffer(int todecode, int start, unsigned char *buf,
+ Tag_t *tagbuf) {
+ int i;
+ uint8_t len, ant, rssi, count;
+ for (i = start; i < start + todecode; i++) {
+// DumpBuffer(buf,s);
+ ant = *buf;
+ buf++;
+ len = *buf;
+ buf++;
+ tagbuf[i].ant = ant;
+#ifdef DEBUG
+ printf("Ant: %d Len: %d",ant,len);
+#endif
+ if (len == 8) {
+ tagbuf[i].b[0] = 0;
+ tagbuf[i].b[1] = 0;
+ tagbuf[i].b[2] = 0;
+ tagbuf[i].b[3] = 0;
+ memcpy(&tagbuf[i].b[4], buf, len);
+ } else if (len == 12) {
+ memcpy(&tagbuf[i].b[0], buf, len);
+ } else {
+ fprintf(stderr, "Unknown Taglength:%d :\n", len);
+ }
+ buf += len;
+ rssi = *buf;
+ buf++;
+ count = *buf;
+ buf++;
+ tagbuf[i].rssi = rssi;
+ tagbuf[i].count = count;
+#ifdef DEBUG
+ printf("Ant: %d Len: %d\n",ant,len);
+// PrintTag(tagbuf[i]);
+#endif
+
+ }
+ return i - start;
+}
+
+#define PRESET_VALUE 0xFFFF
+#define POLYNOMIAL 0x8408
+uint16_t MU80X::_ui16CalculateCrc(unsigned char *data, unsigned char len) {
+
+ unsigned char ucI, ucJ;
+ uint16_t uiCrcValue = PRESET_VALUE;
+ for (ucI = 0; ucI < len; ucI++) {
+ uiCrcValue = uiCrcValue ^ *(data + ucI);
+ for (ucJ = 0; ucJ < 8; ucJ++) {
+ if (uiCrcValue & 0x0001) {
+ uiCrcValue = (uiCrcValue >> 1) ^ POLYNOMIAL;
+ } else {
+ uiCrcValue = (uiCrcValue >> 1);
+ }
+ }
+ }
+ return uiCrcValue;
+}
+
+int MU80X::serial_read(int fh, unsigned char *buf) {
+#ifdef ESP32
+ return (uart_read_bytes(fh, buf, 1, 1));
+#else
+ return (read(fh,buf,1));
+#endif
+}
+
+int MU80X::serial_write(int fh, unsigned char *buf, int len) {
+#ifdef ESP32
+ return (uart_write_bytes(fh, buf, len));
+#else
+ return(write(fh,buf,len));
+#endif
+}
+
+// low level read and write
+int MU80X::iReadProt(int ms) {
+ int cnt = ms;
+ int cc = 0;
+ uint8_t len = 0;
+ int i;
+ while (cnt > 0) {
+ if ((cc == 0) & (serial_read(_devh, &RecvBuf[0]) == 1)) {
+ len = (uint8_t) RecvBuf[0];
+#ifdef DEBUG
+ printf("\nNeed to receive:%d\n", len+1);
+#endif
+ fflush (stdout);
+ cc = 1;
+ cnt = ms;
+ i = 1;
+ while (i <= len) {
+ if (serial_read(_devh, &RecvBuf[i]) == 1) {
+ i++;
+ cnt = ms;
+ } else {
+// printf(" X ");fflush(stdout);
+ cnt--;
+ if (cnt == 0)
+ return ERR_NOANSWER;
+#ifdef ESP32
+ vTaskDelay(1);
+#else
+ usleep(1000);
+#endif
+ }
+ }
+#ifdef DEBUG
+ printf("Received:%d\n", len+1);
+ fflush(stdout);
+#endif
+ return len + 1;
+ }
+
+ cnt--;
+#ifdef ESP32
+ vTaskDelay(1);
+#else
+ usleep(1000);
+#endif
+ }
+ return -1;
+}
+
+int MU80X::iSendProt(uint8_t len, uint8_t adr, uint8_t cmd,
+ unsigned char *data) {
+ int res = 0;
+ uint16_t CRC = 0;
+ SendBuf[0] = len + 4;
+ SendBuf[1] = adr;
+ SendBuf[2] = cmd;
+ memcpy(&SendBuf[3], data, len);
+ CRC = _ui16CalculateCrc(SendBuf, len + 3);
+ SendBuf[3 + len] = CRC & 0xFF;
+ SendBuf[4 + len] = CRC >> 8;
+#ifdef DEBUG
+ printf("Send:");
+ DumpBuffer(SendBuf, len + 5);
+#endif
+ res = serial_write(_devh, (unsigned char *)SendBuf, (int)len + 5);
+#ifdef DEBUG
+ printf("Written:%d\n", res);
+#endif
+ if (res == len + 5) {
+ res = iReadProt(1000);
+ if (res > 0) {
+ uint8_t LEN = RecvBuf[0];
+ uint16_t RCRC = RecvBuf[LEN - 1] + (RecvBuf[LEN] << 8);
+ uint16_t CCRC = _ui16CalculateCrc(RecvBuf, LEN - 1);
+#ifdef DEBUG
+ printf("CRC: %04X %04X\n", RCRC, CCRC);
+#endif
+ if (RCRC == CCRC) {
+ ProtStatus = RecvBuf[2];
+ return res;
+ } else
+ return ERR_CRC;
+ } else
+ return ERR_NOANSWER;
+
+ } else
+ return ERR_WRITE;
+ return res;
+}
+
+int MU80X::iSendProt(uint8_t len, uint8_t adr, uint8_t cmd, unsigned char *data,
+ int wait) {
+ int res = 0;
+ uint16_t CRC = 0;
+ SendBuf[0] = len + 4;
+ SendBuf[1] = adr;
+ SendBuf[2] = cmd;
+ memcpy(&SendBuf[3], data, len);
+ CRC = _ui16CalculateCrc(SendBuf, len + 3);
+ SendBuf[3 + len] = CRC & 0xFF;
+ SendBuf[4 + len] = CRC >> 8;
+#ifdef DEBUG
+ printf("Send:");
+ DumpBuffer(SendBuf, len + 5);
+#endif
+ res = serial_write(_devh, (unsigned char*)SendBuf, (int)len + 5);
+#ifdef DEBUG
+ printf("SendProt wrtn:%d ", res);
+#endif
+ if (res == len + 5) {
+ res = iReadProt(wait);
+#ifdef DEBUG
+ printf(" rcvd:%d\n",res);fflush(stderr);
+#endif
+ if (res > 0) {
+ uint8_t LEN = RecvBuf[0];
+ uint16_t RCRC = RecvBuf[LEN - 1] + (RecvBuf[LEN] << 8);
+ uint16_t CCRC = _ui16CalculateCrc(RecvBuf, LEN - 1);
+ if (RCRC == CCRC) {
+ ProtStatus = RecvBuf[2];
+ return res;
+ } else
+ return ERR_CRC;
+ } else
+ return ERR_NOANSWER;
+
+ } else
+ return ERR_WRITE;
+ return res;
+}
+
+// protocol implementation
+int MU80X::iBufferInventory(uint8_t Q, uint8_t antenna, uint8_t time) {
+ int res = 0;
+ unsigned char param[16];
+ param[0] = Q; // QV
+ param[1] = 0xFF; // SS = TID:01 EPC:FF
+ param[2] = 0x00; // TG no clue
+ param[3] = 0x80 + antenna;
+ param[4] = time;
+ res = iSendProt(5, _devid, 0x18, param, 20000);
+ if (res > 0) {
+#ifdef DEBUG
+ printf("INV:%d Stat:%d\n",res,ProtStatus);fflush(stdout);
+#endif
+// DumpBuffer(RecvBuf, res);
+ printf("-------------------------\n");
+ fflush (stdout);
+ if (RecvBuf[0] == 9) {
+ TagsInBuffer = RecvBuf[5] + (RecvBuf[4] << 8);
+ TagsSeen = RecvBuf[7] + (RecvBuf[6] << 8);
+ }
+ }
+ return res;
+
+}
+
+int MU80X::iClearBuffer() {
+ int res;
+ res = iSendProt(0, _devid, 0x73, NULL);
+ return res;
+}
+
+int MU80X::iGetBuffer(Tag_t *tagbuf) {
+ int res = 0;
+ int havedata = 1;
+ int tagcount = 0;
+ int todecode = 0;
+ int decoded = 0;
+ int readmore = 0;
+ res = iSendProt(0, _devid, 0x72, NULL);
+ if (res < 0)
+ return res;
+ while (havedata) {
+ todecode = RecvBuf[4];
+ readmore = (RecvBuf[3] == 3); // == 3 !
+ decoded = _DecodeBuffer(todecode, tagcount, &RecvBuf[5], tagbuf);
+#ifdef DEBUG
+ DumpBuffer(RecvBuf,res);
+ printf("To decode:%d decoded:%d \n", todecode, decoded);
+ fflush(stdout);
+#endif
+ if (decoded == todecode) {
+ tagcount += decoded;
+ if (readmore) {
+ res = iReadProt(100);
+ if (res < 0)
+ return tagcount;
+ todecode = RecvBuf[4];
+ readmore = (RecvBuf[3] == 3); // == 3 !
+ } else
+ havedata = 0;
+ } else {
+ // sometingwong
+ return ERR_DECODE;
+ }
+ }
+ return tagcount;
+}
+
+int MU80X::iGetReaderInformation(uint8_t addr) {
+ int res;
+ res = iSendProt(0, addr, 0x21, NULL);
+ return res;
+}
+
+int MU80X::iGetReaderInformation() {
+ int res;
+ res = iSendProt(0, _devid, 0x21, NULL);
+ return res;
+}
+
+int MU80X::iGetReaderSerial() {
+ int res;
+ res = iSendProt(0, _devid, 0x4C, NULL);
+ return res;
+}
+
+int MU80X::iSetBaud(uint8_t bd) { // 0=9600,1=19200,2=38400,5=57600,115200
+ int res;
+ unsigned char param[2];
+ param[0] = bd;
+ param[1] = 0;
+ res = iSendProt(1, _devid, 0x28, param);
+ return res;
+}
+
+int MU80X::iSetPower(uint8_t dBm) {
+ int res;
+ unsigned char param[2];
+ param[0] = dBm;
+ param[1] = 0;
+ res = iSendProt(1, _devid, 0x2F, param);
+ return res;
+}
+
+int MU80X::iSetRFRegion() {
+ int res;
+ unsigned char param[2];
+ param[0] = 0x4E; // 0x01 001110 maximum band = 1 + 865,1 + (14x200KHz=2,8 MHz) = 867,9
+ param[1] = 0x00; // 0x00 000000 minimum band = 0 = 865,1 MHz + (0 x 200KHz)
+ param[2] = 0;
+ res = iSendProt(2, _devid, 0x22, param);
+ return res;
+}
+
+int MU80X::iSetScantime(uint8_t time) { // x * 100ms
+ int res;
+ unsigned char param[2];
+ param[0] = time;
+ param[1] = 0;
+ res = iSendProt(1, _devid, 0x25, param);
+ return res;
+}
+
diff --git a/software/main/MU80X.h b/software/main/MU80X.h
new file mode 100644
index 0000000..40b3751
--- /dev/null
+++ b/software/main/MU80X.h
@@ -0,0 +1,101 @@
+#ifndef MU80X_H_
+#define MU80X_H_
+#include "main.h"
+
+#define ESP32
+
+#ifdef ESP32
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "esp_event.h"
+#include "esp_log.h"
+#include "driver/uart.h"
+#else
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <termios.h>
+#endif
+
+#define HashSize 16
+#define CRC_POLY_16 0x8005
+#define ProtBufLen 260
+
+#define ERR_NOERR 0
+#define ERR_CRC -1
+#define ERR_WRITE -2
+#define ERR_NOANSWER -3
+#define ERR_DECODE -4
+
+#define BAUD_9600 0
+#define BAUD_19200 1
+#define BAUD_38400 2
+#define BAUD_57600 5
+#define BAUD_115200 6
+
+class MU80X {
+public:
+#ifdef ESP32
+ MU80X(const int fh);
+#else
+ MU80X(const char *dev = "/dev/ttyUSB0", const uint16_t baud = 57600);
+#endif
+ ~MU80X(void);
+
+ int ConnectionStatus;
+ int iBufferInventory(uint8_t Q, uint8_t antenna, uint8_t time);
+ int iClearBuffer(void); // done
+ void DumpBuffer(unsigned char *buf, int len);
+ int iGetBuffer(Tag_t *tagarr);
+ int iGetReaderInformation();
+ int iGetReaderInformation(uint8_t addr);
+ int iGetReaderSerial(); // done
+ // int iGetGPI(void);
+// int iGetRFIDSettings();
+// int iReset(void);
+ int iReadProt(int ms);
+ int iSendProt(uint8_t len, uint8_t adr, uint8_t cmd, unsigned char *data); // done
+ int iSendProt(uint8_t len, uint8_t adr, uint8_t cmd, unsigned char *data, int wait); // done
+// int iSetAntennas(int antennas); // done each antenna is represented by its bit
+ int iSetBaud(uint8_t Bd); // BAUD_XXXXX definitions
+// int iSetGPO(uint8_t GPO); // later
+ int iSetPower(uint8_t dBm);
+ int iSetRFRegion(); // fixed to ETSI
+ int iSetScantime(uint8_t time);
+ void PrintTag(Tag_t tag);
+ // int iSetRFIDSettings(int Q);
+// int iStop();
+
+ unsigned char SendBuf[ProtBufLen];
+ unsigned char RecvBuf[ProtBufLen];
+ int ProtStatus;
+ int TagsInBuffer;
+ int TagsSeen;
+
+private:
+ // void vCreateTable();
+
+// uint16_t crc_tab16_init = 0xFFFF;
+// uint16_t crc_tab16[256];
+ int serial_read(int fh,unsigned char *buf);
+ int serial_write(int fh, unsigned char * buf,int len);
+ uint16_t _ui16CalculateCrc(unsigned char *data, unsigned char len);
+ int _DecodeBuffer(int tagcount, int start, unsigned char *buf, Tag_t *tagbuf);
+
+ int _devh;
+ uint8_t _devid;
+// unsigned int _baud;
+};
+
+#endif /* MU80X_H_ */
diff --git a/software/main/PCF8575.cpp b/software/main/PCF8575.cpp
new file mode 100644
index 0000000..3308c3b
--- /dev/null
+++ b/software/main/PCF8575.cpp
@@ -0,0 +1,474 @@
+/*
+ * PCF8575 GPIO Port Expand
+ * https://www.mischianti.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Renzo Mischianti www.mischianti.org All right reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "PCF8575.h"
+#include "Wire.h"
+
+/**
+ * Constructor
+ * @param address: i2c address
+ */
+PCF8575::PCF8575(uint8_t address){
+ _wire = &Wire;
+
+ _address = address;
+};
+
+/**
+ * Construcor
+ * @param address: i2c address
+ * @param interruptPin: pin to set interrupt
+ * @param interruptFunction: function to call when interrupt raised
+ */
+PCF8575::PCF8575(uint8_t address, uint8_t interruptPin, void (*interruptFunction)() ){
+ _wire = &Wire;
+
+ _address = address;
+ _interruptPin = interruptPin;
+ _interruptFunction = interruptFunction;
+ _usingInterrupt = true;
+};
+
+#if !defined(__AVR) && !defined(__STM32F1__)
+ /**
+ * Constructor
+ * @param address: i2c address
+ * @param sda: sda pin
+ * @param scl: scl pin
+ */
+ PCF8575::PCF8575(uint8_t address, uint8_t sda, uint8_t scl){
+ _wire = &Wire;
+
+ _address = address;
+ _sda = sda;
+ _scl = scl;
+ };
+
+ /**
+ * Constructor
+ * @param address: i2c address
+ * @param sda: sda pin
+ * @param scl: scl pin
+ * @param interruptPin: pin to set interrupt
+ * @param interruptFunction: function to call when interrupt raised
+ */
+ PCF8575::PCF8575(uint8_t address, uint8_t sda, uint8_t scl, uint8_t interruptPin, void (*interruptFunction)() ){
+ _wire = &Wire;
+
+ _address = address;
+ _sda = sda;
+ _scl = scl;
+
+ _interruptPin = interruptPin;
+ _interruptFunction = interruptFunction;
+
+ _usingInterrupt = true;
+ };
+#endif
+
+#ifdef ESP32
+ /**
+ * Constructor
+ * @param address: i2c address
+ */
+ PCF8575::PCF8575(TwoWire *pWire, uint8_t address){
+ _wire = pWire;
+
+ _address = address;
+ };
+
+ /**
+ * Construcor
+ * @param address: i2c address
+ * @param interruptPin: pin to set interrupt
+ * @param interruptFunction: function to call when interrupt raised
+ */
+ PCF8575::PCF8575(TwoWire *pWire, uint8_t address, uint8_t interruptPin, void (*interruptFunction)() ){
+ _wire = pWire;
+
+ _address = address;
+ _interruptPin = interruptPin;
+ _interruptFunction = interruptFunction;
+ _usingInterrupt = true;
+ };
+
+ /**
+ * Constructor
+ * @param address: i2c address
+ * @param sda: sda pin
+ * @param scl: scl pin
+ */
+ PCF8575::PCF8575(TwoWire *pWire, uint8_t address, uint8_t sda, uint8_t scl){
+ _wire = pWire;
+
+ _address = address;
+ _sda = sda;
+ _scl = scl;
+ };
+
+ /**
+ * Constructor
+ * @param address: i2c address
+ * @param sda: sda pin
+ * @param scl: scl pin
+ * @param interruptPin: pin to set interrupt
+ * @param interruptFunction: function to call when interrupt raised
+ */
+ PCF8575::PCF8575(TwoWire *pWire, uint8_t address, uint8_t sda, uint8_t scl, uint8_t interruptPin, void (*interruptFunction)() ){
+ _wire = pWire;
+
+ _address = address;
+ _sda = sda;
+ _scl = scl;
+
+ _interruptPin = interruptPin;
+ _interruptFunction = interruptFunction;
+
+ _usingInterrupt = true;
+ };
+#endif
+
+/**
+ * wake up i2c controller
+ */
+void PCF8575::begin(){
+ #if !defined(__AVR) && !defined(__STM32F1__)
+ _wire->begin(_sda, _scl);
+ #else
+ // Default pin for AVR some problem on software emulation
+ // #define SCL_PIN _scl
+ // #define SDA_PIN _sda
+ _wire->begin();
+ #endif
+
+// Serial.println( writeMode, BIN);
+// Serial.println( readMode, BIN);
+
+ // Check if there are pins to set low
+ if (writeMode>0 || readMode>0){
+ DEBUG_PRINTLN("Set write mode");
+ _wire->beginTransmission(_address);
+ DEBUG_PRINT(" ");
+ DEBUG_PRINT("usedPin pin ");
+
+
+ uint16_t usedPin = writeMode | readMode;
+ DEBUG_PRINTLN( ~usedPin, BIN);
+// Serial.println( ~usedPin, BIN);
+
+ _wire->write((uint8_t) ~usedPin);
+ _wire->write((uint8_t) (~(usedPin >> 8)));
+
+ DEBUG_PRINTLN("Start end trasmission if stop here check pullup resistor.");
+ _wire->endTransmission();
+ }
+
+ // If using interrupt set interrupt value to pin
+ if (_usingInterrupt){
+ DEBUG_PRINTLN("Using interrupt pin (not all pin is interrupted)");
+ ::pinMode(_interruptPin, INPUT_PULLUP);
+ attachInterrupt(digitalPinToInterrupt(_interruptPin), (*_interruptFunction), FALLING );
+ }
+
+ // inizialize last read
+ lastReadMillis = millis();
+}
+
+/**
+ * Set if fin is OUTPUT or INPUT
+ * @param pin: pin to set
+ * @param mode: mode, supported only INPUT or OUTPUT (to semplify)
+ */
+void PCF8575::pinMode(uint8_t pin, uint8_t mode){
+ DEBUG_PRINT("Set pin ");
+ DEBUG_PRINT(pin);
+ DEBUG_PRINT(" as ");
+ DEBUG_PRINTLN(mode);
+
+ if (mode == OUTPUT){
+ writeMode = writeMode | bit(pin);
+ readMode = readMode & ~bit(pin);
+// DEBUG_PRINT("writeMode: ");
+// DEBUG_PRINT(writeMode, BIN);
+// DEBUG_PRINT("readMode: ");
+// DEBUG_PRINTLN(readMode, BIN);
+
+ }else if (mode == INPUT){
+ writeMode = writeMode & ~bit(pin);
+ readMode = readMode | bit(pin);
+// DEBUG_PRINT("writeMode: ");
+// DEBUG_PRINT(writeMode, BIN);
+// DEBUG_PRINT("readMode: ");
+// DEBUG_PRINTLN(readMode, BIN);
+ }
+ else{
+ DEBUG_PRINTLN("Mode non supported by PCF8575")
+ }
+ DEBUG_PRINT("Write mode: ");
+ DEBUG_PRINTLN(writeMode, BIN);
+
+};
+
+/**
+ * Read value from i2c and bufferize it
+ * @param force
+ */
+void PCF8575::readBuffer(bool force){
+ if (millis() > PCF8575::lastReadMillis+READ_ELAPSED_TIME || _usingInterrupt || force){
+ _wire->requestFrom(_address,(uint8_t)2);// Begin transmission to PCF8575 with the buttons
+ lastReadMillis = millis();
+ if(_wire->available()) // If uint16_ts are available to be recieved
+ {
+ uint16_t iInput = _wire->read();// Read a uint16_t
+ iInput |= _wire->read() << 8;// Read a uint16_t
+ if ((iInput & readMode)>0){
+ byteBuffered = byteBuffered | (uint16_t)iInput;
+ }
+ }
+ }
+}
+
+#ifndef PCF8575_LOW_MEMORY
+ /**
+ * Read value of all INPUT pin
+ * Debounce read more fast than 10millis, non managed for interrupt mode
+ * @return
+ */
+ PCF8575::DigitalInput PCF8575::digitalReadAll(void){
+ DEBUG_PRINTLN("Read from buffer");
+ _wire->requestFrom(_address,(uint8_t)2);// Begin transmission to PCF8575 with the buttons
+ lastReadMillis = millis();
+ if(_wire->available()) // If uint16_ts are available to be recieved
+ {
+ DEBUG_PRINTLN("Data ready");
+ uint16_t iInput = _wire->read();// Read a uint16_t
+ iInput |= _wire->read() << 8;// Read a uint16_t
+
+ if ((iInput & readMode)>0){
+ DEBUG_PRINT("Input ");
+ DEBUG_PRINTLN((uint16_t)iInput, BIN);
+
+ byteBuffered = byteBuffered | (uint16_t)iInput;
+ DEBUG_PRINT("byteBuffered ");
+ DEBUG_PRINTLN(byteBuffered, BIN);
+ }
+ }
+
+ DEBUG_PRINT("Buffer value ");
+ DEBUG_PRINTLN(byteBuffered, BIN);
+#ifdef NOT_SEQUENTIAL_PINOUT
+ if ((bit(0) & readMode)>0) digitalInput.p00 = ((byteBuffered & bit(0))>0)?HIGH:LOW;
+ if ((bit(1) & readMode)>0) digitalInput.p01 = ((byteBuffered & bit(1))>0)?HIGH:LOW;
+ if ((bit(2) & readMode)>0) digitalInput.p02 = ((byteBuffered & bit(2))>0)?HIGH:LOW;
+ if ((bit(3) & readMode)>0) digitalInput.p03 = ((byteBuffered & bit(3))>0)?HIGH:LOW;
+ if ((bit(4) & readMode)>0) digitalInput.p04 = ((byteBuffered & bit(4))>0)?HIGH:LOW;
+ if ((bit(5) & readMode)>0) digitalInput.p05 = ((byteBuffered & bit(5))>0)?HIGH:LOW;
+ if ((bit(6) & readMode)>0) digitalInput.p06 = ((byteBuffered & bit(6))>0)?HIGH:LOW;
+ if ((bit(7) & readMode)>0) digitalInput.p07 = ((byteBuffered & bit(7))>0)?HIGH:LOW;
+ if ((bit(8) & readMode)>0) digitalInput.p10 = ((byteBuffered & bit(8))>0)?HIGH:LOW;
+ if ((bit(9) & readMode)>0) digitalInput.p11 = ((byteBuffered & bit(9))>0)?HIGH:LOW;
+ if ((bit(10) & readMode)>0) digitalInput.p12 = ((byteBuffered & bit(10))>0)?HIGH:LOW;
+ if ((bit(11) & readMode)>0) digitalInput.p13 = ((byteBuffered & bit(11))>0)?HIGH:LOW;
+ if ((bit(12) & readMode)>0) digitalInput.p14 = ((byteBuffered & bit(12))>0)?HIGH:LOW;
+ if ((bit(13) & readMode)>0) digitalInput.p15 = ((byteBuffered & bit(13))>0)?HIGH:LOW;
+ if ((bit(14) & readMode)>0) digitalInput.p16 = ((byteBuffered & bit(14))>0)?HIGH:LOW;
+ if ((bit(15) & readMode)>0) digitalInput.p17 = ((byteBuffered & bit(15))>0)?HIGH:LOW;
+#else
+ if ((bit(0) & readMode)>0) digitalInput.p0 = ((byteBuffered & bit(0))>0)?HIGH:LOW;
+ if ((bit(1) & readMode)>0) digitalInput.p1 = ((byteBuffered & bit(1))>0)?HIGH:LOW;
+ if ((bit(2) & readMode)>0) digitalInput.p2 = ((byteBuffered & bit(2))>0)?HIGH:LOW;
+ if ((bit(3) & readMode)>0) digitalInput.p3 = ((byteBuffered & bit(3))>0)?HIGH:LOW;
+ if ((bit(4) & readMode)>0) digitalInput.p4 = ((byteBuffered & bit(4))>0)?HIGH:LOW;
+ if ((bit(5) & readMode)>0) digitalInput.p5 = ((byteBuffered & bit(5))>0)?HIGH:LOW;
+ if ((bit(6) & readMode)>0) digitalInput.p6 = ((byteBuffered & bit(6))>0)?HIGH:LOW;
+ if ((bit(7) & readMode)>0) digitalInput.p7 = ((byteBuffered & bit(7))>0)?HIGH:LOW;
+ if ((bit(8) & readMode)>0) digitalInput.p8 = ((byteBuffered & bit(8))>0)?HIGH:LOW;
+ if ((bit(9) & readMode)>0) digitalInput.p9 = ((byteBuffered & bit(9))>0)?HIGH:LOW;
+ if ((bit(10) & readMode)>0) digitalInput.p10 = ((byteBuffered & bit(10))>0)?HIGH:LOW;
+ if ((bit(11) & readMode)>0) digitalInput.p11 = ((byteBuffered & bit(11))>0)?HIGH:LOW;
+ if ((bit(12) & readMode)>0) digitalInput.p12 = ((byteBuffered & bit(12))>0)?HIGH:LOW;
+ if ((bit(13) & readMode)>0) digitalInput.p13 = ((byteBuffered & bit(13))>0)?HIGH:LOW;
+ if ((bit(14) & readMode)>0) digitalInput.p14 = ((byteBuffered & bit(14))>0)?HIGH:LOW;
+ if ((bit(15) & readMode)>0) digitalInput.p15 = ((byteBuffered & bit(15))>0)?HIGH:LOW;
+#endif
+ if ((readMode & byteBuffered)>0){
+ byteBuffered = ~readMode & byteBuffered;
+ DEBUG_PRINT("Buffer hight value readed set readed ");
+ DEBUG_PRINTLN(byteBuffered, BIN);
+ }
+ DEBUG_PRINT("Return value ");
+ return digitalInput;
+ };
+#else
+ /**
+ * Read value of all INPUT pin in byte format for low memory usage
+ * Debounce read more fast than 10millis, non managed for interrupt mode
+ * @return
+ */
+ uint16_t PCF8575::digitalReadAll(void){
+ DEBUG_PRINTLN("Read from buffer");
+ _wire->requestFrom(_address,(uint8_t)2);// Begin transmission to PCF8575 with the buttons
+ lastReadMillis = millis();
+ if(_wire->available()) // If uint16_ts are available to be recieved
+ {
+ DEBUG_PRINTLN("Data ready");
+ uint16_t iInput = _wire->read();// Read a uint16_t
+ iInput |= _wire->read() << 8;// Read a uint16_t
+
+ if ((iInput & readMode)>0){
+ DEBUG_PRINT("Input ");
+ DEBUG_PRINTLN((uint16_t)iInput, BIN);
+
+ byteBuffered = byteBuffered | (uint16_t)iInput;
+ DEBUG_PRINT("byteBuffered ");
+ DEBUG_PRINTLN(byteBuffered, BIN);
+ }
+ }
+
+ DEBUG_PRINT("Buffer value ");
+ DEBUG_PRINTLN(byteBuffered, BIN);
+
+ uint16_t byteRead = byteBuffered;
+
+ if ((readMode & byteBuffered)>0){
+ byteBuffered = ~readMode & byteBuffered;
+ DEBUG_PRINT("Buffer hight value readed set readed ");
+ DEBUG_PRINTLN(byteBuffered, BIN);
+ }
+ DEBUG_PRINT("Return value ");
+ return byteRead;
+ };
+#endif
+
+/**
+ * Read value of specified pin
+ * Debounce read more fast than 10millis, non managed for interrupt mode
+ * @param pin
+ * @return
+ */
+uint8_t PCF8575::digitalRead(uint8_t pin){
+ uint8_t value = LOW;
+ if ((bit(pin) & writeMode)>0){
+ DEBUG_PRINTLN("Pin in write mode, return value");
+ DEBUG_PRINT("Write data ");
+ DEBUG_PRINT(writeByteBuffered, BIN);
+ DEBUG_PRINT(" for pin ");
+ DEBUG_PRINT(pin);
+ DEBUG_PRINT(" bin value ");
+ DEBUG_PRINT(bit(pin), BIN);
+ DEBUG_PRINT(" value ");
+ DEBUG_PRINTLN(value);
+
+ if ((bit(pin) & writeByteBuffered)>0){
+ value = HIGH;
+ }else{
+ value = LOW;
+ }
+ return value;
+ }
+
+ DEBUG_PRINT("Read pin ");
+ DEBUG_PRINTLN(pin);
+ // Check if pin already HIGH than read and prevent reread of i2c
+ if ((bit(pin) & byteBuffered)>0){
+ DEBUG_PRINTLN("Pin already up");
+ value = HIGH;
+ }else if ((/*(bit(pin) & byteBuffered)<=0 && */millis() > PCF8575::lastReadMillis+READ_ELAPSED_TIME) /*|| _usingInterrupt*/){
+ DEBUG_PRINTLN("Read from buffer");
+ _wire->requestFrom(_address,(uint8_t)2);// Begin transmission to PCF8575 with the buttons
+ lastReadMillis = millis();
+ if(_wire->available()) // If bytes are available to be recieved
+ {
+ DEBUG_PRINTLN("Data ready");
+ uint16_t iInput = _wire->read();// Read a uint16_t
+ iInput |= _wire->read() << 8;// Read a uint16_t
+
+// Serial.println(iInput, BIN);
+
+ if ((iInput & readMode)>0){
+ DEBUG_PRINT("Input ");
+ DEBUG_PRINTLN((uint16_t)iInput, BIN);
+
+ byteBuffered = byteBuffered | (uint16_t)iInput;
+ DEBUG_PRINT("byteBuffered ");
+ DEBUG_PRINTLN(byteBuffered, BIN);
+
+ if ((bit(pin) & byteBuffered)>0){
+ value = HIGH;
+ }
+ }
+ }
+ }
+ DEBUG_PRINT("Buffer value ");
+ DEBUG_PRINTLN(byteBuffered, BIN);
+ // If HIGH set to low to read buffer only one time
+ if (value==HIGH){
+ byteBuffered = ~bit(pin) & byteBuffered;
+ DEBUG_PRINT("Buffer hight value readed set readed ");
+ DEBUG_PRINTLN(byteBuffered, BIN);
+ }
+ DEBUG_PRINT("Return value ");
+ DEBUG_PRINTLN(value);
+ return value;
+};
+
+/**
+ * Write on pin
+ * @param pin
+ * @param value
+ */
+void PCF8575::digitalWrite(uint8_t pin, uint8_t value){
+ DEBUG_PRINTLN("Begin trasmission");
+ _wire->beginTransmission(_address); //Begin the transmission to PCF8575
+ if (value==HIGH){
+ writeByteBuffered = writeByteBuffered | bit(pin);
+ }else{
+ writeByteBuffered = writeByteBuffered & ~bit(pin);
+ }
+// DEBUG_PRINT("Write data ");
+// DEBUG_PRINT(writeByteBuffered, BIN);
+// DEBUG_PRINT(" for pin ");
+// DEBUG_PRINT(pin);
+// DEBUG_PRINT(" bin value ");
+// DEBUG_PRINT(bit(pin), BIN);
+// DEBUG_PRINT(" value ");
+// DEBUG_PRINTLN(value);
+
+// Serial.print(" --> ");
+// Serial.println(writeByteBuffered);
+// Serial.println((uint8_t) writeByteBuffered);
+// Serial.println((uint8_t) (writeByteBuffered >> 8));
+
+ writeByteBuffered = writeByteBuffered & writeMode;
+ _wire->write((uint8_t) writeByteBuffered);
+ _wire->write((uint8_t) (writeByteBuffered >> 8));
+ DEBUG_PRINTLN("Start end trasmission if stop here check pullup resistor.");
+
+ _wire->endTransmission();
+};
+
+
diff --git a/software/main/PCF8575.h b/software/main/PCF8575.h
new file mode 100644
index 0000000..660b2c6
--- /dev/null
+++ b/software/main/PCF8575.h
@@ -0,0 +1,208 @@
+/*
+ * PCF8575 GPIO Port Expand
+ * https://www.mischianti.org/2019/07/22/pcf8575-i2c-16-bit-digital-i-o-expander/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Renzo Mischianti www.mischianti.org All right reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef PCF8575_h
+#define PCF8575_h
+
+#include "Wire.h"
+
+#if ARDUINO >= 100
+#include "Arduino.h"
+#else
+#include "WProgram.h"
+#endif
+
+// Uncomment to enable printing out nice debug messages.
+// #define PCF8575_DEBUG
+
+// Uncomment for low memory usage this prevent use of complex DigitalInput structure and free 7byte of memory
+// #define PCF8575_LOW_MEMORY
+
+// Define where debug output will be printed.
+#define DEBUG_PRINTER Serial
+
+// Define to manage original pinout of pcf8575
+// like datasheet but not sequential
+//#define NOT_SEQUENTIAL_PINOUT
+
+// Setup debug printing macros.
+#ifdef PCF8575_DEBUG
+ #define DEBUG_PRINT(...) { DEBUG_PRINTER.print(__VA_ARGS__); }
+ #define DEBUG_PRINTLN(...) { DEBUG_PRINTER.println(__VA_ARGS__); }
+#else
+ #define DEBUG_PRINT(...) {}
+ #define DEBUG_PRINTLN(...) {}
+#endif
+
+#define READ_ELAPSED_TIME 10
+
+//#define P0 B00000001
+//#define P1 B00000010
+//#define P2 B00000100
+//#define P3 B00001000
+//#define P4 B00010000
+//#define P5 B00100000
+//#define P6 B01000000
+//#define P7 B10000000
+//
+#ifdef NOT_SEQUENTIAL_PINOUT
+ #define P00 0
+ #define P01 1
+ #define P02 2
+ #define P03 3
+ #define P04 4
+ #define P05 5
+ #define P06 6
+ #define P07 7
+ #define P10 8
+ #define P11 9
+ #define P12 10
+ #define P13 11
+ #define P14 12
+ #define P15 13
+ #define P16 14
+ #define P17 15
+#else
+ #define P0 0
+ #define P1 1
+ #define P2 2
+ #define P3 3
+ #define P4 4
+ #define P5 5
+ #define P6 6
+ #define P7 7
+ #define P8 8
+ #define P9 9
+ #define P10 10
+ #define P11 11
+ #define P12 12
+ #define P13 13
+ #define P14 14
+ #define P15 15
+#endif
+
+#include <math.h>
+
+
+class PCF8575 {
+public:
+
+ PCF8575(uint8_t address);
+ PCF8575(uint8_t address, uint8_t interruptPin, void (*interruptFunction)() );
+
+#if !defined(__AVR) && !defined(__STM32F1__)
+ PCF8575(uint8_t address, uint8_t sda, uint8_t scl);
+ PCF8575(uint8_t address, uint8_t sda, uint8_t scl, uint8_t interruptPin, void (*interruptFunction)());
+#endif
+
+#ifdef ESP32
+ ///// changes for second i2c bus
+ PCF8575(TwoWire *pWire, uint8_t address);
+ PCF8575(TwoWire *pWire, uint8_t address, uint8_t sda, uint8_t scl);
+
+ PCF8575(TwoWire *pWire, uint8_t address, uint8_t interruptPin, void (*interruptFunction)() );
+ PCF8575(TwoWire *pWire, uint8_t address, uint8_t sda, uint8_t scl, uint8_t interruptPin, void (*interruptFunction)());
+#endif
+
+ void begin();
+ void pinMode(uint8_t pin, uint8_t mode);
+
+ void readBuffer(bool force = true);
+ uint8_t digitalRead(uint8_t pin);
+ #ifndef PCF8575_LOW_MEMORY
+ struct DigitalInput {
+#ifdef NOT_SEQUENTIAL_PINOUT
+ uint8_t p00;
+ uint8_t p01;
+ uint8_t p02;
+ uint8_t p03;
+ uint8_t p04;
+ uint8_t p05;
+ uint8_t p06;
+ uint8_t p07;
+ uint8_t p10;
+ uint8_t p11;
+ uint8_t p12;
+ uint8_t p13;
+ uint8_t p14;
+ uint8_t p15;
+ uint8_t p16;
+ uint8_t p17;
+#else
+ uint8_t p0;
+ uint8_t p1;
+ uint8_t p2;
+ uint8_t p3;
+ uint8_t p4;
+ uint8_t p5;
+ uint8_t p6;
+ uint8_t p7;
+ uint8_t p8;
+ uint8_t p9;
+ uint8_t p10;
+ uint8_t p11;
+ uint8_t p12;
+ uint8_t p13;
+ uint8_t p14;
+ uint8_t p15;
+#endif
+ } digitalInput;
+
+
+ DigitalInput digitalReadAll(void);
+ #else
+ uint16_t digitalReadAll(void);
+ #endif
+ void digitalWrite(uint8_t pin, uint8_t value);
+
+private:
+ uint8_t _address;
+
+ #if defined(__AVR) || defined(__STM32F1__)
+ uint8_t _sda;
+ uint8_t _scl;
+ #else
+ uint8_t _sda = SDA;
+ uint8_t _scl = SCL;
+ #endif
+
+ TwoWire *_wire;
+
+ bool _usingInterrupt = false;
+ uint8_t _interruptPin = 2;
+ void (*_interruptFunction)(){};
+
+ uint16_t writeMode = 0;
+ uint16_t readMode = 0;
+ uint16_t byteBuffered = 0;
+ unsigned long lastReadMillis = 0;
+
+ uint16_t writeByteBuffered = 0;
+
+};
+
+#endif
diff --git a/software/main/SimplePgSQL.cpp b/software/main/SimplePgSQL.cpp
new file mode 100644
index 0000000..0e76e0a
--- /dev/null
+++ b/software/main/SimplePgSQL.cpp
@@ -0,0 +1,900 @@
+/*
+ SimplePgSQL.c - Lightweight PostgreSQL connector for Arduino
+ Copyright (C) Bohdan R. Rau 2016 <ethanak@polip.com>
+
+ SimplePgSQL is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ SimplePgSQL is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with SimplePgSQL. If not, write to:
+ The Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor
+ Boston, MA 02110-1301, USA.
+ */
+#include <stdio.h>
+//#include "esp_eth.h"
+#include <string.h>
+#include <sys/param.h>
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "freertos/event_groups.h"
+#include "esp_system.h"
+#include "esp_wifi.h"
+#include "esp_event.h"
+#include "esp_log.h"
+#include "nvs_flash.h"
+#include "esp_netif.h"
+#include "lwip/err.h"
+#include "lwip/sockets.h"
+
+
+#include "SimplePgSQL.h"
+
+#define AUTH_REQ_OK 0 /* User is authenticated */
+#define AUTH_REQ_PASSWORD 3 /* Password */
+#define PGTAG "PGSQL"
+static const char EM_OOM[] = "Out of mem";
+static const char EM_READ[] = "Backend read err";
+static const char EM_WRITE[] = "Backend write err";
+static const char EM_CONN[] = "Cannot conn 2 srv";
+static const char EM_SYNC[] = "Backend out of sync";
+static const char EM_INTR[] = "Internal err";
+static const char EM_UAUTH[] = "auth method !sptd";
+static const char EM_BIN[] = "Bin fmt !sptd";
+static const char EM_EXEC[] = "Previ exe !finished";
+static const char EM_PASSWD[] = "Pwd req";
+static const char EM_EMPTY[] = "empty qry";
+static const char EM_FORMAT[] = "Illegal chr fmt";
+
+PGconnection::PGconnection(const int flags, const unsigned char *Buffer, const int bufSize) {
+ conn_status = CONNECTION_NEEDED;
+ _passwd = NULL;
+ _user = NULL;
+ _buffer = (char *) Buffer;
+ _bufSize = bufSize;
+ bufPos = 0;
+ result_status=0;
+ _available=0;
+ _nfields=0;
+ _ntuples=0;
+ _flags=0;
+}
+
+int PGconnection::PGsetDbLogin(const char *ServerIP, int ServerPort, const char *dbName, const char *dbUser, const char *dbPasswd, const char *dbCharset) {
+
+ char *startpacket;
+ int packetlen;
+ int len;
+
+// close();
+ memset(&DestAddr, 0, sizeof(DestAddr));
+ AddrFamily = AF_INET;
+ ipProtocol = IPPROTO_IP;
+ DestAddr.sin_addr.s_addr = inet_addr(ServerIP);
+ DestAddr.sin_family = AF_INET;
+ DestAddr.sin_port = htons(ServerPort);
+
+ if (!dbName)
+ dbName = dbUser;
+ len = strlen(dbUser) + 1;
+ if (dbPasswd) {
+ len += strlen(dbPasswd) + 1;
+ }
+ _user = (char *) malloc(len);
+ strcpy(_user, dbUser);
+ if (dbPasswd) {
+ _passwd = _user + strlen(dbUser) + 1;
+ strcpy(_passwd, dbPasswd);
+ } else {
+ _passwd = NULL;
+ }
+
+ //int8_t connected = connect(client->connect(server, port);
+ SockH = socket(AddrFamily, SOCK_STREAM, ipProtocol);
+ if (SockH < 0) {
+ ESP_LOGE(PGTAG, "Unable to create socket: errno %d", errno);
+ setMsg_P(EM_CONN, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ } else {
+ int err = connect(SockH, (struct sockaddr *) &DestAddr, sizeof(DestAddr));
+ if (err != 0) {
+ ESP_LOGE(PGTAG, "Socket unable to connect: errno %d", errno);
+ return conn_status = CONNECTION_BAD;
+ }
+ NetConnected = 1;
+ ESP_LOGI(PGTAG, "Successfully connected");
+ }
+
+ packetlen = build_startup_packet(NULL, dbName, dbCharset);
+ if (packetlen > _bufSize - 10) {
+ setMsg_P(EM_OOM, PG_RSTAT_HAVE_ERROR);
+ conn_status = CONNECTION_BAD;
+ return conn_status;
+ }
+
+ startpacket = _buffer + (_bufSize - (packetlen + 1));
+ build_startup_packet(startpacket, dbName, dbCharset);
+ if (pqPacketSend(0, startpacket, packetlen) < 0) {
+ setMsg_P(EM_WRITE, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ attempts = 0;
+ return conn_status = CONNECTION_AWAITING_RESPONSE;
+}
+
+void PGconnection::PGclose(void) {
+ if (NetConnected) {
+ pqPacketSend('X', NULL, 0);
+// client->stop();
+ shutdown(SockH, 0);
+ close(SockH);
+ }
+ if (_user) {
+ free(_user);
+ _user = _passwd = NULL;
+ }
+ NetConnected = 0;
+ conn_status = CONNECTION_NEEDED;
+}
+
+int PGconnection::PGstatus(void) {
+ char bereq;
+ char rc;
+ int32_t msgLen;
+ int32_t areq;
+ char * pwd = _passwd;
+
+ switch (conn_status) {
+ case CONNECTION_NEEDED:
+ case CONNECTION_OK:
+ case CONNECTION_BAD:
+
+ return conn_status;
+
+ case CONNECTION_AWAITING_RESPONSE:
+ if (dataAvailable() == 0) return conn_status;
+ if (attempts++ >= 2) {
+ setMsg_P(EM_SYNC, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ if (pqGetc(&bereq)) {
+ goto read_error;
+ }
+ if (bereq == 'E') {
+ pqGetInt4(&msgLen);
+ pqGetNotice(PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ if (bereq != 'R') {
+ setMsg_P(EM_SYNC, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ if (pqGetInt4(&msgLen)) {
+ goto read_error;
+ }
+ if (pqGetInt4(&areq)) {
+ goto read_error;
+ }
+ if (areq == AUTH_REQ_OK) {
+ if (_user) {
+ free(_user);
+ _user = _passwd = NULL;
+ }
+ result_status = PG_RSTAT_READY;
+ return conn_status = CONNECTION_AUTH_OK;
+ }
+ if (areq != AUTH_REQ_PASSWORD) {
+ setMsg_P(EM_UAUTH, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ if (!_passwd || !*_passwd) {
+ setMsg_P(EM_PASSWD, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ pwd = _passwd;
+ rc = pqPacketSend('p', pwd, strlen(pwd) + 1);
+ if (rc) {
+ goto write_error;
+ }
+ return conn_status;
+
+ case CONNECTION_AUTH_OK:
+ for (;;) {
+ if (dataAvailable() == 0) return conn_status;
+ if (pqGetc(&bereq))
+ goto read_error;
+ if (pqGetInt4(&msgLen))
+ goto read_error;
+ msgLen -= 4;
+ if (bereq == 'A' || bereq == 'N' || bereq == 'S' || bereq == 'K') {
+ if (pqSkipnchar(msgLen))
+ goto read_error;
+ continue;
+ }
+ if (bereq == 'E') {
+ pqGetNotice(PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+
+ /* if (bereq == 'K') {
+ if (pqGetInt4(&be_pid)) goto read_error;
+ if (pqGetInt4(&be_key)) goto read_error;
+ continue;
+ }
+ */
+ if (bereq == 'Z') {
+ pqSkipnchar(msgLen);
+ return conn_status = CONNECTION_OK;
+ }
+ return conn_status = CONNECTION_BAD;
+ }
+ break;
+ default:
+ setMsg_P(EM_INTR, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ read_error: setMsg_P(EM_READ, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ write_error: setMsg_P(EM_WRITE, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+}
+
+int PGconnection::PGexecute(const char *query) {
+ /*
+ if (!(result_status & PG_RSTAT_READY)) {
+ setMsg_P(EM_EXEC, PG_RSTAT_HAVE_ERROR);
+ return -1;
+ }
+ */
+ int len = strlen(query);
+ if (pqPacketSend('Q', query, len + 1)) {
+ setMsg_P(EM_WRITE, PG_RSTAT_HAVE_ERROR);
+ conn_status = CONNECTION_BAD;
+ return -1;
+ }
+ result_status = PG_RSTAT_COMMAND_SENT;
+ return 0;
+}
+
+int PGconnection::PGescapeName(const char *inbuf, char *outbuf) {
+ const char *c;
+ int l = 2;
+ for (c = inbuf; *c; c++) {
+ l++;
+ if (*c == '\\' || *c == '"')
+ l++;
+ }
+ if (outbuf) {
+ *outbuf++ = '"';
+ for (c = inbuf; *c; c++) {
+ *outbuf++ = *c;
+ if (*c == '\\' || *c == '"')
+ *outbuf++ = *c;
+ }
+ *outbuf++ = '"';
+ }
+ return l;
+}
+
+int PGconnection::PGescapeString(const char *inbuf, char *outbuf) {
+ const char *c;
+ int e = 0, l;
+ for (c = inbuf; *c; c++) {
+ if (*c == '\\' || *c == '\'')
+ e++;
+ }
+ l = e + (c - inbuf) + (e ? 4 : 2);
+ if (outbuf) {
+ if (e) {
+ *outbuf++ = ' ';
+ *outbuf++ = 'E';
+ }
+ *outbuf++ = '\'';
+ for (c = inbuf; *c; c++) {
+ *outbuf++ = *c;
+ if (*c == '\\' || *c == '\'')
+ *outbuf++ = *c;
+ }
+ *outbuf++ = '\'';
+ }
+ return l;
+}
+
+char * PGconnection::PGgetValue(int nr) {
+ int i;
+ if (_null & (1 << nr)) return NULL;
+ char *c = _buffer;
+ if (nr < 0 || nr >= _nfields) return NULL;
+ for (i = 0; i < nr; i++) {
+ if (_null & (1 << i)) continue;
+ c += strlen(c) + 1;
+ }
+ return c;
+}
+
+char *PGconnection::PGgetColumn(int n) {
+ char *c;
+ int i;
+ if (!(result_status & PG_RSTAT_HAVE_COLUMNS)) return NULL;
+ if (n < 0 || n >= _nfields) return NULL;
+ for (c = _buffer, i = 0; i < n; i++) {
+ c += strlen(c) + 1;
+ }
+ return c;
+}
+
+char *PGconnection::PGgetMessage(void) {
+ if (!(result_status & PG_RSTAT_HAVE_MESSAGE))
+ return NULL;
+ return _buffer;
+}
+
+void dumpbuffer(char *b,int l) {
+ int i;
+ unsigned int v;
+ for (i=0;i<l;i++) {
+ if (i%8 == 0) {
+ printf("\n%04X ",i);
+ }
+ v=*b;
+ printf("%02X ",v);
+ if (v>31) printf(" %c ",v);
+ else printf(" ");
+ b++;
+ }
+ printf("\n");
+}
+
+int PGconnection::PGgetData(void) {
+ char id;
+ int32_t msgLen;
+ int rc;
+ char *c;
+ int r=0;
+ r=dataAvailable();
+// printf("getData:avail:%d\n",r);fflush(stdout);
+ if (r==0) return 0;
+
+ if (pqGetc(&id)) goto read_error;
+ if (pqGetInt4(&msgLen)) goto read_error;
+// printf("MSG ID: %c Len:%d (avail:%d)\n",id,msgLen,r);fflush(stdout);
+ msgLen -= 4;
+ switch (id) {
+ case 'T':
+ if ((rc = pqGetRowDescriptions())) {
+ if (rc == -2)
+ setMsg_P(EM_OOM, PG_RSTAT_HAVE_ERROR);
+ else if (rc == -3)
+ setMsg_P(EM_BIN, PG_RSTAT_HAVE_ERROR);
+ goto read_error;
+ }
+ if (_flags & PG_FLAG_IGNORE_COLUMNS) {
+ result_status &= ~PG_RSTAT_HAVE_MASK;
+ return 0;
+ }
+ return result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | PG_RSTAT_HAVE_COLUMNS;
+
+ case 'E':
+ if (pqGetNotice(PG_RSTAT_HAVE_ERROR))
+ goto read_error;
+ return result_status;
+
+ case 'N':
+ if (_flags & PG_FLAG_IGNORE_NOTICES) {
+ if (pqSkipnchar(msgLen))
+ goto read_error;
+ return 0;
+ }
+ if (pqGetNotice(PG_RSTAT_HAVE_NOTICE))
+ goto read_error;
+ return result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | PG_RSTAT_HAVE_NOTICE;
+
+ case 'A':
+ if (_flags & PG_FLAG_IGNORE_NOTICES) {
+ if (pqSkipnchar(msgLen))
+ goto read_error;
+ return 0;
+ }
+ if (pqGetNotify(msgLen))
+ goto read_error;
+ return result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | PG_RSTAT_HAVE_NOTICE;
+
+ case 'Z':
+ if (pqSkipnchar(msgLen))
+ goto read_error;
+ result_status = (result_status & PG_RSTAT_HAVE_SUMMARY) | PG_RSTAT_READY;
+ return PG_RSTAT_READY;
+
+ case 'S':
+ case 'K':
+ if (pqSkipnchar(msgLen))
+ goto read_error;
+ return 0;
+
+ case 'C':
+ if (msgLen > _bufSize - 1)
+ goto oom;
+ if (pqGetnchar(_buffer, msgLen))
+ goto read_error;
+ _buffer[msgLen] = 0;
+ _ntuples = 0;
+ result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | PG_RSTAT_HAVE_SUMMARY;
+ for (c = _buffer; *c && !isdigit(*c); c++)
+ ;
+ if (!*c)
+ return result_status;
+ if (strncmp(_buffer, "SELECT ", 7)) {
+ for (; *c && isdigit(*c); c++)
+ ;
+ for (; *c && !isdigit(*c); c++)
+ ;
+ }
+ if (*c)
+ _ntuples = strtol(c, NULL, 10);
+ return result_status;
+
+ case 'D':
+ if ((rc = pqGetRow())) {
+ if (rc == -2)
+ setMsg_P(EM_OOM, PG_RSTAT_HAVE_ERROR);
+ else if (rc == -3)
+ setMsg_P(EM_SYNC, PG_RSTAT_HAVE_ERROR);
+ goto read_error;
+ }
+ if (_flags & PG_FLAG_IGNORE_COLUMNS) {
+ result_status &= ~PG_RSTAT_HAVE_MASK;
+ return 0;
+ }
+
+ return result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | PG_RSTAT_HAVE_ROW;
+
+ case 'I':
+ if (pqSkipnchar(msgLen))
+ goto read_error;
+ setMsg_P(EM_EMPTY, PG_RSTAT_HAVE_ERROR);
+ return result_status;
+
+ default:
+ setMsg_P(EM_SYNC, PG_RSTAT_HAVE_ERROR);
+ conn_status = CONNECTION_BAD;
+ return -1;
+ }
+
+ oom: setMsg_P(EM_OOM, PG_RSTAT_HAVE_ERROR);
+
+ read_error: if (!(result_status & PG_RSTAT_HAVE_ERROR)) {
+ printf("READERROR!\n");fflush(stdout);
+ setMsg_P(EM_READ, PG_RSTAT_HAVE_ERROR);
+ }
+ conn_status = CONNECTION_BAD;
+ return -1;
+}
+
+int PGconnection::PGexecuteFormat(const char *format, ...) {
+ int32_t msgLen;
+ va_list va;
+ va_start(va, format);
+ msgLen = writeFormattedQuery(0, format, va);
+ va_end(va);
+ if (msgLen < 0)
+ return -1;
+ va_start(va, format);
+ msgLen = writeFormattedQuery(msgLen, format, va);
+ va_end(va);
+ if (msgLen) {
+ return -1;
+ }
+ result_status = PG_RSTAT_COMMAND_SENT;
+ return 0;
+}
+
+int PGconnection::build_startup_packet(char *packet, const char *dbName, const char *dbCharset) {
+ int packet_len = 4;
+ if (packet) {
+ memcpy(packet, "\0\003\0\0", 4);
+ }
+#define ADD_STARTUP_OPTION(optname, optval) \
+ do { \
+ if (packet) \
+ strcpy(packet + packet_len, (char *)optname); \
+ packet_len += strlen((char *)optname) + 1; \
+ if (packet) \
+ strcpy(packet + packet_len, (char *)optval); \
+ packet_len += strlen((char *)optval) + 1; \
+ } while(0)
+
+#define ADD_STARTUP_OPTION_P(optname, optval) \
+ do { \
+ if (packet) \
+ strcpy(packet + packet_len, (char *)optname); \
+ packet_len += strlen((char *)optname) + 1; \
+ if (packet) \
+ strcpy(packet + packet_len, (char *)optval); \
+ packet_len += strlen((char *)optval) + 1; \
+ } while(0)
+
+ if (_user && _user[0])
+ ADD_STARTUP_OPTION("user", _user);
+ if (dbName && dbName[0])
+ ADD_STARTUP_OPTION("database", dbName);
+ if (dbCharset && dbCharset[0])
+ ADD_STARTUP_OPTION("client_encoding", dbCharset);
+ ADD_STARTUP_OPTION_P("application_name", "Scaladis");
+#undef ADD_STARTUP_OPTION
+ if (packet)
+ packet[packet_len] = '\0';
+ packet_len++;
+
+ return packet_len;
+}
+
+int PGconnection::pqPacketSend(char pack_type, const char *buf, int buf_len) {
+ char *start = _buffer;
+ int l = _bufSize - 4;
+// int n;
+ if (pack_type) {
+ *start++ = pack_type;
+ l--;
+ }
+ *start++ = ((buf_len + 4) >> 24) & 0xff;
+ *start++ = ((buf_len + 4) >> 16) & 0xff;
+ *start++ = ((buf_len + 4) >> 8) & 0xff;
+ *start++ = (buf_len + 4) & 0xff;
+
+ if (buf) {
+ if (buf_len <= l) {
+ memcpy(start, buf, buf_len);
+ start += buf_len;
+ buf_len = 0;
+ } else {
+ memcpy(start, buf, l);
+ start += l;
+ buf_len -= l;
+ buf += l;
+ }
+ }
+ int err = send(SockH, _buffer, start - _buffer, 0);
+ if (err < 0) {
+ ESP_LOGE(PGTAG, "Send Error occurred during sending: errno %d", errno);
+ return err;
+ }
+ if (buf && buf_len) {
+ err = send(SockH, (const char *) buf, (size_t) buf_len, 0);
+ if (err < 0) {
+ ESP_LOGE(PGTAG, "Send2 Error occurred during sending: errno %d", errno);
+ return err;
+
+ }
+ }
+
+ return 0;
+}
+
+int PGconnection::pqGetc(char *buf) {
+ int i=0;
+// for (i = 0; !client->available() && i < 10; i++) {
+ while (i<10) {
+ if (dataAvailable()>0) break;
+ else {
+ vTaskDelay(i++);
+ }
+ }
+ if (i==10) return -1;
+
+ int len = read(SockH, (void *) buf, 1);
+ _available-=len;
+ return -1+len;
+}
+
+int PGconnection::pqGetInt4(int32_t *result) {
+ uint32_t tmp4 = 0;
+ uint8_t tmp, i;
+ int rt=0;
+ for (i = 0; i < 4; i++) {
+ rt=pqGetc((char *) &tmp);
+ if (rt) return -1;
+ tmp4 = (tmp4 << 8) | tmp;
+ }
+ *result = tmp4;
+ return 0;
+}
+
+int PGconnection::pqGetInt2(int16_t *result) {
+ uint16_t tmp2 = 0;
+ uint8_t tmp, i;
+ for (i = 0; i < 2; i++) {
+ if (pqGetc((char *) &tmp)) return -1;
+ tmp2 = (tmp2 << 8) | tmp;
+ }
+ *result = tmp2;
+ return 0;
+}
+
+int PGconnection::pqGetnchar(char *s, int len) {
+ while (len-- > 0) {
+ if (pqGetc(s++)) return -1;
+ }
+ return 0;
+}
+
+int PGconnection::pqGets(char *s, int maxlen) {
+ int len;
+ char z;
+ for (len = 0; len < maxlen; len++) {
+ if (pqGetc(&z)) return -1;
+ if (s) *s++ = z;
+ if (!z) return len + 1;
+ }
+ return -(len + 1);
+}
+
+int PGconnection::pqSkipnchar(int len) {
+ char dummy;
+ int i;
+ for (i=0;i<len;i++) read(SockH,&dummy,1);
+ /*
+ while (len-- > 0) {
+ if (pqGetc(&dummy))
+ return -1;
+ }
+ */
+ return 0;
+}
+
+int PGconnection::pqGetRow(void) {
+ int i;
+ int bufpos = 0;
+ int32_t len;
+ int16_t cols;
+
+ _null = 0;
+ if (pqGetInt2(&cols)) return -1;
+ if (cols != _nfields) return -3;
+
+ for (i = 0; i < _nfields; i++) {
+ if (pqGetInt4(&len)) return -1;
+ if (len < 0) {
+ _null |= 1 << i;
+ continue;
+ }
+ if (bufpos + len + 1 > _bufSize) {
+ return -2;
+ }
+ if (pqGetnchar(_buffer + bufpos, len))
+ return -1;
+ bufpos += len;
+ _buffer[bufpos++] = 0;
+ }
+ return 0;
+}
+
+int PGconnection::pqGetRowDescriptions(void) {
+ int i;
+ int16_t format;
+ int rc;
+ int bufpos;
+ if (pqGetInt2(&_nfields))
+ return -1;
+ if (_nfields > PG_MAX_FIELDS)
+ return -2; // implementation limit
+ _formats = 0;
+ bufpos = 0;
+
+ for (i = 0; i < _nfields; i++) {
+ if (!(_flags & PG_FLAG_IGNORE_COLUMNS)) {
+ if (bufpos >= _bufSize - 1)
+ return -2;
+ rc = pqGets(_buffer + bufpos, _bufSize - bufpos);
+ if (rc < 0)
+ return -1;
+ bufpos += rc;
+ } else {
+ if (pqGets(NULL, 8192) < 0) {
+ return -1;
+ }
+ }
+ if (pqSkipnchar(16))
+ return -1;
+ if (pqGetInt2(&format))
+ return -1;
+ format = format ? 1 : 0;
+ _formats |= format << i;
+ }
+ if (_formats)
+ return -3;
+ return 0;
+}
+
+void PGconnection::setMsg(const char *s, int type) {
+ strcpy(_buffer, s);
+ result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | type;
+}
+
+void PGconnection::setMsg_P(const char *s, int type) {
+ strcpy(_buffer, s);
+ result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | type;
+}
+
+int PGconnection::pqGetNotice(int type) {
+ int bufpos = 0;
+ char id;
+ int rc;
+ for (;;) {
+ if (pqGetc(&id)) goto read_error;
+ if (!id)
+ break;
+ if (id == 'S' || id == 'M') {
+ if (bufpos && bufpos < _bufSize - 1)
+ _buffer[bufpos++] = ':';
+ rc = pqGets(_buffer + bufpos, _bufSize - bufpos);
+ if (rc < 0)
+ goto read_error;
+ bufpos += rc - 1;
+ } else {
+ rc = pqGets(NULL, 8192);
+ if (rc < 0) goto read_error;
+ }
+ }
+ _buffer[bufpos] = 0;
+ result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | type;
+ return 0;
+
+ read_error: if (!bufpos)
+ setMsg_P(EM_READ, PG_RSTAT_HAVE_ERROR);
+ return -1;
+}
+
+int PGconnection::pqGetNotify(int32_t msgLen) {
+ int32_t pid;
+ int bufpos, i;
+ if (pqGetInt4(&pid))
+ return -1;
+ msgLen -= 4;
+ bufpos = sprintf(_buffer, "%d:", pid);
+ if (msgLen > _bufSize - (bufpos + 1)) {
+ if (pqGetnchar(_buffer + bufpos, _bufSize - (bufpos + 1)))
+ return -1;
+ msgLen -= _bufSize - (bufpos + 1);
+ if (pqSkipnchar(msgLen))
+ return -1;
+ _buffer[msgLen = _bufSize - 1] = 0;
+
+ } else {
+ if (pqGetnchar(_buffer + bufpos, msgLen))
+ return -1;
+ _buffer[bufpos + msgLen] = 0;
+ msgLen += bufpos;
+ }
+ for (i = 0; i < msgLen; i++)
+ if (!_buffer[i])
+ _buffer[i] = ':';
+ return 0;
+}
+
+int PGconnection::dataAvailable() {
+ int res=0;
+// if (_available) return _available;
+ ioctl(SockH,FIONREAD,&res);
+ return res;
+}
+
+int PGconnection::writeMsgPart(const char *s, int len, int fine) {
+ while (len > 0) {
+ int n = len;
+ if (n > _bufSize - bufPos)
+ n = _bufSize - bufPos;
+ memcpy(_buffer + bufPos, s, n);
+ bufPos += n;
+ s += n;
+ len -= n;
+ if (bufPos >= _bufSize) {
+// if (client->write((uint8_t *) Buffer, bufPos) != (size_t) bufPos) return -1;
+ int err = send(SockH, _buffer, bufPos, 0);
+ if (err < 0)
+ return -1;
+ bufPos = 0;
+ }
+ }
+ if (bufPos && fine) {
+// if (client->write((uint8_t *) Buffer, bufPos) != (size_t) bufPos) return -1;
+ int err = send(SockH, _buffer, bufPos, 0);
+ if (err < 0)
+ return -1;
+
+ bufPos = 0;
+ }
+
+ return 0;
+}
+
+int32_t PGconnection::writeFormattedQuery(int32_t length, const char *format, va_list va) {
+ int32_t msgLen = 0;
+ const char *percent;
+ int blen, rc;
+#define LBUFLEN 32
+ char buf[LBUFLEN], znak;
+ if (length) {
+ length += 4;
+ bufPos = 0;
+ _buffer[bufPos++] = 'Q';
+ _buffer[bufPos++] = (length >> 24) & 0xff;
+ _buffer[bufPos++] = (length >> 16) & 0xff;
+ _buffer[bufPos++] = (length >> 8) & 0xff;
+ _buffer[bufPos++] = (length) & 0xff;
+ }
+ for (;;) {
+ percent = strchr(format, '%');
+ if (!percent)
+ break;
+ znak = percent[1];
+ if (!length) {
+ msgLen += (percent - format);
+ } else {
+ rc = writeMsgPart(format, percent - format, false);
+ if (rc)
+ goto write_error;
+ }
+ format = percent + 2;
+ if (znak == 's' || znak == 'n') {
+ char *str = va_arg(va, char *);
+ blen = (znak == 's') ? PGescapeString(str, NULL) : PGescapeName(str, NULL);
+ if (!length) {
+ msgLen += blen;
+ } else {
+ if (bufPos + blen > _bufSize) {
+ rc = writeMsgPart(NULL, 0, true);
+ if (rc)
+ goto write_error;
+ }
+ }
+ if (znak == 's') {
+ PGescapeString(str, _buffer + bufPos);
+ } else {
+ PGescapeName(str, _buffer + bufPos);
+ }
+ bufPos += blen;
+ continue;
+ }
+ if (znak == 'l' || znak == 'd') {
+ if (znak == 'l') {
+ long n = va_arg(va, long);
+ blen = snprintf(buf, LBUFLEN, "'%ld'", n);
+ } else {
+ int n = va_arg(va, int);
+ blen = snprintf(buf, LBUFLEN, "'%d'", n);
+ }
+ if (length) {
+ rc = writeMsgPart(buf, blen, false);
+ if (rc)
+ goto write_error;
+ } else {
+ msgLen += blen;
+ }
+ }
+ setMsg_P(EM_FORMAT, PG_RSTAT_HAVE_ERROR);
+ return -1;
+ }
+ blen = strlen(format);
+ if (length) {
+ rc = writeMsgPart(format, blen, false);
+ if (!rc) {
+ rc = writeMsgPart("\0", 1, true);
+ }
+ if (rc)
+ goto write_error;
+ } else {
+ msgLen += blen + 1;
+ }
+ return msgLen;
+
+ write_error: setMsg_P(EM_WRITE, PG_RSTAT_HAVE_ERROR);
+ conn_status = CONNECTION_BAD;
+ return -1;
+}
diff --git a/software/main/SimplePgSQL.h b/software/main/SimplePgSQL.h
new file mode 100644
index 0000000..9637ee5
--- /dev/null
+++ b/software/main/SimplePgSQL.h
@@ -0,0 +1,209 @@
+/*
+ * SimplePgSQL.h - Lightweight PostgreSQL connector for Arduino
+ * Copyright (C) Bohdan R. Rau 2016 <ethanak@polip.com>
+ *
+ * SimplePgSQL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * SimplePgSQL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with SimplePgSQL. If not, write to:
+ * The Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "esp_system.h"
+#include "esp_netif.h"
+#include "lwip/err.h"
+#include "lwip/sockets.h"
+
+#ifndef _SIMPLEPGSQL
+#define _SIMPLEPGSQL 1
+
+typedef enum {
+ CONNECTION_OK, CONNECTION_BAD, CONNECTION_NEEDED, /* setDbLogin() needed */
+ /* Internal states here */
+ CONNECTION_AWAITING_RESPONSE, /* Waiting for a response from the postmaster. */
+ CONNECTION_AUTH_OK /* Received authentication; waiting for backend startup. */
+} ConnStatusType;
+
+#define PG_BUFFER_SIZE 4096
+
+// maximum number of fields in backend response
+// must not exceed number of bits in _formats and _null
+#define PG_MAX_FIELDS 32
+
+// ignore notices and notifications
+#define PG_FLAG_IGNORE_NOTICES 1
+// do not store column names
+#define PG_FLAG_IGNORE_COLUMNS 2
+
+// ready for next query
+#define PG_RSTAT_READY 1 // command sent
+#define PG_RSTAT_COMMAND_SENT 2 // column names in buffer
+#define PG_RSTAT_HAVE_COLUMNS 4 // row values in buffer
+#define PG_RSTAT_HAVE_ROW 8 // summary (number of tuples/affected rows) received
+#define PG_RSTAT_HAVE_SUMMARY 16 // error message in buffer
+#define PG_RSTAT_HAVE_ERROR 32 // notice/notification in buffer
+#define PG_RSTAT_HAVE_NOTICE 64
+
+#define PG_RSTAT_HAVE_MASK (PG_RSTAT_HAVE_COLUMNS | \
+ PG_RSTAT_HAVE_ROW | \
+ PG_RSTAT_HAVE_SUMMARY | \
+ PG_RSTAT_HAVE_ERROR | \
+ PG_RSTAT_HAVE_NOTICE)
+
+#define PG_RSTAT_HAVE_MESSAGE (PG_RSTAT_HAVE_ERROR | PG_RSTAT_HAVE_NOTICE)
+
+class PGconnection {
+public:
+
+ PGconnection(const int flags, const unsigned char *Buffer, const int bufSize);
+ /*
+ * returns connection status.
+ * passwd may be null in case of 'trust' authorization.
+ * only 'trust', 'password' and 'md5' (if compiled in)
+ * authorization modes are implemented.
+ * ssl mode is not implemented.
+ * database name defaults to user name *
+ */
+ int PGsetDbLogin(const char *ServerIP, int ServerPort, const char *dbName, const char *dbUser, const char *dbPasswd, const char *charset);
+ /*
+ * performs authorization tasks if needed
+ * returns current connection status
+ * must be called periodically until OK, BAD or NEEDED
+ */
+ int PGstatus(void);
+ /*
+ * sends termination command if possible
+ * closes client connection and frees internal buffer
+ */
+ void PGclose(void);
+ /*
+ * sends query to backend
+ * returns negative value on error
+ * or zero on success
+ */
+ int PGexecute(const char *query);
+
+ /* should be called periodically in idle state
+ * if notifications are enabled
+ * returns:
+ * - negative value on error
+ * - zero if no interesting data arrived
+ * - current data status if some data arrived
+ */
+ int PGgetData(void);
+ /*
+ * returns pointer to n-th column name in internal buffer
+ * if available or null if column number out of range
+ * will be invalidated on next getData call
+ */
+ char *PGgetColumn(int n);
+ /*
+ * returns pointer to n-th column value in internal buffer
+ * if available or null if column number out of range
+ * or value is NULL
+ * will be invalidated on next getData call
+ */
+ char *PGgetValue(int);
+ /*
+ * returns pointer to message (error or notice)
+ * if available or NULL
+ * will be invalidated on next getData call
+ */
+ char *PGgetMessage(void);
+ int PGdataStatus(void) {
+ return result_status;
+ }
+ ;
+ int PGnfields(void) {
+ return _nfields;
+ }
+ ;
+ int PGntuples(void) {
+ return _ntuples;
+ }
+ ;
+ /*
+ * returns length of escaped string
+ * single quotes and E prefix (if needed)
+ * will be added.
+ */
+ int PGescapeString(const char *inbuf, char *outbuf);
+ /*
+ * returns length of escaped string
+ * double quotes will be added.
+ */
+ int PGescapeName(const char *inbuf, char *outbuf);
+ /*
+ * sends formatted query to backend
+ * returns negative value on error
+ * or zero on success
+ * Formatting sequences:
+ * %s - string literal (will be escaped with escapeString)
+ * %n - name (will be escaped with escapeName)
+ * %d - int (single quotes will be added)
+ * %l - long int (single quotes will be added)
+ * %% - % character
+ */
+ int PGexecuteFormat(const char *format, ...);
+
+private:
+ int pqPacketSend(char pack_type, const char *buf, int buf_len);
+ int pqGetc(char *);
+ int pqGetInt4(int32_t *result);
+ int pqGetInt2(int16_t *result);
+ int pqGetnchar(char *s, int len);
+ int pqSkipnchar(int len);
+ int pqGets(char *s, int maxlen);
+ int pqGetRowDescriptions(void);
+ int pqGetRow(void);
+ void setMsg(const char *, int);
+ void setMsg_P(const char *, int);
+ int pqGetNotice(int);
+ int pqGetNotify(int32_t);
+ char *_user;
+ char *_passwd;
+// char *Buffer;
+ char *_buffer;
+// int bufSize;
+ int _bufSize;
+ int bufPos;
+ int writeMsgPart(const char *s, int len, int fine);
+ int32_t writeFormattedQuery(int32_t length, const char *format, va_list va);
+ int dataAvailable(void);
+ int build_startup_packet(char *packet, const char *db, const char *charset);
+ uint8_t conn_status;
+ uint8_t attempts;
+ /*
+ int32_t be_pid;
+ int32_t be_key;
+ */
+ int16_t _nfields;
+ int16_t _ntuples;
+ uint32_t _formats;
+ uint32_t _null;
+ uint8_t _binary;
+ uint8_t _flags;
+ uint32_t _available;
+ int result_status;
+ // network stuff
+ struct sockaddr_in DestAddr;
+ int SockH = -1;
+ int ipProtocol = 0;
+ int AddrFamily = 0;
+ int NetConnected=0;
+
+};
+
+#endif
diff --git a/software/main/build/CMakeFiles/3.16.3/CMakeCCompiler.cmake b/software/main/build/CMakeFiles/3.16.3/CMakeCCompiler.cmake
new file mode 100644
index 0000000..2692f73
--- /dev/null
+++ b/software/main/build/CMakeFiles/3.16.3/CMakeCCompiler.cmake
@@ -0,0 +1,76 @@
+set(CMAKE_C_COMPILER "/usr/bin/cc")
+set(CMAKE_C_COMPILER_ARG1 "")
+set(CMAKE_C_COMPILER_ID "GNU")
+set(CMAKE_C_COMPILER_VERSION "9.3.0")
+set(CMAKE_C_COMPILER_VERSION_INTERNAL "")
+set(CMAKE_C_COMPILER_WRAPPER "")
+set(CMAKE_C_STANDARD_COMPUTED_DEFAULT "11")
+set(CMAKE_C_COMPILE_FEATURES "c_std_90;c_function_prototypes;c_std_99;c_restrict;c_variadic_macros;c_std_11;c_static_assert")
+set(CMAKE_C90_COMPILE_FEATURES "c_std_90;c_function_prototypes")
+set(CMAKE_C99_COMPILE_FEATURES "c_std_99;c_restrict;c_variadic_macros")
+set(CMAKE_C11_COMPILE_FEATURES "c_std_11;c_static_assert")
+
+set(CMAKE_C_PLATFORM_ID "Linux")
+set(CMAKE_C_SIMULATE_ID "")
+set(CMAKE_C_COMPILER_FRONTEND_VARIANT "")
+set(CMAKE_C_SIMULATE_VERSION "")
+
+
+
+set(CMAKE_AR "/usr/bin/ar")
+set(CMAKE_C_COMPILER_AR "/usr/bin/gcc-ar-9")
+set(CMAKE_RANLIB "/usr/bin/ranlib")
+set(CMAKE_C_COMPILER_RANLIB "/usr/bin/gcc-ranlib-9")
+set(CMAKE_LINKER "/usr/bin/ld")
+set(CMAKE_MT "")
+set(CMAKE_COMPILER_IS_GNUCC 1)
+set(CMAKE_C_COMPILER_LOADED 1)
+set(CMAKE_C_COMPILER_WORKS TRUE)
+set(CMAKE_C_ABI_COMPILED TRUE)
+set(CMAKE_COMPILER_IS_MINGW )
+set(CMAKE_COMPILER_IS_CYGWIN )
+if(CMAKE_COMPILER_IS_CYGWIN)
+ set(CYGWIN 1)
+ set(UNIX 1)
+endif()
+
+set(CMAKE_C_COMPILER_ENV_VAR "CC")
+
+if(CMAKE_COMPILER_IS_MINGW)
+ set(MINGW 1)
+endif()
+set(CMAKE_C_COMPILER_ID_RUN 1)
+set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m)
+set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
+set(CMAKE_C_LINKER_PREFERENCE 10)
+
+# Save compiler ABI information.
+set(CMAKE_C_SIZEOF_DATA_PTR "8")
+set(CMAKE_C_COMPILER_ABI "ELF")
+set(CMAKE_C_LIBRARY_ARCHITECTURE "x86_64-linux-gnu")
+
+if(CMAKE_C_SIZEOF_DATA_PTR)
+ set(CMAKE_SIZEOF_VOID_P "${CMAKE_C_SIZEOF_DATA_PTR}")
+endif()
+
+if(CMAKE_C_COMPILER_ABI)
+ set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_C_COMPILER_ABI}")
+endif()
+
+if(CMAKE_C_LIBRARY_ARCHITECTURE)
+ set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu")
+endif()
+
+set(CMAKE_C_CL_SHOWINCLUDES_PREFIX "")
+if(CMAKE_C_CL_SHOWINCLUDES_PREFIX)
+ set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_C_CL_SHOWINCLUDES_PREFIX}")
+endif()
+
+
+
+
+
+set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES "/usr/lib/gcc/x86_64-linux-gnu/9/include;/usr/local/include;/usr/include/x86_64-linux-gnu;/usr/include")
+set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "gcc;gcc_s;c;gcc;gcc_s")
+set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "/usr/lib/gcc/x86_64-linux-gnu/9;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib")
+set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "")
diff --git a/software/main/build/CMakeFiles/3.16.3/CMakeCXXCompiler.cmake b/software/main/build/CMakeFiles/3.16.3/CMakeCXXCompiler.cmake
new file mode 100644
index 0000000..504c250
--- /dev/null
+++ b/software/main/build/CMakeFiles/3.16.3/CMakeCXXCompiler.cmake
@@ -0,0 +1,88 @@
+set(CMAKE_CXX_COMPILER "/usr/bin/c++")
+set(CMAKE_CXX_COMPILER_ARG1 "")
+set(CMAKE_CXX_COMPILER_ID "GNU")
+set(CMAKE_CXX_COMPILER_VERSION "9.3.0")
+set(CMAKE_CXX_COMPILER_VERSION_INTERNAL "")
+set(CMAKE_CXX_COMPILER_WRAPPER "")
+set(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT "14")
+set(CMAKE_CXX_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters;cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates;cxx_std_14;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates;cxx_std_17;cxx_std_20")
+set(CMAKE_CXX98_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters")
+set(CMAKE_CXX11_COMPILE_FEATURES "cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates")
+set(CMAKE_CXX14_COMPILE_FEATURES "cxx_std_14;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates")
+set(CMAKE_CXX17_COMPILE_FEATURES "cxx_std_17")
+set(CMAKE_CXX20_COMPILE_FEATURES "cxx_std_20")
+
+set(CMAKE_CXX_PLATFORM_ID "Linux")
+set(CMAKE_CXX_SIMULATE_ID "")
+set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT "")
+set(CMAKE_CXX_SIMULATE_VERSION "")
+
+
+
+set(CMAKE_AR "/usr/bin/ar")
+set(CMAKE_CXX_COMPILER_AR "/usr/bin/gcc-ar-9")
+set(CMAKE_RANLIB "/usr/bin/ranlib")
+set(CMAKE_CXX_COMPILER_RANLIB "/usr/bin/gcc-ranlib-9")
+set(CMAKE_LINKER "/usr/bin/ld")
+set(CMAKE_MT "")
+set(CMAKE_COMPILER_IS_GNUCXX 1)
+set(CMAKE_CXX_COMPILER_LOADED 1)
+set(CMAKE_CXX_COMPILER_WORKS TRUE)
+set(CMAKE_CXX_ABI_COMPILED TRUE)
+set(CMAKE_COMPILER_IS_MINGW )
+set(CMAKE_COMPILER_IS_CYGWIN )
+if(CMAKE_COMPILER_IS_CYGWIN)
+ set(CYGWIN 1)
+ set(UNIX 1)
+endif()
+
+set(CMAKE_CXX_COMPILER_ENV_VAR "CXX")
+
+if(CMAKE_COMPILER_IS_MINGW)
+ set(MINGW 1)
+endif()
+set(CMAKE_CXX_COMPILER_ID_RUN 1)
+set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;CPP)
+set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC)
+
+foreach (lang C OBJC OBJCXX)
+ if (CMAKE_${lang}_COMPILER_ID_RUN)
+ foreach(extension IN LISTS CMAKE_${lang}_SOURCE_FILE_EXTENSIONS)
+ list(REMOVE_ITEM CMAKE_CXX_SOURCE_FILE_EXTENSIONS ${extension})
+ endforeach()
+ endif()
+endforeach()
+
+set(CMAKE_CXX_LINKER_PREFERENCE 30)
+set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1)
+
+# Save compiler ABI information.
+set(CMAKE_CXX_SIZEOF_DATA_PTR "8")
+set(CMAKE_CXX_COMPILER_ABI "ELF")
+set(CMAKE_CXX_LIBRARY_ARCHITECTURE "x86_64-linux-gnu")
+
+if(CMAKE_CXX_SIZEOF_DATA_PTR)
+ set(CMAKE_SIZEOF_VOID_P "${CMAKE_CXX_SIZEOF_DATA_PTR}")
+endif()
+
+if(CMAKE_CXX_COMPILER_ABI)
+ set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_CXX_COMPILER_ABI}")
+endif()
+
+if(CMAKE_CXX_LIBRARY_ARCHITECTURE)
+ set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu")
+endif()
+
+set(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX "")
+if(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX)
+ set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_CXX_CL_SHOWINCLUDES_PREFIX}")
+endif()
+
+
+
+
+
+set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "/usr/include/c++/9;/usr/include/x86_64-linux-gnu/c++/9;/usr/include/c++/9/backward;/usr/lib/gcc/x86_64-linux-gnu/9/include;/usr/local/include;/usr/include/x86_64-linux-gnu;/usr/include")
+set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "stdc++;m;gcc_s;gcc;c;gcc_s;gcc")
+set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "/usr/lib/gcc/x86_64-linux-gnu/9;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib")
+set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "")
diff --git a/software/main/build/CMakeFiles/3.16.3/CMakeDetermineCompilerABI_C.bin b/software/main/build/CMakeFiles/3.16.3/CMakeDetermineCompilerABI_C.bin
new file mode 100644
index 0000000..b6f7a32
--- /dev/null
+++ b/software/main/build/CMakeFiles/3.16.3/CMakeDetermineCompilerABI_C.bin
Binary files differ
diff --git a/software/main/build/CMakeFiles/3.16.3/CMakeDetermineCompilerABI_CXX.bin b/software/main/build/CMakeFiles/3.16.3/CMakeDetermineCompilerABI_CXX.bin
new file mode 100644
index 0000000..d8ed013
--- /dev/null
+++ b/software/main/build/CMakeFiles/3.16.3/CMakeDetermineCompilerABI_CXX.bin
Binary files differ
diff --git a/software/main/build/CMakeFiles/3.16.3/CMakeSystem.cmake b/software/main/build/CMakeFiles/3.16.3/CMakeSystem.cmake
new file mode 100644
index 0000000..442aabb
--- /dev/null
+++ b/software/main/build/CMakeFiles/3.16.3/CMakeSystem.cmake
@@ -0,0 +1,15 @@
+set(CMAKE_HOST_SYSTEM "Linux-5.11.0-43-generic")
+set(CMAKE_HOST_SYSTEM_NAME "Linux")
+set(CMAKE_HOST_SYSTEM_VERSION "5.11.0-43-generic")
+set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64")
+
+
+
+set(CMAKE_SYSTEM "Linux-5.11.0-43-generic")
+set(CMAKE_SYSTEM_NAME "Linux")
+set(CMAKE_SYSTEM_VERSION "5.11.0-43-generic")
+set(CMAKE_SYSTEM_PROCESSOR "x86_64")
+
+set(CMAKE_CROSSCOMPILING "FALSE")
+
+set(CMAKE_SYSTEM_LOADED 1)
diff --git a/software/main/build/CMakeFiles/3.16.3/CompilerIdC/CMakeCCompilerId.c b/software/main/build/CMakeFiles/3.16.3/CompilerIdC/CMakeCCompilerId.c
new file mode 100644
index 0000000..d884b50
--- /dev/null
+++ b/software/main/build/CMakeFiles/3.16.3/CompilerIdC/CMakeCCompilerId.c
@@ -0,0 +1,671 @@
+#ifdef __cplusplus
+# error "A C++ compiler has been selected for C."
+#endif
+
+#if defined(__18CXX)
+# define ID_VOID_MAIN
+#endif
+#if defined(__CLASSIC_C__)
+/* cv-qualifiers did not exist in K&R C */
+# define const
+# define volatile
+#endif
+
+
+/* Version number components: V=Version, R=Revision, P=Patch
+ Version date components: YYYY=Year, MM=Month, DD=Day */
+
+#if defined(__INTEL_COMPILER) || defined(__ICC)
+# define COMPILER_ID "Intel"
+# if defined(_MSC_VER)
+# define SIMULATE_ID "MSVC"
+# endif
+# if defined(__GNUC__)
+# define SIMULATE_ID "GNU"
+# endif
+ /* __INTEL_COMPILER = VRP */
+# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
+# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
+# if defined(__INTEL_COMPILER_UPDATE)
+# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE)
+# else
+# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
+# endif
+# if defined(__INTEL_COMPILER_BUILD_DATE)
+ /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
+# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
+# endif
+# if defined(_MSC_VER)
+ /* _MSC_VER = VVRR */
+# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
+# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
+# endif
+# if defined(__GNUC__)
+# define SIMULATE_VERSION_MAJOR DEC(__GNUC__)
+# elif defined(__GNUG__)
+# define SIMULATE_VERSION_MAJOR DEC(__GNUG__)
+# endif
+# if defined(__GNUC_MINOR__)
+# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__)
+# endif
+# if defined(__GNUC_PATCHLEVEL__)
+# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
+# endif
+
+#elif defined(__PATHCC__)
+# define COMPILER_ID "PathScale"
+# define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
+# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
+# if defined(__PATHCC_PATCHLEVEL__)
+# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
+# endif
+
+#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
+# define COMPILER_ID "Embarcadero"
+# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
+# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
+# define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF)
+
+#elif defined(__BORLANDC__)
+# define COMPILER_ID "Borland"
+ /* __BORLANDC__ = 0xVRR */
+# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
+# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
+
+#elif defined(__WATCOMC__) && __WATCOMC__ < 1200
+# define COMPILER_ID "Watcom"
+ /* __WATCOMC__ = VVRR */
+# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
+# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
+# if (__WATCOMC__ % 10) > 0
+# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
+# endif
+
+#elif defined(__WATCOMC__)
+# define COMPILER_ID "OpenWatcom"
+ /* __WATCOMC__ = VVRP + 1100 */
+# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100)
+# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
+# if (__WATCOMC__ % 10) > 0
+# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
+# endif
+
+#elif defined(__SUNPRO_C)
+# define COMPILER_ID "SunPro"
+# if __SUNPRO_C >= 0x5100
+ /* __SUNPRO_C = 0xVRRP */
+# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12)
+# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF)
+# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
+# else
+ /* __SUNPRO_CC = 0xVRP */
+# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8)
+# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF)
+# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
+# endif
+
+#elif defined(__HP_cc)
+# define COMPILER_ID "HP"
+ /* __HP_cc = VVRRPP */
+# define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000)
+# define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100)
+# define COMPILER_VERSION_PATCH DEC(__HP_cc % 100)
+
+#elif defined(__DECC)
+# define COMPILER_ID "Compaq"
+ /* __DECC_VER = VVRRTPPPP */
+# define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000)
+# define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100)
+# define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000)
+
+#elif defined(__IBMC__) && defined(__COMPILER_VER__)
+# define COMPILER_ID "zOS"
+ /* __IBMC__ = VRP */
+# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
+# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
+# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
+
+#elif defined(__ibmxl__) && defined(__clang__)
+# define COMPILER_ID "XLClang"
+# define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__)
+# define COMPILER_VERSION_MINOR DEC(__ibmxl_release__)
+# define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__)
+# define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__)
+
+
+#elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ >= 800
+# define COMPILER_ID "XL"
+ /* __IBMC__ = VRP */
+# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
+# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
+# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
+
+#elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ < 800
+# define COMPILER_ID "VisualAge"
+ /* __IBMC__ = VRP */
+# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
+# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
+# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
+
+#elif defined(__PGI)
+# define COMPILER_ID "PGI"
+# define COMPILER_VERSION_MAJOR DEC(__PGIC__)
+# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
+# if defined(__PGIC_PATCHLEVEL__)
+# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
+# endif
+
+#elif defined(_CRAYC)
+# define COMPILER_ID "Cray"
+# define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR)
+# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
+
+#elif defined(__TI_COMPILER_VERSION__)
+# define COMPILER_ID "TI"
+ /* __TI_COMPILER_VERSION__ = VVVRRRPPP */
+# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
+# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
+# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
+
+#elif defined(__FUJITSU) || defined(__FCC_VERSION) || defined(__fcc_version)
+# define COMPILER_ID "Fujitsu"
+
+#elif defined(__ghs__)
+# define COMPILER_ID "GHS"
+/* __GHS_VERSION_NUMBER = VVVVRP */
+# ifdef __GHS_VERSION_NUMBER
+# define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100)
+# define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10)
+# define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10)
+# endif
+
+#elif defined(__TINYC__)
+# define COMPILER_ID "TinyCC"
+
+#elif defined(__BCC__)
+# define COMPILER_ID "Bruce"
+
+#elif defined(__SCO_VERSION__)
+# define COMPILER_ID "SCO"
+
+#elif defined(__ARMCC_VERSION) && !defined(__clang__)
+# define COMPILER_ID "ARMCC"
+#if __ARMCC_VERSION >= 1000000
+ /* __ARMCC_VERSION = VRRPPPP */
+ # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000)
+ # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100)
+ # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
+#else
+ /* __ARMCC_VERSION = VRPPPP */
+ # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000)
+ # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10)
+ # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
+#endif
+
+
+#elif defined(__clang__) && defined(__apple_build_version__)
+# define COMPILER_ID "AppleClang"
+# if defined(_MSC_VER)
+# define SIMULATE_ID "MSVC"
+# endif
+# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
+# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
+# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
+# if defined(_MSC_VER)
+ /* _MSC_VER = VVRR */
+# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
+# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
+# endif
+# define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
+
+#elif defined(__clang__) && defined(__ARMCOMPILER_VERSION)
+# define COMPILER_ID "ARMClang"
+ # define COMPILER_VERSION_MAJOR DEC(__ARMCOMPILER_VERSION/1000000)
+ # define COMPILER_VERSION_MINOR DEC(__ARMCOMPILER_VERSION/10000 % 100)
+ # define COMPILER_VERSION_PATCH DEC(__ARMCOMPILER_VERSION % 10000)
+# define COMPILER_VERSION_INTERNAL DEC(__ARMCOMPILER_VERSION)
+
+#elif defined(__clang__)
+# define COMPILER_ID "Clang"
+# if defined(_MSC_VER)
+# define SIMULATE_ID "MSVC"
+# endif
+# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
+# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
+# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
+# if defined(_MSC_VER)
+ /* _MSC_VER = VVRR */
+# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
+# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
+# endif
+
+#elif defined(__GNUC__)
+# define COMPILER_ID "GNU"
+# define COMPILER_VERSION_MAJOR DEC(__GNUC__)
+# if defined(__GNUC_MINOR__)
+# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
+# endif
+# if defined(__GNUC_PATCHLEVEL__)
+# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
+# endif
+
+#elif defined(_MSC_VER)
+# define COMPILER_ID "MSVC"
+ /* _MSC_VER = VVRR */
+# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
+# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
+# if defined(_MSC_FULL_VER)
+# if _MSC_VER >= 1400
+ /* _MSC_FULL_VER = VVRRPPPPP */
+# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
+# else
+ /* _MSC_FULL_VER = VVRRPPPP */
+# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
+# endif
+# endif
+# if defined(_MSC_BUILD)
+# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
+# endif
+
+#elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
+# define COMPILER_ID "ADSP"
+#if defined(__VISUALDSPVERSION__)
+ /* __VISUALDSPVERSION__ = 0xVVRRPP00 */
+# define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
+# define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
+# define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF)
+#endif
+
+#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
+# define COMPILER_ID "IAR"
+# if defined(__VER__) && defined(__ICCARM__)
+# define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000)
+# define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000)
+# define COMPILER_VERSION_PATCH DEC((__VER__) % 1000)
+# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
+# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__) || defined(__ICC8051__))
+# define COMPILER_VERSION_MAJOR DEC((__VER__) / 100)
+# define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100))
+# define COMPILER_VERSION_PATCH DEC(__SUBVERSION__)
+# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
+# endif
+
+#elif defined(__SDCC_VERSION_MAJOR) || defined(SDCC)
+# define COMPILER_ID "SDCC"
+# if defined(__SDCC_VERSION_MAJOR)
+# define COMPILER_VERSION_MAJOR DEC(__SDCC_VERSION_MAJOR)
+# define COMPILER_VERSION_MINOR DEC(__SDCC_VERSION_MINOR)
+# define COMPILER_VERSION_PATCH DEC(__SDCC_VERSION_PATCH)
+# else
+ /* SDCC = VRP */
+# define COMPILER_VERSION_MAJOR DEC(SDCC/100)
+# define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10)
+# define COMPILER_VERSION_PATCH DEC(SDCC % 10)
+# endif
+
+
+/* These compilers are either not known or too old to define an
+ identification macro. Try to identify the platform and guess that
+ it is the native compiler. */
+#elif defined(__hpux) || defined(__hpua)
+# define COMPILER_ID "HP"
+
+#else /* unknown compiler */
+# define COMPILER_ID ""
+#endif
+
+/* Construct the string literal in pieces to prevent the source from
+ getting matched. Store it in a pointer rather than an array
+ because some compilers will just produce instructions to fill the
+ array rather than assigning a pointer to a static array. */
+char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
+#ifdef SIMULATE_ID
+char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
+#endif
+
+#ifdef __QNXNTO__
+char const* qnxnto = "INFO" ":" "qnxnto[]";
+#endif
+
+#if defined(__CRAYXE) || defined(__CRAYXC)
+char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
+#endif
+
+#define STRINGIFY_HELPER(X) #X
+#define STRINGIFY(X) STRINGIFY_HELPER(X)
+
+/* Identify known platforms by name. */
+#if defined(__linux) || defined(__linux__) || defined(linux)
+# define PLATFORM_ID "Linux"
+
+#elif defined(__CYGWIN__)
+# define PLATFORM_ID "Cygwin"
+
+#elif defined(__MINGW32__)
+# define PLATFORM_ID "MinGW"
+
+#elif defined(__APPLE__)
+# define PLATFORM_ID "Darwin"
+
+#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
+# define PLATFORM_ID "Windows"
+
+#elif defined(__FreeBSD__) || defined(__FreeBSD)
+# define PLATFORM_ID "FreeBSD"
+
+#elif defined(__NetBSD__) || defined(__NetBSD)
+# define PLATFORM_ID "NetBSD"
+
+#elif defined(__OpenBSD__) || defined(__OPENBSD)
+# define PLATFORM_ID "OpenBSD"
+
+#elif defined(__sun) || defined(sun)
+# define PLATFORM_ID "SunOS"
+
+#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
+# define PLATFORM_ID "AIX"
+
+#elif defined(__hpux) || defined(__hpux__)
+# define PLATFORM_ID "HP-UX"
+
+#elif defined(__HAIKU__)
+# define PLATFORM_ID "Haiku"
+
+#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
+# define PLATFORM_ID "BeOS"
+
+#elif defined(__QNX__) || defined(__QNXNTO__)
+# define PLATFORM_ID "QNX"
+
+#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
+# define PLATFORM_ID "Tru64"
+
+#elif defined(__riscos) || defined(__riscos__)
+# define PLATFORM_ID "RISCos"
+
+#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
+# define PLATFORM_ID "SINIX"
+
+#elif defined(__UNIX_SV__)
+# define PLATFORM_ID "UNIX_SV"
+
+#elif defined(__bsdos__)
+# define PLATFORM_ID "BSDOS"
+
+#elif defined(_MPRAS) || defined(MPRAS)
+# define PLATFORM_ID "MP-RAS"
+
+#elif defined(__osf) || defined(__osf__)
+# define PLATFORM_ID "OSF1"
+
+#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
+# define PLATFORM_ID "SCO_SV"
+
+#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
+# define PLATFORM_ID "ULTRIX"
+
+#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
+# define PLATFORM_ID "Xenix"
+
+#elif defined(__WATCOMC__)
+# if defined(__LINUX__)
+# define PLATFORM_ID "Linux"
+
+# elif defined(__DOS__)
+# define PLATFORM_ID "DOS"
+
+# elif defined(__OS2__)
+# define PLATFORM_ID "OS2"
+
+# elif defined(__WINDOWS__)
+# define PLATFORM_ID "Windows3x"
+
+# else /* unknown platform */
+# define PLATFORM_ID
+# endif
+
+#elif defined(__INTEGRITY)
+# if defined(INT_178B)
+# define PLATFORM_ID "Integrity178"
+
+# else /* regular Integrity */
+# define PLATFORM_ID "Integrity"
+# endif
+
+#else /* unknown platform */
+# define PLATFORM_ID
+
+#endif
+
+/* For windows compilers MSVC and Intel we can determine
+ the architecture of the compiler being used. This is because
+ the compilers do not have flags that can change the architecture,
+ but rather depend on which compiler is being used
+*/
+#if defined(_WIN32) && defined(_MSC_VER)
+# if defined(_M_IA64)
+# define ARCHITECTURE_ID "IA64"
+
+# elif defined(_M_X64) || defined(_M_AMD64)
+# define ARCHITECTURE_ID "x64"
+
+# elif defined(_M_IX86)
+# define ARCHITECTURE_ID "X86"
+
+# elif defined(_M_ARM64)
+# define ARCHITECTURE_ID "ARM64"
+
+# elif defined(_M_ARM)
+# if _M_ARM == 4
+# define ARCHITECTURE_ID "ARMV4I"
+# elif _M_ARM == 5
+# define ARCHITECTURE_ID "ARMV5I"
+# else
+# define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM)
+# endif
+
+# elif defined(_M_MIPS)
+# define ARCHITECTURE_ID "MIPS"
+
+# elif defined(_M_SH)
+# define ARCHITECTURE_ID "SHx"
+
+# else /* unknown architecture */
+# define ARCHITECTURE_ID ""
+# endif
+
+#elif defined(__WATCOMC__)
+# if defined(_M_I86)
+# define ARCHITECTURE_ID "I86"
+
+# elif defined(_M_IX86)
+# define ARCHITECTURE_ID "X86"
+
+# else /* unknown architecture */
+# define ARCHITECTURE_ID ""
+# endif
+
+#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
+# if defined(__ICCARM__)
+# define ARCHITECTURE_ID "ARM"
+
+# elif defined(__ICCRX__)
+# define ARCHITECTURE_ID "RX"
+
+# elif defined(__ICCRH850__)
+# define ARCHITECTURE_ID "RH850"
+
+# elif defined(__ICCRL78__)
+# define ARCHITECTURE_ID "RL78"
+
+# elif defined(__ICCRISCV__)
+# define ARCHITECTURE_ID "RISCV"
+
+# elif defined(__ICCAVR__)
+# define ARCHITECTURE_ID "AVR"
+
+# elif defined(__ICC430__)
+# define ARCHITECTURE_ID "MSP430"
+
+# elif defined(__ICCV850__)
+# define ARCHITECTURE_ID "V850"
+
+# elif defined(__ICC8051__)
+# define ARCHITECTURE_ID "8051"
+
+# else /* unknown architecture */
+# define ARCHITECTURE_ID ""
+# endif
+
+#elif defined(__ghs__)
+# if defined(__PPC64__)
+# define ARCHITECTURE_ID "PPC64"
+
+# elif defined(__ppc__)
+# define ARCHITECTURE_ID "PPC"
+
+# elif defined(__ARM__)
+# define ARCHITECTURE_ID "ARM"
+
+# elif defined(__x86_64__)
+# define ARCHITECTURE_ID "x64"
+
+# elif defined(__i386__)
+# define ARCHITECTURE_ID "X86"
+
+# else /* unknown architecture */
+# define ARCHITECTURE_ID ""
+# endif
+#else
+# define ARCHITECTURE_ID
+#endif
+
+/* Convert integer to decimal digit literals. */
+#define DEC(n) \
+ ('0' + (((n) / 10000000)%10)), \
+ ('0' + (((n) / 1000000)%10)), \
+ ('0' + (((n) / 100000)%10)), \
+ ('0' + (((n) / 10000)%10)), \
+ ('0' + (((n) / 1000)%10)), \
+ ('0' + (((n) / 100)%10)), \
+ ('0' + (((n) / 10)%10)), \
+ ('0' + ((n) % 10))
+
+/* Convert integer to hex digit literals. */
+#define HEX(n) \
+ ('0' + ((n)>>28 & 0xF)), \
+ ('0' + ((n)>>24 & 0xF)), \
+ ('0' + ((n)>>20 & 0xF)), \
+ ('0' + ((n)>>16 & 0xF)), \
+ ('0' + ((n)>>12 & 0xF)), \
+ ('0' + ((n)>>8 & 0xF)), \
+ ('0' + ((n)>>4 & 0xF)), \
+ ('0' + ((n) & 0xF))
+
+/* Construct a string literal encoding the version number components. */
+#ifdef COMPILER_VERSION_MAJOR
+char const info_version[] = {
+ 'I', 'N', 'F', 'O', ':',
+ 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
+ COMPILER_VERSION_MAJOR,
+# ifdef COMPILER_VERSION_MINOR
+ '.', COMPILER_VERSION_MINOR,
+# ifdef COMPILER_VERSION_PATCH
+ '.', COMPILER_VERSION_PATCH,
+# ifdef COMPILER_VERSION_TWEAK
+ '.', COMPILER_VERSION_TWEAK,
+# endif
+# endif
+# endif
+ ']','\0'};
+#endif
+
+/* Construct a string literal encoding the internal version number. */
+#ifdef COMPILER_VERSION_INTERNAL
+char const info_version_internal[] = {
+ 'I', 'N', 'F', 'O', ':',
+ 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',
+ 'i','n','t','e','r','n','a','l','[',
+ COMPILER_VERSION_INTERNAL,']','\0'};
+#endif
+
+/* Construct a string literal encoding the version number components. */
+#ifdef SIMULATE_VERSION_MAJOR
+char const info_simulate_version[] = {
+ 'I', 'N', 'F', 'O', ':',
+ 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',
+ SIMULATE_VERSION_MAJOR,
+# ifdef SIMULATE_VERSION_MINOR
+ '.', SIMULATE_VERSION_MINOR,
+# ifdef SIMULATE_VERSION_PATCH
+ '.', SIMULATE_VERSION_PATCH,
+# ifdef SIMULATE_VERSION_TWEAK
+ '.', SIMULATE_VERSION_TWEAK,
+# endif
+# endif
+# endif
+ ']','\0'};
+#endif
+
+/* Construct the string literal in pieces to prevent the source from
+ getting matched. Store it in a pointer rather than an array
+ because some compilers will just produce instructions to fill the
+ array rather than assigning a pointer to a static array. */
+char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
+char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
+
+
+
+
+#if !defined(__STDC__)
+# if (defined(_MSC_VER) && !defined(__clang__)) \
+ || (defined(__ibmxl__) || defined(__IBMC__))
+# define C_DIALECT "90"
+# else
+# define C_DIALECT
+# endif
+#elif __STDC_VERSION__ >= 201000L
+# define C_DIALECT "11"
+#elif __STDC_VERSION__ >= 199901L
+# define C_DIALECT "99"
+#else
+# define C_DIALECT "90"
+#endif
+const char* info_language_dialect_default =
+ "INFO" ":" "dialect_default[" C_DIALECT "]";
+
+/*--------------------------------------------------------------------------*/
+
+#ifdef ID_VOID_MAIN
+void main() {}
+#else
+# if defined(__CLASSIC_C__)
+int main(argc, argv) int argc; char *argv[];
+# else
+int main(int argc, char* argv[])
+# endif
+{
+ int require = 0;
+ require += info_compiler[argc];
+ require += info_platform[argc];
+ require += info_arch[argc];
+#ifdef COMPILER_VERSION_MAJOR
+ require += info_version[argc];
+#endif
+#ifdef COMPILER_VERSION_INTERNAL
+ require += info_version_internal[argc];
+#endif
+#ifdef SIMULATE_ID
+ require += info_simulate[argc];
+#endif
+#ifdef SIMULATE_VERSION_MAJOR
+ require += info_simulate_version[argc];
+#endif
+#if defined(__CRAYXE) || defined(__CRAYXC)
+ require += info_cray[argc];
+#endif
+ require += info_language_dialect_default[argc];
+ (void)argv;
+ return require;
+}
+#endif
diff --git a/software/main/build/CMakeFiles/3.16.3/CompilerIdC/a.out b/software/main/build/CMakeFiles/3.16.3/CompilerIdC/a.out
new file mode 100644
index 0000000..46f1233
--- /dev/null
+++ b/software/main/build/CMakeFiles/3.16.3/CompilerIdC/a.out
Binary files differ
diff --git a/software/main/build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp b/software/main/build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp
new file mode 100644
index 0000000..69cfdba
--- /dev/null
+++ b/software/main/build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp
@@ -0,0 +1,660 @@
+/* This source file must have a .cpp extension so that all C++ compilers
+ recognize the extension without flags. Borland does not know .cxx for
+ example. */
+#ifndef __cplusplus
+# error "A C compiler has been selected for C++."
+#endif
+
+
+/* Version number components: V=Version, R=Revision, P=Patch
+ Version date components: YYYY=Year, MM=Month, DD=Day */
+
+#if defined(__COMO__)
+# define COMPILER_ID "Comeau"
+ /* __COMO_VERSION__ = VRR */
+# define COMPILER_VERSION_MAJOR DEC(__COMO_VERSION__ / 100)
+# define COMPILER_VERSION_MINOR DEC(__COMO_VERSION__ % 100)
+
+#elif defined(__INTEL_COMPILER) || defined(__ICC)
+# define COMPILER_ID "Intel"
+# if defined(_MSC_VER)
+# define SIMULATE_ID "MSVC"
+# endif
+# if defined(__GNUC__)
+# define SIMULATE_ID "GNU"
+# endif
+ /* __INTEL_COMPILER = VRP */
+# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
+# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
+# if defined(__INTEL_COMPILER_UPDATE)
+# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE)
+# else
+# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
+# endif
+# if defined(__INTEL_COMPILER_BUILD_DATE)
+ /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
+# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
+# endif
+# if defined(_MSC_VER)
+ /* _MSC_VER = VVRR */
+# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
+# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
+# endif
+# if defined(__GNUC__)
+# define SIMULATE_VERSION_MAJOR DEC(__GNUC__)
+# elif defined(__GNUG__)
+# define SIMULATE_VERSION_MAJOR DEC(__GNUG__)
+# endif
+# if defined(__GNUC_MINOR__)
+# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__)
+# endif
+# if defined(__GNUC_PATCHLEVEL__)
+# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
+# endif
+
+#elif defined(__PATHCC__)
+# define COMPILER_ID "PathScale"
+# define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
+# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
+# if defined(__PATHCC_PATCHLEVEL__)
+# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
+# endif
+
+#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
+# define COMPILER_ID "Embarcadero"
+# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
+# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
+# define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF)
+
+#elif defined(__BORLANDC__)
+# define COMPILER_ID "Borland"
+ /* __BORLANDC__ = 0xVRR */
+# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
+# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
+
+#elif defined(__WATCOMC__) && __WATCOMC__ < 1200
+# define COMPILER_ID "Watcom"
+ /* __WATCOMC__ = VVRR */
+# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
+# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
+# if (__WATCOMC__ % 10) > 0
+# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
+# endif
+
+#elif defined(__WATCOMC__)
+# define COMPILER_ID "OpenWatcom"
+ /* __WATCOMC__ = VVRP + 1100 */
+# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100)
+# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
+# if (__WATCOMC__ % 10) > 0
+# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
+# endif
+
+#elif defined(__SUNPRO_CC)
+# define COMPILER_ID "SunPro"
+# if __SUNPRO_CC >= 0x5100
+ /* __SUNPRO_CC = 0xVRRP */
+# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12)
+# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF)
+# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
+# else
+ /* __SUNPRO_CC = 0xVRP */
+# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8)
+# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF)
+# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
+# endif
+
+#elif defined(__HP_aCC)
+# define COMPILER_ID "HP"
+ /* __HP_aCC = VVRRPP */
+# define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000)
+# define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100)
+# define COMPILER_VERSION_PATCH DEC(__HP_aCC % 100)
+
+#elif defined(__DECCXX)
+# define COMPILER_ID "Compaq"
+ /* __DECCXX_VER = VVRRTPPPP */
+# define COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000)
+# define COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000 % 100)
+# define COMPILER_VERSION_PATCH DEC(__DECCXX_VER % 10000)
+
+#elif defined(__IBMCPP__) && defined(__COMPILER_VER__)
+# define COMPILER_ID "zOS"
+ /* __IBMCPP__ = VRP */
+# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
+# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
+# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
+
+#elif defined(__ibmxl__) && defined(__clang__)
+# define COMPILER_ID "XLClang"
+# define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__)
+# define COMPILER_VERSION_MINOR DEC(__ibmxl_release__)
+# define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__)
+# define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__)
+
+
+#elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ >= 800
+# define COMPILER_ID "XL"
+ /* __IBMCPP__ = VRP */
+# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
+# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
+# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
+
+#elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ < 800
+# define COMPILER_ID "VisualAge"
+ /* __IBMCPP__ = VRP */
+# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
+# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
+# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
+
+#elif defined(__PGI)
+# define COMPILER_ID "PGI"
+# define COMPILER_VERSION_MAJOR DEC(__PGIC__)
+# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
+# if defined(__PGIC_PATCHLEVEL__)
+# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
+# endif
+
+#elif defined(_CRAYC)
+# define COMPILER_ID "Cray"
+# define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR)
+# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
+
+#elif defined(__TI_COMPILER_VERSION__)
+# define COMPILER_ID "TI"
+ /* __TI_COMPILER_VERSION__ = VVVRRRPPP */
+# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
+# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
+# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
+
+#elif defined(__FUJITSU) || defined(__FCC_VERSION) || defined(__fcc_version)
+# define COMPILER_ID "Fujitsu"
+
+#elif defined(__ghs__)
+# define COMPILER_ID "GHS"
+/* __GHS_VERSION_NUMBER = VVVVRP */
+# ifdef __GHS_VERSION_NUMBER
+# define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100)
+# define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10)
+# define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10)
+# endif
+
+#elif defined(__SCO_VERSION__)
+# define COMPILER_ID "SCO"
+
+#elif defined(__ARMCC_VERSION) && !defined(__clang__)
+# define COMPILER_ID "ARMCC"
+#if __ARMCC_VERSION >= 1000000
+ /* __ARMCC_VERSION = VRRPPPP */
+ # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000)
+ # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100)
+ # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
+#else
+ /* __ARMCC_VERSION = VRPPPP */
+ # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000)
+ # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10)
+ # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
+#endif
+
+
+#elif defined(__clang__) && defined(__apple_build_version__)
+# define COMPILER_ID "AppleClang"
+# if defined(_MSC_VER)
+# define SIMULATE_ID "MSVC"
+# endif
+# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
+# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
+# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
+# if defined(_MSC_VER)
+ /* _MSC_VER = VVRR */
+# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
+# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
+# endif
+# define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
+
+#elif defined(__clang__) && defined(__ARMCOMPILER_VERSION)
+# define COMPILER_ID "ARMClang"
+ # define COMPILER_VERSION_MAJOR DEC(__ARMCOMPILER_VERSION/1000000)
+ # define COMPILER_VERSION_MINOR DEC(__ARMCOMPILER_VERSION/10000 % 100)
+ # define COMPILER_VERSION_PATCH DEC(__ARMCOMPILER_VERSION % 10000)
+# define COMPILER_VERSION_INTERNAL DEC(__ARMCOMPILER_VERSION)
+
+#elif defined(__clang__)
+# define COMPILER_ID "Clang"
+# if defined(_MSC_VER)
+# define SIMULATE_ID "MSVC"
+# endif
+# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
+# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
+# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
+# if defined(_MSC_VER)
+ /* _MSC_VER = VVRR */
+# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
+# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
+# endif
+
+#elif defined(__GNUC__) || defined(__GNUG__)
+# define COMPILER_ID "GNU"
+# if defined(__GNUC__)
+# define COMPILER_VERSION_MAJOR DEC(__GNUC__)
+# else
+# define COMPILER_VERSION_MAJOR DEC(__GNUG__)
+# endif
+# if defined(__GNUC_MINOR__)
+# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
+# endif
+# if defined(__GNUC_PATCHLEVEL__)
+# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
+# endif
+
+#elif defined(_MSC_VER)
+# define COMPILER_ID "MSVC"
+ /* _MSC_VER = VVRR */
+# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
+# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
+# if defined(_MSC_FULL_VER)
+# if _MSC_VER >= 1400
+ /* _MSC_FULL_VER = VVRRPPPPP */
+# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
+# else
+ /* _MSC_FULL_VER = VVRRPPPP */
+# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
+# endif
+# endif
+# if defined(_MSC_BUILD)
+# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
+# endif
+
+#elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
+# define COMPILER_ID "ADSP"
+#if defined(__VISUALDSPVERSION__)
+ /* __VISUALDSPVERSION__ = 0xVVRRPP00 */
+# define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
+# define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
+# define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF)
+#endif
+
+#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
+# define COMPILER_ID "IAR"
+# if defined(__VER__) && defined(__ICCARM__)
+# define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000)
+# define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000)
+# define COMPILER_VERSION_PATCH DEC((__VER__) % 1000)
+# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
+# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__) || defined(__ICC8051__))
+# define COMPILER_VERSION_MAJOR DEC((__VER__) / 100)
+# define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100))
+# define COMPILER_VERSION_PATCH DEC(__SUBVERSION__)
+# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
+# endif
+
+
+/* These compilers are either not known or too old to define an
+ identification macro. Try to identify the platform and guess that
+ it is the native compiler. */
+#elif defined(__hpux) || defined(__hpua)
+# define COMPILER_ID "HP"
+
+#else /* unknown compiler */
+# define COMPILER_ID ""
+#endif
+
+/* Construct the string literal in pieces to prevent the source from
+ getting matched. Store it in a pointer rather than an array
+ because some compilers will just produce instructions to fill the
+ array rather than assigning a pointer to a static array. */
+char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
+#ifdef SIMULATE_ID
+char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
+#endif
+
+#ifdef __QNXNTO__
+char const* qnxnto = "INFO" ":" "qnxnto[]";
+#endif
+
+#if defined(__CRAYXE) || defined(__CRAYXC)
+char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
+#endif
+
+#define STRINGIFY_HELPER(X) #X
+#define STRINGIFY(X) STRINGIFY_HELPER(X)
+
+/* Identify known platforms by name. */
+#if defined(__linux) || defined(__linux__) || defined(linux)
+# define PLATFORM_ID "Linux"
+
+#elif defined(__CYGWIN__)
+# define PLATFORM_ID "Cygwin"
+
+#elif defined(__MINGW32__)
+# define PLATFORM_ID "MinGW"
+
+#elif defined(__APPLE__)
+# define PLATFORM_ID "Darwin"
+
+#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
+# define PLATFORM_ID "Windows"
+
+#elif defined(__FreeBSD__) || defined(__FreeBSD)
+# define PLATFORM_ID "FreeBSD"
+
+#elif defined(__NetBSD__) || defined(__NetBSD)
+# define PLATFORM_ID "NetBSD"
+
+#elif defined(__OpenBSD__) || defined(__OPENBSD)
+# define PLATFORM_ID "OpenBSD"
+
+#elif defined(__sun) || defined(sun)
+# define PLATFORM_ID "SunOS"
+
+#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
+# define PLATFORM_ID "AIX"
+
+#elif defined(__hpux) || defined(__hpux__)
+# define PLATFORM_ID "HP-UX"
+
+#elif defined(__HAIKU__)
+# define PLATFORM_ID "Haiku"
+
+#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
+# define PLATFORM_ID "BeOS"
+
+#elif defined(__QNX__) || defined(__QNXNTO__)
+# define PLATFORM_ID "QNX"
+
+#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
+# define PLATFORM_ID "Tru64"
+
+#elif defined(__riscos) || defined(__riscos__)
+# define PLATFORM_ID "RISCos"
+
+#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
+# define PLATFORM_ID "SINIX"
+
+#elif defined(__UNIX_SV__)
+# define PLATFORM_ID "UNIX_SV"
+
+#elif defined(__bsdos__)
+# define PLATFORM_ID "BSDOS"
+
+#elif defined(_MPRAS) || defined(MPRAS)
+# define PLATFORM_ID "MP-RAS"
+
+#elif defined(__osf) || defined(__osf__)
+# define PLATFORM_ID "OSF1"
+
+#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
+# define PLATFORM_ID "SCO_SV"
+
+#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
+# define PLATFORM_ID "ULTRIX"
+
+#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
+# define PLATFORM_ID "Xenix"
+
+#elif defined(__WATCOMC__)
+# if defined(__LINUX__)
+# define PLATFORM_ID "Linux"
+
+# elif defined(__DOS__)
+# define PLATFORM_ID "DOS"
+
+# elif defined(__OS2__)
+# define PLATFORM_ID "OS2"
+
+# elif defined(__WINDOWS__)
+# define PLATFORM_ID "Windows3x"
+
+# else /* unknown platform */
+# define PLATFORM_ID
+# endif
+
+#elif defined(__INTEGRITY)
+# if defined(INT_178B)
+# define PLATFORM_ID "Integrity178"
+
+# else /* regular Integrity */
+# define PLATFORM_ID "Integrity"
+# endif
+
+#else /* unknown platform */
+# define PLATFORM_ID
+
+#endif
+
+/* For windows compilers MSVC and Intel we can determine
+ the architecture of the compiler being used. This is because
+ the compilers do not have flags that can change the architecture,
+ but rather depend on which compiler is being used
+*/
+#if defined(_WIN32) && defined(_MSC_VER)
+# if defined(_M_IA64)
+# define ARCHITECTURE_ID "IA64"
+
+# elif defined(_M_X64) || defined(_M_AMD64)
+# define ARCHITECTURE_ID "x64"
+
+# elif defined(_M_IX86)
+# define ARCHITECTURE_ID "X86"
+
+# elif defined(_M_ARM64)
+# define ARCHITECTURE_ID "ARM64"
+
+# elif defined(_M_ARM)
+# if _M_ARM == 4
+# define ARCHITECTURE_ID "ARMV4I"
+# elif _M_ARM == 5
+# define ARCHITECTURE_ID "ARMV5I"
+# else
+# define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM)
+# endif
+
+# elif defined(_M_MIPS)
+# define ARCHITECTURE_ID "MIPS"
+
+# elif defined(_M_SH)
+# define ARCHITECTURE_ID "SHx"
+
+# else /* unknown architecture */
+# define ARCHITECTURE_ID ""
+# endif
+
+#elif defined(__WATCOMC__)
+# if defined(_M_I86)
+# define ARCHITECTURE_ID "I86"
+
+# elif defined(_M_IX86)
+# define ARCHITECTURE_ID "X86"
+
+# else /* unknown architecture */
+# define ARCHITECTURE_ID ""
+# endif
+
+#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
+# if defined(__ICCARM__)
+# define ARCHITECTURE_ID "ARM"
+
+# elif defined(__ICCRX__)
+# define ARCHITECTURE_ID "RX"
+
+# elif defined(__ICCRH850__)
+# define ARCHITECTURE_ID "RH850"
+
+# elif defined(__ICCRL78__)
+# define ARCHITECTURE_ID "RL78"
+
+# elif defined(__ICCRISCV__)
+# define ARCHITECTURE_ID "RISCV"
+
+# elif defined(__ICCAVR__)
+# define ARCHITECTURE_ID "AVR"
+
+# elif defined(__ICC430__)
+# define ARCHITECTURE_ID "MSP430"
+
+# elif defined(__ICCV850__)
+# define ARCHITECTURE_ID "V850"
+
+# elif defined(__ICC8051__)
+# define ARCHITECTURE_ID "8051"
+
+# else /* unknown architecture */
+# define ARCHITECTURE_ID ""
+# endif
+
+#elif defined(__ghs__)
+# if defined(__PPC64__)
+# define ARCHITECTURE_ID "PPC64"
+
+# elif defined(__ppc__)
+# define ARCHITECTURE_ID "PPC"
+
+# elif defined(__ARM__)
+# define ARCHITECTURE_ID "ARM"
+
+# elif defined(__x86_64__)
+# define ARCHITECTURE_ID "x64"
+
+# elif defined(__i386__)
+# define ARCHITECTURE_ID "X86"
+
+# else /* unknown architecture */
+# define ARCHITECTURE_ID ""
+# endif
+#else
+# define ARCHITECTURE_ID
+#endif
+
+/* Convert integer to decimal digit literals. */
+#define DEC(n) \
+ ('0' + (((n) / 10000000)%10)), \
+ ('0' + (((n) / 1000000)%10)), \
+ ('0' + (((n) / 100000)%10)), \
+ ('0' + (((n) / 10000)%10)), \
+ ('0' + (((n) / 1000)%10)), \
+ ('0' + (((n) / 100)%10)), \
+ ('0' + (((n) / 10)%10)), \
+ ('0' + ((n) % 10))
+
+/* Convert integer to hex digit literals. */
+#define HEX(n) \
+ ('0' + ((n)>>28 & 0xF)), \
+ ('0' + ((n)>>24 & 0xF)), \
+ ('0' + ((n)>>20 & 0xF)), \
+ ('0' + ((n)>>16 & 0xF)), \
+ ('0' + ((n)>>12 & 0xF)), \
+ ('0' + ((n)>>8 & 0xF)), \
+ ('0' + ((n)>>4 & 0xF)), \
+ ('0' + ((n) & 0xF))
+
+/* Construct a string literal encoding the version number components. */
+#ifdef COMPILER_VERSION_MAJOR
+char const info_version[] = {
+ 'I', 'N', 'F', 'O', ':',
+ 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
+ COMPILER_VERSION_MAJOR,
+# ifdef COMPILER_VERSION_MINOR
+ '.', COMPILER_VERSION_MINOR,
+# ifdef COMPILER_VERSION_PATCH
+ '.', COMPILER_VERSION_PATCH,
+# ifdef COMPILER_VERSION_TWEAK
+ '.', COMPILER_VERSION_TWEAK,
+# endif
+# endif
+# endif
+ ']','\0'};
+#endif
+
+/* Construct a string literal encoding the internal version number. */
+#ifdef COMPILER_VERSION_INTERNAL
+char const info_version_internal[] = {
+ 'I', 'N', 'F', 'O', ':',
+ 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',
+ 'i','n','t','e','r','n','a','l','[',
+ COMPILER_VERSION_INTERNAL,']','\0'};
+#endif
+
+/* Construct a string literal encoding the version number components. */
+#ifdef SIMULATE_VERSION_MAJOR
+char const info_simulate_version[] = {
+ 'I', 'N', 'F', 'O', ':',
+ 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',
+ SIMULATE_VERSION_MAJOR,
+# ifdef SIMULATE_VERSION_MINOR
+ '.', SIMULATE_VERSION_MINOR,
+# ifdef SIMULATE_VERSION_PATCH
+ '.', SIMULATE_VERSION_PATCH,
+# ifdef SIMULATE_VERSION_TWEAK
+ '.', SIMULATE_VERSION_TWEAK,
+# endif
+# endif
+# endif
+ ']','\0'};
+#endif
+
+/* Construct the string literal in pieces to prevent the source from
+ getting matched. Store it in a pointer rather than an array
+ because some compilers will just produce instructions to fill the
+ array rather than assigning a pointer to a static array. */
+char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
+char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
+
+
+
+
+#if defined(__INTEL_COMPILER) && defined(_MSVC_LANG) && _MSVC_LANG < 201403L
+# if defined(__INTEL_CXX11_MODE__)
+# if defined(__cpp_aggregate_nsdmi)
+# define CXX_STD 201402L
+# else
+# define CXX_STD 201103L
+# endif
+# else
+# define CXX_STD 199711L
+# endif
+#elif defined(_MSC_VER) && defined(_MSVC_LANG)
+# define CXX_STD _MSVC_LANG
+#else
+# define CXX_STD __cplusplus
+#endif
+
+const char* info_language_dialect_default = "INFO" ":" "dialect_default["
+#if CXX_STD > 201703L
+ "20"
+#elif CXX_STD >= 201703L
+ "17"
+#elif CXX_STD >= 201402L
+ "14"
+#elif CXX_STD >= 201103L
+ "11"
+#else
+ "98"
+#endif
+"]";
+
+/*--------------------------------------------------------------------------*/
+
+int main(int argc, char* argv[])
+{
+ int require = 0;
+ require += info_compiler[argc];
+ require += info_platform[argc];
+#ifdef COMPILER_VERSION_MAJOR
+ require += info_version[argc];
+#endif
+#ifdef COMPILER_VERSION_INTERNAL
+ require += info_version_internal[argc];
+#endif
+#ifdef SIMULATE_ID
+ require += info_simulate[argc];
+#endif
+#ifdef SIMULATE_VERSION_MAJOR
+ require += info_simulate_version[argc];
+#endif
+#if defined(__CRAYXE) || defined(__CRAYXC)
+ require += info_cray[argc];
+#endif
+ require += info_language_dialect_default[argc];
+ (void)argv;
+ return require;
+}
diff --git a/software/main/build/CMakeFiles/3.16.3/CompilerIdCXX/a.out b/software/main/build/CMakeFiles/3.16.3/CompilerIdCXX/a.out
new file mode 100644
index 0000000..c868426
--- /dev/null
+++ b/software/main/build/CMakeFiles/3.16.3/CompilerIdCXX/a.out
Binary files differ
diff --git a/software/main/build/CMakeFiles/CMakeOutput.log b/software/main/build/CMakeFiles/CMakeOutput.log
new file mode 100644
index 0000000..fba2dae
--- /dev/null
+++ b/software/main/build/CMakeFiles/CMakeOutput.log
@@ -0,0 +1,429 @@
+The system is: Linux - 5.11.0-43-generic - x86_64
+Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
+Compiler: /usr/bin/cc
+Build flags:
+Id flags:
+
+The output was:
+0
+
+
+Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.out"
+
+The C compiler identification is GNU, found in "/home/steffen/scaladis/schrank_ant_pcb/main/build/CMakeFiles/3.16.3/CompilerIdC/a.out"
+
+Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
+Compiler: /usr/bin/c++
+Build flags:
+Id flags:
+
+The output was:
+0
+
+
+Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out"
+
+The CXX compiler identification is GNU, found in "/home/steffen/scaladis/schrank_ant_pcb/main/build/CMakeFiles/3.16.3/CompilerIdCXX/a.out"
+
+Determining if the C compiler works passed with the following output:
+Change Dir: /home/steffen/scaladis/schrank_ant_pcb/main/build/CMakeFiles/CMakeTmp
+
+Run Build Command(s):/usr/bin/ninja cmTC_2eb2e && [1/2] Building C object CMakeFiles/cmTC_2eb2e.dir/testCCompiler.c.o
+[2/2] Linking C executable cmTC_2eb2e
+
+
+
+Detecting C compiler ABI info compiled with the following output:
+Change Dir: /home/steffen/scaladis/schrank_ant_pcb/main/build/CMakeFiles/CMakeTmp
+
+Run Build Command(s):/usr/bin/ninja cmTC_4ec92 && [1/2] Building C object CMakeFiles/cmTC_4ec92.dir/CMakeCCompilerABI.c.o
+Using built-in specs.
+COLLECT_GCC=/usr/bin/cc
+OFFLOAD_TARGET_NAMES=nvptx-none:hsa
+OFFLOAD_TARGET_DEFAULT=1
+Target: x86_64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
+Thread model: posix
+gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_4ec92.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=generic' '-march=x86-64'
+ /usr/lib/gcc/x86_64-linux-gnu/9/cc1 -quiet -v -imultiarch x86_64-linux-gnu /usr/share/cmake-3.16/Modules/CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_4ec92.dir/CMakeCCompilerABI.c.o -version -fasynchronous-unwind-tables -fstack-protector-strong -Wformat -Wformat-security -fstack-clash-protection -fcf-protection -o /tmp/ccL2lXYU.s
+GNU C17 (Ubuntu 9.3.0-17ubuntu1~20.04) version 9.3.0 (x86_64-linux-gnu)
+ compiled by GNU C version 9.3.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22.1-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
+ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/9/include-fixed"
+ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/lib/gcc/x86_64-linux-gnu/9/include
+ /usr/local/include
+ /usr/include/x86_64-linux-gnu
+ /usr/include
+End of search list.
+GNU C17 (Ubuntu 9.3.0-17ubuntu1~20.04) version 9.3.0 (x86_64-linux-gnu)
+ compiled by GNU C version 9.3.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22.1-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+Compiler executable checksum: bbf13931d8de1abe14040c9909cb6969
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_4ec92.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=generic' '-march=x86-64'
+ as -v --64 -o CMakeFiles/cmTC_4ec92.dir/CMakeCCompilerABI.c.o /tmp/ccL2lXYU.s
+GNU assembler version 2.34 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.34
+COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/
+LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_4ec92.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=generic' '-march=x86-64'
+[2/2] Linking C executable cmTC_4ec92
+Using built-in specs.
+COLLECT_GCC=/usr/bin/cc
+COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
+OFFLOAD_TARGET_NAMES=nvptx-none:hsa
+OFFLOAD_TARGET_DEFAULT=1
+Target: x86_64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
+Thread model: posix
+gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
+COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/
+LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_4ec92' '-mtune=generic' '-march=x86-64'
+ /usr/lib/gcc/x86_64-linux-gnu/9/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/9/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper -plugin-opt=-fresolution=/tmp/cczqceAf.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o cmTC_4ec92 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/9/../../.. CMakeFiles/cmTC_4ec92.dir/CMakeCCompilerABI.c.o -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o
+COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_4ec92' '-mtune=generic' '-march=x86-64'
+
+
+
+Parsed C implicit include dir info from above output: rv=done
+ found start of include info
+ found start of implicit include info
+ add: [/usr/lib/gcc/x86_64-linux-gnu/9/include]
+ add: [/usr/local/include]
+ add: [/usr/include/x86_64-linux-gnu]
+ add: [/usr/include]
+ end of search list found
+ collapse include dir [/usr/lib/gcc/x86_64-linux-gnu/9/include] ==> [/usr/lib/gcc/x86_64-linux-gnu/9/include]
+ collapse include dir [/usr/local/include] ==> [/usr/local/include]
+ collapse include dir [/usr/include/x86_64-linux-gnu] ==> [/usr/include/x86_64-linux-gnu]
+ collapse include dir [/usr/include] ==> [/usr/include]
+ implicit include dirs: [/usr/lib/gcc/x86_64-linux-gnu/9/include;/usr/local/include;/usr/include/x86_64-linux-gnu;/usr/include]
+
+
+Parsed C implicit link information from above output:
+ link line regex: [^( *|.*[/\])(ld|CMAKE_LINK_STARTFILE-NOTFOUND|([^/\]+-)?ld|collect2)[^/\]*( |$)]
+ ignore line: [Change Dir: /home/steffen/scaladis/schrank_ant_pcb/main/build/CMakeFiles/CMakeTmp]
+ ignore line: []
+ ignore line: [Run Build Command(s):/usr/bin/ninja cmTC_4ec92 && [1/2] Building C object CMakeFiles/cmTC_4ec92.dir/CMakeCCompilerABI.c.o]
+ ignore line: [Using built-in specs.]
+ ignore line: [COLLECT_GCC=/usr/bin/cc]
+ ignore line: [OFFLOAD_TARGET_NAMES=nvptx-none:hsa]
+ ignore line: [OFFLOAD_TARGET_DEFAULT=1]
+ ignore line: [Target: x86_64-linux-gnu]
+ ignore line: [Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c ada c++ go brig d fortran objc obj-c++ gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32 m64 mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu]
+ ignore line: [Thread model: posix]
+ ignore line: [gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) ]
+ ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_4ec92.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=generic' '-march=x86-64']
+ ignore line: [ /usr/lib/gcc/x86_64-linux-gnu/9/cc1 -quiet -v -imultiarch x86_64-linux-gnu /usr/share/cmake-3.16/Modules/CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_4ec92.dir/CMakeCCompilerABI.c.o -version -fasynchronous-unwind-tables -fstack-protector-strong -Wformat -Wformat-security -fstack-clash-protection -fcf-protection -o /tmp/ccL2lXYU.s]
+ ignore line: [GNU C17 (Ubuntu 9.3.0-17ubuntu1~20.04) version 9.3.0 (x86_64-linux-gnu)]
+ ignore line: [ compiled by GNU C version 9.3.0 GMP version 6.2.0 MPFR version 4.0.2 MPC version 1.1.0 isl version isl-0.22.1-GMP]
+ ignore line: []
+ ignore line: [GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072]
+ ignore line: [ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"]
+ ignore line: [ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/9/include-fixed"]
+ ignore line: [ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include"]
+ ignore line: [#include "..." search starts here:]
+ ignore line: [#include <...> search starts here:]
+ ignore line: [ /usr/lib/gcc/x86_64-linux-gnu/9/include]
+ ignore line: [ /usr/local/include]
+ ignore line: [ /usr/include/x86_64-linux-gnu]
+ ignore line: [ /usr/include]
+ ignore line: [End of search list.]
+ ignore line: [GNU C17 (Ubuntu 9.3.0-17ubuntu1~20.04) version 9.3.0 (x86_64-linux-gnu)]
+ ignore line: [ compiled by GNU C version 9.3.0 GMP version 6.2.0 MPFR version 4.0.2 MPC version 1.1.0 isl version isl-0.22.1-GMP]
+ ignore line: []
+ ignore line: [GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072]
+ ignore line: [Compiler executable checksum: bbf13931d8de1abe14040c9909cb6969]
+ ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_4ec92.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=generic' '-march=x86-64']
+ ignore line: [ as -v --64 -o CMakeFiles/cmTC_4ec92.dir/CMakeCCompilerABI.c.o /tmp/ccL2lXYU.s]
+ ignore line: [GNU assembler version 2.34 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.34]
+ ignore line: [COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/]
+ ignore line: [LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/]
+ ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_4ec92.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=generic' '-march=x86-64']
+ ignore line: [[2/2] Linking C executable cmTC_4ec92]
+ ignore line: [Using built-in specs.]
+ ignore line: [COLLECT_GCC=/usr/bin/cc]
+ ignore line: [COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper]
+ ignore line: [OFFLOAD_TARGET_NAMES=nvptx-none:hsa]
+ ignore line: [OFFLOAD_TARGET_DEFAULT=1]
+ ignore line: [Target: x86_64-linux-gnu]
+ ignore line: [Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c ada c++ go brig d fortran objc obj-c++ gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32 m64 mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu]
+ ignore line: [Thread model: posix]
+ ignore line: [gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) ]
+ ignore line: [COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/]
+ ignore line: [LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/]
+ ignore line: [COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_4ec92' '-mtune=generic' '-march=x86-64']
+ link line: [ /usr/lib/gcc/x86_64-linux-gnu/9/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/9/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper -plugin-opt=-fresolution=/tmp/cczqceAf.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o cmTC_4ec92 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/9/../../.. CMakeFiles/cmTC_4ec92.dir/CMakeCCompilerABI.c.o -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o]
+ arg [/usr/lib/gcc/x86_64-linux-gnu/9/collect2] ==> ignore
+ arg [-plugin] ==> ignore
+ arg [/usr/lib/gcc/x86_64-linux-gnu/9/liblto_plugin.so] ==> ignore
+ arg [-plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper] ==> ignore
+ arg [-plugin-opt=-fresolution=/tmp/cczqceAf.res] ==> ignore
+ arg [-plugin-opt=-pass-through=-lgcc] ==> ignore
+ arg [-plugin-opt=-pass-through=-lgcc_s] ==> ignore
+ arg [-plugin-opt=-pass-through=-lc] ==> ignore
+ arg [-plugin-opt=-pass-through=-lgcc] ==> ignore
+ arg [-plugin-opt=-pass-through=-lgcc_s] ==> ignore
+ arg [--build-id] ==> ignore
+ arg [--eh-frame-hdr] ==> ignore
+ arg [-m] ==> ignore
+ arg [elf_x86_64] ==> ignore
+ arg [--hash-style=gnu] ==> ignore
+ arg [--as-needed] ==> ignore
+ arg [-export-dynamic] ==> ignore
+ arg [-dynamic-linker] ==> ignore
+ arg [/lib64/ld-linux-x86-64.so.2] ==> ignore
+ arg [-pie] ==> ignore
+ arg [-znow] ==> ignore
+ arg [-zrelro] ==> ignore
+ arg [-o] ==> ignore
+ arg [cmTC_4ec92] ==> ignore
+ arg [/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o] ==> ignore
+ arg [/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o] ==> ignore
+ arg [/usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o] ==> ignore
+ arg [-L/usr/lib/gcc/x86_64-linux-gnu/9] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/9]
+ arg [-L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu]
+ arg [-L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib]
+ arg [-L/lib/x86_64-linux-gnu] ==> dir [/lib/x86_64-linux-gnu]
+ arg [-L/lib/../lib] ==> dir [/lib/../lib]
+ arg [-L/usr/lib/x86_64-linux-gnu] ==> dir [/usr/lib/x86_64-linux-gnu]
+ arg [-L/usr/lib/../lib] ==> dir [/usr/lib/../lib]
+ arg [-L/usr/lib/gcc/x86_64-linux-gnu/9/../../..] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../..]
+ arg [CMakeFiles/cmTC_4ec92.dir/CMakeCCompilerABI.c.o] ==> ignore
+ arg [-lgcc] ==> lib [gcc]
+ arg [--push-state] ==> ignore
+ arg [--as-needed] ==> ignore
+ arg [-lgcc_s] ==> lib [gcc_s]
+ arg [--pop-state] ==> ignore
+ arg [-lc] ==> lib [c]
+ arg [-lgcc] ==> lib [gcc]
+ arg [--push-state] ==> ignore
+ arg [--as-needed] ==> ignore
+ arg [-lgcc_s] ==> lib [gcc_s]
+ arg [--pop-state] ==> ignore
+ arg [/usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o] ==> ignore
+ arg [/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o] ==> ignore
+ collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/9] ==> [/usr/lib/gcc/x86_64-linux-gnu/9]
+ collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu] ==> [/usr/lib/x86_64-linux-gnu]
+ collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib] ==> [/usr/lib]
+ collapse library dir [/lib/x86_64-linux-gnu] ==> [/lib/x86_64-linux-gnu]
+ collapse library dir [/lib/../lib] ==> [/lib]
+ collapse library dir [/usr/lib/x86_64-linux-gnu] ==> [/usr/lib/x86_64-linux-gnu]
+ collapse library dir [/usr/lib/../lib] ==> [/usr/lib]
+ collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../..] ==> [/usr/lib]
+ implicit libs: [gcc;gcc_s;c;gcc;gcc_s]
+ implicit dirs: [/usr/lib/gcc/x86_64-linux-gnu/9;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib]
+ implicit fwks: []
+
+
+Determining if the CXX compiler works passed with the following output:
+Change Dir: /home/steffen/scaladis/schrank_ant_pcb/main/build/CMakeFiles/CMakeTmp
+
+Run Build Command(s):/usr/bin/ninja cmTC_a89a3 && [1/2] Building CXX object CMakeFiles/cmTC_a89a3.dir/testCXXCompiler.cxx.o
+[2/2] Linking CXX executable cmTC_a89a3
+
+
+
+Detecting CXX compiler ABI info compiled with the following output:
+Change Dir: /home/steffen/scaladis/schrank_ant_pcb/main/build/CMakeFiles/CMakeTmp
+
+Run Build Command(s):/usr/bin/ninja cmTC_5523e && [1/2] Building CXX object CMakeFiles/cmTC_5523e.dir/CMakeCXXCompilerABI.cpp.o
+Using built-in specs.
+COLLECT_GCC=/usr/bin/c++
+OFFLOAD_TARGET_NAMES=nvptx-none:hsa
+OFFLOAD_TARGET_DEFAULT=1
+Target: x86_64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
+Thread model: posix
+gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_5523e.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+ /usr/lib/gcc/x86_64-linux-gnu/9/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE /usr/share/cmake-3.16/Modules/CMakeCXXCompilerABI.cpp -quiet -dumpbase CMakeCXXCompilerABI.cpp -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_5523e.dir/CMakeCXXCompilerABI.cpp.o -version -fasynchronous-unwind-tables -fstack-protector-strong -Wformat -Wformat-security -fstack-clash-protection -fcf-protection -o /tmp/ccPwHizr.s
+GNU C++14 (Ubuntu 9.3.0-17ubuntu1~20.04) version 9.3.0 (x86_64-linux-gnu)
+ compiled by GNU C version 9.3.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22.1-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/9"
+ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
+ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/9/include-fixed"
+ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/include/c++/9
+ /usr/include/x86_64-linux-gnu/c++/9
+ /usr/include/c++/9/backward
+ /usr/lib/gcc/x86_64-linux-gnu/9/include
+ /usr/local/include
+ /usr/include/x86_64-linux-gnu
+ /usr/include
+End of search list.
+GNU C++14 (Ubuntu 9.3.0-17ubuntu1~20.04) version 9.3.0 (x86_64-linux-gnu)
+ compiled by GNU C version 9.3.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22.1-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+Compiler executable checksum: 466f818abe2f30ba03783f22bd12d815
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_5523e.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+ as -v --64 -o CMakeFiles/cmTC_5523e.dir/CMakeCXXCompilerABI.cpp.o /tmp/ccPwHizr.s
+GNU assembler version 2.34 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.34
+COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/
+LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_5523e.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+[2/2] Linking CXX executable cmTC_5523e
+Using built-in specs.
+COLLECT_GCC=/usr/bin/c++
+COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
+OFFLOAD_TARGET_NAMES=nvptx-none:hsa
+OFFLOAD_TARGET_DEFAULT=1
+Target: x86_64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
+Thread model: posix
+gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
+COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/
+LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_5523e' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+ /usr/lib/gcc/x86_64-linux-gnu/9/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/9/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper -plugin-opt=-fresolution=/tmp/cc6pbjaI.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o cmTC_5523e /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/9/../../.. CMakeFiles/cmTC_5523e.dir/CMakeCXXCompilerABI.cpp.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o
+COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_5523e' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+
+
+
+Parsed CXX implicit include dir info from above output: rv=done
+ found start of include info
+ found start of implicit include info
+ add: [/usr/include/c++/9]
+ add: [/usr/include/x86_64-linux-gnu/c++/9]
+ add: [/usr/include/c++/9/backward]
+ add: [/usr/lib/gcc/x86_64-linux-gnu/9/include]
+ add: [/usr/local/include]
+ add: [/usr/include/x86_64-linux-gnu]
+ add: [/usr/include]
+ end of search list found
+ collapse include dir [/usr/include/c++/9] ==> [/usr/include/c++/9]
+ collapse include dir [/usr/include/x86_64-linux-gnu/c++/9] ==> [/usr/include/x86_64-linux-gnu/c++/9]
+ collapse include dir [/usr/include/c++/9/backward] ==> [/usr/include/c++/9/backward]
+ collapse include dir [/usr/lib/gcc/x86_64-linux-gnu/9/include] ==> [/usr/lib/gcc/x86_64-linux-gnu/9/include]
+ collapse include dir [/usr/local/include] ==> [/usr/local/include]
+ collapse include dir [/usr/include/x86_64-linux-gnu] ==> [/usr/include/x86_64-linux-gnu]
+ collapse include dir [/usr/include] ==> [/usr/include]
+ implicit include dirs: [/usr/include/c++/9;/usr/include/x86_64-linux-gnu/c++/9;/usr/include/c++/9/backward;/usr/lib/gcc/x86_64-linux-gnu/9/include;/usr/local/include;/usr/include/x86_64-linux-gnu;/usr/include]
+
+
+Parsed CXX implicit link information from above output:
+ link line regex: [^( *|.*[/\])(ld|CMAKE_LINK_STARTFILE-NOTFOUND|([^/\]+-)?ld|collect2)[^/\]*( |$)]
+ ignore line: [Change Dir: /home/steffen/scaladis/schrank_ant_pcb/main/build/CMakeFiles/CMakeTmp]
+ ignore line: []
+ ignore line: [Run Build Command(s):/usr/bin/ninja cmTC_5523e && [1/2] Building CXX object CMakeFiles/cmTC_5523e.dir/CMakeCXXCompilerABI.cpp.o]
+ ignore line: [Using built-in specs.]
+ ignore line: [COLLECT_GCC=/usr/bin/c++]
+ ignore line: [OFFLOAD_TARGET_NAMES=nvptx-none:hsa]
+ ignore line: [OFFLOAD_TARGET_DEFAULT=1]
+ ignore line: [Target: x86_64-linux-gnu]
+ ignore line: [Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c ada c++ go brig d fortran objc obj-c++ gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32 m64 mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu]
+ ignore line: [Thread model: posix]
+ ignore line: [gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) ]
+ ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_5523e.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64']
+ ignore line: [ /usr/lib/gcc/x86_64-linux-gnu/9/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE /usr/share/cmake-3.16/Modules/CMakeCXXCompilerABI.cpp -quiet -dumpbase CMakeCXXCompilerABI.cpp -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_5523e.dir/CMakeCXXCompilerABI.cpp.o -version -fasynchronous-unwind-tables -fstack-protector-strong -Wformat -Wformat-security -fstack-clash-protection -fcf-protection -o /tmp/ccPwHizr.s]
+ ignore line: [GNU C++14 (Ubuntu 9.3.0-17ubuntu1~20.04) version 9.3.0 (x86_64-linux-gnu)]
+ ignore line: [ compiled by GNU C version 9.3.0 GMP version 6.2.0 MPFR version 4.0.2 MPC version 1.1.0 isl version isl-0.22.1-GMP]
+ ignore line: []
+ ignore line: [GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072]
+ ignore line: [ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/9"]
+ ignore line: [ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"]
+ ignore line: [ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/9/include-fixed"]
+ ignore line: [ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include"]
+ ignore line: [#include "..." search starts here:]
+ ignore line: [#include <...> search starts here:]
+ ignore line: [ /usr/include/c++/9]
+ ignore line: [ /usr/include/x86_64-linux-gnu/c++/9]
+ ignore line: [ /usr/include/c++/9/backward]
+ ignore line: [ /usr/lib/gcc/x86_64-linux-gnu/9/include]
+ ignore line: [ /usr/local/include]
+ ignore line: [ /usr/include/x86_64-linux-gnu]
+ ignore line: [ /usr/include]
+ ignore line: [End of search list.]
+ ignore line: [GNU C++14 (Ubuntu 9.3.0-17ubuntu1~20.04) version 9.3.0 (x86_64-linux-gnu)]
+ ignore line: [ compiled by GNU C version 9.3.0 GMP version 6.2.0 MPFR version 4.0.2 MPC version 1.1.0 isl version isl-0.22.1-GMP]
+ ignore line: []
+ ignore line: [GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072]
+ ignore line: [Compiler executable checksum: 466f818abe2f30ba03783f22bd12d815]
+ ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_5523e.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64']
+ ignore line: [ as -v --64 -o CMakeFiles/cmTC_5523e.dir/CMakeCXXCompilerABI.cpp.o /tmp/ccPwHizr.s]
+ ignore line: [GNU assembler version 2.34 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.34]
+ ignore line: [COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/]
+ ignore line: [LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/]
+ ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_5523e.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64']
+ ignore line: [[2/2] Linking CXX executable cmTC_5523e]
+ ignore line: [Using built-in specs.]
+ ignore line: [COLLECT_GCC=/usr/bin/c++]
+ ignore line: [COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper]
+ ignore line: [OFFLOAD_TARGET_NAMES=nvptx-none:hsa]
+ ignore line: [OFFLOAD_TARGET_DEFAULT=1]
+ ignore line: [Target: x86_64-linux-gnu]
+ ignore line: [Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c ada c++ go brig d fortran objc obj-c++ gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32 m64 mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu]
+ ignore line: [Thread model: posix]
+ ignore line: [gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) ]
+ ignore line: [COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/]
+ ignore line: [LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/]
+ ignore line: [COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_5523e' '-shared-libgcc' '-mtune=generic' '-march=x86-64']
+ link line: [ /usr/lib/gcc/x86_64-linux-gnu/9/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/9/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper -plugin-opt=-fresolution=/tmp/cc6pbjaI.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o cmTC_5523e /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/9/../../.. CMakeFiles/cmTC_5523e.dir/CMakeCXXCompilerABI.cpp.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o]
+ arg [/usr/lib/gcc/x86_64-linux-gnu/9/collect2] ==> ignore
+ arg [-plugin] ==> ignore
+ arg [/usr/lib/gcc/x86_64-linux-gnu/9/liblto_plugin.so] ==> ignore
+ arg [-plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper] ==> ignore
+ arg [-plugin-opt=-fresolution=/tmp/cc6pbjaI.res] ==> ignore
+ arg [-plugin-opt=-pass-through=-lgcc_s] ==> ignore
+ arg [-plugin-opt=-pass-through=-lgcc] ==> ignore
+ arg [-plugin-opt=-pass-through=-lc] ==> ignore
+ arg [-plugin-opt=-pass-through=-lgcc_s] ==> ignore
+ arg [-plugin-opt=-pass-through=-lgcc] ==> ignore
+ arg [--build-id] ==> ignore
+ arg [--eh-frame-hdr] ==> ignore
+ arg [-m] ==> ignore
+ arg [elf_x86_64] ==> ignore
+ arg [--hash-style=gnu] ==> ignore
+ arg [--as-needed] ==> ignore
+ arg [-export-dynamic] ==> ignore
+ arg [-dynamic-linker] ==> ignore
+ arg [/lib64/ld-linux-x86-64.so.2] ==> ignore
+ arg [-pie] ==> ignore
+ arg [-znow] ==> ignore
+ arg [-zrelro] ==> ignore
+ arg [-o] ==> ignore
+ arg [cmTC_5523e] ==> ignore
+ arg [/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o] ==> ignore
+ arg [/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o] ==> ignore
+ arg [/usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o] ==> ignore
+ arg [-L/usr/lib/gcc/x86_64-linux-gnu/9] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/9]
+ arg [-L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu]
+ arg [-L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib]
+ arg [-L/lib/x86_64-linux-gnu] ==> dir [/lib/x86_64-linux-gnu]
+ arg [-L/lib/../lib] ==> dir [/lib/../lib]
+ arg [-L/usr/lib/x86_64-linux-gnu] ==> dir [/usr/lib/x86_64-linux-gnu]
+ arg [-L/usr/lib/../lib] ==> dir [/usr/lib/../lib]
+ arg [-L/usr/lib/gcc/x86_64-linux-gnu/9/../../..] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../..]
+ arg [CMakeFiles/cmTC_5523e.dir/CMakeCXXCompilerABI.cpp.o] ==> ignore
+ arg [-lstdc++] ==> lib [stdc++]
+ arg [-lm] ==> lib [m]
+ arg [-lgcc_s] ==> lib [gcc_s]
+ arg [-lgcc] ==> lib [gcc]
+ arg [-lc] ==> lib [c]
+ arg [-lgcc_s] ==> lib [gcc_s]
+ arg [-lgcc] ==> lib [gcc]
+ arg [/usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o] ==> ignore
+ arg [/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o] ==> ignore
+ collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/9] ==> [/usr/lib/gcc/x86_64-linux-gnu/9]
+ collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu] ==> [/usr/lib/x86_64-linux-gnu]
+ collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib] ==> [/usr/lib]
+ collapse library dir [/lib/x86_64-linux-gnu] ==> [/lib/x86_64-linux-gnu]
+ collapse library dir [/lib/../lib] ==> [/lib]
+ collapse library dir [/usr/lib/x86_64-linux-gnu] ==> [/usr/lib/x86_64-linux-gnu]
+ collapse library dir [/usr/lib/../lib] ==> [/usr/lib]
+ collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../..] ==> [/usr/lib]
+ implicit libs: [stdc++;m;gcc_s;gcc;c;gcc_s;gcc]
+ implicit dirs: [/usr/lib/gcc/x86_64-linux-gnu/9;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib]
+ implicit fwks: []
+
+
diff --git a/software/main/build/CMakeFiles/cmake.check_cache b/software/main/build/CMakeFiles/cmake.check_cache
new file mode 100644
index 0000000..3dccd73
--- /dev/null
+++ b/software/main/build/CMakeFiles/cmake.check_cache
@@ -0,0 +1 @@
+# This file is generated by cmake for dependency checking of the CMakeCache.txt file
diff --git a/software/main/component.mk b/software/main/component.mk
new file mode 100644
index 0000000..a98f634
--- /dev/null
+++ b/software/main/component.mk
@@ -0,0 +1,4 @@
+#
+# "main" pseudo-component makefile.
+#
+# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
diff --git a/software/main/config.cpp b/software/main/config.cpp
new file mode 100644
index 0000000..6421bf8
--- /dev/null
+++ b/software/main/config.cpp
@@ -0,0 +1,265 @@
+/*
+ * config.cpp
+ *
+ * Created on: 26.02.2022
+ * Author: steffen
+ */
+
+#include "config.h"
+
+int ReadConfig() {
+ ESP_LOGI(TAG, "Initializing SPIFFS");
+ esp_vfs_spiffs_conf_t conf = { .base_path = "/spiffs", .partition_label = NULL, .max_files = 5, .format_if_mount_failed = false };
+
+ // Use settings defined above to initialize and mount SPIFFS filesystem.
+ // Note: esp_vfs_spiffs_register is an all-in-one convenience function.
+ esp_err_t ret = esp_vfs_spiffs_register(&conf);
+ if (ret != ESP_OK) {
+ if (ret == ESP_FAIL) {
+ ESP_LOGE(TAG, "Failed to mount or format filesystem");
+ } else if (ret == ESP_ERR_NOT_FOUND) {
+ ESP_LOGE(TAG, "Failed to find SPIFFS partition");
+ } else {
+ ESP_LOGE(TAG, "Failed to initialize SPIFFS (%s)", esp_err_to_name(ret));
+ }
+ return -1;
+ }
+
+ size_t total = 0, used = 0;
+ ret = esp_spiffs_info(conf.partition_label, &total, &used);
+ if (ret != ESP_OK) {
+ ESP_LOGE(TAG, "Failed to get SPIFFS partition information (%s)", esp_err_to_name(ret));
+ } else {
+ ESP_LOGI(TAG, "Partition size: total: %d, used: %d", total, used);
+ }
+
+ // Use POSIX and C standard library functions to work with files.
+ // First create a file.
+ ESP_LOGI(TAG, "Opening config file");
+
+ // Open renamed file for reading
+ ESP_LOGI(TAG, "Reading file");
+ FILE *f = fopen("/spiffs/parameter.dat", "r");
+ if (f == NULL) {
+ ESP_LOGE(TAG, "Failed to open file for reading");
+ return -2;
+ }
+ char line[64];
+ while (fgets(line, sizeof(line), f) > NULL) {
+ // strip newline
+ char *pos = strchr(line, '\n');
+ if (pos) {
+ *pos = '\0';
+ }
+ if (strlen(line) > 6) {
+ if (strncmp(line, "netip", 5) == 0) {
+ strncpy(netip, &line[6], 15);
+ } else if (strncmp(line, "netma", 5) == 0) {
+ strncpy(netma, &line[6], 15);
+ } else if (strncmp(line, "netgw", 5) == 0) {
+ strncpy(netgw, &line[6], 15);
+ } else if (strncmp(line, "srvip", 5) == 0) {
+ strncpy(srvip, &line[6], 15);
+ } else if (strncmp(line, "srvpo", 5) == 0) {
+ srvpo = atoi(&line[6]);
+ } else if (strncmp(line, "boxid", 5) == 0) {
+ boxid = atoi(&line[6]);
+ } else if (strncmp(line, "subbx", 5) == 0) {
+ subbx = atoi(&line[6]);
+ } else if (strncmp(line, "dbnam", 5) == 0) {
+ strncpy(dbnam, &line[6], 15);
+ } else if (strncmp(line, "xxxxx", 5) == 0) {
+
+ }
+ }
+ ESP_LOGI(TAG, "Read from file: '%s'", line);
+ }
+ fclose(f);
+ // All done, unmount partition and disable SPIFFS
+ esp_vfs_spiffs_unregister(conf.partition_label);
+ ESP_LOGI(TAG, "SPIFFS unmounted");
+
+ return 1;
+}
+int WriteConfig(char *buff) {
+ ESP_LOGI(TAG, "Initializing SPIFFS");
+ esp_vfs_spiffs_conf_t conf = { .base_path = "/spiffs", .partition_label = NULL, .max_files = 5, .format_if_mount_failed = false };
+
+ // Use settings defined above to initialize and mount SPIFFS filesystem.
+ // Note: esp_vfs_spiffs_register is an all-in-one convenience function.
+ esp_err_t ret = esp_vfs_spiffs_register(&conf);
+ if (ret != ESP_OK) {
+ if (ret == ESP_FAIL) {
+ ESP_LOGE(TAG, "Failed to mount or format filesystem");
+ } else if (ret == ESP_ERR_NOT_FOUND) {
+ ESP_LOGE(TAG, "Failed to find SPIFFS partition");
+ } else {
+ ESP_LOGE(TAG, "Failed to initialize SPIFFS (%s)", esp_err_to_name(ret));
+ }
+ return -1;
+ }
+
+ size_t total = 0, used = 0;
+ ret = esp_spiffs_info(conf.partition_label, &total, &used);
+ if (ret != ESP_OK) {
+ ESP_LOGE(TAG, "Failed to get SPIFFS partition information (%s)", esp_err_to_name(ret));
+ } else {
+ ESP_LOGI(TAG, "Partition size: total: %d, used: %d", total, used);
+ }
+
+ ESP_LOGI(TAG, "Opening config file");
+ ESP_LOGI(TAG, "Writing file");
+ FILE *f = fopen("/spiffs/parameter.dat", "w");
+ if (f == NULL) {
+ ESP_LOGE(TAG, "Failed to open file for writing");
+ return -2;
+ }
+
+ fprintf(f, "%s", buff);
+
+ fclose(f);
+ // All done, unmount partition and disable SPIFFS
+ esp_vfs_spiffs_unregister(conf.partition_label);
+ ESP_LOGI(TAG, "SPIFFS unmounted");
+
+ return 1;
+}
+int SaveConfig(void) { // saves the config from settings screen
+ uint8_t ip1 = 0, ip2 = 0, ip3 = 0, ip4 = 0;
+ char buff[32];
+ int i = 0;
+ ESP_LOGI(TAG, "Initializing SPIFFS");
+ esp_vfs_spiffs_conf_t conf = { .base_path = "/spiffs", .partition_label = NULL, .max_files = 5, .format_if_mount_failed = false };
+
+ esp_err_t ret = esp_vfs_spiffs_register(&conf);
+ if (ret != ESP_OK) {
+ if (ret == ESP_FAIL) {
+ ESP_LOGE(TAG, "Failed to mount or format filesystem");
+ } else if (ret == ESP_ERR_NOT_FOUND) {
+ ESP_LOGE(TAG, "Failed to find SPIFFS partition");
+ } else {
+ ESP_LOGE(TAG, "Failed to initialize SPIFFS (%s)", esp_err_to_name(ret));
+ }
+ return -1;
+ }
+
+ size_t total = 0, used = 0;
+ ret = esp_spiffs_info(conf.partition_label, &total, &used);
+ if (ret != ESP_OK) {
+ ESP_LOGE(TAG, "Failed to get SPIFFS partition information (%s)", esp_err_to_name(ret));
+ } else {
+ ESP_LOGI(TAG, "Partition size: total: %d, used: %d", total, used);
+ }
+
+ ESP_LOGI(TAG, "Opening config file");
+ FILE *f = fopen("/spiffs/parameter.dat", "w");
+ if (f == NULL) {
+ ESP_LOGE(TAG, "Failed to open file for writing");
+ return -2;
+ }
+
+ LCD->iReadValue((char *)"ip1",buff);
+ ip1=atoi(buff);
+ LCD->iReadValue((char *)"ip2",buff);
+ ip2=atoi(buff);
+ LCD->iReadValue((char *)"ip3",buff);
+ ip3=atoi(buff);
+ LCD->iReadValue((char *)"ip4",buff);
+ ip4=atoi(buff);
+ fprintf(f, "netip=%d.%d.%d.%d\n", ip1, ip2, ip3, ip4);
+
+ LCD->iReadValue((char *)"ma1",buff);
+ ip1=atoi(buff);
+ LCD->iReadValue((char *)"ma2",buff);
+ ip2=atoi(buff);
+ LCD->iReadValue((char *)"ma3",buff);
+ ip3=atoi(buff);
+ LCD->iReadValue((char *)"ma4",buff);
+ ip4=atoi(buff);
+ fprintf(f, "netma=%d.%d.%d.%d\n", ip1, ip2, ip3, ip4);
+
+ LCD->iReadValue((char *)"gw1",buff);
+ ip1=atoi(buff);
+ LCD->iReadValue((char *)"gw2",buff);
+ ip2=atoi(buff);
+ LCD->iReadValue((char *)"gw3",buff);
+ ip3=atoi(buff);
+ LCD->iReadValue((char *)"gw4",buff);
+ ip4=atoi(buff);
+ fprintf(f, "netgw=%d.%d.%d.%d\n", ip1, ip2, ip3, ip4);
+
+ LCD->iReadValue((char *)"sip1",buff);
+ ip1=atoi(buff);
+ LCD->iReadValue((char *)"sip2",buff);
+ ip2=atoi(buff);
+ LCD->iReadValue((char *)"sip3",buff);
+ ip3=atoi(buff);
+ LCD->iReadValue((char *)"sip4",buff);
+ ip4=atoi(buff);
+ fprintf(f, "srvip=%d.%d.%d.%d\n", ip1, ip2, ip3, ip4);
+
+ LCD->iReadValue((char *)"srvpo1",buff);
+ i=atoi(buff);
+ fprintf(f, "srvpo=%d\n", i);
+
+ LCD->iReadValue((char *)"boxid1",buff);
+ i=atoi(buff);
+ fprintf(f, "boxid=%d\n", i);
+
+ LCD->iReadValue((char *)"subbx1",buff);
+ i=atoi(buff);
+ fprintf(f, "subbx=%d\n", i);
+
+ LCD->iReadValue((char *)"dbnam1",buff);
+ fprintf(f, "dbnam=%s\n", buff);
+
+ fclose(f);
+ // All done, unmount partition and disable SPIFFS
+ esp_vfs_spiffs_unregister(conf.partition_label);
+ ESP_LOGI(TAG, "SPIFFS unmounted");
+
+ return 0;
+}
+void WriteVals(char *name, char *strvals) {
+ uint8_t ipp = 0;
+ uint32_t ip;
+ int i;
+ char nm[32];
+ ip = esp_ip4addr_aton(strvals);
+ for (i = 1; i < 5; i++) {
+ ipp = ip & 0xFF;
+ sprintf(nm, "%s%d", name, i);
+ LCD->iWriteValue(nm, ipp);
+ ip = ip >> 8;
+ }
+}
+int HandleEdit(void) {
+ int sl=1;
+ int res;
+ while (sl) {
+ res=LCD->iReadProt(1);
+ printf("HE Res:%d\n",res);fflush(stdout);
+ if (res==HMIResultOK) {
+ vTaskDelay(1);
+ res=LCD->iReadProt(1);
+ vTaskDelay(1);
+ SaveConfig();
+ sl=0;
+ LCD->iSendProt(6, (char*) "page 0");
+ } else vTaskDelay(50);
+ }
+ return res;
+}
+int EditConfig() {
+ LCD->iSendProt(6, (char*) "page 3");
+ WriteVals((char *)"ip",netip);
+ WriteVals((char *)"gw",netgw);
+ WriteVals((char *)"ma",netma);
+ WriteVals((char *)"ma",netma);
+ WriteVals((char *)"sip",srvip);
+ LCD->iWriteValue((char*) "srvpo1", srvpo);
+ LCD->iWriteValue((char*) "boxid1", boxid);
+ LCD->iWriteValue((char*) "subbx1", subbx);
+ LCD->iWriteValue((char*) "dbnam1", dbnam);
+ return HandleEdit();
+}
diff --git a/software/main/config.h b/software/main/config.h
new file mode 100644
index 0000000..fe5c896
--- /dev/null
+++ b/software/main/config.h
@@ -0,0 +1,33 @@
+/*
+ * config.h
+ *
+ * Created on: 26.02.2022
+ * Author: steffen
+ */
+
+#ifndef MAIN_CONFIG_H_
+#define MAIN_CONFIG_H_
+#include "main.h"
+#include "HMI.h"
+
+extern const char *TAG;
+extern HMI* LCD;
+
+static char netip[16];
+static char netma[16];
+static char netgw[16];
+static char srvip[16];
+static char dbnam[16];
+static int srvpo;
+static int boxid;
+static int subbx;
+
+int EditConfig();
+int HandleEdit(void);
+int ReadConfig();
+int SaveConfig(void);
+int WriteConfig(char *buff);
+void WriteVals(char *name, char *strvals);
+
+
+#endif /* MAIN_CONFIG_H_ */
diff --git a/software/main/etc.cpp b/software/main/etc.cpp
new file mode 100644
index 0000000..a240398
--- /dev/null
+++ b/software/main/etc.cpp
@@ -0,0 +1,17 @@
+/*
+ * etc.cpp
+ *
+ * Created on: 26.02.2022
+ * Author: steffen
+ */
+#include "etc.h"
+
+void DumpBuf(void *buf, int len) {
+ int i, c;
+ char *lb = (char*) buf;
+ for (i = 0; i < len; i++) {
+ c = (char) *lb++;
+ printf("%02X ", c);
+ }
+ printf("\n");
+}
diff --git a/software/main/etc.h b/software/main/etc.h
new file mode 100644
index 0000000..b5fc1f0
--- /dev/null
+++ b/software/main/etc.h
@@ -0,0 +1,14 @@
+/*
+ * etc.h
+ *
+ * Created on: 26.02.2022
+ * Author: steffen
+ */
+
+#ifndef MAIN_ETC_H_
+#define MAIN_ETC_H_
+#include "main.h"
+
+void DumpBuf(void *buf, int len);
+
+#endif /* MAIN_ETC_H_ */
diff --git a/software/main/iic.cpp b/software/main/iic.cpp
new file mode 100644
index 0000000..ac74818
--- /dev/null
+++ b/software/main/iic.cpp
@@ -0,0 +1,174 @@
+/*
+ * iic.cpp
+ *
+ * Created on: 26.02.2022
+ * Author: steffen
+ */
+
+#include "iic.h"
+
+esp_err_t I2C_read(uint8_t slave_addr, uint8_t reg_addr, uint8_t *data, uint8_t len) {
+ return i2c_master_write_read_device(I2C_MASTER_NUM, slave_addr, &reg_addr, 1, data, 2, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+}
+esp_err_t I2C_register_write_byte(uint8_t slave_addr, uint8_t reg_addr, uint8_t data) {
+ uint8_t write_buf[2] = { reg_addr, data };
+ return i2c_master_write_to_device(I2C_MASTER_NUM, slave_addr, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+}
+esp_err_t I2C_init(void) {
+ int res1,res2;
+ int I2C_master_port = I2C_MASTER_NUM;
+ i2c_config_t I2C_conf = { .mode = I2C_MODE_MASTER, .sda_io_num = I2C_MASTER_SDA_IO, .scl_io_num = I2C_MASTER_SCL_IO, .sda_pullup_en = GPIO_PULLUP_ENABLE, .scl_pullup_en = GPIO_PULLUP_ENABLE, .master { .clk_speed = I2C_MASTER_FREQ_HZ, } };
+ i2c_param_config(I2C_master_port, &I2C_conf);
+ res1=i2c_driver_install(I2C_master_port, I2C_conf.mode,
+ I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0);
+
+ I2C_buf[0] = 0x7F; // write data to output port 1
+ I2C_buf[1] = 0x00; // write data to output port 1
+ res1 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP1, I2C_buf, 2, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ res2 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP2, I2C_buf, 2, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ printf("\nMaster wrote %d %d %02X\n", res1,res2,I2C_buf[0]);
+
+ I2C_buf[0] = 0x02; // write data to output port 1
+ I2C_buf[1] = 0xFF; // write data to output port 1
+ I2C_buf[2] = 0xFF; // write data to output port 1
+ I2C_buf[3] = 0x00; // write data to output port 1
+ I2C_buf[4] = 0x00; // write data to output port 1
+ res1 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP1, I2C_buf, 5, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ res2 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP2, I2C_buf, 5, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ printf("\nMaster wrote %d %d %02X\n", res1,res2,I2C_buf[0]);
+
+ I2C_buf[0] = 0x11; // write data to output port 1
+ I2C_buf[1] = 0x10; // write data to output port 1
+ res1 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP1, I2C_buf, 2, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ res2 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP2, I2C_buf, 2, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ printf("\nMaster wrote %d %d %02X\n", res1,res2,I2C_buf[0]);
+
+
+
+ // printf("\nI2C wrote 0x%02X%02X: %d\n", I2C_buf[0], I2C_buf[1], res1);
+// I2C_buf[0] = 0x00; // lese 3 bytes
+// res2 = i2c_master_read_from_device(I2C_MASTER_NUM, I2C_PORTEXP1, I2C_buf, 1, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+
+
+ /*
+ I2C_buf[0] = 0x8C; // write config port 0 with auto inc
+ I2C_buf[1] = 0xFF; // Port 0 Input
+ I2C_buf[2] = 0x00; // Port 1 Output
+ I2C_buf[3] = 0xFF; // Port 2 Input
+ res = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP1, I2C_buf, 4, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ printf("\nMaster wrote %02X %02X: %d\n", I2C_buf[0], I2C_buf[1], res);
+
+ I2C_buf[0] = 0x05; // write data to output port 1
+ I2C_buf[1] = 0x00;
+ res = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP1, I2C_buf, 2, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ printf("\nMaster wrote %02X %02X: %d\n", I2C_buf[0], I2C_buf[1], res);
+*/
+ return res1;
+}
+esp_err_t ADC_init(void) {
+ int res;
+
+ I2C_buf[0] = 0x01; // -> config register
+ I2C_buf[1] = 0x40; // 0 100 000 0 A0-GND +-6.144 CONT
+ I2C_buf[2] = 0x0; // O00 0 0 0 11 8 SPS no comp
+ res = i2c_master_write_to_device(I2C_MASTER_NUM, ADC_DEFAULT_IIC_ADDR, I2C_buf, 3, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ printf("\nMaster wrote %02X %02X: %d\n", I2C_buf[0], I2C_buf[1], res);
+ return res;
+}
+int ADCReadAll(void) {
+// for i in range(ADC_CHAN_NUM):
+// data=self.bus.read_i2c_block_data(self.addr,REG_RAW_DATA_START+i,2)
+// val=data[1]<<8|data[0]
+// array.append(val)
+ int res1=0,res2,i;
+ I2C_buf[0] = 0x00; // conversion register
+ I2C_buf[1] = 0x00;
+ I2C_buf[2] = 0x00;
+ res1 = i2c_master_write_to_device(I2C_MASTER_NUM, ADC_DEFAULT_IIC_ADDR, I2C_buf, 1, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+// printf("\nI2C wrote 0x%02X: %d\n", I2C_buf[0], res1);
+
+ for (i=0;i<256;i++) {
+ res2 = i2c_master_read_from_device(I2C_MASTER_NUM, ADC_DEFAULT_IIC_ADDR, I2C_buf, 2, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ printf("I2C read %02x -> ",i);
+// for (i=0;i<4;i++) {
+ printf(" %02X %02X ",I2C_buf[0],I2C_buf[1]);
+// }
+ printf(" %d\n", res2);
+ }
+// printf(" #:S%d R:%d ", res1, res2);
+ fflush(stdout);
+
+ return res1;
+}
+int DoorIsClosed(int doormask) {
+ int res1,res2;
+ I2C_buf[0] = 0x80; // Setze CMD read port 0
+ I2C_buf[1] = 0x00;
+ I2C_buf[2] = 0x00;
+ res1 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP1, I2C_buf, 1, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+// printf("\nI2C wrote 0x%02X%02X: %d\n", I2C_buf[0], I2C_buf[1], res1);
+ I2C_buf[0] = 0x00; // lese 3 bytes
+ res2 = i2c_master_read_from_device(I2C_MASTER_NUM, I2C_PORTEXP1, I2C_buf, 3, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+// printf("\nI2C read 0x %02X %02X %02X: %d\n", I2C_buf[0], I2C_buf[1], I2C_buf[2], res2);
+ printf(" #:S%d R:%d ", res1, res2);
+ fflush(stdout);
+ // Open 0x0F = 0000 1111
+ // 1 closed 0x0B = 0000 1011
+ // 2 closed 0x0E = 0000 1110
+ // 3 closed 0x0D = 0000 1101
+ // 4 closed 0x07 = 0000 0111
+ if ((I2C_buf[LOCKR_PORT] & doormask)==0) {
+ return 1;
+ } else {
+ return 0;
+ }
+
+}
+int DoorOpen(int door) {
+ int mask=0;
+ int maskr=0;
+ int res;
+ int to=10;
+ switch (door) { // we allow only one door to open
+ case 1: {
+ mask = LOCK1;
+ maskr= LOCK1R;
+ } break;
+ case 2: {
+ mask = LOCK2;
+ maskr= LOCK2R;
+ } break;
+ case 3: {
+ mask = LOCK3;
+ maskr= LOCK3R;
+ } break;
+ default: {
+ mask = LOCK4;
+ maskr= LOCK4R;
+ }
+ }
+
+ I2C_buf[0] = 0x05;
+ I2C_buf[1] = mask;
+ printf("\nMASTER wrote %02X %02X\n", I2C_buf[0], I2C_buf[1]);fflush(stdout);
+ res = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP1, I2C_buf, 2, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ printf("\nI2C wrote 0x%02X%02X: %d\n", I2C_buf[0], I2C_buf[1], res);fflush(stdout);
+ while (to>0) {
+ if (DoorIsClosed(maskr)==0) {
+ to=0;
+ } else {
+ to--;
+ vTaskDelay(1);
+ }
+ }
+ I2C_buf[0] = 0x05;
+ I2C_buf[1] = 0x00;
+ printf("\nMASTER wrote 0x%02X%02X\n", I2C_buf[0], I2C_buf[1]);fflush(stdout);
+ res = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP1, I2C_buf, 2, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ printf("\nI2C wrote 0x%02X%02X: %d\n", I2C_buf[0], I2C_buf[1], res);
+
+ return 0;
+}
+
+
+
diff --git a/software/main/iic.h b/software/main/iic.h
new file mode 100644
index 0000000..9e1954e
--- /dev/null
+++ b/software/main/iic.h
@@ -0,0 +1,25 @@
+/*
+ * iic.h
+ *
+ * Created on: 26.02.2022
+ * Author: steffen
+ */
+
+#ifndef MAIN_IIC_H_
+#define MAIN_IIC_H_
+#include "main.h"
+
+static uint8_t I2C_buf[16];
+
+esp_err_t I2C_read(uint8_t slave_addr, uint8_t reg_addr, uint8_t *data, uint8_t len) ;
+esp_err_t I2C_register_write_byte(uint8_t slave_addr, uint8_t reg_addr, uint8_t data);
+//uint8_t write_buf[2] = { reg_addr, data };
+// return i2c_master_write_to_device(I2C_MASTER_NUM, slave_addr, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+//}
+esp_err_t I2C_init(void);
+esp_err_t ADC_init(void);
+int ADCReadAll(void);
+int DoorIsClosed(int doormask);
+int DoorOpen(int door);
+
+#endif /* MAIN_IIC_H_ */
diff --git a/software/main/main.cpp b/software/main/main.cpp
new file mode 100644
index 0000000..632fc96
--- /dev/null
+++ b/software/main/main.cpp
@@ -0,0 +1,413 @@
+
+#include "main.h"
+#include "sdkconfig.h"
+
+#include "SimplePgSQL.h"
+#include "MU80X.h"
+#include "HMI.h"
+#include "etc.h"
+#include "uart.h"
+#include "iic.h"
+#include "config.h"
+
+// PGSQL
+#define PGBufferSize 16384
+#define PGCharset "utf-8"
+#define PGUser "mega"
+#define PGPassword "osteoglossum"
+static PGconnection *PGconn;
+static unsigned char PGbuffer[PGBufferSize];
+
+// ETC
+const char *TAG = "SCALADIS";
+//static int cnt = 0;
+//static int protcnt = 0;
+static int serlen;
+static int network_connected = 0;
+MU80X *UHF;
+HMI *LCD;
+
+
+unsigned long long ReadAuth(void);
+
+/** ETH */
+static void eth_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) {
+ uint8_t mac_addr[6] = { 0 };
+ /* we can get the ethernet driver handle from event data */
+ esp_eth_handle_t eth_handle = *(esp_eth_handle_t*) event_data;
+
+ switch (event_id) {
+ case ETHERNET_EVENT_CONNECTED:
+ esp_eth_ioctl(eth_handle, ETH_CMD_G_MAC_ADDR, mac_addr);
+ ESP_LOGI(TAG, "Eth Link Up");
+ ESP_LOGI(TAG, "Eth MAC %02x:%02x:%02x:%02x:%02x:%02x", mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
+ break;
+ case ETHERNET_EVENT_DISCONNECTED:
+ ESP_LOGI(TAG, "Eth Link Down");
+ break;
+ case ETHERNET_EVENT_START:
+ ESP_LOGI(TAG, "Eth Started");
+ break;
+ case ETHERNET_EVENT_STOP:
+ ESP_LOGI(TAG, "Eth Stopped");
+ break;
+ default:
+ break;
+ }
+}
+static void got_ip_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) {
+ ip_event_got_ip_t *event = (ip_event_got_ip_t*) event_data;
+ const esp_netif_ip_info_t *ip_info = &event->ip_info;
+
+ ESP_LOGI(TAG, "Ethernet Got IP Address");
+ ESP_LOGI(TAG, "~~~~~~~~~~~");
+ ESP_LOGI(TAG, "ETHIP :" IPSTR, IP2STR(&ip_info->ip));
+ ESP_LOGI(TAG, "ETHMASK:" IPSTR, IP2STR(&ip_info->netmask));
+ ESP_LOGI(TAG, "ETHGW :" IPSTR, IP2STR(&ip_info->gw));
+ ESP_LOGI(TAG, "~~~~~~~~~~~");
+ network_connected = 1;
+}
+static void ETH_init(int dhcp) {
+ ESP_ERROR_CHECK(esp_netif_init());
+ ESP_ERROR_CHECK(esp_event_loop_create_default());
+
+ // Create new default instance of esp-netif for Ethernet
+ esp_netif_config_t cfg = ESP_NETIF_DEFAULT_ETH();
+ esp_netif_t *eth_netif = esp_netif_new(&cfg);
+
+ // Init MAC and PHY configs to default
+ eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
+ eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
+
+ phy_config.phy_addr = CONFIG_EXAMPLE_ETH_PHY_ADDR;
+ phy_config.reset_gpio_num = CONFIG_EXAMPLE_ETH_PHY_RST_GPIO;
+ mac_config.smi_mdc_gpio_num = CONFIG_EXAMPLE_ETH_MDC_GPIO;
+ mac_config.smi_mdio_gpio_num = CONFIG_EXAMPLE_ETH_MDIO_GPIO;
+ esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&mac_config);
+ esp_eth_phy_t *phy = esp_eth_phy_new_lan87xx(&phy_config);
+ esp_eth_config_t config = ETH_DEFAULT_CONFIG(mac, phy);
+ esp_eth_handle_t eth_handle = NULL;
+ ESP_ERROR_CHECK(esp_eth_driver_install(&config, &eth_handle));
+ ESP_ERROR_CHECK(esp_netif_attach(eth_netif, esp_eth_new_netif_glue(eth_handle)));
+
+ if (dhcp == 0) {
+ strcpy(netip, (char*) "192.168.178.32");
+ strcpy(netgw, (char*) "192.168.178.1");
+ strcpy(netma, (char*) "255.255.255.0");
+ strcpy(srvip, (char*) "192.168.178.32");
+ srvpo = 5432;
+ boxid = 1;
+ subbx = 1;
+ ReadConfig();
+
+ esp_netif_ip_info_t ip_info;
+ memset(&ip_info, 0, sizeof(esp_netif_ip_info_t));
+ esp_netif_str_to_ip4((const char*) netip, &ip_info.ip);
+ esp_netif_str_to_ip4((const char*) netgw, &ip_info.gw);
+ esp_netif_str_to_ip4((const char*) netma, &ip_info.netmask);
+ esp_netif_set_ip_info(eth_netif, &ip_info);
+ }
+ ESP_ERROR_CHECK(esp_eth_start(eth_handle));
+}
+
+/** UHF */
+void UHF_init(void) {
+ int res;
+ UHF = new MU80X(UHF_UART_CHANNEL);
+ res = UHF->iSetRFRegion();
+ res = UHF->iSetPower(30);
+ UHF->DumpBuffer(UHF->RecvBuf, res);
+ UHF->iClearBuffer();
+}
+void UHF_loop(void) {
+ int i;
+ unsigned long long ID;
+ for (i = 0; i < 1000; i++) {
+ if ((ID=ReadAuth())>0) {
+ printf("ID:%lld",ID);fflush(stdout);
+ }
+ UHF->iBufferInventory(7, 0, 10);
+ printf("%d -> Tags in Buffer:%d Tags seen:%d\n", i, UHF->TagsInBuffer,UHF->TagsSeen);
+ fflush(stdout);
+ vTaskDelay(10);
+ };
+ while (0) {
+ vTaskDelay(100);
+ };
+}
+
+unsigned long long ReadAuth(void) {
+ char authbuff[1024];
+ char *pos;
+ int received = 0;
+ int timeout = 60;
+ serlen = uart_read_bytes(RDR_UART_CHANNEL, authbuff, 256, 1);
+ if (serlen > 0) {
+
+ pos = strchr(authbuff, '\n');
+ if (pos) {
+ *pos = '\0';
+ }
+
+ if (strncmp(authbuff, "CONFIG", 6) == 0) { // we have to receive the init file
+ printf("Ready to receive config file !\n");
+ fflush(stdout);
+ while ((received == 0) & (timeout > 0)) {
+ serlen = uart_read_bytes(RDR_UART_CHANNEL, authbuff, 1023, 100);
+ if (serlen) {
+ authbuff[serlen] = 0;
+ WriteConfig(authbuff);
+ received = 1;
+ } else {
+ vTaskDelay(100);
+ timeout--;
+ printf("TO:%d\n", timeout);
+ fflush(stdout);
+ }
+ }
+ }
+ }
+ authbuff[serlen]=0;
+ printf("SERLEN:%d->%s\n", serlen,authbuff);
+ fflush(stdout);
+ return sscanf("%X",authbuff);
+}
+
+/** GPIO **/
+void IO_init(void) {
+ // outputs
+
+#define GPO_BIT_MASK (1ULL << PHY_PWR)
+ gpio_config_t o_conf;
+ o_conf.intr_type = GPIO_INTR_DISABLE;
+ o_conf.mode = GPIO_MODE_OUTPUT;
+ o_conf.pin_bit_mask = GPO_BIT_MASK;
+ o_conf.pull_down_en = GPIO_PULLDOWN_ENABLE;
+ o_conf.pull_up_en = GPIO_PULLUP_DISABLE;
+ gpio_config(&o_conf);
+ gpio_set_level((gpio_num_t) PHY_PWR, 1);
+
+ // inputs
+ /*
+ #define GPI_BIT_MASK ((1ULL << SWITCH)|(1ULL << SWITCH))
+ gpio_config_t i_conf;
+ i_conf.intr_type = GPIO_INTR_DISABLE;
+ i_conf.mode = GPIO_MODE_INPUT;
+ i_conf.pin_bit_mask = GPI_BIT_MASK;
+ i_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
+ i_conf.pull_up_en = GPIO_PULLUP_DISABLE;
+ gpio_config(&i_conf);
+ */
+}
+void HMI_init(void) {
+ LCD = new HMI(LCD_UART_CHANNEL);
+}
+
+/** PGSQL **/
+void PGInit(void) {
+ PGconn = new PGconnection(0,PGbuffer,PGBufferSize);
+}
+int getInfo(char *info) {
+ int rc, i;
+ int pgstat = 0;
+ int cnt = 1000;
+ char *msg;
+ char lbuf[1024];
+ rc = PGconn->PGsetDbLogin(srvip, srvpo, dbnam, PGUser, PGPassword, PGCharset);
+ printf("Login result:%d\n", rc);
+ if (rc < 1)
+ return -1;
+ pgstat = 1;
+ while (cnt > 0) {
+
+ if (pgstat == 1) { // we are connected to srv/db, now we need to rcv the msgs from srv
+ rc = PGconn->PGstatus();
+ printf("Status:%d\n", rc);
+ fflush(stdout);
+ if (rc == CONNECTION_BAD || rc == CONNECTION_NEEDED) {
+ printf("ERROR: %s", PGconn->PGgetMessage());
+ pgstat = -1;
+ } else if (rc == CONNECTION_OK) {
+ pgstat = 2;
+ printf("Ready to submit qry\n");
+ }
+ }
+
+ if (pgstat == 2) {
+ sprintf(lbuf, "SELECT name,gname FROM accounts WHERE id=(cast(x'%s' AS int));", info);
+ rc = PGconn->PGexecute(lbuf);
+ printf("EXEC result:%d\n", rc);
+// vTaskDelay(1);
+ if (rc == 0) {
+ pgstat = 3;
+ } else {
+ cnt = 0;
+ }
+ }
+ if (pgstat == 3) {
+ rc = PGconn->PGgetData();
+ // printf("RC:%d\n",rc);fflush(stdout);
+ if (rc < 0) {
+ printf("Get Data Error:%d\n", rc);
+ fflush(stdout);
+ } else if (rc > 0) {
+ if (rc & PG_RSTAT_HAVE_COLUMNS) {
+ printf("We got columns !\n");
+ fflush(stdout);
+ int cols = PGconn->PGnfields();
+ printf("Cols: %d\n", cols);
+ fflush(stdout);
+ /*
+ for (i = 0; i < cols; i++) {
+ if (i) printf(" | ");
+ printf(" %s ",PGconn->PGgetColumn(i));
+ }
+ */
+ printf("\n==========\n");
+ fflush(stdout);
+ } else if (rc & PG_RSTAT_HAVE_ROW) {
+ // printf("We got rows !\n");fflush (stdout);
+ for (i = 0; i < PGconn->PGnfields(); i++) {
+ // if (i) printf(" | ");
+ // msg = PGconn->PGgetValue(i);
+ sprintf(lbuf, "Info:\r\n%s\r\n%s", PGconn->PGgetValue(1), PGconn->PGgetValue(0));
+ // if (!msg) msg = (char *) "NULL";
+ // printf(" %s", msg);fflush(stdout);
+ }
+ // printf("\n");fflush(stdout);
+ } else if (rc & PG_RSTAT_HAVE_SUMMARY) {
+ printf("Rows affected: ");
+ printf("%d\n", PGconn->PGntuples());
+ } else if (rc & PG_RSTAT_HAVE_MESSAGE) {
+ printf("We got msg !\n");
+ fflush(stdout);
+ msg = PGconn->PGgetMessage();
+ if (!msg)
+ msg = (char*) "NULL";
+ printf("MSG: %s\n", msg);
+ fflush(stdout);
+ }
+ if (rc & PG_RSTAT_READY) {
+ printf("We made it !\n");
+ fflush(stdout);
+ cnt = 0;
+ break;
+ }
+ }
+ } // pgstat==3
+ vTaskDelay(1);
+ cnt--;
+ } // while (cnt>0)
+ PGconn->PGclose();
+ return rc;
+}
+
+static void init(void) {
+// int res;
+// printf("UART-Init:\n\n");
+// UART_init();
+// printf("IO-Init:\n\n");
+// IO_init();
+// printf("ETH-Init:\n\n");
+// ETH_init(0);
+// printf("UHF-Init:\n\n");
+// UHF_init();
+// printf("HMI-Init:\n\n");
+// HMI_init();
+ printf("I2C-Init:\n\n");
+ ESP_ERROR_CHECK(I2C_init());
+// printf("ADC-Init:\n\n");
+// ESP_ERROR_CHECK(ADC_init());
+ ESP_LOGI(TAG, "I2C initialized successfully");
+
+}
+static void main_loop() {
+ int res1 = 0, res2 = 0;
+ printf("Main loop\n");
+ fflush(stdout);
+// res1 = LCD->iSendProt(6, (char*) "page 0", 1);
+ printf("res:%d\n", res1);
+ fflush(stdout);
+// int door=1;
+
+// UHF_loop();
+// EditConfig();
+// UHF_loop();
+
+ while (1) {
+// ADCReadAll();
+
+ I2C_buf[0] = 0x02; // write data to output port 1
+ I2C_buf[1] = 0x55; // write data to output port 1
+ I2C_buf[2] = 0xAA; // write data to output port 1
+ res1 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP1, I2C_buf, 3, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ // printf("\nI2C wrote 0x%02X%02X: %d\n", I2C_buf[0], I2C_buf[1], res1);
+// I2C_buf[0] = 0x00; // lese 3 bytes
+// res2 = i2c_master_read_from_device(I2C_MASTER_NUM, I2C_PORTEXP1, I2C_buf, 1, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+
+ printf("\nMaster wrote %d %d %02X\n", res1,res2,I2C_buf[0]);
+
+
+ vTaskDelay(500 / portTICK_PERIOD_MS);
+ I2C_buf[0] = 0x02; // write data to output port 1
+ I2C_buf[1] = 0xAA; // write data to output port 1
+ I2C_buf[2] = 0x55; // write data to output port 1
+ res1 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP1, I2C_buf, 3, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ // printf("\nI2C wrote 0x%02X%02X: %d\n", I2C_buf[0], I2C_buf[1], res1);
+// I2C_buf[0] = 0x00; // lese 3 bytes
+// res2 = i2c_master_read_from_device(I2C_MASTER_NUM, I2C_PORTEXP1, I2C_buf, 1, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+
+ printf("\nMaster wrote %d %d %02X\n", res1,res2,I2C_buf[0]);
+
+
+ vTaskDelay(500 / portTICK_PERIOD_MS);
+ }
+
+ while (0) {
+ printf("Closed 1:%d\n",DoorIsClosed(LOCK1R));fflush(stdout);
+ printf("Closed 2:%d\n",DoorIsClosed(LOCK2R));fflush(stdout);
+ printf("Closed 3:%d\n",DoorIsClosed(LOCK3R));fflush(stdout);
+ printf("Closed 4:%d\n",DoorIsClosed(LOCK4R));fflush(stdout);
+ /*
+ res1 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP, I2C_buf, 2, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ printf("\nI2C wrote 0x%02X%02X: %d\n", I2C_buf[0], I2C_buf[1], res1);
+
+ vTaskDelay(1);
+
+ I2C_buf[0] = 0x05;
+ I2C_buf[1] = 0x00;
+ res1 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP, I2C_buf, 2, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ printf("\nI2C wrote 0x%02X%02X: %d\n", I2C_buf[0], I2C_buf[1], res1);
+
+ I2C_buf[0] = 0x80; // Setze CMD read port 0
+ I2C_buf[1] = 0x00;
+ I2C_buf[2] = 0x00;
+ res1 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP, I2C_buf, 1, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ printf("\nI2C wrote 0x%02X%02X: %d\n", I2C_buf[0], I2C_buf[1], res1);
+ I2C_buf[0] = 0x00; // lese 3 bytes
+ res2 = i2c_master_read_from_device(I2C_MASTER_NUM, I2C_PORTEXP, I2C_buf, 3, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ printf("\nI2C read 0x %02X %02X %02X: %d\n", I2C_buf[0], I2C_buf[1], I2C_buf[2], res2);
+ vTaskDelay(2000 / portTICK_PERIOD_MS);
+ printf(" #:S%d R:%d ", res1, res2);
+ fflush(stdout);
+ */
+
+ vTaskDelay(10000 / portTICK_PERIOD_MS);
+ DoorOpen(1);
+// vTaskDelay(10);
+ DoorOpen(2);
+ vTaskDelay(10);
+ DoorOpen(3);
+ vTaskDelay(10);
+ DoorOpen(4);
+ vTaskDelay(10);
+ printf("\n\n\n");fflush(stdout);
+ }
+}
+
+extern "C" {
+void app_main(void) {
+ init();
+ main_loop();
+}
+}
diff --git a/software/main/main.h b/software/main/main.h
new file mode 100644
index 0000000..cd7d9ec
--- /dev/null
+++ b/software/main/main.h
@@ -0,0 +1,130 @@
+/*
+ * main.h
+ *
+ * Created on: 26.02.2022
+ * Author: steffen
+ */
+#ifndef MAIN_MAIN_H_
+#define MAIN_MAIN_H_
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+#include <freertos/FreeRTOS.h>
+#include <freertos/task.h>
+#include <esp_netif.h>
+#include <esp_eth.h>
+#include <esp_log.h>
+#include <esp_spiffs.h>
+#include <esp_err.h>
+#include <driver/uart.h>
+#include <driver/gpio.h>
+#include <driver/i2c.h>
+#include <lwip/err.h>
+#include <lwip/sockets.h>
+
+
+// +3,3V // Pin 1
+// GND // Pin 2
+// ESP_EN // Pin 3
+#define UHF_RXD_MISO 36 // pin 4 UART
+#define LCD_RXD_MISO 39 // pin 5 UART
+// NC pin 6
+#define I2Cint 35 // pin 7 EXP
+#define SCL 32 // pin 8 EXP
+#define SDA 33 // pin 9 EXP
+#define EMAC_RXD0_RMII 25 // pin 10 ETH
+#define EMAC_RXD1_RMII 26 // pin 11 ETH
+#define EMAC_RX_CRS_DV 27 // pin 12 ETH
+#define HS2_CLK 14 // pin 13 ETH
+#define PHY_PWR 12 // pin 14 ETH
+// // pin 15 GND
+#define I2C_SDA_40p 13 // pin 16 40p
+// NC pin 17 bis 22
+#define HS2_CMD 15 // pin 23 ETH
+#define HS2_DATA0 02 // pin 24 ETH
+#define ETH_CLKREF 0 // pin 25 ETH
+#define UHF_TXD_MOSI 04 // pin 26 UART
+#define LCD_TXD_MOSI 16 // pin 27 UART
+#define EMAC_CLK_OUT_180 17 // pin 28 ETH
+#define SPI_CS 05 // pin 29 40p
+#define MDIO_RMII 18 // pin 30 ETH
+#define EMAC_TXD0_RMII 19 // pin 31 ETH
+//NC pin 32
+#define EMAC_TX_EN_RMII 21 // pin 33 ETH
+#define RDR_RXD_MISO 03 // pin 34 UART
+#define RDR_TXD_MOSI 01 // pin 35 UART
+#define EMAC_TXD1_RMII 22 // pin 36 ETH
+#define MDC_RMII 23 // pin 37 ETH
+//GND pin 38, 39
+#define RDR_UART_CHANNEL 0
+#define RDR_UART_BAUD_RATE 9600
+//#define RDR_UART_BAUD_RATE 115200
+#define RDR_UART_RX_PIN RDR_RXD_MISO
+#define RDR_UART_TX_PIN RDR_TXD_MOSI
+
+#define LCD_UART_CHANNEL 1
+#define LCD_UART_BAUD_RATE 115200
+#define LCD_UART_RX_PIN LCD_RXD_MISO
+#define LCD_UART_TX_PIN LCD_TXD_MOSI
+
+#define UHF_UART_CHANNEL 2 // for easy adaptation in the future
+#define UHF_UART_BAUD_RATE 115200
+#define UHF_UART_RX_PIN UHF_RXD_MISO
+#define UHF_UART_TX_PIN UHF_TXD_MOSI
+
+#define I2C_MASTER_SCL_IO SCL
+#define I2C_MASTER_SDA_IO SDA
+#define I2C_MASTER_NUM 0 /*!< I2C master i2c port number, the number of i2c peripheral interfaces available will depend on the chip */
+#define I2C_MASTER_FREQ_HZ 100000 /*!< I2C master clock frequency */
+#define I2C_MASTER_TX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */
+#define I2C_MASTER_RX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */
+#define I2C_MASTER_TIMEOUT_MS 1000
+
+#define I2C_PORTEXP1 0x58
+#define I2C_PORTEXP2 0x5A
+
+#define ADC_DEFAULT_IIC_ADDR 0x48
+#define ADC_CHAN_NUM 8
+#define ADC_REG_RAW_DATA_START 0x10
+#define ADC_REG_VOL_START 0x20
+#define ADC_REG_RTO_START 0x30
+#define ADC_REG_SET_ADDR 0xC0
+
+// GPA Output
+// GPB Input
+
+#define LOCK1 0x40
+#define LOCK2 0x10
+#define LOCK3 0x20
+#define LOCK4 0x80
+#define LOCK_MASK LOCK1+LOCK2+LOCK3+LOCK4
+#define LOCKPORT 0x01
+
+#define LOCK1R 0x04
+#define LOCK2R 0x01
+#define LOCK3R 0x02
+#define LOCK4R 0x08
+#define LOCKR_MASK LOCK1R+LOCK2R+LOCK3R+LOCK4R
+#define LOCKR_PORT 0x02
+
+#define TASK_STACK_SIZE 2048
+#define READ_BUF_SIZE 1024
+
+#define STX 0x02
+#define ETX 0x03
+#define EOT 0x04
+
+#define MAX_TAGS 256
+
+typedef struct {
+ unsigned char b[12];
+ unsigned char ant;
+ unsigned char rssi;
+ unsigned char count;
+} Tag_t;
+
+
+
+
+#endif /* MAIN_MAIN_H_ */
diff --git a/software/main/uart.cpp b/software/main/uart.cpp
new file mode 100644
index 0000000..c764ba2
--- /dev/null
+++ b/software/main/uart.cpp
@@ -0,0 +1,57 @@
+/*
+ * uart.cpp
+ *
+ * Created on: 26.02.2022
+ * Author: steffen
+ */
+#include "uart.h"
+
+void UART_init(void) {
+ int intr_alloc_flags = ESP_INTR_FLAG_IRAM;
+
+ vTaskDelay(100);
+#ifdef DEBUG
+ printf("LCD\n");
+ fflush(stdout);
+#endif
+ uart_config_t lcd_uart_config = {
+ .baud_rate = LCD_UART_BAUD_RATE,
+ .data_bits = UART_DATA_8_BITS,
+ .parity = UART_PARITY_DISABLE,
+ .stop_bits = UART_STOP_BITS_1,
+ .flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
+ .source_clk = UART_SCLK_APB,
+ };
+
+ ESP_ERROR_CHECK(uart_driver_install(LCD_UART_CHANNEL, READ_BUF_SIZE * 2, 0, 0, NULL, intr_alloc_flags));
+ ESP_ERROR_CHECK(uart_param_config(LCD_UART_CHANNEL, &lcd_uart_config));
+ ESP_ERROR_CHECK(uart_set_pin(LCD_UART_CHANNEL, LCD_UART_TX_PIN, LCD_UART_RX_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE));
+
+#ifdef DEBUG
+ printf("UHF\n");
+ fflush(stdout);
+#endif
+ uart_config_t uhf_uart_config = {
+ .baud_rate = UHF_UART_BAUD_RATE,
+ .data_bits = UART_DATA_8_BITS,
+ .parity = UART_PARITY_DISABLE,
+ .stop_bits = UART_STOP_BITS_1,
+ .flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
+ .source_clk = UART_SCLK_APB,
+ };
+
+ ESP_ERROR_CHECK(uart_driver_install(UHF_UART_CHANNEL, READ_BUF_SIZE * 2, 0, 0, NULL, intr_alloc_flags));
+ ESP_ERROR_CHECK(uart_param_config(UHF_UART_CHANNEL, &uhf_uart_config));
+ ESP_ERROR_CHECK(uart_set_pin(UHF_UART_CHANNEL, UHF_UART_TX_PIN, UHF_UART_RX_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE));
+}
+int UART_read(int channel, void *buf, int len = READ_BUF_SIZE) {
+ return (uart_read_bytes(channel, buf, len, 1));
+}
+int UART_write(int channel, void *buf, int len) {
+ return (uart_write_bytes(channel, serout, len));
+}
+void UART_debug(char *buf, int len) {
+ UART_write(0, (void*) buf, len);
+}
+
+
diff --git a/software/main/uart.h b/software/main/uart.h
new file mode 100644
index 0000000..14389a6
--- /dev/null
+++ b/software/main/uart.h
@@ -0,0 +1,22 @@
+/*
+ * uart.h
+ *
+ * Created on: 26.02.2022
+ * Author: steffen
+ */
+#ifndef MAIN_UART_H_
+#define MAIN_UART_H_
+#include "main.h"
+
+//static char serin[READ_BUF_SIZE + 16];
+static char serout[READ_BUF_SIZE + 16];
+
+void UART_init(void);
+void UART_debug(char *buf, int len);
+int UART_read(int channel, void *buf, int len);
+int UART_write(int channel, void *buf, int len);
+
+
+
+
+#endif /* MAIN_UART_H_ */
diff --git a/software/michi_funcs/AW9523B.cpp b/software/michi_funcs/AW9523B.cpp
new file mode 100644
index 0000000..bc65ace
--- /dev/null
+++ b/software/michi_funcs/AW9523B.cpp
@@ -0,0 +1,225 @@
+/**************************************************************************/
+/*!
+ @file AW9523B.cpp
+
+ Author: Michi
+ License: MIT (see LICENSE)
+*/
+/**************************************************************************/
+
+
+#ifdef STM32
+ #include "stm32l4xx_hal.h"
+#else
+ #include <sys/types.h>
+ #include <stdio.h>
+ #include "driver/i2c.h"
+ #define I2C_MASTER_TIMEOUT_MS 1000
+#endif
+#include "AW9523B.hpp"
+
+
+//#include <stdint.h>
+//#include <stdbool.h>
+
+
+#define _REG(port, reg) (port == P0 ? reg : reg + 1)
+
+AW9523B *i2c_gpio;
+
+uint8_t AW9523B::readI2C(uint8_t reg)
+{
+ //AW9523B_REG_ID
+ uint8_t gelesen = 0;
+ uint16_t MemAddress;
+ MemAddress = reg;
+//HAL_StatusTypeDef HAL_I2C_Mem_Read(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout)
+#ifdef STM32
+ HAL_StatusTypeDef ret;
+ ret = HAL_I2C_Mem_Read( &(this->i2c_handle), _addr, MemAddress, 1, &gelesen, 1, HAL_MAX_DELAY);
+ if (ret != HAL_OK)
+#else
+ esp_err_t res1;
+ printf("I2C read I2C-Bus:%d Addr:%d Register: %d BEGIN \n", this->i2c_num, _addr, reg );
+ //res1 = i2c_master_read_from_device(this->i2c_num, _addr, /*i2c_buf*/&gelesen, 1, I2C_MASTER_TIMEOUT_MS / portTICK_RATE_MS);
+ res1 = i2c_master_write_read_device(this->i2c_num, _addr, &reg, 1, &gelesen, 2, I2C_MASTER_TIMEOUT_MS / portTICK_RATE_MS);
+ printf(" --> gelesen Byte: %d \n", gelesen );
+ if (res1 != ESP_OK)
+#endif
+ { printf("ERROR I2C read I2C -------------------------- \n"); ESP_ERROR_CHECK_WITHOUT_ABORT(res1); return 0; }
+ else { printf(" I2C read I2C-Bus OK \n"); return gelesen; }
+}
+
+//bool i2c_write(uint16_t MemAddress, uint8_t *pData)
+uint8_t AW9523B::writeI2C(uint8_t reg, uint8_t val)
+{
+ //AW9523B_REG_ID
+ uint16_t MemAddress;
+ MemAddress = reg;
+ //HAL_I2C_Mem_Write(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress,
+ //uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout)
+#ifdef STM32
+ HAL_StatusTypeDef ret;
+ ret = HAL_I2C_Mem_Write( &(this->i2c_handle), _addr, MemAddress, 1, &val, 1, HAL_MAX_DELAY);
+ if (ret != HAL_OK)
+#else
+ uint8_t I2C_buf[3];
+ esp_err_t res1 = ESP_OK;
+ I2C_buf[0] = reg; //0x02; // write to register 0x02
+ I2C_buf[1] = 255;
+ I2C_buf[2] = 255;
+ //res1 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP1, I2C_buf, 3, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ //ESP_ERROR_CHECK(res1 );
+ if (res1 != ESP_OK)
+#endif
+ { printf("ERROR I2C write I2C -------------------------- \n"); ESP_ERROR_CHECK_WITHOUT_ABORT(res1); return false; }
+ else { printf(" I2C write I2C OK \n"); return true; }
+}
+
+
+#ifdef STM32
+AW9523B::AW9523B(uint8_t address, I2C_HandleTypeDef _i2c_handle) //AD[1:0] address offset
+{
+ i2c_handle = _i2c_handle;
+ _addr = AW9523B_I2C_ADDRESS + (address & 0x03);
+#else
+AW9523B::AW9523B(uint8_t address, int _i2c_num) //AD[1:0] address offset
+{
+ i2c_num = _i2c_num; //I2C number, 0 or 1 on ESP32
+ _addr = 0x58;/*AW9523B_I2C_ADDRESS; 0x58 for first AW9523, 0x58 for the second */
+#endif
+}
+
+bool AW9523B::begin()
+{
+// Wire.begin();
+// return readI2C(AW9523B_REG_ID) == AW9523B_ID;
+#ifdef STM32
+ HAL_StatusTypeDef ret;
+ ret = HAL_I2C_IsDeviceReady (&i2c_handle, _addr, 1, 1000);
+ if (ret == HAL_OK)
+#else
+ uint8_t I2C_buf[3];
+ esp_err_t res1 = ESP_OK, res2 = ESP_OK;
+ I2C_buf[0] = 0x7F; // write to soft-RESET register on AW9523
+ I2C_buf[1] = 0x00; // write 0 to reset the AW9523
+// res1 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP1, I2C_buf, 2, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+// res2 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP2, I2C_buf, 2, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ printf("\nMaster wrote %d %d %02X\n", res1,res2,I2C_buf[0]);
+
+ if ( readI2C(AW9523B_REG_ID) == AW9523B_ID )
+#endif
+ {
+ return true;
+ } else { return false; }
+}
+
+void AW9523B::scanAllAddress(void)
+{
+ esp_err_t res1;
+ uint8_t gelesen = 0;
+ uint8_t reg_addr = AW9523B_REG_ID;
+ printf("Scanning I2C bus for devices:\n");
+ fflush(stdout);
+ for (int i=0; i<255; i++)
+ {
+ //i2c_master_write_read_device(I2C_MASTER_NUM, slave_addr, &reg_addr, 1, data, 2, I2C_MASTER_TIMEOUT_MS / portTICK_RATE_MS);
+ //res1 = i2c_master_read_from_device(0, i, AW9523B_REG_ID, 1, &gelesen, 1, I2C_MASTER_TIMEOUT_MS / portTICK_RATE_MS);
+ res1 = i2c_master_write_read_device(0, i, &reg_addr, 1, &gelesen, 1, I2C_MASTER_TIMEOUT_MS / portTICK_RATE_MS);
+ if (res1 == ESP_OK)
+ {
+ printf("\ndevice found on I2C-address %d, read value: %d AW9523=16 \n", i, gelesen);
+
+ }
+ else { printf("."); }
+ fflush(stdout);
+ gelesen = 0;
+ }
+ printf("\nfinish I2C Bus scan\n");
+}
+
+void AW9523B::configInOut(AW9523BPort port, uint8_t inout)
+{
+ writeI2C(_REG(port, AW9523B_P0_CONF_STATE), inout);
+}
+
+void AW9523B::configLedGPIO(AW9523BPort port, uint8_t ledGpio)
+{
+ writeI2C(_REG(port, AW9523B_P0_LED_MODE), ledGpio);
+}
+
+void AW9523B::setPort0Mode(AW9523BPortMode mode)
+{
+ writeI2C(AW9523B_REG_GLOB_CTR, mode | ledsDim);
+}
+
+void AW9523B::setLedsDim(AW9523BLedsDim dim)
+{
+ writeI2C(AW9523B_REG_GLOB_CTR, dim | portMode);
+}
+
+void AW9523B::setLed(AW9523BLedDimCtrl led, uint8_t value)
+{
+ writeI2C(led, value);
+}
+
+void AW9523B::portIn(AW9523BPort port)
+{
+ _portIn = _REG(port, AW9523B_P0_IN_STATE);
+}
+
+void AW9523B::portOut(AW9523BPort port)
+{
+ _portOut = _REG(port, AW9523B_P0_OUT_STATE);
+}
+
+uint8_t AW9523B::read()
+{
+ return readI2C(_portIn);
+}
+
+uint8_t AW9523B::read(AW9523BPort port)
+{
+ return readI2C(AW9523B_P0_IN_STATE + port);
+}
+
+uint8_t AW9523B::write(uint8_t data)
+{
+ return writeI2C(_portOut, data);
+}
+
+uint8_t AW9523B::write(AW9523BPort port, uint8_t data)
+{
+ return writeI2C(AW9523B_P0_OUT_STATE + port, data);
+}
+
+void AW9523B::reset()
+{
+ writeI2C(AW9523B_REG_SOFT_RST, 0);
+}
+
+#ifdef STM32
+ extern "C" bool AW9523B_init(uint8_t address, I2C_HandleTypeDef _i2c_handle)
+ {
+ i2c_gpio = new AW9523B(address, _i2c_handle);
+ if (!i2c_gpio->begin() )
+ {
+ //Serial.println("Error: AW9523B not found!");
+ return false;
+ } else
+ {
+ i2c_gpio->reset();
+ i2c_gpio->setPort0Mode(PUSH_PULL);
+ return true;
+ }
+ }
+ extern "C" void AW9523B_destroy(void)
+ {
+ delete i2c_gpio;
+ }
+ extern "C" void AW9523B_setAllOutputHigh(void)
+ {
+ i2c_gpio->write(P0, 255);
+ i2c_gpio->write(P1, 255);
+ }
+#endif
diff --git a/software/michi_funcs/AW9523B.hpp b/software/michi_funcs/AW9523B.hpp
new file mode 100644
index 0000000..4699a02
--- /dev/null
+++ b/software/michi_funcs/AW9523B.hpp
@@ -0,0 +1,151 @@
+
+/**************************************************************************/
+/*!
+ @file AW9523B.h
+
+ Author: Manuel Polo (https://about.me/mrmx)
+ License: MIT (see LICENSE)
+*/
+/**************************************************************************/
+
+#ifndef _AW9523B_H_
+#define _AW9523B_H_
+
+//#include <Arduino.h>
+//#include <stdint.h>
+//#include <stdbool.h>
+
+#ifdef STM32
+ #include "stm32l4xx_hal.h"
+#endif
+
+
+/** Registers */
+#define AW9523B_I2C_ADDRESS 0x58 ///< I2C base address for AW9523B
+#define AW9523B_REG_ID 0x10 ///< id register
+#define AW9523B_ID 0x23 ///< id value
+#define AW9523B_P0_IN_STATE 0x00 ///< P0 port input state
+#define AW9523B_P1_IN_STATE 0x01 ///< P1 port input state
+#define AW9523B_P0_OUT_STATE 0x02 ///< P0 port output state
+#define AW9523B_P1_OUT_STATE 0x03 ///< P1 port output state
+#define AW9523B_P0_CONF_STATE 0x04 ///< P0 port config state
+#define AW9523B_P1_CONF_STATE 0x05 ///< P1 port config state
+#define AW9523B_REG_GLOB_CTR 0x11 ///< Global control register
+#define AW9523B_P0_LED_MODE 0x12 ///< P0 port led mode switch register
+#define AW9523B_P1_LED_MODE 0x13 ///< P1 port led mode switch register
+#define AW9523B_REG_SOFT_RST 0x7F ///< Soft reset register
+
+
+
+/** AW9523B Port constants */
+enum AW9523BPort
+{
+ P0 = 0x00, // Port 0
+ P1 = 0x01, // Port 1
+};
+
+enum AW9523BPortMode
+{
+ OPEN_DRAIN = 0x00, // Port 0 open drain mode
+ PUSH_PULL = 1 << 4 // Port 0 push pull mode
+};
+
+/** AW9523B Port0 LED dimmer constants: 256 step dimming range select*/
+enum AW9523BLedsDim
+{
+ DIM_MAX = 0x00,//B00, // 0~IMAX 37mA(typical)
+ DIM_MED = 0x01,//B01, // 0~(IMAX×3/4)
+ DIM_LOW = 0x02,//B10, // 0~(IMAX×2/4)
+ DIM_MIN = 0x03,//B11, // 0~(IMAX×1/4)
+};
+
+/** AW9523B LED dimm current control registers*/
+enum AW9523BLedDimCtrl
+{
+ P1_0 = 0x20, // DIM0
+ P1_1 = 0x21, // DIM1
+ P1_2 = 0x22, // DIM2
+ P1_3 = 0x23, // DIM3
+ P0_0 = 0x24, // DIM4
+ P0_1 = 0x25, // DIM5
+ P0_2 = 0x26, // DIM6
+ P0_3 = 0x27, // DIM7
+ P0_4 = 0x28, // DIM8
+ P0_5 = 0x29, // DIM9
+ P0_6 = 0x2A, // DIM10
+ P0_7 = 0x2B, // DIM11
+ P1_4 = 0x2C, // DIM12
+ P1_5 = 0x2D, // DIM13
+ P1_6 = 0x2E, // DIM14
+ P1_7 = 0x2F, // DIM15
+};
+
+// Uncomment to enable debug messages
+//#define AW9523B_DEBUG
+
+// Define where debug output will be printed
+#define DEBUG_PRINTER Serial
+
+// Setup debug printing macros
+#ifdef AW9523B_DEBUG
+#define DEBUG_PRINT(...) \
+ { \
+ DEBUG_PRINTER.print(__VA_ARGS__); \
+ }
+#define DEBUG_PRINTLN(...) \
+ { \
+ DEBUG_PRINTER.println(__VA_ARGS__); \
+ }
+#else
+#define DEBUG_PRINT(...) \
+ { \
+ }
+#define DEBUG_PRINTLN(...) \
+ { \
+ }
+#endif
+
+/**************************************************************************/
+/*!
+ @brief AW9523B I2C 16bit GPIO expander and LED driver
+*/
+/**************************************************************************/
+class AW9523B
+{
+
+public:
+#ifdef STM32
+ AW9523B(uint8_t address, I2C_HandleTypeDef _i2c_handle); //AD[1:0] address offset
+#else
+ AW9523B(uint8_t address, int _i2c_num); //AD[1:0] address offset
+#endif
+ bool begin();
+ void configInOut(AW9523BPort port, uint8_t inout);
+ void configLedGPIO(AW9523BPort port, uint8_t ledGpio);
+ void setPort0Mode(AW9523BPortMode mode);
+ void setLedsDim(AW9523BLedsDim value);
+ void setLed(AW9523BLedDimCtrl led, uint8_t value);
+ void portIn(AW9523BPort port);
+ void portOut(AW9523BPort port);
+ uint8_t read();
+ uint8_t read(AW9523BPort port);
+ uint8_t write(uint8_t data);
+ uint8_t write(AW9523BPort port, uint8_t data);
+ void reset();
+ void scanAllAddress(void);
+private:
+ uint8_t writeI2C(uint8_t reg, uint8_t val);
+ uint8_t readI2C(uint8_t reg);
+ uint8_t _addr;
+ uint8_t _portIn = AW9523B_P0_IN_STATE;
+ uint8_t _portOut = AW9523B_P0_OUT_STATE;
+ AW9523BPortMode portMode = OPEN_DRAIN;
+ AW9523BLedsDim ledsDim = DIM_MAX;
+#ifdef STM32
+ I2C_HandleTypeDef i2c_handle;//Michi
+#else
+ /*i2c_port_t*/int i2c_num;
+#endif
+};
+
+#endif // _AW9523B_H_
diff --git a/software/michi_funcs/SimplePgSQL.cpp b/software/michi_funcs/SimplePgSQL.cpp
new file mode 100644
index 0000000..0d1612a
--- /dev/null
+++ b/software/michi_funcs/SimplePgSQL.cpp
@@ -0,0 +1,1278 @@
+/*
+ * SimplePgSQL.c - Lightweight PostgreSQL connector for Arduino
+ * Copyright (C) Bohdan R. Rau 2016 <ethanak@polip.com>
+ *
+ * SimplePgSQL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * SimplePgSQL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with SimplePgSQL. If not, write to:
+ * The Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301, USA.
+ */
+
+ // 238 469 / 34004
+
+ //version 2022-02-17
+
+#include "SimplePgSQL.h"
+
+
+
+#ifdef ESP32
+#define strchr_P strchr
+#endif
+
+#ifdef PG_USE_MD5
+static void
+bytesToHex(const uint8_t b[16], char *s)
+{
+ int q, w;
+#ifndef ESP32
+ static PROGMEM const char hex[] = "0123456789abcdef";
+ for (q = 0, w = 0; q < 16; q++)
+ {
+ s[w++] = pgm_read_byte(&hex[(b[q] >> 4) & 0x0F]);
+ s[w++] = pgm_read_byte(&hex[b[q] & 0x0F]);
+ }
+#else
+ static const char hex[] = "0123456789abcdef";
+ for (q = 0, w = 0; q < 16; q++)
+ {
+ s[w++] = hex[(b[q] >> 4) & 0x0F];
+ s[w++] = hex[b[q] & 0x0F];
+ }
+#endif
+ s[w] = '\0';
+}
+
+#ifdef ESP32_IDF
+#include "esp_log.h"
+#endif
+
+#ifdef ESP32
+#include <mbedtls/md5.h>
+
+static void pg_md5_encrypt(const char *password, char *salt, int salt_len, char *outbuf)
+{
+ md5_context_t context;
+ uint8_t sum[16];
+ *outbuf++ = 'm';
+ *outbuf++ = 'd';
+ *outbuf++ = '5';
+ mbedtls_md5_init(&context);
+ mbedtls_md5_update_ret(&context, (uint8_t *)password, strlen(password));
+ mbedtls_md5_update_ret(&context, (uint8_t *)salt, salt_len);
+ mbedtls_md5_finish_ret( &context, sum);
+ bytesToHex(sum, outbuf);
+}
+#elif defined(ESP8266)
+#include <md5.h>
+static void pg_md5_encrypt(const char *password, char *salt, int salt_len, char *outbuf)
+{
+ md5_context_t context;
+ uint8_t sum[16];
+ *outbuf++ = 'm';
+ *outbuf++ = 'd';
+ *outbuf++ = '5';
+ MD5Init(&context);
+ MD5Update(&context, (uint8_t *)password, strlen(password));
+ MD5Update(&context, (uint8_t *)salt, salt_len);
+ MD5Final(sum, &context);
+ bytesToHex(sum, outbuf);
+}
+#else
+//#include <MD5.h>
+static void pg_md5_encrypt(const char *password, char *salt, int salt_len, char *outbuf)
+{
+ MD5_CTX context;
+ uint8_t sum[16];
+ *outbuf++ = 'm';
+ *outbuf++ = 'd';
+ *outbuf++ = '5';
+
+ MD5::MD5Init(&context);
+ MD5::MD5Update(&context, (uint8_t *)password, strlen(password));
+ MD5::MD5Update(&context, (uint8_t *)salt, salt_len);
+ MD5::MD5Final(sum, &context);
+ bytesToHex(sum, outbuf);
+}
+#endif
+#endif
+
+#define MD5_PASSWD_LEN 35
+#define AUTH_REQ_OK 0 /* User is authenticated */
+#define AUTH_REQ_PASSWORD 3 /* Password */
+#define AUTH_REQ_MD5 5 /* md5 password */
+
+#ifndef ESP32_IDF
+static PROGMEM const char EM_OOM [] = "Out of memory";
+static PROGMEM const char EM_READ [] = "Backend read error";
+static PROGMEM const char EM_WRITE [] = "Backend write error";
+static PROGMEM const char EM_CONN [] = "Cannot connect to server";
+static PROGMEM const char EM_SYNC [] = "Backend out of sync";
+static PROGMEM const char EM_INTR [] = "Internal error";
+static PROGMEM const char EM_UAUTH [] = "Unsupported auth method";
+static PROGMEM const char EM_BIN [] = "Binary format not supported";
+static PROGMEM const char EM_EXEC [] = "Previous execution not finished";
+static PROGMEM const char EM_PASSWD [] = "Password required";
+static PROGMEM const char EM_EMPTY [] = "Query is empty";
+static PROGMEM const char EM_FORMAT [] = "Illegal formatting character";
+#else
+static const char EM_OOM [] = "Out of memory";
+static const char EM_READ [] = "Backend read error";
+static const char EM_WRITE [] = "Backend write error";
+static const char EM_CONN [] = "Cannot connect to server";
+static const char EM_SYNC [] = "Backend out of sync";
+static const char EM_INTR [] = "Internal error";
+static const char EM_UAUTH [] = "Unsupported auth method";
+static const char EM_BIN [] = "Binary format not supported";
+static const char EM_EXEC [] = "Previous execution not finished";
+static const char EM_PASSWD [] = "Password required";
+static const char EM_EMPTY [] = "Query is empty";
+static const char EM_FORMAT [] = "Illegal formatting character";
+
+#define PGTAG "PGSQL"
+#endif
+
+#ifndef ESP32_IDF
+PGconnection::PGconnection(Client *c,
+ int flags,
+ int memory,
+ char *foreignBuffer)
+{
+ conn_status = CONNECTION_NEEDED;
+ client = c;
+ Buffer = foreignBuffer;
+ _passwd = NULL;
+ _flags = flags & ~PG_FLAG_STATIC_BUFFER;
+
+ if (memory <= 0) bufSize = PG_BUFFER_SIZE;
+ else bufSize = memory;
+ if (foreignBuffer) {
+ _flags |= PG_FLAG_STATIC_BUFFER;
+ }
+}
+#else
+PGconnection::PGconnection(const int flags, const unsigned char *_Buffer, const int _bufSize) {
+ conn_status = CONNECTION_NEEDED;
+ _passwd = NULL;
+ _user = NULL;
+ Buffer = (char *) _Buffer;
+ bufSize = _bufSize;
+ bufPos = 0;
+ result_status=0;
+ _available=0;
+ _nfields=0;
+ _ntuples=0;
+ _flags=0;
+
+ conn_status = CONNECTION_NEEDED;
+ _flags = flags & ~PG_FLAG_STATIC_BUFFER;
+ bufSize = PG_BUFFER_SIZE;
+}
+#endif
+
+#ifndef ESP32_IDF
+int PGconnection::setDbLogin(IPAddress server,
+ const char *user,
+ const char *passwd,
+ const char *db,
+ const char *charset,
+ int port)
+{
+
+ char *startpacket;
+ int packetlen;
+ int len;
+
+ close();
+ if (!db) db = user;
+ len = strlen(user) + 1;
+ if (passwd) {
+ len += strlen(passwd) + 1;
+ }
+ _user = (char *)malloc(len);
+ strcpy(_user, user);
+ if (passwd) {
+ _passwd = _user + strlen(user) + 1;
+ strcpy(_passwd, passwd);
+ }
+ else {
+ _passwd = NULL;
+ }
+ if (!Buffer) Buffer = (char *) malloc(bufSize);
+ byte connected = client -> connect(server, port);
+ if (!connected) {
+ setMsg_P(EM_CONN, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ packetlen = build_startup_packet(NULL, db, charset);
+ if (packetlen > bufSize - 10) {
+ setMsg_P(EM_OOM, PG_RSTAT_HAVE_ERROR);
+ conn_status = CONNECTION_BAD;
+ return conn_status;
+ }
+ startpacket=Buffer + (bufSize - (packetlen + 1));
+ build_startup_packet(startpacket, db, charset);
+ if (pqPacketSend(0, startpacket, packetlen) < 0) {
+ setMsg_P(EM_WRITE, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ attempts = 0;
+ return conn_status = CONNECTION_AWAITING_RESPONSE;
+}
+#else
+int PGconnection::setDbLogin(const char *ServerIP, int ServerPort, const char *dbName, const char *dbUser, const char *dbPasswd, const char *dbCharset) {
+
+ char *startpacket;
+ int packetlen;
+ int len;
+
+// close();
+ memset(&DestAddr, 0, sizeof(DestAddr));
+ AddrFamily = AF_INET;
+ ipProtocol = IPPROTO_IP;
+ DestAddr.sin_addr.s_addr = inet_addr(ServerIP);
+ DestAddr.sin_family = AF_INET;
+ DestAddr.sin_port = htons(ServerPort);
+
+ if (!dbName)
+ dbName = dbUser;
+ len = strlen(dbUser) + 1;
+ if (dbPasswd) {
+ len += strlen(dbPasswd) + 1;
+ }
+ _user = (char *) malloc(len);
+ strcpy(_user, dbUser);
+ if (dbPasswd) {
+ _passwd = _user + strlen(dbUser) + 1;
+ strcpy(_passwd, dbPasswd);
+ } else {
+ _passwd = NULL;
+ }
+
+ //int8_t connected = connect(client->connect(server, port);
+ SockH = socket(AddrFamily, SOCK_STREAM, ipProtocol);
+ if (SockH < 0) {
+ ESP_LOGE(PGTAG, "Unable to create socket: errno %d", errno);
+ setMsg_P(EM_CONN, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ } else {
+ int err = connect(SockH, (struct sockaddr *) &DestAddr, sizeof(DestAddr));
+ if (err != 0) {
+ ESP_LOGE(PGTAG, "Socket unable to connect: errno %d", errno);
+ return conn_status = CONNECTION_BAD;
+ }
+ NetConnected = 1;
+ ESP_LOGI(PGTAG, "Successfully connected");
+ }
+
+ packetlen = build_startup_packet(NULL, dbName, dbCharset);
+ if (packetlen > bufSize - 10) {
+ setMsg_P(EM_OOM, PG_RSTAT_HAVE_ERROR);
+ conn_status = CONNECTION_BAD;
+ return conn_status;
+ }
+
+ startpacket = Buffer + (bufSize - (packetlen + 1));
+ build_startup_packet(startpacket, dbName, dbCharset);
+ if (pqPacketSend(0, startpacket, packetlen) < 0) {
+ setMsg_P(EM_WRITE, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ attempts = 0;
+ return conn_status = CONNECTION_AWAITING_RESPONSE;
+}
+
+void close_socket(int _SockH)
+{
+ close(_SockH);
+}
+#endif
+
+void PGconnection::close(void)
+{
+#ifndef ESP32_IDF
+ if (client->connected()) {
+#else
+ if (NetConnected) {
+#endif
+ pqPacketSend('X', NULL, 0);
+#ifndef ESP32_IDF
+ client->stop();
+#else
+ shutdown(SockH, 0);
+ close_socket(SockH);
+#endif
+ }
+ if (Buffer && !(_flags & PG_FLAG_STATIC_BUFFER)) {
+ free(Buffer);
+ Buffer = NULL;
+ }
+ if (_user) {
+ free(_user);
+ _user = _passwd = NULL;
+ }
+ conn_status = CONNECTION_NEEDED;
+
+#ifndef ESP32_IDF
+ NetConnected = 0;
+#endif
+}
+
+#ifdef ESP32_IDF
+int PGconnection::dataAvailable() {
+ int res=0;
+// if (_available) return _available;
+ ioctl(SockH,FIONREAD,&res);
+ return res;
+}
+#endif
+
+int PGconnection::status(void)
+{
+ char bereq;
+ char rc;
+ int32_t msgLen;
+ int32_t areq;
+ char * pwd = _passwd;
+#ifdef PG_USE_MD5
+ char salt[4];
+#endif
+
+ switch(conn_status) {
+ case CONNECTION_NEEDED:
+ case CONNECTION_OK:
+ case CONNECTION_BAD:
+
+ return conn_status;
+
+ case CONNECTION_AWAITING_RESPONSE:
+#ifndef ESP32_IDF
+ if (!client->available()) return conn_status;
+#else
+ if (dataAvailable() == 0) return conn_status;
+#endif
+ if (attempts++ >= 2) {
+ setMsg_P(EM_SYNC, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ if (pqGetc(&bereq)) {
+ goto read_error;
+ }
+ if (bereq == 'E') {
+ pqGetInt4(&msgLen);
+ pqGetNotice(PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ if (bereq != 'R') {
+ setMsg_P(EM_SYNC, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ if (pqGetInt4(&msgLen)) {
+ goto read_error;
+ }
+ if (pqGetInt4(&areq)) {
+ goto read_error;
+ }
+ if (areq == AUTH_REQ_OK) {
+ if (_user) {
+ free(_user);
+ _user = _passwd=NULL;
+ }
+ result_status = PG_RSTAT_READY;
+ return conn_status = CONNECTION_AUTH_OK;
+ }
+ if (
+#ifdef PG_USE_MD5
+ areq != AUTH_REQ_MD5 &&
+#endif
+ areq != AUTH_REQ_PASSWORD) {
+ setMsg_P(EM_UAUTH, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ if (!_passwd || !*_passwd) {
+ setMsg_P(EM_PASSWD, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ pwd = _passwd;
+#ifdef PG_USE_MD5
+ if (areq == AUTH_REQ_MD5) {
+ if (pqGetnchar(salt, 4)) goto read_error;
+ if (bufSize < 3 * MD5_PASSWD_LEN + 10) {
+ setMsg_P(EM_OOM, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ char *crypt_pwd = Buffer + (bufSize - (2 * (MD5_PASSWD_LEN + 1)));
+ char *crypt_pwd2 = crypt_pwd + MD5_PASSWD_LEN + 1;
+ pg_md5_encrypt(pwd, _user, strlen(_user), crypt_pwd2);
+ pg_md5_encrypt(crypt_pwd2 + 3, salt,4, crypt_pwd);
+ pwd = crypt_pwd;
+ }
+#endif
+ rc=pqPacketSend('p', pwd, strlen(pwd) + 1);
+ if (rc) {
+ goto write_error;
+ }
+ return conn_status;
+
+ case CONNECTION_AUTH_OK:
+ for (;;) {
+#ifndef ESP32_IDF
+ if (!client -> available()) return conn_status;
+#else
+ if (dataAvailable() == 0) return conn_status;
+#endif
+ if (pqGetc(&bereq)) goto read_error;
+ if (pqGetInt4(&msgLen)) goto read_error;
+ msgLen -= 4;
+ if (bereq == 'A' || bereq == 'N' || bereq == 'S' || bereq == 'K') {
+ if (pqSkipnchar(msgLen)) goto read_error;
+ continue;
+ }
+ if (bereq == 'E') {
+ pqGetNotice(PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+
+/* if (bereq == 'K') {
+ if (pqGetInt4(&be_pid)) goto read_error;
+ if (pqGetInt4(&be_key)) goto read_error;
+ continue;
+ }
+*/
+ if (bereq == 'Z') {
+ pqSkipnchar(msgLen);
+ return conn_status = CONNECTION_OK;
+ }
+ return conn_status = CONNECTION_BAD;
+ }
+
+ default:
+ setMsg_P(EM_INTR, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+read_error:
+ setMsg_P(EM_READ, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+write_error:
+ setMsg_P(EM_WRITE, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+}
+
+int PGconnection::execute(const char *query, int progmem)
+{
+#ifndef ESP32
+// for unknown reason, this status check get wrong on ESP32-IDF.
+// uncommenting solve the problem for now, but need invesitgation
+ if (!(result_status & PG_RSTAT_READY)) {
+ setMsg_P(EM_EXEC, PG_RSTAT_HAVE_ERROR);
+ return -1;
+ }
+#endif
+ int len =
+#ifndef ESP32
+ progmem ? strlen_P(query) :
+#endif
+ strlen(query);
+
+#ifndef ESP32_IDF
+ if (pqPacketSend('Q', query, len+1, progmem)) {
+#else
+ if (pqPacketSend('Q', query, len + 1)) {
+#endif
+ setMsg_P(EM_WRITE, PG_RSTAT_HAVE_ERROR);
+ conn_status = CONNECTION_BAD;
+ return -1;
+ }
+ result_status = PG_RSTAT_COMMAND_SENT;
+ return 0;
+
+}
+/*
+int PGconnection::PGexecute(const char *query) {
+ int len = strlen(query);
+ if (pqPacketSend('Q', query, len + 1)) {
+ setMsg_P(EM_WRITE, PG_RSTAT_HAVE_ERROR);
+ conn_status = CONNECTION_BAD;
+ return -1;
+ }
+ result_status = PG_RSTAT_COMMAND_SENT;
+ return 0;
+}
+*/
+
+
+int PGconnection::escapeName(const char *inbuf, char *outbuf)
+{
+ const char *c;
+ int l = 2;
+ for (c=inbuf; *c; c++) {
+ l++;
+ if (*c == '\\' || *c == '"') l++;
+ }
+ if (outbuf) {
+ *outbuf++='"';
+ for (c=inbuf; *c; c++) {
+ *outbuf++ = *c;
+ if (*c == '\\' || *c == '"') *outbuf++ = *c;
+ }
+ *outbuf++='"';
+ }
+ return l;
+}
+
+int PGconnection::escapeString(const char *inbuf, char *outbuf)
+{
+ const char *c;
+ int e = 0, l;
+ for (c=inbuf; *c; c++) {
+ if (*c == '\\' || *c == '\'') e++;
+ }
+ l = e + (c - inbuf) + (e ? 4 : 2);
+ if (outbuf) {
+ if (e) {
+ *outbuf++=' ';
+ *outbuf++='E';
+ }
+ *outbuf++='\'';
+ for (c=inbuf; *c; c++) {
+ *outbuf++ = *c;
+ if (*c == '\\' || *c == '\'') *outbuf++ = *c;
+ }
+ *outbuf++='\'';
+ }
+ return l;
+}
+
+char * PGconnection::getValue(int nr)
+{
+ int i;
+ if (_null & (1<<nr)) return NULL;
+ char *c=Buffer;
+ if (nr < 0 || nr >= _nfields) return NULL;
+ for (i=0; i < nr; i++) {
+ if (_null & (1 <<i)) continue;
+ c += strlen(c) + 1;
+ }
+ return c;
+}
+
+char *PGconnection::getColumn(int n)
+{
+ char *c;int i;
+ if (!(result_status & PG_RSTAT_HAVE_COLUMNS)) return NULL;
+ if (n < 0 || n >= _nfields) return NULL;
+ for (c = Buffer, i = 0; i<n; i++) {
+ c += strlen(c) + 1;
+ }
+ return c;
+}
+
+char *PGconnection::getMessage(void)
+{
+ if (!(result_status & PG_RSTAT_HAVE_MESSAGE)) return NULL;
+ return Buffer;
+}
+
+int PGconnection::getData(void)
+{
+ char id;
+ int32_t msgLen;
+ int rc;
+ char *c;
+#ifndef ESP32_IDF
+ if (!client -> available()) return 0;
+#else
+ if (dataAvailable() == 0) return 0;
+#endif
+
+
+ if (pqGetc(&id)) goto read_error;
+ if (pqGetInt4(&msgLen)) goto read_error;
+ //Serial.printf("ID=%c\n", id);
+ msgLen -= 4;
+ switch(id) {
+ case 'T':
+ if ((rc=pqGetRowDescriptions())) {
+ if (rc == -2) setMsg_P(EM_OOM, PG_RSTAT_HAVE_ERROR);
+ else if (rc == -3) setMsg_P(EM_BIN, PG_RSTAT_HAVE_ERROR);
+ goto read_error;
+ }
+ if (_flags & PG_FLAG_IGNORE_COLUMNS) {
+ result_status &= ~PG_RSTAT_HAVE_MASK;
+ return 0;
+ }
+ return result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | PG_RSTAT_HAVE_COLUMNS;
+
+ case 'E':
+ if (pqGetNotice(PG_RSTAT_HAVE_ERROR)) goto read_error;
+ return result_status;
+
+ case 'N':
+ if (_flags & PG_FLAG_IGNORE_NOTICES) {
+ if (pqSkipnchar(msgLen)) goto read_error;
+ return 0;
+ }
+ if(pqGetNotice(PG_RSTAT_HAVE_NOTICE)) goto read_error;
+ return result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | PG_RSTAT_HAVE_NOTICE;
+
+ case 'A':
+ if (_flags & PG_FLAG_IGNORE_NOTICES) {
+ if (pqSkipnchar(msgLen)) goto read_error;
+ return 0;
+ }
+ if (pqGetNotify(msgLen)) goto read_error;
+ return result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | PG_RSTAT_HAVE_NOTICE;
+
+ case 'Z':
+ if (pqSkipnchar(msgLen)) goto read_error;
+ result_status = (result_status & PG_RSTAT_HAVE_SUMMARY) | PG_RSTAT_READY;
+ return PG_RSTAT_READY;
+
+ case 'S': // parameters setting ignored
+ case 'K': // should not be here?
+ if (pqSkipnchar(msgLen)) goto read_error;
+ return 0;
+
+ case 'C': // summary
+ if (msgLen > bufSize - 1) goto oom;
+ if (pqGetnchar(Buffer, msgLen)) goto read_error;
+ Buffer[msgLen] = 0;
+ _ntuples = 0;
+ result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | PG_RSTAT_HAVE_SUMMARY;
+ for (c = Buffer; *c && !isdigit(*c); c++);
+ if (!*c) return result_status;
+ if (strncmp(Buffer,"SELECT ",7)) {
+ for (; *c && isdigit(*c); c++);
+ for (; *c && !isdigit(*c); c++);
+ }
+ if (*c) _ntuples = strtol(c, NULL, 10);
+ return result_status;
+
+ case 'D':
+ if ((rc=pqGetRow())) {
+ if (rc == -2) setMsg_P(EM_OOM, PG_RSTAT_HAVE_ERROR);
+ else if (rc == -3) setMsg_P(EM_SYNC, PG_RSTAT_HAVE_ERROR);
+ goto read_error;
+ }
+ if (_flags & PG_FLAG_IGNORE_COLUMNS) {
+ result_status &= ~PG_RSTAT_HAVE_MASK;
+ return 0;
+ }
+ return result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | PG_RSTAT_HAVE_ROW;
+
+ case 'I':
+ if (pqSkipnchar(msgLen)) goto read_error;
+ setMsg_P(EM_EMPTY, PG_RSTAT_HAVE_ERROR);
+ return result_status;
+
+ default:
+ setMsg_P(EM_SYNC, PG_RSTAT_HAVE_ERROR);
+ conn_status = CONNECTION_BAD;
+ return -1;
+ }
+
+oom:
+ setMsg_P(EM_OOM, PG_RSTAT_HAVE_ERROR);
+
+read_error:
+ if (!(result_status & PG_RSTAT_HAVE_ERROR)) {
+ setMsg_P(EM_READ, PG_RSTAT_HAVE_ERROR);
+ }
+ conn_status = CONNECTION_BAD;
+ return -1;
+}
+
+int PGconnection::executeFormat(int progmem, const char *format, ...)
+{
+ int32_t msgLen;
+ va_list va;
+ va_start(va, format);
+ msgLen = writeFormattedQuery(0, progmem, format, va);
+ va_end(va);
+ if (msgLen < 0) return -1;
+ va_start(va, format);
+ msgLen = writeFormattedQuery(msgLen, progmem, format, va);
+ va_end(va);
+ if (msgLen) {
+ return -1;
+ }
+ result_status = PG_RSTAT_COMMAND_SENT;
+ return 0;
+}
+
+#ifdef ESP8266
+
+// there is no strchr_P in ESP8266 ROM :(
+
+static const char *strchr_P(const char *str, char c)
+{
+ char z;
+ for (;;) {
+ z = pgm_read_byte(str);
+ if (!z) return NULL;
+ if (z == c) return str;
+ str++;
+ }
+}
+
+#endif
+
+#ifdef ESP32_IDF
+//emulate Arduino PSTR()
+char *PSTR(char *str)
+{
+ return str;
+}
+const char *PSTR(const char *str)
+{
+ return str;
+}
+
+//emulate strcpy_P()
+char *strcpy_P(char * destination, const char * source )
+{
+ return strcpy(destination, source);
+}
+
+int strlen_P(char *str)
+{
+ return strlen(str);
+}
+int strlen_P(const char *str)
+{
+ return strlen(str);
+}
+#endif
+
+int PGconnection::build_startup_packet(
+ char *packet,
+ const char *db,
+ const char *charset)
+{
+ int packet_len = 4;
+ if (packet) {
+ memcpy(packet,"\0\003\0\0", 4);
+ }
+#define ADD_STARTUP_OPTION(optname, optval) \
+ do { \
+ if (packet) \
+ strcpy_P(packet + packet_len, (char *)optname); \
+ packet_len += strlen_P((char *)optname) + 1; \
+ if (packet) \
+ strcpy(packet + packet_len, (char *)optval); \
+ packet_len += strlen((char *)optval) + 1; \
+ } while(0)
+
+#define ADD_STARTUP_OPTION_P(optname, optval) \
+ do { \
+ if (packet) \
+ strcpy_P(packet + packet_len, (char *)optname); \
+ packet_len += strlen_P((char *)optname) + 1; \
+ if (packet) \
+ strcpy_P(packet + packet_len, (char *)optval); \
+ packet_len += strlen_P((char *)optval) + 1; \
+ } while(0)
+
+ if (_user && _user[0])
+ ADD_STARTUP_OPTION(PSTR("user"), _user);
+ if (db && db[0])
+ ADD_STARTUP_OPTION(PSTR("database"), db);
+ if (charset && charset[0])
+ ADD_STARTUP_OPTION(PSTR("client_encoding"), charset);
+ ADD_STARTUP_OPTION_P(PSTR("application_name"), PSTR("arduino"));
+#undef ADD_STARTUP_OPTION
+ if (packet)
+ packet[packet_len] = '\0';
+ packet_len++;
+
+ return packet_len;
+}
+
+int PGconnection::pqPacketSend(char pack_type, const char *buf, int buf_len, int progmem)
+{
+ char *start = Buffer;
+ int l = bufSize - 4;
+#ifndef ESP32
+ int n;
+#endif
+ if (pack_type) {
+ *start++ = pack_type;
+ l--;
+ }
+#ifdef __AVR__
+ *start++=0;
+ *start++=0;
+#else
+ *start++ = ((buf_len + 4) >> 24) & 0xff;
+ *start++ = ((buf_len + 4) >> 16) & 0xff;
+#endif
+ *start++ = ((buf_len + 4) >> 8) & 0xff;
+ *start++ = (buf_len + 4) & 0xff;
+#ifndef ESP32
+ if (progmem) {
+ while (buf_len > 0) {
+ while (buf_len > 0 && l > 0) {
+ *start++ = pgm_read_byte(buf++);
+ buf_len--;
+ }
+ n = client->write((const uint8_t *)Buffer, start - Buffer);
+ if (n != start - Buffer) return -1;
+ start = Buffer;
+ l = bufSize;
+ }
+ }
+ else {
+#endif
+ if (buf) {
+ if (buf_len <= l) {
+ memcpy(start, buf, buf_len);
+ start += buf_len;
+ buf_len = 0;
+ }
+ else {
+ memcpy(start, buf, l);
+ start += l;
+ buf_len -= l;
+ buf += l;
+ }
+ }
+#ifndef ESP32_IDF
+ n = client->write((const uint8_t *)Buffer, start - Buffer);
+ if (n != start - Buffer) return -1;
+ if (buf && buf_len) {
+ n = client->write((const uint8_t *)buf, buf_len);
+ if (n != buf_len) return -1;
+ }
+#else
+ int err = send(SockH, /*_buffer*/Buffer, start - /*_buffer*/Buffer, 0);
+ if (err < 0) {
+ ESP_LOGE(PGTAG, "pqPacketSend: Send Error occurred during sending: errno %d", errno);
+ return err;
+ }
+ if (buf && buf_len) {
+ err = send(SockH, (const char *) buf, (size_t) buf_len, 0);
+ if (err < 0) {
+ ESP_LOGE(PGTAG, "Send2 Error occurred during sending: errno %d", errno);
+ return err;
+
+ }
+ }
+#endif
+
+#ifndef ESP32
+ }
+#endif
+ return 0;
+}
+
+int PGconnection::pqGetc(char *buf)
+{
+ int i;
+#ifndef ESP32_IDF
+ for (i=0; !client->available() && i < 10; i++) {
+ delay (i * 10 + 10);
+ }
+ if (!client->available()) {
+ return -1;
+ }
+ *buf = client->read();
+ return 0;
+#else
+ i = 0;
+ while (i<10) {
+ if (dataAvailable()>0) break;
+ else {
+ vTaskDelay(i++);
+ }
+ }
+ if (i==10) return -1;
+
+ int len = read(SockH, (void *) buf, 1);
+ _available-=len;
+ return -1+len;
+#endif
+}
+
+int PGconnection::pqGetInt4(int32_t *result)
+{
+ uint32_t tmp4 = 0;
+ byte tmp,i;
+ for (i = 0; i < 4; i++) {
+ if (pqGetc((char *)&tmp)) return -1;
+ tmp4 = (tmp4 << 8) | tmp;
+ }
+ *result = tmp4;
+ return 0;
+}
+
+int PGconnection::pqGetInt2(int16_t *result)
+{
+ uint16_t tmp2 = 0;
+ byte tmp,i;
+ for (i = 0; i < 2; i++) {
+ if (pqGetc((char *)&tmp)) return -1;
+ tmp2 = (tmp2 << 8) | tmp;
+ }
+ *result = tmp2;
+ return 0;
+}
+
+int PGconnection::pqGetnchar(char *s, int len)
+{
+ while (len-- > 0) {
+ if (pqGetc(s++)) return -1;
+ }
+ return 0;
+}
+
+int PGconnection::pqGets(char *s, int maxlen)
+{
+ int len;
+ char z;
+ for (len = 0;len < maxlen; len++) {
+ if (pqGetc(&z)) return -1;
+ if (s) *s++ = z;
+ if (!z) return len+1;
+ }
+ return - (len + 1);
+}
+
+int PGconnection::pqSkipnchar(int len)
+{
+ char dummy;
+ while (len-- > 0) {
+ if (pqGetc(&dummy)) return -1;
+ }
+ return 0;
+}
+
+int PGconnection::pqGetRow(void)
+{
+ int i;
+ int bufpos = 0;
+ int32_t len;
+ int16_t cols;
+
+ _null = 0;
+ if (pqGetInt2(&cols)) return -1;
+ if (cols != _nfields) {
+ return -3;
+ }
+ for (i=0; i < _nfields; i++) {
+ if (pqGetInt4(&len)) return -1;
+ if (len < 0) {
+ _null |= 1<<i;
+ continue;
+ }
+ if (bufpos + len + 1 > bufSize) {
+ return -2;
+ }
+ if (pqGetnchar(Buffer + bufpos, len)) return -1;
+ bufpos += len;
+ Buffer[bufpos++]=0;
+ }
+ return 0;
+}
+
+
+int PGconnection::pqGetRowDescriptions(void)
+{
+ int i;
+ int16_t format;
+ int rc;
+ int bufpos;
+ if (pqGetInt2(&_nfields)) return -1;
+ if (_nfields > PG_MAX_FIELDS) return -2; // implementation limit
+ _formats = 0;
+ bufpos = 0;
+ for (i = 0;i < _nfields; i++) {
+ if (!(_flags & PG_FLAG_IGNORE_COLUMNS)) {
+ if (bufpos >= bufSize - 1) return -2;
+ rc = pqGets(Buffer + bufpos, bufSize - bufpos);
+ if (rc < 0) return -1;
+ bufpos += rc;
+ }
+ else {
+ if (pqGets(NULL, 8192) < 0) {
+ return -1;
+ }
+ }
+ if (pqSkipnchar(16)) return -1;
+ if (pqGetInt2(&format)) return -1;
+ format = format ? 1 : 0;
+ _formats |= format << i;
+ }
+ if (_formats) return -3;
+ return 0;
+}
+
+void PGconnection::setMsg(const char *s, int type)
+{
+ strcpy(Buffer, s);
+ result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | type;
+}
+
+void PGconnection::setMsg_P(const char *s, int type)
+{
+ strcpy_P(Buffer, s);
+ result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | type;
+}
+
+int PGconnection::pqGetNotice(int type)
+{
+ int bufpos = 0;
+ char id;
+ int rc;
+ for (;;) {
+ if (pqGetc(&id)) goto read_error;
+ if (!id) break;
+ if (id == 'S' || id == 'M') {
+ if (bufpos && bufpos < bufSize - 1) Buffer[bufpos++]=':';
+ rc = pqGets(Buffer + bufpos, bufSize - bufpos);
+ if (rc < 0) goto read_error;
+ bufpos += rc -1;
+ }
+ else {
+ rc = pqGets(NULL, 8192);
+ if (rc < 0) goto read_error;
+ }
+ }
+ Buffer[bufpos] = 0;
+ result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | type;
+ return 0;
+
+read_error:
+ if (!bufpos) setMsg_P(EM_READ, PG_RSTAT_HAVE_ERROR);
+ return -1;
+}
+
+int PGconnection::pqGetNotify(int32_t msgLen)
+{
+ int32_t pid;
+ int bufpos, i;
+ if (pqGetInt4(&pid)) return -1;
+ msgLen -= 4;
+ bufpos = sprintf(Buffer,"%d:",pid);
+ if (msgLen > bufSize - (bufpos + 1)) {
+ if (pqGetnchar(Buffer+bufpos, bufSize - (bufpos + 1)))
+ return -1;
+ msgLen -= bufSize - (bufpos + 1);
+ if (pqSkipnchar(msgLen)) return -1;
+ Buffer[msgLen = bufSize - 1] = 0;
+
+ }
+ else {
+ if (pqGetnchar(Buffer+ bufpos, msgLen)) return -1;
+ Buffer[bufpos + msgLen] = 0;
+ msgLen += bufpos;
+ }
+ for (i=0; i<msgLen; i++) if (!Buffer[i]) Buffer[i] = ':';
+ return 0;
+}
+
+#ifndef ESP32
+int PGconnection::writeMsgPart_P(const char *s, int len, int fine)
+{
+ while (len > 0) {
+ if (bufPos >= bufSize) {
+ if (client->write((uint8_t *)Buffer, bufPos) != (size_t)bufPos) {
+ return -1;
+ }
+ bufPos = 0;
+ }
+ Buffer[bufPos++] = pgm_read_byte(s++);
+ len--;
+ }
+ if (bufPos && fine) {
+ if (client->write((uint8_t *)Buffer, bufPos) != (size_t)bufPos) {
+ return -1;
+ }
+ bufPos = 0;
+ }
+ return 0;
+}
+#endif
+
+int PGconnection::writeMsgPart(const char *s, int len, int fine)
+{
+ while (len > 0) {
+ int n = len;
+ if (n > bufSize - bufPos) n = bufSize - bufPos;
+ memcpy(Buffer + bufPos, s, n);
+ bufPos += n;
+ s += n;
+ len -= n;
+ if (bufPos >= bufSize) {
+#ifndef ESP32_IDF
+ if (client->write((uint8_t *)Buffer, bufPos) != (size_t)bufPos) {
+ return -1;
+ }
+#else
+ int err = send(SockH, /*_buffer*/Buffer, bufPos, 0);
+ if (err < 0)
+ return -1;
+#endif
+
+ bufPos = 0;
+ }
+ }
+ if (bufPos && fine) {
+#ifndef ESP32_IDF
+ if (client->write((uint8_t *)Buffer, bufPos) != (size_t)bufPos) {
+ return -1;
+ }
+#else
+ int err = send(SockH, /*_buffer*/Buffer, bufPos, 0);
+ if (err < 0)
+ return -1;
+#endif
+ bufPos = 0;
+ }
+
+ return 0;
+}
+
+int32_t PGconnection::writeFormattedQuery(int32_t length, int progmem, const char *format, va_list va)
+{
+ int32_t msgLen = 0;
+ const char *percent;
+ int blen, rc;
+ char buf[32], znak;
+#ifdef ESP32
+ (void) progmem;
+#endif
+ if (length) {
+ length += 4;
+ bufPos = 0;
+ Buffer[bufPos++] = 'Q';
+ Buffer[bufPos++] = (length >> 24) & 0xff;
+ Buffer[bufPos++] = (length >> 16) & 0xff;
+ Buffer[bufPos++] = (length >> 8) & 0xff;
+ Buffer[bufPos++] = (length) & 0xff;
+ }
+ for (;;) {
+#ifndef ESP32
+ if (progmem) {
+ percent = strchr_P(format, '%');
+ }
+ else {
+#endif
+ percent = strchr(format, '%');
+#ifndef ESP32
+ }
+#endif
+ if (!percent) break;
+#ifndef ESP32
+ if (progmem) {
+ znak = pgm_read_byte(percent+1);
+ }
+ else {
+#endif
+ znak = percent[1];
+#ifndef ESP32
+ }
+#endif
+ if (!length) {
+ msgLen += (percent - format);
+ }
+ else {
+#ifndef ESP32
+ if (progmem) {
+ rc = writeMsgPart_P(format, percent - format, false);
+ }
+ else {
+#endif
+ rc = writeMsgPart(format, percent - format, false);
+#ifndef ESP32
+ }
+#endif
+ if (rc) goto write_error;
+ }
+ format = percent + 2;
+ if (znak == 's' || znak == 'n') {
+ char *str = va_arg(va, char *);
+ blen = (znak == 's') ? escapeString(str, NULL) : escapeName(str, NULL);
+ if (!length) {
+ msgLen += blen;
+ }
+ else {
+ if (bufPos + blen > bufSize) {
+ rc = writeMsgPart(NULL, 0, true);
+ if (rc) goto write_error;
+ }
+ }
+ if (znak == 's') {
+ escapeString(str, Buffer + bufPos);
+ }
+ else {
+ escapeName(str, Buffer + bufPos);
+ }
+ bufPos += blen;
+ continue;
+ }
+ if (znak == 'l' || znak == 'd') {
+ if (znak == 'l') {
+ long n = va_arg(va, long);
+ blen = snprintf(buf, 32, "'%ld'", n);
+ }
+ else {
+ int n = va_arg(va, int);
+ blen = snprintf(buf, 32, "'%d'", n);
+ }
+ if (length) {
+ rc = writeMsgPart(buf, blen, false);
+ if (rc) goto write_error;
+ }
+ else {
+ msgLen += blen;
+ }
+ }
+ setMsg_P(EM_FORMAT, PG_RSTAT_HAVE_ERROR);
+ return -1;
+ }
+#ifndef ESP32
+ if (progmem) {
+ blen = strlen_P(format);
+ }
+ else {
+#endif
+ blen = strlen(format);
+#ifndef ESP32
+ }
+#endif
+ if (length) {
+#ifndef ESP32
+ if (progmem) {
+ rc = writeMsgPart_P(format, blen, false);
+ }
+ else {
+#endif
+ rc = writeMsgPart(format, blen, false);
+#ifndef ESP32
+ }
+#endif
+ if (!rc) {
+ rc = writeMsgPart("\0",1,true);
+ }
+ if (rc) goto write_error;
+ }
+ else {
+ msgLen += blen + 1;
+ }
+ return msgLen;
+write_error:
+ setMsg_P(EM_WRITE, PG_RSTAT_HAVE_ERROR);
+ conn_status = CONNECTION_BAD;
+ return -1;
+}
diff --git a/software/michi_funcs/SimplePgSQL.h b/software/michi_funcs/SimplePgSQL.h
new file mode 100644
index 0000000..383c899
--- /dev/null
+++ b/software/michi_funcs/SimplePgSQL.h
@@ -0,0 +1,278 @@
+/*
+ * SimplePgSQL.h - Lightweight PostgreSQL connector for Arduino
+ * Copyright (C) Bohdan R. Rau 2016 <ethanak@polip.com>
+ *
+ * SimplePgSQL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * SimplePgSQL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with SimplePgSQL. If not, write to:
+ * The Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301, USA.
+ */
+#ifndef _SIMPLEPGSQL
+#define _SIMPLEPGSQL 1
+
+//Michi begin
+#define ESP32
+#define ESP32_IDF
+//Michi end
+
+#ifdef __AVR__
+// You need MD5 library from https://github.com/tzikis/ArduinoMD5
+// for Arduino boards. Uncomment only if you have this library and
+// you must use md5 passwords.
+// Do not use it on 32 kB ATMega processors!
+
+// #define PG_USE_MD5 1
+
+#else
+// ESP8266 has MD5 code in ROM so there is no need to comment
+#define PG_USE_MD5 1
+#endif
+
+
+
+
+#ifndef ESP32_IDF
+ #include <Arduino.h>
+ #include <Client.h>
+#else
+ #include "esp_system.h"
+ #include "esp_netif.h"
+ #include "lwip/err.h"
+ #include "lwip/sockets.h"
+
+ #define byte uint8_t
+#endif
+
+typedef enum
+{
+ CONNECTION_OK,
+ CONNECTION_BAD,
+ CONNECTION_NEEDED, /* setDbLogin() needed */
+ /* Internal states here */
+ CONNECTION_AWAITING_RESPONSE, /* Waiting for a response from the
+ * postmaster. */
+ CONNECTION_AUTH_OK /* Received authentication; waiting for
+ * backend startup. */
+} ConnStatusType;
+
+#ifdef ESP8266
+#define PG_BUFFER_SIZE 2048
+#elif defined(ESP32)
+#define PG_BUFFER_SIZE 16384
+#else
+#define PG_BUFFER_SIZE 256
+#endif
+
+// maximum number of fields in backend response
+// must not exceed number of bits in _formats and _null
+#ifdef ESP32
+#define PG_MAX_FIELDS 64
+#else
+#define PG_MAX_FIELDS 32
+#endif
+// ignore notices and notifications
+#define PG_FLAG_IGNORE_NOTICES 1
+// do not store column names
+#define PG_FLAG_IGNORE_COLUMNS 2
+// never set this flag manually!
+# define PG_FLAG_STATIC_BUFFER 4
+
+// ready for next query
+#define PG_RSTAT_READY 1
+// command sent
+#define PG_RSTAT_COMMAND_SENT 2
+// column names in buffer
+#define PG_RSTAT_HAVE_COLUMNS 4
+// row values in buffer
+#define PG_RSTAT_HAVE_ROW 8
+// summary (number of tuples/affected rows) received
+#define PG_RSTAT_HAVE_SUMMARY 16
+// error message in buffer
+#define PG_RSTAT_HAVE_ERROR 32
+// notice/notification in buffer
+#define PG_RSTAT_HAVE_NOTICE 64
+
+#define PG_RSTAT_HAVE_MASK (PG_RSTAT_HAVE_COLUMNS | \
+ PG_RSTAT_HAVE_ROW | \
+ PG_RSTAT_HAVE_SUMMARY | \
+ PG_RSTAT_HAVE_ERROR | \
+ PG_RSTAT_HAVE_NOTICE)
+
+#define PG_RSTAT_HAVE_MESSAGE (PG_RSTAT_HAVE_ERROR | PG_RSTAT_HAVE_NOTICE)
+
+// Framework abstraction - Michi
+// only here, differences of Arduino, ESP32-Arduino, ESP32-IDF or Platform.io should be made
+//class fw_function {
+// public:
+// send_network_packet();
+//}
+
+
+class PGconnection {
+ public:
+#ifndef ESP32_IDF
+ PGconnection(Client *c, int flags = 0, int memory = 0, char *foreignBuffer = NULL);
+#else
+ PGconnection(const int flags, const unsigned char *_Buffer, const int bufSize);
+#endif
+ /*
+ * returns connection status.
+ * passwd may be null in case of 'trust' authorization.
+ * only 'trust', 'password' and 'md5' (if compiled in)
+ * authorization modes are implemented.
+ * ssl mode is not implemented.
+ * database name defaults to user name *
+ */
+#ifndef ESP32_IDF
+ int setDbLogin(IPAddress server, const char *user, const char *passwd = NULL, const char *db = NULL, const char *charset = NULL, int port = 5432);
+#else
+ int setDbLogin(const char *ServerIP, int ServerPort, const char *dbName, const char *dbUser, const char *dbPasswd, const char *charset);
+#endif
+ /*
+ * performs authorization tasks if needed
+ * returns current connection status
+ * must be called periodically until OK, BAD or NEEDED
+ */
+ int status(void);
+ /*
+ * sends termination command if possible
+ * closes client connection and frees internal buffer
+ */
+ void close(void);
+ /*
+ * sends query to backend
+ * returns negative value on error
+ * or zero on success
+ */
+ int execute(const char *query, int progmem = 0);
+ int PGexecute(const char *query); //old version from 17.02.2022
+
+ /* should be called periodically in idle state
+ * if notifications are enabled
+ * returns:
+ * - negative value on error
+ * - zero if no interesting data arrived
+ * - current data status if some data arrived
+ */
+
+ int getData(void);
+ /*
+ * returns pointer to n-th column name in internal buffer
+ * if available or null if column number out of range
+ * will be invalidated on next getData call
+ */
+ char *getColumn(int n);
+ /*
+ * returns pointer to n-th column value in internal buffer
+ * if available or null if column number out of range
+ * or value is NULL
+ * will be invalidated on next getData call
+ */
+ char *getValue(int);
+ /*
+ * returns pointer to message (error or notice)
+ * if available or NULL
+ * will be invalidated on next getData call
+ */
+ char *getMessage(void);
+ int dataStatus(void) {
+ return result_status;
+ };
+ int nfields(void) {
+ return _nfields;
+ };
+ int ntuples(void) {
+ return _ntuples;
+ };
+ /*
+ * returns length of escaped string
+ * single quotes and E prefix (if needed)
+ * will be added.
+ */
+ int escapeString(const char *inbuf, char *outbuf);
+ /*
+ * returns length of escaped string
+ * double quotes will be added.
+ */
+ int escapeName(const char *inbuf, char *outbuf);
+ /*
+ * sends formatted query to backend
+ * returns negative value on error
+ * or zero on success
+ * Formatting sequences:
+ * %s - string literal (will be escaped with escapeString)
+ * %n - name (will be escaped with escapeName)
+ * %d - int (single quotes will be added)
+ * %l - long int (single quotes will be added)
+ * %% - % character
+ */
+ int executeFormat(int progmem, const char *format, ...);
+
+
+ private:
+#ifndef ESP32_IDF
+ Client *client;
+#endif
+ int pqPacketSend(char pack_type, const char *buf, int buf_len, int progmem = 0);
+ int pqGetc(char *);
+ int pqGetInt4(int32_t *result);
+ int pqGetInt2(int16_t *result);
+ int pqGetnchar(char *s, int len);
+ int pqSkipnchar(int len);
+ int pqGets(char *s, int maxlen);
+ int pqGetRowDescriptions(void);
+ int pqGetRow(void);
+ void setMsg(const char *, int);
+ void setMsg_P(const char *, int);
+ int pqGetNotice(int);
+ int pqGetNotify(int32_t);
+ char *_user;
+ char *_passwd;
+ char *Buffer;
+ int bufSize;
+ int bufPos;
+ int writeMsgPart(const char *s, int len, int fine);
+ int writeMsgPart_P(const char *s, int len, int fine);
+ int32_t writeFormattedQuery(int32_t length, int progmem, const char *format, va_list va);
+
+ int build_startup_packet(char *packet, const char *db, const char *charset);
+ byte conn_status;
+ byte attempts;
+/*
+ int32_t be_pid;
+ int32_t be_key;
+*/
+ int16_t _nfields;
+ int16_t _ntuples;
+#ifdef ESP32_IDF
+ uint64_t _formats;
+ uint64_t _null;
+ uint32_t _available; //michi
+ struct sockaddr_in DestAddr;
+ int SockH = -1;
+ int ipProtocol = 0;
+ int AddrFamily = 0;
+ int NetConnected=0;
+
+ int dataAvailable(void);
+#else
+ uint32_t _formats;
+ uint32_t _null;
+#endif
+ byte _binary;
+ byte _flags;
+ int result_status;
+};
+
+#endif
diff --git a/software/michi_funcs/SimplePgSQL_cpp.old b/software/michi_funcs/SimplePgSQL_cpp.old
new file mode 100644
index 0000000..0e76e0a
--- /dev/null
+++ b/software/michi_funcs/SimplePgSQL_cpp.old
@@ -0,0 +1,900 @@
+/*
+ SimplePgSQL.c - Lightweight PostgreSQL connector for Arduino
+ Copyright (C) Bohdan R. Rau 2016 <ethanak@polip.com>
+
+ SimplePgSQL is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ SimplePgSQL is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with SimplePgSQL. If not, write to:
+ The Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor
+ Boston, MA 02110-1301, USA.
+ */
+#include <stdio.h>
+//#include "esp_eth.h"
+#include <string.h>
+#include <sys/param.h>
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "freertos/event_groups.h"
+#include "esp_system.h"
+#include "esp_wifi.h"
+#include "esp_event.h"
+#include "esp_log.h"
+#include "nvs_flash.h"
+#include "esp_netif.h"
+#include "lwip/err.h"
+#include "lwip/sockets.h"
+
+
+#include "SimplePgSQL.h"
+
+#define AUTH_REQ_OK 0 /* User is authenticated */
+#define AUTH_REQ_PASSWORD 3 /* Password */
+#define PGTAG "PGSQL"
+static const char EM_OOM[] = "Out of mem";
+static const char EM_READ[] = "Backend read err";
+static const char EM_WRITE[] = "Backend write err";
+static const char EM_CONN[] = "Cannot conn 2 srv";
+static const char EM_SYNC[] = "Backend out of sync";
+static const char EM_INTR[] = "Internal err";
+static const char EM_UAUTH[] = "auth method !sptd";
+static const char EM_BIN[] = "Bin fmt !sptd";
+static const char EM_EXEC[] = "Previ exe !finished";
+static const char EM_PASSWD[] = "Pwd req";
+static const char EM_EMPTY[] = "empty qry";
+static const char EM_FORMAT[] = "Illegal chr fmt";
+
+PGconnection::PGconnection(const int flags, const unsigned char *Buffer, const int bufSize) {
+ conn_status = CONNECTION_NEEDED;
+ _passwd = NULL;
+ _user = NULL;
+ _buffer = (char *) Buffer;
+ _bufSize = bufSize;
+ bufPos = 0;
+ result_status=0;
+ _available=0;
+ _nfields=0;
+ _ntuples=0;
+ _flags=0;
+}
+
+int PGconnection::PGsetDbLogin(const char *ServerIP, int ServerPort, const char *dbName, const char *dbUser, const char *dbPasswd, const char *dbCharset) {
+
+ char *startpacket;
+ int packetlen;
+ int len;
+
+// close();
+ memset(&DestAddr, 0, sizeof(DestAddr));
+ AddrFamily = AF_INET;
+ ipProtocol = IPPROTO_IP;
+ DestAddr.sin_addr.s_addr = inet_addr(ServerIP);
+ DestAddr.sin_family = AF_INET;
+ DestAddr.sin_port = htons(ServerPort);
+
+ if (!dbName)
+ dbName = dbUser;
+ len = strlen(dbUser) + 1;
+ if (dbPasswd) {
+ len += strlen(dbPasswd) + 1;
+ }
+ _user = (char *) malloc(len);
+ strcpy(_user, dbUser);
+ if (dbPasswd) {
+ _passwd = _user + strlen(dbUser) + 1;
+ strcpy(_passwd, dbPasswd);
+ } else {
+ _passwd = NULL;
+ }
+
+ //int8_t connected = connect(client->connect(server, port);
+ SockH = socket(AddrFamily, SOCK_STREAM, ipProtocol);
+ if (SockH < 0) {
+ ESP_LOGE(PGTAG, "Unable to create socket: errno %d", errno);
+ setMsg_P(EM_CONN, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ } else {
+ int err = connect(SockH, (struct sockaddr *) &DestAddr, sizeof(DestAddr));
+ if (err != 0) {
+ ESP_LOGE(PGTAG, "Socket unable to connect: errno %d", errno);
+ return conn_status = CONNECTION_BAD;
+ }
+ NetConnected = 1;
+ ESP_LOGI(PGTAG, "Successfully connected");
+ }
+
+ packetlen = build_startup_packet(NULL, dbName, dbCharset);
+ if (packetlen > _bufSize - 10) {
+ setMsg_P(EM_OOM, PG_RSTAT_HAVE_ERROR);
+ conn_status = CONNECTION_BAD;
+ return conn_status;
+ }
+
+ startpacket = _buffer + (_bufSize - (packetlen + 1));
+ build_startup_packet(startpacket, dbName, dbCharset);
+ if (pqPacketSend(0, startpacket, packetlen) < 0) {
+ setMsg_P(EM_WRITE, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ attempts = 0;
+ return conn_status = CONNECTION_AWAITING_RESPONSE;
+}
+
+void PGconnection::PGclose(void) {
+ if (NetConnected) {
+ pqPacketSend('X', NULL, 0);
+// client->stop();
+ shutdown(SockH, 0);
+ close(SockH);
+ }
+ if (_user) {
+ free(_user);
+ _user = _passwd = NULL;
+ }
+ NetConnected = 0;
+ conn_status = CONNECTION_NEEDED;
+}
+
+int PGconnection::PGstatus(void) {
+ char bereq;
+ char rc;
+ int32_t msgLen;
+ int32_t areq;
+ char * pwd = _passwd;
+
+ switch (conn_status) {
+ case CONNECTION_NEEDED:
+ case CONNECTION_OK:
+ case CONNECTION_BAD:
+
+ return conn_status;
+
+ case CONNECTION_AWAITING_RESPONSE:
+ if (dataAvailable() == 0) return conn_status;
+ if (attempts++ >= 2) {
+ setMsg_P(EM_SYNC, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ if (pqGetc(&bereq)) {
+ goto read_error;
+ }
+ if (bereq == 'E') {
+ pqGetInt4(&msgLen);
+ pqGetNotice(PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ if (bereq != 'R') {
+ setMsg_P(EM_SYNC, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ if (pqGetInt4(&msgLen)) {
+ goto read_error;
+ }
+ if (pqGetInt4(&areq)) {
+ goto read_error;
+ }
+ if (areq == AUTH_REQ_OK) {
+ if (_user) {
+ free(_user);
+ _user = _passwd = NULL;
+ }
+ result_status = PG_RSTAT_READY;
+ return conn_status = CONNECTION_AUTH_OK;
+ }
+ if (areq != AUTH_REQ_PASSWORD) {
+ setMsg_P(EM_UAUTH, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ if (!_passwd || !*_passwd) {
+ setMsg_P(EM_PASSWD, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ pwd = _passwd;
+ rc = pqPacketSend('p', pwd, strlen(pwd) + 1);
+ if (rc) {
+ goto write_error;
+ }
+ return conn_status;
+
+ case CONNECTION_AUTH_OK:
+ for (;;) {
+ if (dataAvailable() == 0) return conn_status;
+ if (pqGetc(&bereq))
+ goto read_error;
+ if (pqGetInt4(&msgLen))
+ goto read_error;
+ msgLen -= 4;
+ if (bereq == 'A' || bereq == 'N' || bereq == 'S' || bereq == 'K') {
+ if (pqSkipnchar(msgLen))
+ goto read_error;
+ continue;
+ }
+ if (bereq == 'E') {
+ pqGetNotice(PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+
+ /* if (bereq == 'K') {
+ if (pqGetInt4(&be_pid)) goto read_error;
+ if (pqGetInt4(&be_key)) goto read_error;
+ continue;
+ }
+ */
+ if (bereq == 'Z') {
+ pqSkipnchar(msgLen);
+ return conn_status = CONNECTION_OK;
+ }
+ return conn_status = CONNECTION_BAD;
+ }
+ break;
+ default:
+ setMsg_P(EM_INTR, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ }
+ read_error: setMsg_P(EM_READ, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+ write_error: setMsg_P(EM_WRITE, PG_RSTAT_HAVE_ERROR);
+ return conn_status = CONNECTION_BAD;
+}
+
+int PGconnection::PGexecute(const char *query) {
+ /*
+ if (!(result_status & PG_RSTAT_READY)) {
+ setMsg_P(EM_EXEC, PG_RSTAT_HAVE_ERROR);
+ return -1;
+ }
+ */
+ int len = strlen(query);
+ if (pqPacketSend('Q', query, len + 1)) {
+ setMsg_P(EM_WRITE, PG_RSTAT_HAVE_ERROR);
+ conn_status = CONNECTION_BAD;
+ return -1;
+ }
+ result_status = PG_RSTAT_COMMAND_SENT;
+ return 0;
+}
+
+int PGconnection::PGescapeName(const char *inbuf, char *outbuf) {
+ const char *c;
+ int l = 2;
+ for (c = inbuf; *c; c++) {
+ l++;
+ if (*c == '\\' || *c == '"')
+ l++;
+ }
+ if (outbuf) {
+ *outbuf++ = '"';
+ for (c = inbuf; *c; c++) {
+ *outbuf++ = *c;
+ if (*c == '\\' || *c == '"')
+ *outbuf++ = *c;
+ }
+ *outbuf++ = '"';
+ }
+ return l;
+}
+
+int PGconnection::PGescapeString(const char *inbuf, char *outbuf) {
+ const char *c;
+ int e = 0, l;
+ for (c = inbuf; *c; c++) {
+ if (*c == '\\' || *c == '\'')
+ e++;
+ }
+ l = e + (c - inbuf) + (e ? 4 : 2);
+ if (outbuf) {
+ if (e) {
+ *outbuf++ = ' ';
+ *outbuf++ = 'E';
+ }
+ *outbuf++ = '\'';
+ for (c = inbuf; *c; c++) {
+ *outbuf++ = *c;
+ if (*c == '\\' || *c == '\'')
+ *outbuf++ = *c;
+ }
+ *outbuf++ = '\'';
+ }
+ return l;
+}
+
+char * PGconnection::PGgetValue(int nr) {
+ int i;
+ if (_null & (1 << nr)) return NULL;
+ char *c = _buffer;
+ if (nr < 0 || nr >= _nfields) return NULL;
+ for (i = 0; i < nr; i++) {
+ if (_null & (1 << i)) continue;
+ c += strlen(c) + 1;
+ }
+ return c;
+}
+
+char *PGconnection::PGgetColumn(int n) {
+ char *c;
+ int i;
+ if (!(result_status & PG_RSTAT_HAVE_COLUMNS)) return NULL;
+ if (n < 0 || n >= _nfields) return NULL;
+ for (c = _buffer, i = 0; i < n; i++) {
+ c += strlen(c) + 1;
+ }
+ return c;
+}
+
+char *PGconnection::PGgetMessage(void) {
+ if (!(result_status & PG_RSTAT_HAVE_MESSAGE))
+ return NULL;
+ return _buffer;
+}
+
+void dumpbuffer(char *b,int l) {
+ int i;
+ unsigned int v;
+ for (i=0;i<l;i++) {
+ if (i%8 == 0) {
+ printf("\n%04X ",i);
+ }
+ v=*b;
+ printf("%02X ",v);
+ if (v>31) printf(" %c ",v);
+ else printf(" ");
+ b++;
+ }
+ printf("\n");
+}
+
+int PGconnection::PGgetData(void) {
+ char id;
+ int32_t msgLen;
+ int rc;
+ char *c;
+ int r=0;
+ r=dataAvailable();
+// printf("getData:avail:%d\n",r);fflush(stdout);
+ if (r==0) return 0;
+
+ if (pqGetc(&id)) goto read_error;
+ if (pqGetInt4(&msgLen)) goto read_error;
+// printf("MSG ID: %c Len:%d (avail:%d)\n",id,msgLen,r);fflush(stdout);
+ msgLen -= 4;
+ switch (id) {
+ case 'T':
+ if ((rc = pqGetRowDescriptions())) {
+ if (rc == -2)
+ setMsg_P(EM_OOM, PG_RSTAT_HAVE_ERROR);
+ else if (rc == -3)
+ setMsg_P(EM_BIN, PG_RSTAT_HAVE_ERROR);
+ goto read_error;
+ }
+ if (_flags & PG_FLAG_IGNORE_COLUMNS) {
+ result_status &= ~PG_RSTAT_HAVE_MASK;
+ return 0;
+ }
+ return result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | PG_RSTAT_HAVE_COLUMNS;
+
+ case 'E':
+ if (pqGetNotice(PG_RSTAT_HAVE_ERROR))
+ goto read_error;
+ return result_status;
+
+ case 'N':
+ if (_flags & PG_FLAG_IGNORE_NOTICES) {
+ if (pqSkipnchar(msgLen))
+ goto read_error;
+ return 0;
+ }
+ if (pqGetNotice(PG_RSTAT_HAVE_NOTICE))
+ goto read_error;
+ return result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | PG_RSTAT_HAVE_NOTICE;
+
+ case 'A':
+ if (_flags & PG_FLAG_IGNORE_NOTICES) {
+ if (pqSkipnchar(msgLen))
+ goto read_error;
+ return 0;
+ }
+ if (pqGetNotify(msgLen))
+ goto read_error;
+ return result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | PG_RSTAT_HAVE_NOTICE;
+
+ case 'Z':
+ if (pqSkipnchar(msgLen))
+ goto read_error;
+ result_status = (result_status & PG_RSTAT_HAVE_SUMMARY) | PG_RSTAT_READY;
+ return PG_RSTAT_READY;
+
+ case 'S':
+ case 'K':
+ if (pqSkipnchar(msgLen))
+ goto read_error;
+ return 0;
+
+ case 'C':
+ if (msgLen > _bufSize - 1)
+ goto oom;
+ if (pqGetnchar(_buffer, msgLen))
+ goto read_error;
+ _buffer[msgLen] = 0;
+ _ntuples = 0;
+ result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | PG_RSTAT_HAVE_SUMMARY;
+ for (c = _buffer; *c && !isdigit(*c); c++)
+ ;
+ if (!*c)
+ return result_status;
+ if (strncmp(_buffer, "SELECT ", 7)) {
+ for (; *c && isdigit(*c); c++)
+ ;
+ for (; *c && !isdigit(*c); c++)
+ ;
+ }
+ if (*c)
+ _ntuples = strtol(c, NULL, 10);
+ return result_status;
+
+ case 'D':
+ if ((rc = pqGetRow())) {
+ if (rc == -2)
+ setMsg_P(EM_OOM, PG_RSTAT_HAVE_ERROR);
+ else if (rc == -3)
+ setMsg_P(EM_SYNC, PG_RSTAT_HAVE_ERROR);
+ goto read_error;
+ }
+ if (_flags & PG_FLAG_IGNORE_COLUMNS) {
+ result_status &= ~PG_RSTAT_HAVE_MASK;
+ return 0;
+ }
+
+ return result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | PG_RSTAT_HAVE_ROW;
+
+ case 'I':
+ if (pqSkipnchar(msgLen))
+ goto read_error;
+ setMsg_P(EM_EMPTY, PG_RSTAT_HAVE_ERROR);
+ return result_status;
+
+ default:
+ setMsg_P(EM_SYNC, PG_RSTAT_HAVE_ERROR);
+ conn_status = CONNECTION_BAD;
+ return -1;
+ }
+
+ oom: setMsg_P(EM_OOM, PG_RSTAT_HAVE_ERROR);
+
+ read_error: if (!(result_status & PG_RSTAT_HAVE_ERROR)) {
+ printf("READERROR!\n");fflush(stdout);
+ setMsg_P(EM_READ, PG_RSTAT_HAVE_ERROR);
+ }
+ conn_status = CONNECTION_BAD;
+ return -1;
+}
+
+int PGconnection::PGexecuteFormat(const char *format, ...) {
+ int32_t msgLen;
+ va_list va;
+ va_start(va, format);
+ msgLen = writeFormattedQuery(0, format, va);
+ va_end(va);
+ if (msgLen < 0)
+ return -1;
+ va_start(va, format);
+ msgLen = writeFormattedQuery(msgLen, format, va);
+ va_end(va);
+ if (msgLen) {
+ return -1;
+ }
+ result_status = PG_RSTAT_COMMAND_SENT;
+ return 0;
+}
+
+int PGconnection::build_startup_packet(char *packet, const char *dbName, const char *dbCharset) {
+ int packet_len = 4;
+ if (packet) {
+ memcpy(packet, "\0\003\0\0", 4);
+ }
+#define ADD_STARTUP_OPTION(optname, optval) \
+ do { \
+ if (packet) \
+ strcpy(packet + packet_len, (char *)optname); \
+ packet_len += strlen((char *)optname) + 1; \
+ if (packet) \
+ strcpy(packet + packet_len, (char *)optval); \
+ packet_len += strlen((char *)optval) + 1; \
+ } while(0)
+
+#define ADD_STARTUP_OPTION_P(optname, optval) \
+ do { \
+ if (packet) \
+ strcpy(packet + packet_len, (char *)optname); \
+ packet_len += strlen((char *)optname) + 1; \
+ if (packet) \
+ strcpy(packet + packet_len, (char *)optval); \
+ packet_len += strlen((char *)optval) + 1; \
+ } while(0)
+
+ if (_user && _user[0])
+ ADD_STARTUP_OPTION("user", _user);
+ if (dbName && dbName[0])
+ ADD_STARTUP_OPTION("database", dbName);
+ if (dbCharset && dbCharset[0])
+ ADD_STARTUP_OPTION("client_encoding", dbCharset);
+ ADD_STARTUP_OPTION_P("application_name", "Scaladis");
+#undef ADD_STARTUP_OPTION
+ if (packet)
+ packet[packet_len] = '\0';
+ packet_len++;
+
+ return packet_len;
+}
+
+int PGconnection::pqPacketSend(char pack_type, const char *buf, int buf_len) {
+ char *start = _buffer;
+ int l = _bufSize - 4;
+// int n;
+ if (pack_type) {
+ *start++ = pack_type;
+ l--;
+ }
+ *start++ = ((buf_len + 4) >> 24) & 0xff;
+ *start++ = ((buf_len + 4) >> 16) & 0xff;
+ *start++ = ((buf_len + 4) >> 8) & 0xff;
+ *start++ = (buf_len + 4) & 0xff;
+
+ if (buf) {
+ if (buf_len <= l) {
+ memcpy(start, buf, buf_len);
+ start += buf_len;
+ buf_len = 0;
+ } else {
+ memcpy(start, buf, l);
+ start += l;
+ buf_len -= l;
+ buf += l;
+ }
+ }
+ int err = send(SockH, _buffer, start - _buffer, 0);
+ if (err < 0) {
+ ESP_LOGE(PGTAG, "Send Error occurred during sending: errno %d", errno);
+ return err;
+ }
+ if (buf && buf_len) {
+ err = send(SockH, (const char *) buf, (size_t) buf_len, 0);
+ if (err < 0) {
+ ESP_LOGE(PGTAG, "Send2 Error occurred during sending: errno %d", errno);
+ return err;
+
+ }
+ }
+
+ return 0;
+}
+
+int PGconnection::pqGetc(char *buf) {
+ int i=0;
+// for (i = 0; !client->available() && i < 10; i++) {
+ while (i<10) {
+ if (dataAvailable()>0) break;
+ else {
+ vTaskDelay(i++);
+ }
+ }
+ if (i==10) return -1;
+
+ int len = read(SockH, (void *) buf, 1);
+ _available-=len;
+ return -1+len;
+}
+
+int PGconnection::pqGetInt4(int32_t *result) {
+ uint32_t tmp4 = 0;
+ uint8_t tmp, i;
+ int rt=0;
+ for (i = 0; i < 4; i++) {
+ rt=pqGetc((char *) &tmp);
+ if (rt) return -1;
+ tmp4 = (tmp4 << 8) | tmp;
+ }
+ *result = tmp4;
+ return 0;
+}
+
+int PGconnection::pqGetInt2(int16_t *result) {
+ uint16_t tmp2 = 0;
+ uint8_t tmp, i;
+ for (i = 0; i < 2; i++) {
+ if (pqGetc((char *) &tmp)) return -1;
+ tmp2 = (tmp2 << 8) | tmp;
+ }
+ *result = tmp2;
+ return 0;
+}
+
+int PGconnection::pqGetnchar(char *s, int len) {
+ while (len-- > 0) {
+ if (pqGetc(s++)) return -1;
+ }
+ return 0;
+}
+
+int PGconnection::pqGets(char *s, int maxlen) {
+ int len;
+ char z;
+ for (len = 0; len < maxlen; len++) {
+ if (pqGetc(&z)) return -1;
+ if (s) *s++ = z;
+ if (!z) return len + 1;
+ }
+ return -(len + 1);
+}
+
+int PGconnection::pqSkipnchar(int len) {
+ char dummy;
+ int i;
+ for (i=0;i<len;i++) read(SockH,&dummy,1);
+ /*
+ while (len-- > 0) {
+ if (pqGetc(&dummy))
+ return -1;
+ }
+ */
+ return 0;
+}
+
+int PGconnection::pqGetRow(void) {
+ int i;
+ int bufpos = 0;
+ int32_t len;
+ int16_t cols;
+
+ _null = 0;
+ if (pqGetInt2(&cols)) return -1;
+ if (cols != _nfields) return -3;
+
+ for (i = 0; i < _nfields; i++) {
+ if (pqGetInt4(&len)) return -1;
+ if (len < 0) {
+ _null |= 1 << i;
+ continue;
+ }
+ if (bufpos + len + 1 > _bufSize) {
+ return -2;
+ }
+ if (pqGetnchar(_buffer + bufpos, len))
+ return -1;
+ bufpos += len;
+ _buffer[bufpos++] = 0;
+ }
+ return 0;
+}
+
+int PGconnection::pqGetRowDescriptions(void) {
+ int i;
+ int16_t format;
+ int rc;
+ int bufpos;
+ if (pqGetInt2(&_nfields))
+ return -1;
+ if (_nfields > PG_MAX_FIELDS)
+ return -2; // implementation limit
+ _formats = 0;
+ bufpos = 0;
+
+ for (i = 0; i < _nfields; i++) {
+ if (!(_flags & PG_FLAG_IGNORE_COLUMNS)) {
+ if (bufpos >= _bufSize - 1)
+ return -2;
+ rc = pqGets(_buffer + bufpos, _bufSize - bufpos);
+ if (rc < 0)
+ return -1;
+ bufpos += rc;
+ } else {
+ if (pqGets(NULL, 8192) < 0) {
+ return -1;
+ }
+ }
+ if (pqSkipnchar(16))
+ return -1;
+ if (pqGetInt2(&format))
+ return -1;
+ format = format ? 1 : 0;
+ _formats |= format << i;
+ }
+ if (_formats)
+ return -3;
+ return 0;
+}
+
+void PGconnection::setMsg(const char *s, int type) {
+ strcpy(_buffer, s);
+ result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | type;
+}
+
+void PGconnection::setMsg_P(const char *s, int type) {
+ strcpy(_buffer, s);
+ result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | type;
+}
+
+int PGconnection::pqGetNotice(int type) {
+ int bufpos = 0;
+ char id;
+ int rc;
+ for (;;) {
+ if (pqGetc(&id)) goto read_error;
+ if (!id)
+ break;
+ if (id == 'S' || id == 'M') {
+ if (bufpos && bufpos < _bufSize - 1)
+ _buffer[bufpos++] = ':';
+ rc = pqGets(_buffer + bufpos, _bufSize - bufpos);
+ if (rc < 0)
+ goto read_error;
+ bufpos += rc - 1;
+ } else {
+ rc = pqGets(NULL, 8192);
+ if (rc < 0) goto read_error;
+ }
+ }
+ _buffer[bufpos] = 0;
+ result_status = (result_status & ~PG_RSTAT_HAVE_MASK) | type;
+ return 0;
+
+ read_error: if (!bufpos)
+ setMsg_P(EM_READ, PG_RSTAT_HAVE_ERROR);
+ return -1;
+}
+
+int PGconnection::pqGetNotify(int32_t msgLen) {
+ int32_t pid;
+ int bufpos, i;
+ if (pqGetInt4(&pid))
+ return -1;
+ msgLen -= 4;
+ bufpos = sprintf(_buffer, "%d:", pid);
+ if (msgLen > _bufSize - (bufpos + 1)) {
+ if (pqGetnchar(_buffer + bufpos, _bufSize - (bufpos + 1)))
+ return -1;
+ msgLen -= _bufSize - (bufpos + 1);
+ if (pqSkipnchar(msgLen))
+ return -1;
+ _buffer[msgLen = _bufSize - 1] = 0;
+
+ } else {
+ if (pqGetnchar(_buffer + bufpos, msgLen))
+ return -1;
+ _buffer[bufpos + msgLen] = 0;
+ msgLen += bufpos;
+ }
+ for (i = 0; i < msgLen; i++)
+ if (!_buffer[i])
+ _buffer[i] = ':';
+ return 0;
+}
+
+int PGconnection::dataAvailable() {
+ int res=0;
+// if (_available) return _available;
+ ioctl(SockH,FIONREAD,&res);
+ return res;
+}
+
+int PGconnection::writeMsgPart(const char *s, int len, int fine) {
+ while (len > 0) {
+ int n = len;
+ if (n > _bufSize - bufPos)
+ n = _bufSize - bufPos;
+ memcpy(_buffer + bufPos, s, n);
+ bufPos += n;
+ s += n;
+ len -= n;
+ if (bufPos >= _bufSize) {
+// if (client->write((uint8_t *) Buffer, bufPos) != (size_t) bufPos) return -1;
+ int err = send(SockH, _buffer, bufPos, 0);
+ if (err < 0)
+ return -1;
+ bufPos = 0;
+ }
+ }
+ if (bufPos && fine) {
+// if (client->write((uint8_t *) Buffer, bufPos) != (size_t) bufPos) return -1;
+ int err = send(SockH, _buffer, bufPos, 0);
+ if (err < 0)
+ return -1;
+
+ bufPos = 0;
+ }
+
+ return 0;
+}
+
+int32_t PGconnection::writeFormattedQuery(int32_t length, const char *format, va_list va) {
+ int32_t msgLen = 0;
+ const char *percent;
+ int blen, rc;
+#define LBUFLEN 32
+ char buf[LBUFLEN], znak;
+ if (length) {
+ length += 4;
+ bufPos = 0;
+ _buffer[bufPos++] = 'Q';
+ _buffer[bufPos++] = (length >> 24) & 0xff;
+ _buffer[bufPos++] = (length >> 16) & 0xff;
+ _buffer[bufPos++] = (length >> 8) & 0xff;
+ _buffer[bufPos++] = (length) & 0xff;
+ }
+ for (;;) {
+ percent = strchr(format, '%');
+ if (!percent)
+ break;
+ znak = percent[1];
+ if (!length) {
+ msgLen += (percent - format);
+ } else {
+ rc = writeMsgPart(format, percent - format, false);
+ if (rc)
+ goto write_error;
+ }
+ format = percent + 2;
+ if (znak == 's' || znak == 'n') {
+ char *str = va_arg(va, char *);
+ blen = (znak == 's') ? PGescapeString(str, NULL) : PGescapeName(str, NULL);
+ if (!length) {
+ msgLen += blen;
+ } else {
+ if (bufPos + blen > _bufSize) {
+ rc = writeMsgPart(NULL, 0, true);
+ if (rc)
+ goto write_error;
+ }
+ }
+ if (znak == 's') {
+ PGescapeString(str, _buffer + bufPos);
+ } else {
+ PGescapeName(str, _buffer + bufPos);
+ }
+ bufPos += blen;
+ continue;
+ }
+ if (znak == 'l' || znak == 'd') {
+ if (znak == 'l') {
+ long n = va_arg(va, long);
+ blen = snprintf(buf, LBUFLEN, "'%ld'", n);
+ } else {
+ int n = va_arg(va, int);
+ blen = snprintf(buf, LBUFLEN, "'%d'", n);
+ }
+ if (length) {
+ rc = writeMsgPart(buf, blen, false);
+ if (rc)
+ goto write_error;
+ } else {
+ msgLen += blen;
+ }
+ }
+ setMsg_P(EM_FORMAT, PG_RSTAT_HAVE_ERROR);
+ return -1;
+ }
+ blen = strlen(format);
+ if (length) {
+ rc = writeMsgPart(format, blen, false);
+ if (!rc) {
+ rc = writeMsgPart("\0", 1, true);
+ }
+ if (rc)
+ goto write_error;
+ } else {
+ msgLen += blen + 1;
+ }
+ return msgLen;
+
+ write_error: setMsg_P(EM_WRITE, PG_RSTAT_HAVE_ERROR);
+ conn_status = CONNECTION_BAD;
+ return -1;
+}
diff --git a/software/michi_funcs/SimplePgSQL_h.old b/software/michi_funcs/SimplePgSQL_h.old
new file mode 100644
index 0000000..9637ee5
--- /dev/null
+++ b/software/michi_funcs/SimplePgSQL_h.old
@@ -0,0 +1,209 @@
+/*
+ * SimplePgSQL.h - Lightweight PostgreSQL connector for Arduino
+ * Copyright (C) Bohdan R. Rau 2016 <ethanak@polip.com>
+ *
+ * SimplePgSQL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * SimplePgSQL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with SimplePgSQL. If not, write to:
+ * The Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "esp_system.h"
+#include "esp_netif.h"
+#include "lwip/err.h"
+#include "lwip/sockets.h"
+
+#ifndef _SIMPLEPGSQL
+#define _SIMPLEPGSQL 1
+
+typedef enum {
+ CONNECTION_OK, CONNECTION_BAD, CONNECTION_NEEDED, /* setDbLogin() needed */
+ /* Internal states here */
+ CONNECTION_AWAITING_RESPONSE, /* Waiting for a response from the postmaster. */
+ CONNECTION_AUTH_OK /* Received authentication; waiting for backend startup. */
+} ConnStatusType;
+
+#define PG_BUFFER_SIZE 4096
+
+// maximum number of fields in backend response
+// must not exceed number of bits in _formats and _null
+#define PG_MAX_FIELDS 32
+
+// ignore notices and notifications
+#define PG_FLAG_IGNORE_NOTICES 1
+// do not store column names
+#define PG_FLAG_IGNORE_COLUMNS 2
+
+// ready for next query
+#define PG_RSTAT_READY 1 // command sent
+#define PG_RSTAT_COMMAND_SENT 2 // column names in buffer
+#define PG_RSTAT_HAVE_COLUMNS 4 // row values in buffer
+#define PG_RSTAT_HAVE_ROW 8 // summary (number of tuples/affected rows) received
+#define PG_RSTAT_HAVE_SUMMARY 16 // error message in buffer
+#define PG_RSTAT_HAVE_ERROR 32 // notice/notification in buffer
+#define PG_RSTAT_HAVE_NOTICE 64
+
+#define PG_RSTAT_HAVE_MASK (PG_RSTAT_HAVE_COLUMNS | \
+ PG_RSTAT_HAVE_ROW | \
+ PG_RSTAT_HAVE_SUMMARY | \
+ PG_RSTAT_HAVE_ERROR | \
+ PG_RSTAT_HAVE_NOTICE)
+
+#define PG_RSTAT_HAVE_MESSAGE (PG_RSTAT_HAVE_ERROR | PG_RSTAT_HAVE_NOTICE)
+
+class PGconnection {
+public:
+
+ PGconnection(const int flags, const unsigned char *Buffer, const int bufSize);
+ /*
+ * returns connection status.
+ * passwd may be null in case of 'trust' authorization.
+ * only 'trust', 'password' and 'md5' (if compiled in)
+ * authorization modes are implemented.
+ * ssl mode is not implemented.
+ * database name defaults to user name *
+ */
+ int PGsetDbLogin(const char *ServerIP, int ServerPort, const char *dbName, const char *dbUser, const char *dbPasswd, const char *charset);
+ /*
+ * performs authorization tasks if needed
+ * returns current connection status
+ * must be called periodically until OK, BAD or NEEDED
+ */
+ int PGstatus(void);
+ /*
+ * sends termination command if possible
+ * closes client connection and frees internal buffer
+ */
+ void PGclose(void);
+ /*
+ * sends query to backend
+ * returns negative value on error
+ * or zero on success
+ */
+ int PGexecute(const char *query);
+
+ /* should be called periodically in idle state
+ * if notifications are enabled
+ * returns:
+ * - negative value on error
+ * - zero if no interesting data arrived
+ * - current data status if some data arrived
+ */
+ int PGgetData(void);
+ /*
+ * returns pointer to n-th column name in internal buffer
+ * if available or null if column number out of range
+ * will be invalidated on next getData call
+ */
+ char *PGgetColumn(int n);
+ /*
+ * returns pointer to n-th column value in internal buffer
+ * if available or null if column number out of range
+ * or value is NULL
+ * will be invalidated on next getData call
+ */
+ char *PGgetValue(int);
+ /*
+ * returns pointer to message (error or notice)
+ * if available or NULL
+ * will be invalidated on next getData call
+ */
+ char *PGgetMessage(void);
+ int PGdataStatus(void) {
+ return result_status;
+ }
+ ;
+ int PGnfields(void) {
+ return _nfields;
+ }
+ ;
+ int PGntuples(void) {
+ return _ntuples;
+ }
+ ;
+ /*
+ * returns length of escaped string
+ * single quotes and E prefix (if needed)
+ * will be added.
+ */
+ int PGescapeString(const char *inbuf, char *outbuf);
+ /*
+ * returns length of escaped string
+ * double quotes will be added.
+ */
+ int PGescapeName(const char *inbuf, char *outbuf);
+ /*
+ * sends formatted query to backend
+ * returns negative value on error
+ * or zero on success
+ * Formatting sequences:
+ * %s - string literal (will be escaped with escapeString)
+ * %n - name (will be escaped with escapeName)
+ * %d - int (single quotes will be added)
+ * %l - long int (single quotes will be added)
+ * %% - % character
+ */
+ int PGexecuteFormat(const char *format, ...);
+
+private:
+ int pqPacketSend(char pack_type, const char *buf, int buf_len);
+ int pqGetc(char *);
+ int pqGetInt4(int32_t *result);
+ int pqGetInt2(int16_t *result);
+ int pqGetnchar(char *s, int len);
+ int pqSkipnchar(int len);
+ int pqGets(char *s, int maxlen);
+ int pqGetRowDescriptions(void);
+ int pqGetRow(void);
+ void setMsg(const char *, int);
+ void setMsg_P(const char *, int);
+ int pqGetNotice(int);
+ int pqGetNotify(int32_t);
+ char *_user;
+ char *_passwd;
+// char *Buffer;
+ char *_buffer;
+// int bufSize;
+ int _bufSize;
+ int bufPos;
+ int writeMsgPart(const char *s, int len, int fine);
+ int32_t writeFormattedQuery(int32_t length, const char *format, va_list va);
+ int dataAvailable(void);
+ int build_startup_packet(char *packet, const char *db, const char *charset);
+ uint8_t conn_status;
+ uint8_t attempts;
+ /*
+ int32_t be_pid;
+ int32_t be_key;
+ */
+ int16_t _nfields;
+ int16_t _ntuples;
+ uint32_t _formats;
+ uint32_t _null;
+ uint8_t _binary;
+ uint8_t _flags;
+ uint32_t _available;
+ int result_status;
+ // network stuff
+ struct sockaddr_in DestAddr;
+ int SockH = -1;
+ int ipProtocol = 0;
+ int AddrFamily = 0;
+ int NetConnected=0;
+
+};
+
+#endif
diff --git a/software/michi_funcs/board_rev_A.cpp b/software/michi_funcs/board_rev_A.cpp
new file mode 100644
index 0000000..f71e27a
--- /dev/null
+++ b/software/michi_funcs/board_rev_A.cpp
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "freertos/queue.h"
+#include "driver/gpio.h"
+#include "schrank_ant_pcb.h" //contains setting of board revision
+
+#ifndef ESP32_BOARD_REV_B
+
+void io_init(void)
+{
+
+#define GPO_BIT_MASK (1ULL << PHY_PWR)
+ gpio_config_t o_conf;
+ o_conf.intr_type = GPIO_INTR_DISABLE;
+ o_conf.mode = GPIO_MODE_OUTPUT;
+ o_conf.pin_bit_mask = GPO_BIT_MASK;
+ o_conf.pull_down_en = GPIO_PULLDOWN_ENABLE;
+ o_conf.pull_up_en = GPIO_PULLUP_DISABLE;
+ gpio_config(&o_conf);
+ gpio_set_level((gpio_num_t) PHY_PWR, 1);
+
+ // inputs
+ /*
+ #define GPI_BIT_MASK ((1ULL << SWITCH)|(1ULL << SWITCH))
+ gpio_config_t i_conf;
+ i_conf.intr_type = GPIO_INTR_DISABLE;
+ i_conf.mode = GPIO_MODE_INPUT;
+ i_conf.pin_bit_mask = GPI_BIT_MASK;
+ i_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
+ i_conf.pull_up_en = GPIO_PULLUP_DISABLE;
+ gpio_config(&i_conf);
+ */
+}
+
+#endif
diff --git a/software/michi_funcs/board_rev_A.hpp b/software/michi_funcs/board_rev_A.hpp
new file mode 100644
index 0000000..d5eff54
--- /dev/null
+++ b/software/michi_funcs/board_rev_A.hpp
@@ -0,0 +1,49 @@
+#ifndef _BOARD_REV_A_H_
+#define _BOARD_REV_A_H_
+
+#include "schrank_ant_pcb.h" //contains setting of board revision
+
+//board definitions for Rev A board (LAN8720 module)
+
+// +3,3V // Pin 1
+// GND // Pin 2
+// ESP_EN // Pin 3
+#define UHF_RXD_MISO 36 // pin 4 UART
+#define LCD_RXD_MISO 39 // pin 5 UART
+// NC pin 6
+#define I2Cint 35 // pin 7 EXP
+//#define SCL 33 // pin 8 EXP disabled Michi, all boards have SCL on 32
+//#define SDA 32 // pin 9 EXP disabled Michi, all boards have SDA on 33
+#define SCL 32 //new Michi 01.05.2022
+#define SDA 33 //new Michi 01.05.2022
+#define EMAC_RXD0_RMII 25 // pin 10 ETH
+#define EMAC_RXD1_RMII 26 // pin 11 ETH
+#define EMAC_RX_CRS_DV 27 // pin 12 ETH
+#define HS2_CLK 14 // pin 13 ETH
+#define PHY_PWR 12 // pin 14 ETH
+// // pin 15 GND
+#define I2C_SDA_40p 13 // pin 16 40p
+// NC pin 17 bis 22
+#define HS2_CMD 15 // pin 23 ETH
+#define HS2_DATA0 02 // pin 24 ETH
+#define ETH_CLKREF 0 // pin 25 ETH
+#define UHF_TXD_MOSI 04 // pin 26 UART
+#define LCD_TXD_MOSI 16 // pin 27 UART
+#define EMAC_CLK_OUT_180 17 // pin 28 ETH
+#define SPI_CS 05 // pin 29 40p
+#define MDIO_RMII 18 // pin 30 ETH
+#define EMAC_TXD0_RMII 19 // pin 31 ETH
+//NC pin 32
+#define EMAC_TX_EN_RMII 21 // pin 33 ETH
+#define RDR_RXD_MISO 03 // pin 34 UART
+#define RDR_TXD_MOSI 01 // pin 35 UART
+#define EMAC_TXD1_RMII 22 // pin 36 ETH
+#define MDC_RMII 23 // pin 37 ETH
+//GND pin 38, 39
+#define I2C_PORTEXP 0x22
+
+
+void io_init(void);
+
+#endif
+
diff --git a/software/michi_funcs/board_rev_B.cpp b/software/michi_funcs/board_rev_B.cpp
new file mode 100644
index 0000000..902340e
--- /dev/null
+++ b/software/michi_funcs/board_rev_B.cpp
@@ -0,0 +1,102 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "freertos/queue.h"
+#include "driver/gpio.h"
+#include "driver/i2c.h"
+#include "schrank_ant_pcb.h" //contains setting of board revision
+
+#ifdef ESP32_BOARD_REV_B
+#include "board_rev_B.hpp"
+
+void io_init(void)
+{
+ #define GPO_BIT_MASK 0 //we dont have GPIO as outputs, all output is done via I2C Port Expander
+/* as we have not ouput, leave default settings
+ gpio_config_t o_conf;
+ o_conf.intr_type = GPIO_INTR_DISABLE;
+ o_conf.mode = GPIO_MODE_OUTPUT;
+ o_conf.pin_bit_mask = GPO_BIT_MASK;
+ o_conf.pull_down_en = GPIO_PULLDOWN_ENABLE;
+ o_conf.pull_up_en = GPIO_PULLUP_DISABLE;
+ gpio_config(&o_conf);
+*/
+ //gpio_set_level((gpio_num_t) PHY_PWR, 1);
+
+ // inputs
+
+ #define IRQ2Esp 34
+ #define I2Cext_INT 35
+ #define GPI_BIT_MASK ((1ULL<<IRQ2Esp) | (1ULL<<I2Cext_INT))
+ //io_conf.pin_bit_mask = (1ULL<<15);//bit mask of the pins that you want to set,e.g.GPIO15
+ gpio_config_t i_conf;
+ i_conf.intr_type = GPIO_INTR_DISABLE;
+ i_conf.mode = GPIO_MODE_INPUT;
+ i_conf.pin_bit_mask = GPI_BIT_MASK;
+ i_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
+ i_conf.pull_up_en = GPIO_PULLUP_DISABLE;
+ gpio_config(&i_conf);
+
+}
+
+
+
+
+esp_err_t i2c_init(void) {
+ int res1,res2;
+ int I2C_master_port = I2C_MASTER_NUM;
+ uint8_t I2C_buf[5];
+ i2c_config_t I2C_conf = { .mode = I2C_MODE_MASTER, .sda_io_num = I2C_MASTER_SDA_IO, .scl_io_num = I2C_MASTER_SCL_IO, .sda_pullup_en = GPIO_PULLUP_ENABLE, .scl_pullup_en = GPIO_PULLUP_ENABLE, .master { .clk_speed = I2C_MASTER_FREQ_HZ, } };
+ i2c_param_config(I2C_master_port, &I2C_conf);
+
+ printf("\nInstall i2c_driver: Mode=%d sda_io_num=%d scl_io_num=%d\n", I2C_MODE_MASTER, I2C_MASTER_SDA_IO, I2C_MASTER_SCL_IO);
+ res1=i2c_driver_install(I2C_master_port, I2C_conf.mode,
+ I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0);
+ ESP_ERROR_CHECK_WITHOUT_ABORT(res1);
+ printf("After i2c_driver_install\n");
+ vTaskDelay(500 / portTICK_PERIOD_MS);
+
+//1. Init AW9523 on address 0x00
+ I2C_buf[0] = 0x7F; // write to AW9523 Soft Reset register
+ I2C_buf[1] = 0x00; // write data to output port 1
+ I2C_buf[2] = 0x00; // write data to output port 1
+ printf("I2C write to bus %d to I2C-Adress %d byte0 = %d byte 1 = %d\n", I2C_MASTER_NUM, I2C_PORTEXP1, I2C_buf[0], I2C_buf[1] );
+ res1 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP1, I2C_buf, 3, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ printf("I2C write to bus %d to I2C-Adress %d byte0 = %d byte 1 = %d\n", I2C_MASTER_NUM, I2C_PORTEXP2, I2C_buf[0], I2C_buf[1] );
+ res2 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP2, I2C_buf, 3, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ printf("\nMaster wrote %d %d %02X\n", res1,res2,I2C_buf[0]);
+ printf("After AW9523 soft-RESET\n");
+ vTaskDelay(500 / portTICK_PERIOD_MS);
+
+//2. Set outputs push pull in AW9523 Global Control Register
+ I2C_buf[0] = 0x11; // write data to Global Control Register
+ I2C_buf[1] = 0x10; // write data to Global Control Register, set Bit4 to Push Pull
+ res1 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP1, I2C_buf, 2, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ res2 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP2, I2C_buf, 2, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ printf("\nMaster wrote %d %d %02X\n", res1,res2,I2C_buf[0]);
+
+ I2C_buf[0] = 0x02; // write data to output port 1
+ I2C_buf[1] = 0xFF; // write data to output port 1
+ I2C_buf[2] = 0xFF; // write data to output port 1
+ I2C_buf[3] = 0x00; // write data to output port 1
+ I2C_buf[4] = 0x00; // write data to output port 1
+ res1 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP1, I2C_buf, 5, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ res2 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP2, I2C_buf, 5, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+ printf("\nMaster wrote %d %d %02X\n", res1,res2,I2C_buf[0]);
+ printf("After AW9523 all GPIOs HIGH\n");
+ vTaskDelay(500 / portTICK_PERIOD_MS);
+
+
+
+//2. Set AW9523-PhyPower to high
+/* I2C_buf[0] = 0x02; // write to register 0x02
+ I2C_buf[1] = 255; // set all pins high
+ I2C_buf[2] = 255; // set all pins high
+ res1 = i2c_master_write_to_device(I2C_MASTER_NUM, I2C_PORTEXP2, I2C_buf, 3, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
+*/
+ return res1;
+}
+
+#endif
diff --git a/software/michi_funcs/board_rev_B.hpp b/software/michi_funcs/board_rev_B.hpp
new file mode 100644
index 0000000..74d4404
--- /dev/null
+++ b/software/michi_funcs/board_rev_B.hpp
@@ -0,0 +1,63 @@
+#ifndef _BOARD_REV_B_H_
+#define _BOARD_REV_B_H_
+
+//board definitions for Rev B board (LAN8720 on board)
+#include "schrank_ant_pcb.h" //contains setting of board revision
+
+
+#define UHF_RXD_MISO 36 // pin 4 UART
+#define LCD_RXD_MISO 39 // pin 5 UART
+
+#define SCL 32 //new Michi 01.05.2022
+#define SDA 33 //new Michi 01.05.2022
+
+
+#define I2C_MASTER_SCL_IO SCL
+#define I2C_MASTER_SDA_IO SDA
+#define I2C_MASTER_NUM 0 /*!< I2C master i2c port number, the number of i2c peripheral interfaces available will depend on the chip */
+#define I2C_MASTER_FREQ_HZ 100000 /*!< I2C master clock frequency */
+#define I2C_MASTER_TX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */
+#define I2C_MASTER_RX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */
+#define I2C_MASTER_TIMEOUT_MS 1000
+#define I2C_PORTEXP 0x22
+#define I2Cint 35
+#define EMAC_RXD0_RMII 25 // pin 10 ETH
+#define EMAC_RXD1_RMII 26 // pin 11 ETH
+#define EMAC_RX_CRS_DV 27
+#define HS2_CLK 14
+//#define PHY_PWR is in Rev B handled by I2C port expander, no longer a GPIO
+//#define I2C_SDA_40p 13 // the I2C to the RasPi 40 port header is switched with the second port expander
+#define HS2_CMD 15
+#define HS2_DATA0 02
+#define ETH_CLKREF 0
+#define UHF_TXD_MOSI 04
+#define LCD_TXD_MOSI 5
+//#define EMAC_CLK_OUT_180 17 // there is no GPIO17 on the WROVER module
+#define SPI_CS 13// was: 05
+#define MDIO_RMII 18
+#define EMAC_TXD0_RMII 19
+#define EMAC_TX_EN_RMII 21
+#define RDR_RXD_MISO 03
+#define RDR_TXD_MOSI 01
+#define EMAC_TXD1_RMII 22
+#define MDC_RMII 23
+//#define I2C_PORTEXP 0x22
+
+#define I2C_MASTER_NUM 0 /*!< I2C master i2c port number, the number of i2c peripheral interfaces available will depend on the chip */
+
+// AW9523 I2C adress P40 1011000 = 88, 0x58
+// AW9523 I2C adress 10110 AD1 AD0 RW
+//#define AW9523B_I2C_ADDRESS_MAIN 88 //0x58
+#define AW9523B_I2C_ADDRESS_MAIN 0x58
+
+// AW9523 I2C adress P40 10110100 = 90, 0x5A
+#define AW9523B_I2C_ADDRESS_ETH 0x5A //90dec
+#define I2C_PORTEXP1 0x58
+#define I2C_PORTEXP2 0x5A
+
+void io_init(void);
+esp_err_t i2c_init(void);
+void kolban_i2cscanner(void );
+
+#endif
+
diff --git a/software/michi_funcs/component.mk b/software/michi_funcs/component.mk
new file mode 100644
index 0000000..a98f634
--- /dev/null
+++ b/software/michi_funcs/component.mk
@@ -0,0 +1,4 @@
+#
+# "main" pseudo-component makefile.
+#
+# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
diff --git a/software/michi_funcs/db_funcs.cpp b/software/michi_funcs/db_funcs.cpp
new file mode 100644
index 0000000..c1a2f56
--- /dev/null
+++ b/software/michi_funcs/db_funcs.cpp
@@ -0,0 +1,404 @@
+/*
+How to use db_funcs:
+1. in main.cpp #include "db_funcs.h"
+2. in main.cpp, in init()
+ while (network_connected != 1) { vTaskDelay(2000 / portTICK_PERIOD_MS); }
+ strcpy(dbnam ,(char *)"c10mm");
+ strcpy(pg_server_ip ,(char *)"192.168.178.100");
+
+2.a pqConnection = new TpgConnection(); // Verbindungsobject erzeugen
+2.b if ( pqConnection->db_connect( pg_server_ip, srvpo, dbnam, PGUser, PGPassword, PGCharset) == 0) //verbinden
+2.c query1 = new TResultSet( pqConnection->PGconn );
+2.d query1->db_query("select type, state from items limit 10;");
+2.4 for (int iRow = 0; iRow < query1->NumRows-1; iRow++)
+ {
+ std::cout << query1->Zeile[iRow].Spalte[0] << " | ";
+ std::cout << query1->Zeile[iRow].Spalte[1] << " | ";
+ printf("\n");
+ }
+
+3. query1->db_query("select bla bla;"); //naechste Abfrage
+ //oder neues Abfrage-Object erstellen: query2 = new TResultSet( pqConnection->PGconn );
+
+4. in main.cpp, main_loop()
+ db_loop(); //db_loop regelmaessig aufrufen, damit NOTIFY Nachrichten verarbeitet werden.
+
+
+5. Auf Notification reagieren: Vor der mail() Schleife die NOTIFIY Nachrichten registrieren
+ db_query("listen door_open"); //register listen handler for NOTIFY door_open <door_no>
+ db_query("listen door_close"); //register listen handler for NOTIFY door_close <door_no>
+
+*/
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "esp_netif.h"
+#include "esp_eth.h"
+#include "esp_log.h"
+#include "SimplePgSQL.h"
+
+//For ResultSet:
+#include "db_funcs.h"
+#include <vector>
+#include <iostream>
+#include <string>
+
+static int pg_flags = 0;
+
+// PGSQL
+#define PGBufferSize 16384
+#define PGCharset "utf-8"
+#define PGUser "micha"
+#define PGPassword "micha"
+const TickType_t delay1ms = 1 / portTICK_PERIOD_MS;
+const TickType_t delay10ms = 10 / portTICK_PERIOD_MS;
+const TickType_t delay100ms = 100 / portTICK_PERIOD_MS;
+
+//static PGconnection *PGconn = NULL;
+static unsigned char PGbuffer[PGBufferSize];
+static char lastNotify[40];
+
+static const char *PGTAG = "SCALADIS-PG";
+
+static unsigned char pg_lastError_string[80];
+
+//TResultSet ResultSetObject(1);
+
+TpgConnection::TpgConnection()
+{
+ PGconn = NULL;
+}
+
+
+int TpgConnection::db_connect(const char *pg_server_ip, int pg_port, const char *s_db_name, const char *s_db_user, const char *s_db_passwd, const char *s_db_charset)
+{
+//CONNECTION_OK, CONNECTION_BAD, CONNECTION_NEEDED, /* setDbLogin() needed */
+//CONNECTION_AWAITING_RESPONSE, /* Waiting for a response from the postmaster. */
+// CONNECTION_AUTH_OK
+ int loop_fuse = 0;
+ ESP_LOGI(PGTAG,"db_connect Enter");
+ PGconn = new PGconnection(pg_flags, PGbuffer, PGBufferSize);
+ if (PGconn == NULL) { ESP_LOGE(PGTAG, "error creating PGconn object"); }
+
+ last_pgError = PGconn->setDbLogin(pg_server_ip, pg_port, s_db_name, s_db_user, s_db_passwd, s_db_charset);
+
+ while ( (last_pgError != CONNECTION_OK) || (last_pgError != CONNECTION_BAD)
+ || (last_pgError != CONNECTION_NEEDED) )
+ {
+ last_pgError = PGconn->status();
+ vTaskDelay(delay10ms);
+ loop_fuse++;
+ if (loop_fuse > 100) { ESP_LOGE(PGTAG, "PGsetDbLogin break after 10 attempts. "); break; }
+ }
+
+ //ResultSetObject.Zeile.resize(1);
+
+ switch (last_pgError) {
+ case CONNECTION_NEEDED: { ESP_LOGE(PGTAG,"connection needed: %s", PGconn->getMessage()); return -1; }
+ case CONNECTION_OK: { ESP_LOGI(PGTAG,"db_connect sucessful (OK) to db %s", s_db_name); return 0; }
+ case CONNECTION_BAD: { ESP_LOGE(PGTAG,"ERROR: %s", PGconn->getMessage()); return -1; }
+ case CONNECTION_AWAITING_RESPONSE: { ESP_LOGI(PGTAG,"ERROR AWAITING_RESPONSE: %s", PGconn->getMessage()); return -1; }
+ case CONNECTION_AUTH_OK: { ESP_LOGI(PGTAG,"db_connect sucessful (AUTH_OK) to db %s", s_db_name); return 0; }
+ }
+
+
+ ESP_LOGI(PGTAG,"ResultSet created");
+
+ ESP_LOGI(PGTAG,"db_connect EXIT. last_pgError=%d", last_pgError);
+ return 0;
+}
+
+int TpgConnection::db_disconnect(void)
+{
+ ESP_LOGI(PGTAG,"db_disconnect ENTER");
+ if (PGconn == NULL) { ESP_LOGE(PGTAG, "error destroy PGconn object. PGconn = NULL"); return -1; }
+ PGconn->close();
+ delete PGconn;
+ PGconn = NULL;
+ ESP_LOGI(PGTAG,"db_disconnect EXIT");
+ return 0;
+}
+
+void TpgConnection::db_loop(void)
+{
+// bool readyToQuery = false;
+ char *msg = NULL;
+ last_pgError = PGconn->status();
+ if (last_pgError == CONNECTION_BAD || last_pgError == CONNECTION_NEEDED)
+ {
+ ESP_LOGE(PGTAG, "ERROR: %s", PGconn->getMessage() );
+ } else
+ {
+ last_pgError = PGconn->getData();
+ if (last_pgError < 0)
+ {
+ ESP_LOGE(PGTAG, "ERROR: %s", PGconn->getMessage() );
+ } else
+ {
+ if (last_pgError > 0)
+ {
+ //some data arrive
+ msg = PGconn->getMessage();
+ if (msg != NULL)
+ {
+ sprintf( lastNotify, msg); //copy message, to save the NOTIFY
+ ESP_LOGI(PGTAG,"NOTIFY %s", lastNotify);
+ }
+ }
+ }
+ }
+}
+
+// ********************************************************************************************
+
+TResSetRows::TResSetRows()
+{
+ Spalte.resize(1);
+ //ESP_LOGE(PGTAG, "--------------------------> TResSetRows constructor called");
+}
+
+
+TResSetRows::~TResSetRows()
+{
+ Spalte.resize(0);
+ //ESP_LOGE(PGTAG, "--------------------------> TResSetRows destructor called");
+}
+
+TResultSet::TResultSet(PGconnection *PGconnFromCon)
+{
+ PGconn = PGconnFromCon;
+ if (PGconnFromCon == NULL)
+ {
+ ESP_LOGE(PGTAG, "ERROR");
+ ESP_LOGE(PGTAG, "TResultSet::TResultSet(PGconnection *PGconnFromCon) -> PGconnFromCon ist NULL!!!!!!");
+ ESP_LOGE(PGTAG, "");
+ }
+ Zeile.resize(1);
+ NumRows = 0;
+ //ESP_LOGE(PGTAG, "--------------------------> TResultSet constructor called");
+}
+
+TResultSet::~TResultSet()
+{
+ //Speicher aufraeumen
+ ESP_LOGI(PGTAG,"\nTResultSet Destructor called"); //fflush (stdout);
+}
+
+int TResultSet::db_query(const char *sql)
+{
+ int last_pgError;
+ bool queryEnded;
+
+// ESP_LOGI(PGTAG,"db_query ENTER: %s", sql); fflush (stdout);
+ NumRows = 0;//reset NumRows.
+
+ //sprintf(lbuf, "SELECT name,gname FROM accounts WHERE id=(cast(x'%s' AS int));", info);
+ last_pgError = PGconn->execute(sql);
+ if (last_pgError < 0)
+ {
+ printf("ERROR: TResultSet::db_query: PGexecute: %s", PGconn->getMessage());
+ return last_pgError;
+ } else
+ {
+ vTaskDelay(1);
+ queryEnded = false;
+ while (queryEnded == false)
+ {
+ last_pgError = PGconn->getData();
+ if (last_pgError & PG_RSTAT_HAVE_COLUMNS) { process_db_col(); }
+ if (last_pgError & PG_RSTAT_HAVE_ROW) { process_db_row(); }
+ if (last_pgError & PG_RSTAT_HAVE_SUMMARY) { process_db_summary(); }
+ if (last_pgError & PG_RSTAT_HAVE_MESSAGE) { process_db_haveMsg(); }
+ if (last_pgError & PG_RSTAT_READY) { process_db_ready(); }
+ if (last_pgError & PG_RSTAT_COMMAND_SENT) { process_db_cmd_send(); }
+ if (last_pgError & PG_RSTAT_HAVE_ERROR) { process_db_have_error();
+ printf("\n Error from Postgres: ");
+ if ( PGconn->getMessage() != NULL ) { printf("---> %s\n", PGconn->getMessage() ); }
+ fflush (stdout);
+ queryEnded = true; }
+ if (last_pgError & PG_RSTAT_HAVE_NOTICE) { process_db_have_notice(); }
+
+ if (last_pgError < 0)
+ {
+ queryEnded = true;
+ printf("Get Data Error: %d\n", last_pgError );
+ if ( PGconn->getMessage() != NULL ) { printf("---> %s\n", PGconn->getMessage() ); }
+ fflush (stdout);
+ }
+ if (last_pgError == CONNECTION_BAD || last_pgError == CONNECTION_NEEDED)
+ {
+ queryEnded = true;
+ //seem to be the normal end. No Error Message.
+ //ESP_LOGE(PGTAG, "ERROR: CONNECTION BAD or NEEDED:" );
+ //if ( PGconn->getMessage() != NULL ) { ESP_LOGE(PGTAG, "----> %s", PGconn->getMessage() ); }
+ }
+ if (last_pgError == 0) { queryEnded = true; //no more data }
+ }
+
+
+ } //while (queryEnded == false)
+ }
+// ESP_LOGI(PGTAG,"db_query EXIT"); fflush (stdout);
+ return 0;
+}
+
+int TResultSet::db_exec(const char *sql)
+{
+ int last_pgError;
+ bool queryEnded;
+
+// ESP_LOGI(PGTAG,"db_query ENTER: %s", sql); fflush (stdout);
+ NumRows = 0;//reset NumRows.
+
+ last_pgError = PGconn->execute(sql);//call old version from 17.02.2022
+ if (last_pgError < 0)
+ {
+ return last_pgError;
+ } else
+ {
+ vTaskDelay(1);
+ queryEnded = false;
+ while (queryEnded == false)
+ {
+ last_pgError = PGconn->getData();
+ if (last_pgError & PG_RSTAT_HAVE_COLUMNS) { process_db_col(); }
+ if (last_pgError & PG_RSTAT_HAVE_ROW) { process_db_row(); }
+ if (last_pgError & PG_RSTAT_HAVE_SUMMARY) { process_db_summary(); }
+ if (last_pgError & PG_RSTAT_HAVE_MESSAGE) { process_db_haveMsg(); }
+ if (last_pgError & PG_RSTAT_READY) { process_db_ready(); }
+ if (last_pgError & PG_RSTAT_COMMAND_SENT) { process_db_cmd_send(); }
+ if (last_pgError & PG_RSTAT_HAVE_ERROR) {
+ process_db_have_error();
+ printf("\n Error from Postgres: ");
+ if ( PGconn->getMessage() != NULL ) { printf("---> %s\n", PGconn->getMessage() ); }
+ fflush (stdout);
+ queryEnded = true; }
+ if (last_pgError & PG_RSTAT_HAVE_NOTICE) { process_db_have_notice(); }
+
+ if (last_pgError < 0)
+ {
+ queryEnded = true;
+ printf("Insert/Update Error: %d\n", last_pgError );
+ if ( PGconn->getMessage() != NULL ) { printf("---> %s\n", PGconn->getMessage() ); }
+ fflush (stdout);
+ }
+ if (last_pgError == CONNECTION_BAD || last_pgError == CONNECTION_NEEDED)
+ {
+ queryEnded = true;
+ //seem to be the normal end. No Error Message.
+ //ESP_LOGE(PGTAG, "ERROR: CONNECTION BAD or NEEDED:" );
+ //if ( PGconn->getMessage() != NULL ) { ESP_LOGE(PGTAG, "----> %s", PGconn->getMessage() ); }
+ }
+ if (last_pgError == 0) { queryEnded = true; //no more data }
+ }
+
+
+ } //while (queryEnded == false)
+ }
+ fflush (stdout);
+ return 0;
+}
+
+
+void TResultSet::process_db_col(void)
+{
+ int nCols;
+ int iCurrCol;
+// ESP_LOGI(PGTAG,"---> PG_RSTAT_HAVE_COLS");
+ printf("Spalten gefunden: \n" );
+ fflush (stdout);
+
+ //iRow = 1; // erste Zeile hat die Spaltennamen!
+ CurrentRow = 1;
+ nCols = PGconn->nfields();
+ this->NumCols = nCols;
+ Zeile[0].numCols = nCols;
+
+ Zeile.resize( 1 ); //erste Zeile
+ Zeile[0].Spalte.resize(nCols);
+// printf("Set Result buffer auf Spalten: %d\n", nCols );
+ fflush (stdout);
+ //alloc 1 row only, for the column names. More is added later.
+ for (iCurrCol = 0; iCurrCol < nCols; iCurrCol++)
+ {
+ if (iCurrCol) printf(" | ");
+ this->Zeile[0].Spalte[iCurrCol] = PGconn->getColumn(iCurrCol);
+// std::cout << Zeile[0].Spalte[iCurrCol] ;
+// fflush (stdout);
+ }
+
+ printf("\n==========\n");
+ fflush(stdout);
+}
+
+void TResultSet::process_db_row(void)
+{
+ //char *msg;
+ int iRow;
+ int iCurrField;
+ std::string sFeld;
+// ESP_LOGI(PGTAG,"---> PG_RSTAT_HAVE_ROW");
+ this->CurrentRow++;
+ NumRows++;
+ iRow = this->CurrentRow;
+ this->Zeile.resize( iRow ); //naechste Zeile
+ this->Zeile[iRow-1].Spalte.resize( this->Zeile[0].numCols );
+
+// printf("Row %d:", iRow );
+ for (iCurrField = 0; iCurrField < PGconn->nfields(); iCurrField++)
+ {
+ //printf(" | ");
+ //msg = PGconn->getValue( iCurrField );
+ //copy the string, to save the result
+ if (!PGconn->getValue( iCurrField ) )
+ { Zeile[iRow-1].Spalte[iCurrField].copy( (char *)"NULL", 0, 4); }
+ else
+ {
+ sFeld = PGconn->getValue( iCurrField );
+ Zeile[iRow-1].Spalte[iCurrField] = sFeld; //assign string to string
+ }
+ //printf(" %s", msg);fflush(stdout);
+// std::cout << Zeile[iRow-1].Spalte[iCurrField] << " | " ;
+ }
+// std::cout << "\n ";
+}
+
+
+
+
+
+void TResultSet::process_db_summary(void)
+{
+// ESP_LOGI(PGTAG,"---> PG_RSTAT_HAVE_SUMMARY");
+}
+
+void TResultSet::process_db_haveMsg(void)
+{
+// ESP_LOGI(PGTAG,"---> PG_RSTAT_HAVE_MESSAGE");
+}
+
+void TResultSet::process_db_ready(void)
+{
+// ESP_LOGI(PGTAG,"---> PG_RSTAT_READY");
+}
+
+void TResultSet::process_db_cmd_send(void)
+{
+// ESP_LOGI(PGTAG,"---> PG_RSTAT_COMMAND_SENT");
+}
+
+void TResultSet::process_db_have_error(void)
+{
+// ESP_LOGE(PGTAG,"---> PG_RSTAT_HAVE_ERROR");
+}
+
+void TResultSet::process_db_have_notice(void)
+{
+// ESP_LOGI(PGTAG,"---> PG_RSTAT_HAVE_NOTICE");
+}
+
+
+
+
diff --git a/software/michi_funcs/db_funcs.h b/software/michi_funcs/db_funcs.h
new file mode 100644
index 0000000..cf26c84
--- /dev/null
+++ b/software/michi_funcs/db_funcs.h
@@ -0,0 +1,66 @@
+/*
+ * db_funcs.h
+ *
+ * Created on: 11.01.2022
+ * Author: michi
+ */
+
+#ifndef DB_FUNCS_H_
+#define DB_FUNCS_H_
+//#include "schrank_ant_pcb.h"
+#include <vector>
+#include <iostream>
+#include <string>
+#include "SimplePgSQL.h"
+
+class TpgConnection { // rows
+ public:
+ TpgConnection();
+ ~TpgConnection();
+ int db_connect(const char *pg_server_ip, int pg_port, const char *s_db_name, const char *s_db_user, const char *s_db_passwd, const char *s_db_charset);
+ int db_disconnect(void);
+ void db_loop(void);
+ PGconnection *PGconn;
+ int last_pgError;
+ };
+
+
+//int db_query(const char *sql);
+
+class TResSetRows { // 1 entry is a collection of string fields
+ public:
+ TResSetRows(); //constructor
+ ~TResSetRows(); //destructor
+ std::vector<std::string> Spalte;
+ int numCols;
+ int CurrCol;
+
+ };
+
+class TResultSet { // rows
+ public:
+ TResultSet(PGconnection *PGconnFromCon);
+ ~TResultSet();
+ std::vector<TResSetRows> Zeile;
+ int CurrentRow;
+ int db_query(const char *sql);
+ int db_exec(const char *sql);
+ int NumRows;
+ int NumCols;
+
+ private:
+ PGconnection *PGconn;
+ void process_db_row(void);
+ void process_db_col(void);
+
+ void process_db_summary(void);
+ void process_db_haveMsg(void);
+ void process_db_ready(void);
+ void process_db_cmd_send(void);
+ void process_db_have_error(void);
+ void process_db_have_notice(void);
+ };
+
+
+
+#endif /* DB_FUNCS_H_ */
diff --git a/software/michi_funcs/sdcard_funcs.cpp b/software/michi_funcs/sdcard_funcs.cpp
new file mode 100644
index 0000000..93f8e20
--- /dev/null
+++ b/software/michi_funcs/sdcard_funcs.cpp
@@ -0,0 +1,153 @@
+/* SD card and FAT filesystem example.
+ This example code is in the Public Domain (or CC0 licensed, at your option.)
+
+ Unless required by applicable law or agreed to in writing, this
+ software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied.
+*/
+
+// This example uses SDMMC peripheral to communicate with SD card.
+
+#include <string.h>
+#include <sys/unistd.h>
+#include <sys/stat.h>
+#include "esp_vfs_fat.h"
+#include "sdmmc_cmd.h"
+#include "driver/sdmmc_host.h"
+
+static const char *TAG = "example";
+
+#define MOUNT_POINT "/sdcard"
+
+
+void test_sdcard(void)
+{
+ esp_err_t ret;
+
+ // 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 = {
+#ifdef CONFIG_EXAMPLE_FORMAT_IF_MOUNT_FAILED
+ .format_if_mount_failed = true,
+#else
+ .format_if_mount_failed = false,
+#endif // EXAMPLE_FORMAT_IF_MOUNT_FAILED
+ .max_files = 5,
+ .allocation_unit_size = 16 * 1024
+ };
+ sdmmc_card_t *card;
+ const char mount_point[] = MOUNT_POINT;
+ ESP_LOGI(TAG, "Initializing SD card");
+
+ // Use settings defined above to initialize SD card and mount FAT filesystem.
+ // Note: esp_vfs_fat_sdmmc/sdspi_mount is all-in-one convenience functions.
+ // Please check its source code and implement error recovery when developing
+ // production applications.
+
+ ESP_LOGI(TAG, "Using SDMMC peripheral");
+ sdmmc_host_t host = SDMMC_HOST_DEFAULT();
+
+ // This initializes the slot without card detect (CD) and write protect (WP) signals.
+ // Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals.
+ sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
+
+ // Set bus width to use:
+#ifdef CONFIG_EXAMPLE_SDMMC_BUS_WIDTH_4
+ slot_config.width = 4;
+#else
+ slot_config.width = 1;
+#endif
+
+ // On chips where the GPIOs used for SD card can be configured, set them in
+ // the slot_config structure:
+#ifdef CONFIG_SOC_SDMMC_USE_GPIO_MATRIX
+ slot_config.clk = CONFIG_EXAMPLE_PIN_CLK;
+ slot_config.cmd = CONFIG_EXAMPLE_PIN_CMD;
+ slot_config.d0 = CONFIG_EXAMPLE_PIN_D0;
+#ifdef CONFIG_EXAMPLE_SDMMC_BUS_WIDTH_4
+ slot_config.d1 = CONFIG_EXAMPLE_PIN_D1;
+ slot_config.d2 = CONFIG_EXAMPLE_PIN_D2;
+ slot_config.d3 = CONFIG_EXAMPLE_PIN_D3;
+#endif // CONFIG_EXAMPLE_SDMMC_BUS_WIDTH_4
+#endif // CONFIG_SOC_SDMMC_USE_GPIO_MATRIX
+
+ // Enable internal pullups on enabled pins. The internal pullups
+ // are insufficient however, please make sure 10k external pullups are
+ // connected on the bus. This is for debug / example purpose only.
+ slot_config.flags |= SDMMC_SLOT_FLAG_INTERNAL_PULLUP;
+
+ ESP_LOGI(TAG, "Mounting filesystem");
+ ret = esp_vfs_fat_sdmmc_mount(mount_point, &host, &slot_config, &mount_config, &card);
+
+ if (ret != ESP_OK) {
+ if (ret == ESP_FAIL) {
+ ESP_LOGE(TAG, "Failed to mount filesystem. "
+ "If you want the card to be formatted, set the EXAMPLE_FORMAT_IF_MOUNT_FAILED menuconfig option.");
+ } else {
+ ESP_LOGE(TAG, "Failed to initialize the card (%s). "
+ "Make sure SD card lines have pull-up resistors in place.", esp_err_to_name(ret));
+ }
+ return;
+ }
+ ESP_LOGI(TAG, "Filesystem mounted");
+
+ // Card has been initialized, print its properties
+ sdmmc_card_print_info(stdout, card);
+
+ // Use POSIX and C standard library functions to work with files:
+
+ // First create a file.
+ const char *file_hello = MOUNT_POINT"/hello.txt";
+
+ ESP_LOGI(TAG, "Opening file %s", file_hello);
+ FILE *f = fopen(file_hello, "w");
+ if (f == NULL) {
+ ESP_LOGE(TAG, "Failed to open file for writing");
+ return;
+ }
+ fprintf(f, "Hello %s!\n", card->cid.name);
+ fclose(f);
+ ESP_LOGI(TAG, "File written");
+
+ const char *file_foo = MOUNT_POINT"/foo.txt";
+
+ // Check if destination file exists before renaming
+ struct stat st;
+ if (stat(file_foo, &st) == 0) {
+ // Delete it if it exists
+ unlink(file_foo);
+ }
+
+ // Rename original file
+ ESP_LOGI(TAG, "Renaming file %s to %s", file_hello, file_foo);
+ if (rename(file_hello, file_foo) != 0) {
+ ESP_LOGE(TAG, "Rename failed");
+ return;
+ }
+
+ // Open renamed file for reading
+ ESP_LOGI(TAG, "Reading file %s", file_foo);
+ f = fopen(file_foo, "r");
+ if (f == NULL) {
+ ESP_LOGE(TAG, "Failed to open file for reading");
+ return;
+ }
+
+ // Read a line from file
+ char line[64];
+ fgets(line, sizeof(line), f);
+ fclose(f);
+
+ // Strip newline
+ char *pos = strchr(line, '\n');
+ if (pos) {
+ *pos = '\0';
+ }
+ ESP_LOGI(TAG, "Read from file: '%s'", line);
+
+ // All done, unmount partition and disable SDMMC peripheral
+ esp_vfs_fat_sdcard_unmount(mount_point, card);
+ ESP_LOGI(TAG, "Card unmounted");
+}
+
diff --git a/software/michi_funcs/sdcard_funcs.hpp b/software/michi_funcs/sdcard_funcs.hpp
new file mode 100644
index 0000000..495ac4a
--- /dev/null
+++ b/software/michi_funcs/sdcard_funcs.hpp
@@ -0,0 +1,6 @@
+#ifndef _SDCARD_FUNCS_H_
+#define _SDCARD_FUNCS_H_
+
+void test_sdcard(void);
+
+#endif
diff --git a/software/partitions.csv b/software/partitions.csv
new file mode 100644
index 0000000..2ea2f45
--- /dev/null
+++ b/software/partitions.csv
@@ -0,0 +1,9 @@
+# Name, Type, SubType, Offset, Size, Flags
+# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
+nvs,data,nvs,0x9000,16K,
+otadata,data,ota,0xd000,8K,
+phy_init,data,phy,0xf000,4K,
+factory,app,factory,0x10000,1M,
+ota_0,app,ota_0,0x110000,1M,
+ota_1,app,ota_1,0x210000,1M,
+storage,data, spiffs, ,768k,
diff --git a/software/rcbuf.txt b/software/rcbuf.txt
new file mode 100644
index 0000000..6bdc90d
--- /dev/null
+++ b/software/rcbuf.txt
@@ -0,0 +1,54 @@
+0000 52 R 00 00 00 08 00 00 00
+0008 00 53 S 00 00 00 1E 61 a 70 p
+0010 70 p 6C l 69 i 63 c 61 a 74 t 69 i 6F o
+0018 6E n 5F _ 6E n 61 a 6D m 65 e 00 53 S
+0020 63 c 61 a 6C l 61 a 64 d 69 i 73 s 00
+0028 53 S 00 00 00 19 63 c 6C l 69 i
+0030 65 e 6E n 74 t 5F _ 65 e 6E n 63 c 6F o
+0038 64 d 69 i 6E n 67 g 00 55 U 54 T 46 F
+0040 38 8 00 53 S 00 00 00 17 44 D
+0048 61 a 74 t 65 e 53 S 74 t 79 y 6C l 65 e
+0050 00 49 I 53 S 4F O 2C , 20 4D M 44 D
+0058 59 Y 00 53 S 00 00 00 19 69 i
+0060 6E n 74 t 65 e 67 g 65 e 72 r 5F _ 64 d
+0068 61 a 74 t 65 e 74 t 69 i 6D m 65 e 73 s
+0070 00 6F o 6E n 00 53 S 00 00 00
+0078 1B 49 I 6E n 74 t 65 e 72 r 76 v 61 a
+0080 6C l 53 S 74 t 79 y 6C l 65 e 00 70 p
+0088 6F o 73 s 74 t 67 g 72 r 65 e 73 s 00
+0090 53 S 00 00 00 14 69 i 73 s 5F _
+0098 73 s 75 u 70 p 65 e 72 r 75 u 73 s 65 e
+00A0 72 r 00 6F o 6E n 00 53 S 00 00
+00A8 00 19 73 s 65 e 72 r 76 v 65 e 72 r
+00B0 5F _ 65 e 6E n 63 c 6F o 64 d 69 i 6E n
+00B8 67 g 00 55 U 54 T 46 F 38 8 00 53 S
+00C0 00 00 00 19 73 s 65 e 72 r 76 v
+00C8 65 e 72 r 5F _ 76 v 65 e 72 r 73 s 69 i
+00D0 6F o 6E n 00 31 1 31 1 2E . 31 1 32 2
+00D8 00 53 S 00 00 00 20 73 s 65 e
+00E0 73 s 73 s 69 i 6F o 6E n 5F _ 61 a 75 u
+00E8 74 t 68 h 6F o 72 r 69 i 7A z 61 a 74 t
+00F0 69 i 6F o 6E n 00 65 e 73 s 70 p 33 3
+00F8 32 2 00 53 S 00 00 00 23 # 73 s
+0100 74 t 61 a 6E n 64 d 61 a 72 r 64 d 5F _
+0108 63 c 6F o 6E n 66 f 6F o 72 r 6D m 69 i
+0110 6E n 67 g 5F _ 73 s 74 t 72 r 69 i 6E n
+0118 67 g 73 s 00 6F o 6E n 00 53 S 00
+0120 00 00 1B 54 T 69 i 6D m 65 e 5A Z
+0128 6F o 6E n 65 e 00 45 E 75 u 72 r 6F o
+0130 70 p 65 e 2F / 42 B 65 e 72 r 6C l 69 i
+0138 6E n 00 4B K 00 00 00 0C 00
+0140 00 93 � 2B + 83 � 82 � EE � 6E n 5A Z
+0148 00 00 00 05 49 I 54 T 00 00
+0150 00 1C 00 01 6E n 6F o 77 w 00
+0158 00 00 00 00 00 00 00 00
+0160 04 A0 � 00 08 FF � FF � FF � FF �
+0168 00 00 44 D 00 00 00 26 & 00
+0170 01 00 00 00 1C 32 2 30 0 32 2
+0178 31 1 2D - 30 0 37 7 2D - 30 0 39 9 20
+0180 31 1 32 2 3A : 31 1 32 2 3A : 34 4 34 4
+0188 2E . 34 4 32 2 31 1 38 8 38 8 2B + 30 0
+0190 32 2 43 C 00 00 00 0D 53 S 45 E
+0198 4C L 45 E 43 C 54 T 20 31 1 00 5A Z
+01A0 00 00 00 05 49 I
+
diff --git a/software/sdkconfig b/software/sdkconfig
new file mode 100644
index 0000000..e0a4cd9
--- /dev/null
+++ b/software/sdkconfig
@@ -0,0 +1,1382 @@
+#
+# Automatically generated file. DO NOT EDIT.
+# Espressif IoT Development Framework (ESP-IDF) Project Configuration
+#
+CONFIG_IDF_CMAKE=y
+CONFIG_IDF_TARGET_ARCH_XTENSA=y
+CONFIG_IDF_TARGET="esp32"
+CONFIG_IDF_TARGET_ESP32=y
+CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000
+
+#
+# SDK tool configuration
+#
+CONFIG_SDK_TOOLPREFIX="xtensa-esp32-elf-"
+# CONFIG_SDK_TOOLCHAIN_SUPPORTS_TIME_WIDE_64_BITS is not set
+# end of SDK tool configuration
+
+#
+# Build type
+#
+CONFIG_APP_BUILD_TYPE_APP_2NDBOOT=y
+# CONFIG_APP_BUILD_TYPE_ELF_RAM is not set
+CONFIG_APP_BUILD_GENERATE_BINARIES=y
+CONFIG_APP_BUILD_BOOTLOADER=y
+CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y
+# end of Build type
+
+#
+# Application manager
+#
+CONFIG_APP_COMPILE_TIME_DATE=y
+# CONFIG_APP_EXCLUDE_PROJECT_VER_VAR is not set
+# CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR is not set
+# CONFIG_APP_PROJECT_VER_FROM_CONFIG is not set
+CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16
+# end of Application manager
+
+#
+# Bootloader config
+#
+CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x1000
+CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
+# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set
+# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF is not set
+# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set
+# CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set
+# CONFIG_BOOTLOADER_LOG_LEVEL_ERROR is not set
+# CONFIG_BOOTLOADER_LOG_LEVEL_WARN is not set
+CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y
+# CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG is not set
+# CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE is not set
+CONFIG_BOOTLOADER_LOG_LEVEL=3
+# CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_8V is not set
+CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V=y
+# CONFIG_BOOTLOADER_FACTORY_RESET is not set
+# CONFIG_BOOTLOADER_APP_TEST is not set
+CONFIG_BOOTLOADER_WDT_ENABLE=y
+# CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE is not set
+CONFIG_BOOTLOADER_WDT_TIME_MS=9000
+# CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE is not set
+# CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP is not set
+# CONFIG_BOOTLOADER_SKIP_VALIDATE_ON_POWER_ON is not set
+# CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS is not set
+CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0
+# CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set
+CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT=y
+# end of Bootloader config
+
+#
+# Security features
+#
+# CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT is not set
+# CONFIG_SECURE_BOOT is not set
+# CONFIG_SECURE_FLASH_ENC_ENABLED is not set
+# end of Security features
+
+#
+# Serial flasher config
+#
+CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200
+# CONFIG_ESPTOOLPY_NO_STUB is not set
+# CONFIG_ESPTOOLPY_FLASHMODE_QIO is not set
+# CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set
+CONFIG_ESPTOOLPY_FLASHMODE_DIO=y
+# CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set
+CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y
+CONFIG_ESPTOOLPY_FLASHMODE="dio"
+# CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set
+CONFIG_ESPTOOLPY_FLASHFREQ_40M=y
+# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set
+# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set
+CONFIG_ESPTOOLPY_FLASHFREQ="40m"
+# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set
+# CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set
+CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
+# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set
+# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set
+CONFIG_ESPTOOLPY_FLASHSIZE="4MB"
+CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y
+CONFIG_ESPTOOLPY_BEFORE_RESET=y
+# CONFIG_ESPTOOLPY_BEFORE_NORESET is not set
+CONFIG_ESPTOOLPY_BEFORE="default_reset"
+CONFIG_ESPTOOLPY_AFTER_RESET=y
+# CONFIG_ESPTOOLPY_AFTER_NORESET is not set
+CONFIG_ESPTOOLPY_AFTER="hard_reset"
+# CONFIG_ESPTOOLPY_MONITOR_BAUD_CONSOLE is not set
+# CONFIG_ESPTOOLPY_MONITOR_BAUD_9600B is not set
+# CONFIG_ESPTOOLPY_MONITOR_BAUD_57600B is not set
+CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y
+# CONFIG_ESPTOOLPY_MONITOR_BAUD_230400B is not set
+# CONFIG_ESPTOOLPY_MONITOR_BAUD_921600B is not set
+# CONFIG_ESPTOOLPY_MONITOR_BAUD_2MB is not set
+# CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER is not set
+CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER_VAL=115200
+CONFIG_ESPTOOLPY_MONITOR_BAUD=115200
+# end of Serial flasher config
+
+#
+# Partition Table
+#
+# CONFIG_PARTITION_TABLE_SINGLE_APP is not set
+# CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE is not set
+# CONFIG_PARTITION_TABLE_TWO_OTA is not set
+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 is not set
+# end of Partition Table
+
+#
+# Example Configuration
+#
+CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=y
+# CONFIG_EXAMPLE_USE_DM9051 is not set
+# CONFIG_EXAMPLE_USE_W5500 is not set
+# CONFIG_EXAMPLE_USE_KSZ8851SNL is not set
+# CONFIG_EXAMPLE_ETH_PHY_IP101 is not set
+# CONFIG_EXAMPLE_ETH_PHY_RTL8201 is not set
+CONFIG_EXAMPLE_ETH_PHY_LAN8720=y
+# CONFIG_EXAMPLE_ETH_PHY_DP83848 is not set
+# CONFIG_EXAMPLE_ETH_PHY_KSZ8041 is not set
+# CONFIG_EXAMPLE_ETH_PHY_KSZ8081 is not set
+CONFIG_EXAMPLE_ETH_MDC_GPIO=23
+CONFIG_EXAMPLE_ETH_MDIO_GPIO=18
+CONFIG_EXAMPLE_ETH_PHY_RST_GPIO=14
+CONFIG_EXAMPLE_ETH_PHY_ADDR=1
+# end of Example Configuration
+
+#
+# Compiler options
+#
+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=y
+# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set
+# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set
+CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL=2
+# CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT is not set
+CONFIG_COMPILER_HIDE_PATHS_MACROS=y
+# 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
+# CONFIG_COMPILER_STACK_CHECK_MODE_STRONG is not set
+# CONFIG_COMPILER_STACK_CHECK_MODE_ALL is not set
+# CONFIG_COMPILER_WARN_WRITE_STRINGS is not set
+# CONFIG_COMPILER_DISABLE_GCC8_WARNINGS is not set
+# CONFIG_COMPILER_DUMP_RTL_FILES is not set
+# end of Compiler options
+
+#
+# Component config
+#
+
+#
+# Application Level Tracing
+#
+# CONFIG_APPTRACE_DEST_JTAG is not set
+CONFIG_APPTRACE_DEST_NONE=y
+CONFIG_APPTRACE_LOCK_ENABLE=y
+# end of Application Level Tracing
+
+#
+# ESP-ASIO
+#
+# CONFIG_ASIO_SSL_SUPPORT is not set
+# end of ESP-ASIO
+
+#
+# Bluetooth
+#
+# CONFIG_BT_ENABLED is not set
+# end of Bluetooth
+
+#
+# CoAP Configuration
+#
+CONFIG_COAP_MBEDTLS_PSK=y
+# CONFIG_COAP_MBEDTLS_PKI is not set
+# CONFIG_COAP_MBEDTLS_DEBUG is not set
+CONFIG_COAP_LOG_DEFAULT_LEVEL=0
+# end of CoAP Configuration
+
+#
+# Driver configurations
+#
+
+#
+# ADC configuration
+#
+# CONFIG_ADC_FORCE_XPD_FSM is not set
+CONFIG_ADC_DISABLE_DAC=y
+# end of ADC configuration
+
+#
+# MCPWM configuration
+#
+# CONFIG_MCPWM_ISR_IN_IRAM is not set
+# end of MCPWM configuration
+
+#
+# SPI configuration
+#
+# CONFIG_SPI_MASTER_IN_IRAM is not set
+CONFIG_SPI_MASTER_ISR_IN_IRAM=y
+# CONFIG_SPI_SLAVE_IN_IRAM is not set
+CONFIG_SPI_SLAVE_ISR_IN_IRAM=y
+# end of SPI configuration
+
+#
+# TWAI configuration
+#
+# CONFIG_TWAI_ISR_IN_IRAM is not set
+# CONFIG_TWAI_ERRATA_FIX_BUS_OFF_REC is not set
+# CONFIG_TWAI_ERRATA_FIX_TX_INTR_LOST is not set
+# CONFIG_TWAI_ERRATA_FIX_RX_FRAME_INVALID is not set
+# CONFIG_TWAI_ERRATA_FIX_RX_FIFO_CORRUPT is not set
+# end of TWAI configuration
+
+#
+# UART configuration
+#
+CONFIG_UART_ISR_IN_IRAM=y
+# end of UART configuration
+
+#
+# RTCIO configuration
+#
+# CONFIG_RTCIO_SUPPORT_RTC_GPIO_DESC is not set
+# end of RTCIO configuration
+
+#
+# GPIO Configuration
+#
+# CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL is not set
+# end of GPIO Configuration
+
+#
+# GDMA Configuration
+#
+# CONFIG_GDMA_CTRL_FUNC_IN_IRAM is not set
+# CONFIG_GDMA_ISR_IRAM_SAFE is not set
+# end of GDMA Configuration
+# end of Driver configurations
+
+#
+# eFuse Bit Manager
+#
+# CONFIG_EFUSE_CUSTOM_TABLE is not set
+# CONFIG_EFUSE_VIRTUAL is not set
+# CONFIG_EFUSE_CODE_SCHEME_COMPAT_NONE is not set
+CONFIG_EFUSE_CODE_SCHEME_COMPAT_3_4=y
+# CONFIG_EFUSE_CODE_SCHEME_COMPAT_REPEAT is not set
+CONFIG_EFUSE_MAX_BLK_LEN=192
+# end of eFuse Bit Manager
+
+#
+# ESP-TLS
+#
+CONFIG_ESP_TLS_USING_MBEDTLS=y
+# CONFIG_ESP_TLS_USE_SECURE_ELEMENT is not set
+# CONFIG_ESP_TLS_SERVER is not set
+# CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set
+# CONFIG_ESP_TLS_PSK_VERIFICATION is not set
+# CONFIG_ESP_TLS_INSECURE is not set
+# end of ESP-TLS
+
+#
+# ESP32-specific
+#
+CONFIG_ESP32_REV_MIN_0=y
+# CONFIG_ESP32_REV_MIN_1 is not set
+# CONFIG_ESP32_REV_MIN_2 is not set
+# CONFIG_ESP32_REV_MIN_3 is not set
+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=y
+# CONFIG_ESP32_DEFAULT_CPU_FREQ_240 is not set
+CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=160
+# CONFIG_ESP32_SPIRAM_SUPPORT is not set
+# CONFIG_ESP32_TRAX is not set
+CONFIG_ESP32_TRACEMEM_RESERVE_DRAM=0x0
+# CONFIG_ESP32_ULP_COPROC_ENABLED is not set
+CONFIG_ESP32_ULP_COPROC_RESERVE_MEM=0
+CONFIG_ESP32_DEBUG_OCDAWARE=y
+CONFIG_ESP32_BROWNOUT_DET=y
+CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_0=y
+# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_1 is not set
+# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_2 is not set
+# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_3 is not set
+# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_4 is not set
+# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_5 is not set
+# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_6 is not set
+# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_7 is not set
+CONFIG_ESP32_BROWNOUT_DET_LVL=0
+CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y
+# CONFIG_ESP32_TIME_SYSCALL_USE_RTC is not set
+# CONFIG_ESP32_TIME_SYSCALL_USE_FRC1 is not set
+# CONFIG_ESP32_TIME_SYSCALL_USE_NONE is not set
+CONFIG_ESP32_RTC_CLK_SRC_INT_RC=y
+# CONFIG_ESP32_RTC_CLK_SRC_EXT_CRYS is not set
+# CONFIG_ESP32_RTC_CLK_SRC_EXT_OSC is not set
+# CONFIG_ESP32_RTC_CLK_SRC_INT_8MD256 is not set
+CONFIG_ESP32_RTC_CLK_CAL_CYCLES=1024
+CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=2000
+CONFIG_ESP32_XTAL_FREQ_40=y
+# CONFIG_ESP32_XTAL_FREQ_26 is not set
+# CONFIG_ESP32_XTAL_FREQ_AUTO is not set
+CONFIG_ESP32_XTAL_FREQ=40
+# CONFIG_ESP32_DISABLE_BASIC_ROM_CONSOLE is not set
+# CONFIG_ESP32_NO_BLOBS is not set
+# CONFIG_ESP32_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set
+# CONFIG_ESP32_COMPATIBLE_PRE_V3_1_BOOTLOADERS is not set
+# CONFIG_ESP32_USE_FIXED_STATIC_RAM_SIZE is not set
+CONFIG_ESP32_DPORT_DIS_INTERRUPT_LVL=5
+# end of ESP32-specific
+
+#
+# ADC-Calibration
+#
+CONFIG_ADC_CAL_EFUSE_TP_ENABLE=y
+CONFIG_ADC_CAL_EFUSE_VREF_ENABLE=y
+CONFIG_ADC_CAL_LUT_ENABLE=y
+# end of ADC-Calibration
+
+#
+# Common ESP-related
+#
+CONFIG_ESP_ERR_TO_NAME_LOOKUP=y
+# end of Common ESP-related
+
+#
+# Ethernet
+#
+CONFIG_ETH_ENABLED=y
+CONFIG_ETH_USE_ESP32_EMAC=y
+CONFIG_ETH_PHY_INTERFACE_RMII=y
+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 is not set
+# CONFIG_ETH_USE_OPENETH is not set
+# end of Ethernet
+
+#
+# Event Loop Library
+#
+# CONFIG_ESP_EVENT_LOOP_PROFILING is not set
+CONFIG_ESP_EVENT_POST_FROM_ISR=y
+CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y
+# end of Event Loop Library
+
+#
+# GDB Stub
+#
+# end of GDB Stub
+
+#
+# ESP HTTP client
+#
+CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y
+CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH=y
+CONFIG_ESP_HTTP_CLIENT_ENABLE_DIGEST_AUTH=y
+# end of ESP HTTP client
+
+#
+# HTTP Server
+#
+CONFIG_HTTPD_MAX_REQ_HDR_LEN=512
+CONFIG_HTTPD_MAX_URI_LEN=512
+CONFIG_HTTPD_ERR_RESP_NO_DELAY=y
+CONFIG_HTTPD_PURGE_BUF_LEN=32
+# CONFIG_HTTPD_LOG_PURGE_DATA is not set
+# CONFIG_HTTPD_WS_SUPPORT is not set
+# end of HTTP Server
+
+#
+# ESP HTTPS OTA
+#
+# CONFIG_OTA_ALLOW_HTTP is not set
+# end of ESP HTTPS OTA
+
+#
+# ESP HTTPS server
+#
+# CONFIG_ESP_HTTPS_SERVER_ENABLE is not set
+# end of ESP HTTPS server
+
+#
+# Hardware Settings
+#
+
+#
+# MAC Config
+#
+CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA=y
+CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP=y
+CONFIG_ESP_MAC_ADDR_UNIVERSE_BT=y
+CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y
+# CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_TWO is not set
+CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR=y
+CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES=4
+# end of MAC Config
+
+#
+# Sleep Config
+#
+CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y
+CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND=y
+# CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND is not set
+# CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND is not set
+# end of Sleep Config
+# end of Hardware Settings
+
+#
+# IPC (Inter-Processor Call)
+#
+CONFIG_ESP_IPC_TASK_STACK_SIZE=1024
+CONFIG_ESP_IPC_USES_CALLERS_PRIORITY=y
+CONFIG_ESP_IPC_ISR_ENABLE=y
+# end of IPC (Inter-Processor Call)
+
+#
+# LCD and Touch Panel
+#
+
+#
+# LCD Peripheral Configuration
+#
+CONFIG_LCD_PANEL_IO_FORMAT_BUF_SIZE=32
+# end of LCD Peripheral Configuration
+# end of LCD and Touch Panel
+
+#
+# ESP NETIF Adapter
+#
+CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120
+CONFIG_ESP_NETIF_TCPIP_LWIP=y
+# CONFIG_ESP_NETIF_LOOPBACK is not set
+# CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER is not set
+# end of ESP NETIF Adapter
+
+#
+# PHY
+#
+CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y
+# CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION is not set
+CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=20
+CONFIG_ESP_PHY_MAX_TX_POWER=20
+CONFIG_ESP_PHY_REDUCE_TX_POWER=y
+# end of PHY
+
+#
+# Power Management
+#
+# CONFIG_PM_ENABLE is not set
+# end of Power Management
+
+#
+# ESP System Settings
+#
+# CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set
+CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y
+# CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set
+# CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set
+# CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set
+
+#
+# Memory protection
+#
+# end of Memory protection
+
+CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE=32
+CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2304
+CONFIG_ESP_MAIN_TASK_STACK_SIZE=3584
+CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0=y
+# CONFIG_ESP_MAIN_TASK_AFFINITY_CPU1 is not set
+# CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY is not set
+CONFIG_ESP_MAIN_TASK_AFFINITY=0x0
+CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE=2048
+CONFIG_ESP_CONSOLE_UART_DEFAULT=y
+# CONFIG_ESP_CONSOLE_UART_CUSTOM is not set
+# CONFIG_ESP_CONSOLE_NONE is not set
+CONFIG_ESP_CONSOLE_UART=y
+CONFIG_ESP_CONSOLE_MULTIPLE_UART=y
+CONFIG_ESP_CONSOLE_UART_NUM=0
+CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200
+CONFIG_ESP_INT_WDT=y
+CONFIG_ESP_INT_WDT_TIMEOUT_MS=300
+CONFIG_ESP_INT_WDT_CHECK_CPU1=y
+CONFIG_ESP_TASK_WDT=y
+# CONFIG_ESP_TASK_WDT_PANIC is not set
+CONFIG_ESP_TASK_WDT_TIMEOUT_S=5
+CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y
+CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=y
+# CONFIG_ESP_PANIC_HANDLER_IRAM is not set
+# CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_5 is not set
+CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4=y
+# end of ESP System Settings
+
+#
+# High resolution timer (esp_timer)
+#
+# CONFIG_ESP_TIMER_PROFILING is not set
+CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER=y
+CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER=y
+CONFIG_ESP_TIMER_TASK_STACK_SIZE=3584
+CONFIG_ESP_TIMER_INTERRUPT_LEVEL=1
+# CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD is not set
+# CONFIG_ESP_TIMER_IMPL_FRC2 is not set
+CONFIG_ESP_TIMER_IMPL_TG0_LAC=y
+# end of High resolution timer (esp_timer)
+
+#
+# Wi-Fi
+#
+CONFIG_ESP32_WIFI_ENABLED=y
+CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10
+CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32
+# CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set
+CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y
+CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1
+CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32
+# CONFIG_ESP32_WIFI_CSI_ENABLED is not set
+CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y
+CONFIG_ESP32_WIFI_TX_BA_WIN=6
+CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y
+CONFIG_ESP32_WIFI_RX_BA_WIN=6
+CONFIG_ESP32_WIFI_NVS_ENABLED=y
+CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y
+# CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 is not set
+CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752
+CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32
+CONFIG_ESP32_WIFI_IRAM_OPT=y
+CONFIG_ESP32_WIFI_RX_IRAM_OPT=y
+CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y
+# CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set
+# CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is not set
+# CONFIG_ESP_WIFI_GMAC_SUPPORT is not set
+CONFIG_ESP_WIFI_SOFTAP_SUPPORT=y
+# end of Wi-Fi
+
+#
+# Core dump
+#
+# CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH is not set
+# CONFIG_ESP_COREDUMP_ENABLE_TO_UART is not set
+CONFIG_ESP_COREDUMP_ENABLE_TO_NONE=y
+# end of Core dump
+
+#
+# FAT Filesystem support
+#
+# CONFIG_FATFS_CODEPAGE_DYNAMIC is not set
+CONFIG_FATFS_CODEPAGE_437=y
+# CONFIG_FATFS_CODEPAGE_720 is not set
+# CONFIG_FATFS_CODEPAGE_737 is not set
+# CONFIG_FATFS_CODEPAGE_771 is not set
+# CONFIG_FATFS_CODEPAGE_775 is not set
+# CONFIG_FATFS_CODEPAGE_850 is not set
+# CONFIG_FATFS_CODEPAGE_852 is not set
+# CONFIG_FATFS_CODEPAGE_855 is not set
+# CONFIG_FATFS_CODEPAGE_857 is not set
+# CONFIG_FATFS_CODEPAGE_860 is not set
+# CONFIG_FATFS_CODEPAGE_861 is not set
+# CONFIG_FATFS_CODEPAGE_862 is not set
+# CONFIG_FATFS_CODEPAGE_863 is not set
+# CONFIG_FATFS_CODEPAGE_864 is not set
+# CONFIG_FATFS_CODEPAGE_865 is not set
+# CONFIG_FATFS_CODEPAGE_866 is not set
+# CONFIG_FATFS_CODEPAGE_869 is not set
+# CONFIG_FATFS_CODEPAGE_932 is not set
+# CONFIG_FATFS_CODEPAGE_936 is not set
+# CONFIG_FATFS_CODEPAGE_949 is not set
+# CONFIG_FATFS_CODEPAGE_950 is not set
+CONFIG_FATFS_CODEPAGE=437
+CONFIG_FATFS_LFN_NONE=y
+# CONFIG_FATFS_LFN_HEAP is not set
+# CONFIG_FATFS_LFN_STACK is not set
+CONFIG_FATFS_FS_LOCK=0
+CONFIG_FATFS_TIMEOUT_MS=10000
+CONFIG_FATFS_PER_FILE_CACHE=y
+# CONFIG_FATFS_USE_FASTSEEK is not set
+# end of FAT Filesystem support
+
+#
+# Modbus configuration
+#
+CONFIG_FMB_COMM_MODE_TCP_EN=y
+CONFIG_FMB_TCP_PORT_DEFAULT=502
+CONFIG_FMB_TCP_PORT_MAX_CONN=5
+CONFIG_FMB_TCP_CONNECTION_TOUT_SEC=20
+CONFIG_FMB_COMM_MODE_RTU_EN=y
+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_PORT_TASK_STACK_SIZE=4096
+CONFIG_FMB_SERIAL_BUF_SIZE=256
+CONFIG_FMB_SERIAL_ASCII_BITS_PER_SYMB=8
+CONFIG_FMB_SERIAL_ASCII_TIMEOUT_RESPOND_MS=1000
+CONFIG_FMB_PORT_TASK_PRIO=10
+# CONFIG_FMB_PORT_TASK_AFFINITY_NO_AFFINITY is not set
+CONFIG_FMB_PORT_TASK_AFFINITY_CPU0=y
+# CONFIG_FMB_PORT_TASK_AFFINITY_CPU1 is not set
+CONFIG_FMB_PORT_TASK_AFFINITY=0x0
+CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT=y
+CONFIG_FMB_CONTROLLER_SLAVE_ID=0x00112233
+CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT=20
+CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE=20
+CONFIG_FMB_CONTROLLER_STACK_SIZE=4096
+CONFIG_FMB_EVENT_QUEUE_TIMEOUT=20
+# CONFIG_FMB_TIMER_PORT_ENABLED is not set
+CONFIG_FMB_TIMER_GROUP=0
+CONFIG_FMB_TIMER_INDEX=0
+CONFIG_FMB_MASTER_TIMER_GROUP=0
+CONFIG_FMB_MASTER_TIMER_INDEX=0
+# CONFIG_FMB_TIMER_ISR_IN_IRAM is not set
+# end of Modbus configuration
+
+#
+# FreeRTOS
+#
+# CONFIG_FREERTOS_UNICORE is not set
+CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF
+CONFIG_FREERTOS_TICK_SUPPORT_CORETIMER=y
+CONFIG_FREERTOS_CORETIMER_0=y
+# CONFIG_FREERTOS_CORETIMER_1 is not set
+CONFIG_FREERTOS_SYSTICK_USES_CCOUNT=y
+CONFIG_FREERTOS_HZ=100
+CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y
+# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE is not set
+# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL is not set
+CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY=y
+# CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set
+CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y
+CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=1
+CONFIG_FREERTOS_ASSERT_FAIL_ABORT=y
+# CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE is not set
+# CONFIG_FREERTOS_ASSERT_DISABLE is not set
+CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1536
+CONFIG_FREERTOS_ISR_STACKSIZE=1536
+# CONFIG_FREERTOS_LEGACY_HOOKS is not set
+CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16
+CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
+# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set
+CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1
+CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048
+CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10
+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_TASK_FUNCTION_WRAPPER=y
+CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y
+# CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set
+# CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set
+CONFIG_FREERTOS_DEBUG_OCDAWARE=y
+# CONFIG_FREERTOS_FPU_IN_ISR is not set
+CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT=y
+# CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH is not set
+# end of FreeRTOS
+
+#
+# Hardware Abstraction Layer (HAL) and Low Level (LL)
+#
+CONFIG_HAL_ASSERTION_EQUALS_SYSTEM=y
+# CONFIG_HAL_ASSERTION_DISABLE is not set
+# CONFIG_HAL_ASSERTION_SILIENT is not set
+# CONFIG_HAL_ASSERTION_ENABLE is not set
+CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=2
+# end of Hardware Abstraction Layer (HAL) and Low Level (LL)
+
+#
+# Heap memory debugging
+#
+CONFIG_HEAP_POISONING_DISABLED=y
+# CONFIG_HEAP_POISONING_LIGHT is not set
+# CONFIG_HEAP_POISONING_COMPREHENSIVE is not set
+CONFIG_HEAP_TRACING_OFF=y
+# CONFIG_HEAP_TRACING_STANDALONE is not set
+# CONFIG_HEAP_TRACING_TOHOST is not set
+# CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS is not set
+# end of Heap memory debugging
+
+#
+# jsmn
+#
+# CONFIG_JSMN_PARENT_LINKS is not set
+# CONFIG_JSMN_STRICT is not set
+# end of jsmn
+
+#
+# libsodium
+#
+# end of libsodium
+
+#
+# Log output
+#
+# CONFIG_LOG_DEFAULT_LEVEL_NONE is not set
+# CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set
+# CONFIG_LOG_DEFAULT_LEVEL_WARN is not set
+CONFIG_LOG_DEFAULT_LEVEL_INFO=y
+# CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set
+# CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set
+CONFIG_LOG_DEFAULT_LEVEL=3
+CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=y
+# CONFIG_LOG_MAXIMUM_LEVEL_DEBUG is not set
+# CONFIG_LOG_MAXIMUM_LEVEL_VERBOSE is not set
+CONFIG_LOG_MAXIMUM_LEVEL=3
+CONFIG_LOG_COLORS=y
+CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y
+# CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set
+# end of Log output
+
+#
+# LWIP
+#
+CONFIG_LWIP_LOCAL_HOSTNAME="espressif"
+# CONFIG_LWIP_NETIF_API is not set
+# CONFIG_LWIP_TCPIP_CORE_LOCKING is not set
+CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y
+# CONFIG_LWIP_L2_TO_L3_COPY is not set
+# CONFIG_LWIP_IRAM_OPTIMIZATION is not set
+CONFIG_LWIP_TIMERS_ONDEMAND=y
+CONFIG_LWIP_MAX_SOCKETS=10
+# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set
+# CONFIG_LWIP_SO_LINGER is not set
+CONFIG_LWIP_SO_REUSE=y
+CONFIG_LWIP_SO_REUSE_RXTOALL=y
+# CONFIG_LWIP_SO_RCVBUF is not set
+# CONFIG_LWIP_NETBUF_RECVINFO is not set
+CONFIG_LWIP_IP4_FRAG=y
+CONFIG_LWIP_IP6_FRAG=y
+# CONFIG_LWIP_IP4_REASSEMBLY is not set
+# CONFIG_LWIP_IP6_REASSEMBLY is not set
+# CONFIG_LWIP_IP_FORWARD is not set
+# CONFIG_LWIP_STATS is not set
+# CONFIG_LWIP_ETHARP_TRUST_IP_MAC is not set
+CONFIG_LWIP_ESP_GRATUITOUS_ARP=y
+CONFIG_LWIP_GARP_TMR_INTERVAL=60
+CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32
+CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y
+# CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID is not set
+CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID=y
+# CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set
+CONFIG_LWIP_DHCP_OPTIONS_LEN=68
+
+#
+# DHCP server
+#
+# CONFIG_LWIP_DHCPS is not set
+# end of DHCP server
+
+# CONFIG_LWIP_AUTOIP is not set
+CONFIG_LWIP_IPV6=y
+# CONFIG_LWIP_IPV6_AUTOCONFIG is not set
+CONFIG_LWIP_IPV6_NUM_ADDRESSES=3
+# CONFIG_LWIP_IPV6_FORWARD is not set
+# CONFIG_LWIP_NETIF_STATUS_CALLBACK is not set
+CONFIG_LWIP_NETIF_LOOPBACK=y
+CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8
+
+#
+# TCP
+#
+CONFIG_LWIP_MAX_ACTIVE_TCP=16
+CONFIG_LWIP_MAX_LISTENING_TCP=16
+CONFIG_LWIP_TCP_HIGH_SPEED_RETRANSMISSION=y
+CONFIG_LWIP_TCP_MAXRTX=12
+CONFIG_LWIP_TCP_SYNMAXRTX=12
+CONFIG_LWIP_TCP_MSS=1440
+CONFIG_LWIP_TCP_TMR_INTERVAL=250
+CONFIG_LWIP_TCP_MSL=60000
+CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5744
+CONFIG_LWIP_TCP_WND_DEFAULT=5744
+CONFIG_LWIP_TCP_RECVMBOX_SIZE=6
+CONFIG_LWIP_TCP_QUEUE_OOSEQ=y
+# CONFIG_LWIP_TCP_SACK_OUT is not set
+# CONFIG_LWIP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set
+CONFIG_LWIP_TCP_OVERSIZE_MSS=y
+# CONFIG_LWIP_TCP_OVERSIZE_QUARTER_MSS is not set
+# CONFIG_LWIP_TCP_OVERSIZE_DISABLE is not set
+CONFIG_LWIP_TCP_RTO_TIME=1500
+# end of TCP
+
+#
+# UDP
+#
+CONFIG_LWIP_MAX_UDP_PCBS=16
+CONFIG_LWIP_UDP_RECVMBOX_SIZE=6
+# end of UDP
+
+#
+# Checksums
+#
+# CONFIG_LWIP_CHECKSUM_CHECK_IP is not set
+# CONFIG_LWIP_CHECKSUM_CHECK_UDP is not set
+CONFIG_LWIP_CHECKSUM_CHECK_ICMP=y
+# end of Checksums
+
+CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=3072
+CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y
+# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set
+# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU1 is not set
+CONFIG_LWIP_TCPIP_TASK_AFFINITY=0x7FFFFFFF
+# CONFIG_LWIP_PPP_SUPPORT is not set
+CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE=3
+CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS=5
+# CONFIG_LWIP_SLIP_SUPPORT is not set
+
+#
+# ICMP
+#
+CONFIG_LWIP_ICMP=y
+# CONFIG_LWIP_MULTICAST_PING is not set
+# CONFIG_LWIP_BROADCAST_PING is not set
+# end of ICMP
+
+#
+# LWIP RAW API
+#
+CONFIG_LWIP_MAX_RAW_PCBS=16
+# end of LWIP RAW API
+
+#
+# SNTP
+#
+CONFIG_LWIP_SNTP_MAX_SERVERS=1
+# CONFIG_LWIP_DHCP_GET_NTP_SRV is not set
+CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000
+# end of SNTP
+
+CONFIG_LWIP_ESP_LWIP_ASSERT=y
+
+#
+# Hooks
+#
+# CONFIG_LWIP_HOOK_TCP_ISN_NONE is not set
+CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT=y
+# CONFIG_LWIP_HOOK_TCP_ISN_CUSTOM is not set
+CONFIG_LWIP_HOOK_IP6_ROUTE_NONE=y
+# CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT is not set
+# CONFIG_LWIP_HOOK_IP6_ROUTE_CUSTOM is not set
+CONFIG_LWIP_HOOK_ND6_GET_GW_NONE=y
+# CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT is not set
+# CONFIG_LWIP_HOOK_ND6_GET_GW_CUSTOM is not set
+CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y
+# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_DEFAULT is not set
+# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM is not set
+# end of Hooks
+
+# CONFIG_LWIP_DEBUG is not set
+# end of LWIP
+
+#
+# mbedTLS
+#
+CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y
+# CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set
+# CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set
+CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y
+CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384
+CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096
+# CONFIG_MBEDTLS_DYNAMIC_BUFFER is not set
+# CONFIG_MBEDTLS_DEBUG is not set
+
+#
+# Certificate Bundle
+#
+CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y
+CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y
+# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set
+# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set
+# CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set
+# end of Certificate Bundle
+
+# CONFIG_MBEDTLS_ECP_RESTARTABLE is not set
+# CONFIG_MBEDTLS_CMAC_C is not set
+CONFIG_MBEDTLS_HARDWARE_AES=y
+CONFIG_MBEDTLS_HARDWARE_MPI=y
+CONFIG_MBEDTLS_HARDWARE_SHA=y
+CONFIG_MBEDTLS_ROM_MD5=y
+# CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set
+# CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set
+CONFIG_MBEDTLS_HAVE_TIME=y
+# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set
+CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y
+CONFIG_MBEDTLS_SHA512_C=y
+CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y
+# CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set
+# CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set
+# CONFIG_MBEDTLS_TLS_DISABLED is not set
+CONFIG_MBEDTLS_TLS_SERVER=y
+CONFIG_MBEDTLS_TLS_CLIENT=y
+CONFIG_MBEDTLS_TLS_ENABLED=y
+
+#
+# TLS Key Exchange Methods
+#
+# CONFIG_MBEDTLS_PSK_MODES is not set
+CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y
+CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA=y
+CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE=y
+CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=y
+CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=y
+CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y
+CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y
+# end of TLS Key Exchange Methods
+
+CONFIG_MBEDTLS_SSL_RENEGOTIATION=y
+# CONFIG_MBEDTLS_SSL_PROTO_SSL3 is not set
+CONFIG_MBEDTLS_SSL_PROTO_TLS1=y
+CONFIG_MBEDTLS_SSL_PROTO_TLS1_1=y
+CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y
+# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set
+# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set
+CONFIG_MBEDTLS_SSL_ALPN=y
+CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y
+CONFIG_MBEDTLS_X509_CHECK_KEY_USAGE=y
+CONFIG_MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE=y
+CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=y
+
+#
+# Symmetric Ciphers
+#
+CONFIG_MBEDTLS_AES_C=y
+# CONFIG_MBEDTLS_CAMELLIA_C is not set
+# CONFIG_MBEDTLS_DES_C is not set
+CONFIG_MBEDTLS_RC4_DISABLED=y
+# CONFIG_MBEDTLS_RC4_ENABLED_NO_DEFAULT is not set
+# CONFIG_MBEDTLS_RC4_ENABLED is not set
+# CONFIG_MBEDTLS_BLOWFISH_C is not set
+# CONFIG_MBEDTLS_XTEA_C is not set
+CONFIG_MBEDTLS_CCM_C=y
+CONFIG_MBEDTLS_GCM_C=y
+# CONFIG_MBEDTLS_NIST_KW_C is not set
+# end of Symmetric Ciphers
+
+# CONFIG_MBEDTLS_RIPEMD160_C is not set
+
+#
+# Certificates
+#
+CONFIG_MBEDTLS_PEM_PARSE_C=y
+CONFIG_MBEDTLS_PEM_WRITE_C=y
+CONFIG_MBEDTLS_X509_CRL_PARSE_C=y
+CONFIG_MBEDTLS_X509_CSR_PARSE_C=y
+# end of Certificates
+
+CONFIG_MBEDTLS_ECP_C=y
+CONFIG_MBEDTLS_ECDH_C=y
+CONFIG_MBEDTLS_ECDSA_C=y
+# CONFIG_MBEDTLS_ECJPAKE_C is not set
+CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y
+CONFIG_MBEDTLS_ECP_NIST_OPTIM=y
+# CONFIG_MBEDTLS_POLY1305_C is not set
+# CONFIG_MBEDTLS_CHACHA20_C is not set
+# CONFIG_MBEDTLS_HKDF_C is not set
+# CONFIG_MBEDTLS_THREADING_C is not set
+# CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI is not set
+# CONFIG_MBEDTLS_SECURITY_RISKS is not set
+# end of mbedTLS
+
+#
+# mDNS
+#
+CONFIG_MDNS_MAX_SERVICES=10
+CONFIG_MDNS_TASK_PRIORITY=1
+CONFIG_MDNS_TASK_STACK_SIZE=4096
+# CONFIG_MDNS_TASK_AFFINITY_NO_AFFINITY is not set
+CONFIG_MDNS_TASK_AFFINITY_CPU0=y
+# CONFIG_MDNS_TASK_AFFINITY_CPU1 is not set
+CONFIG_MDNS_TASK_AFFINITY=0x0
+CONFIG_MDNS_SERVICE_ADD_TIMEOUT_MS=2000
+# CONFIG_MDNS_STRICT_MODE is not set
+CONFIG_MDNS_TIMER_PERIOD_MS=100
+# CONFIG_MDNS_NETWORKING_SOCKET is not set
+CONFIG_MDNS_MULTIPLE_INSTANCE=y
+# end of mDNS
+
+#
+# ESP-MQTT Configurations
+#
+CONFIG_MQTT_PROTOCOL_311=y
+CONFIG_MQTT_TRANSPORT_SSL=y
+CONFIG_MQTT_TRANSPORT_WEBSOCKET=y
+CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE=y
+# CONFIG_MQTT_MSG_ID_INCREMENTAL is not set
+# CONFIG_MQTT_SKIP_PUBLISH_IF_DISCONNECTED is not set
+# CONFIG_MQTT_REPORT_DELETED_MESSAGES is not set
+# CONFIG_MQTT_USE_CUSTOM_CONFIG is not set
+# CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED is not set
+# CONFIG_MQTT_CUSTOM_OUTBOX is not set
+# end of ESP-MQTT Configurations
+
+#
+# Newlib
+#
+CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y
+# CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF is not set
+# CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR is not set
+# CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF is not set
+# CONFIG_NEWLIB_STDIN_LINE_ENDING_LF is not set
+CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y
+# CONFIG_NEWLIB_NANO_FORMAT is not set
+# end of Newlib
+
+#
+# NVS
+#
+# end of NVS
+
+#
+# OpenSSL
+#
+# CONFIG_OPENSSL_DEBUG is not set
+CONFIG_OPENSSL_ERROR_STACK=y
+# CONFIG_OPENSSL_ASSERT_DO_NOTHING is not set
+CONFIG_OPENSSL_ASSERT_EXIT=y
+# end of OpenSSL
+
+#
+# OpenThread
+#
+# CONFIG_OPENTHREAD_ENABLED is not set
+# end of OpenThread
+
+#
+# PThreads
+#
+CONFIG_PTHREAD_TASK_PRIO_DEFAULT=5
+CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072
+CONFIG_PTHREAD_STACK_MIN=768
+CONFIG_PTHREAD_DEFAULT_CORE_NO_AFFINITY=y
+# CONFIG_PTHREAD_DEFAULT_CORE_0 is not set
+# CONFIG_PTHREAD_DEFAULT_CORE_1 is not set
+CONFIG_PTHREAD_TASK_CORE_DEFAULT=-1
+CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread"
+# end of PThreads
+
+#
+# SPI Flash driver
+#
+# CONFIG_SPI_FLASH_VERIFY_WRITE is not set
+# CONFIG_SPI_FLASH_ENABLE_COUNTERS is not set
+CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y
+CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS=y
+# CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS is not set
+# CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED is not set
+# CONFIG_SPI_FLASH_USE_LEGACY_IMPL is not set
+# CONFIG_SPI_FLASH_SHARE_SPI1_BUS is not set
+# CONFIG_SPI_FLASH_BYPASS_BLOCK_ERASE is not set
+CONFIG_SPI_FLASH_YIELD_DURING_ERASE=y
+CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS=20
+CONFIG_SPI_FLASH_ERASE_YIELD_TICKS=1
+CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=8192
+# CONFIG_SPI_FLASH_SIZE_OVERRIDE is not set
+# CONFIG_SPI_FLASH_CHECK_ERASE_TIMEOUT_DISABLED is not set
+# CONFIG_SPI_FLASH_OVERRIDE_CHIP_DRIVER_LIST is not set
+
+#
+# Auto-detect flash chips
+#
+CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP=y
+CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP=y
+CONFIG_SPI_FLASH_SUPPORT_GD_CHIP=y
+CONFIG_SPI_FLASH_SUPPORT_WINBOND_CHIP=y
+# end of Auto-detect flash chips
+
+CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE=y
+# end of SPI Flash driver
+
+#
+# SPIFFS Configuration
+#
+CONFIG_SPIFFS_MAX_PARTITIONS=3
+
+#
+# SPIFFS Cache Configuration
+#
+CONFIG_SPIFFS_CACHE=y
+CONFIG_SPIFFS_CACHE_WR=y
+# CONFIG_SPIFFS_CACHE_STATS is not set
+# end of SPIFFS Cache Configuration
+
+CONFIG_SPIFFS_PAGE_CHECK=y
+CONFIG_SPIFFS_GC_MAX_RUNS=10
+# CONFIG_SPIFFS_GC_STATS is not set
+CONFIG_SPIFFS_PAGE_SIZE=256
+CONFIG_SPIFFS_OBJ_NAME_LEN=32
+# CONFIG_SPIFFS_FOLLOW_SYMLINKS is not set
+CONFIG_SPIFFS_USE_MAGIC=y
+CONFIG_SPIFFS_USE_MAGIC_LENGTH=y
+CONFIG_SPIFFS_META_LENGTH=4
+CONFIG_SPIFFS_USE_MTIME=y
+
+#
+# Debug Configuration
+#
+# CONFIG_SPIFFS_DBG is not set
+# CONFIG_SPIFFS_API_DBG is not set
+# CONFIG_SPIFFS_GC_DBG is not set
+# CONFIG_SPIFFS_CACHE_DBG is not set
+# CONFIG_SPIFFS_CHECK_DBG is not set
+# CONFIG_SPIFFS_TEST_VISUALISATION is not set
+# end of Debug Configuration
+# end of SPIFFS Configuration
+
+#
+# TCP Transport
+#
+
+#
+# Websocket
+#
+CONFIG_WS_TRANSPORT=y
+CONFIG_WS_BUFFER_SIZE=1024
+# end of Websocket
+# end of TCP Transport
+
+#
+# Unity unit testing library
+#
+CONFIG_UNITY_ENABLE_FLOAT=y
+CONFIG_UNITY_ENABLE_DOUBLE=y
+# CONFIG_UNITY_ENABLE_64BIT is not set
+# CONFIG_UNITY_ENABLE_COLOR is not set
+CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y
+# CONFIG_UNITY_ENABLE_FIXTURE is not set
+# CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL is not set
+# end of Unity unit testing library
+
+#
+# Virtual file system
+#
+CONFIG_VFS_SUPPORT_IO=y
+CONFIG_VFS_SUPPORT_DIR=y
+CONFIG_VFS_SUPPORT_SELECT=y
+CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y
+CONFIG_VFS_SUPPORT_TERMIOS=y
+
+#
+# Host File System I/O (Semihosting)
+#
+CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1
+CONFIG_VFS_SEMIHOSTFS_HOST_PATH_MAX_LEN=128
+# end of Host File System I/O (Semihosting)
+# end of Virtual file system
+
+#
+# Wear Levelling
+#
+# CONFIG_WL_SECTOR_SIZE_512 is not set
+CONFIG_WL_SECTOR_SIZE_4096=y
+CONFIG_WL_SECTOR_SIZE=4096
+# end of Wear Levelling
+
+#
+# Wi-Fi Provisioning Manager
+#
+CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16
+CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30
+# end of Wi-Fi Provisioning Manager
+
+#
+# Supplicant
+#
+CONFIG_WPA_MBEDTLS_CRYPTO=y
+# CONFIG_WPA_WAPI_PSK is not set
+# CONFIG_WPA_SUITE_B_192 is not set
+# CONFIG_WPA_DEBUG_PRINT is not set
+# CONFIG_WPA_TESTING_OPTIONS is not set
+# CONFIG_WPA_WPS_STRICT is not set
+# CONFIG_WPA_11KV_SUPPORT is not set
+# end of Supplicant
+# end of Component config
+
+#
+# Compatibility options
+#
+# CONFIG_LEGACY_INCLUDE_COMMON_HEADERS is not set
+# end of Compatibility options
+
+# Deprecated options for backward compatibility
+CONFIG_TOOLPREFIX="xtensa-esp32-elf-"
+# CONFIG_LOG_BOOTLOADER_LEVEL_NONE is not set
+# CONFIG_LOG_BOOTLOADER_LEVEL_ERROR is not set
+# CONFIG_LOG_BOOTLOADER_LEVEL_WARN is not set
+CONFIG_LOG_BOOTLOADER_LEVEL_INFO=y
+# CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG is not set
+# CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE is not set
+CONFIG_LOG_BOOTLOADER_LEVEL=3
+# CONFIG_APP_ROLLBACK_ENABLE is not set
+# CONFIG_FLASH_ENCRYPTION_ENABLED is not set
+# CONFIG_FLASHMODE_QIO is not set
+# CONFIG_FLASHMODE_QOUT is not set
+CONFIG_FLASHMODE_DIO=y
+# CONFIG_FLASHMODE_DOUT is not set
+# CONFIG_MONITOR_BAUD_9600B is not set
+# CONFIG_MONITOR_BAUD_57600B is not set
+CONFIG_MONITOR_BAUD_115200B=y
+# CONFIG_MONITOR_BAUD_230400B is not set
+# CONFIG_MONITOR_BAUD_921600B is not set
+# CONFIG_MONITOR_BAUD_2MB is not set
+# CONFIG_MONITOR_BAUD_OTHER is not set
+CONFIG_MONITOR_BAUD_OTHER_VAL=115200
+CONFIG_MONITOR_BAUD=115200
+CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG=y
+# CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set
+CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y
+# CONFIG_OPTIMIZATION_ASSERTIONS_SILENT is not set
+# CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED is not set
+CONFIG_OPTIMIZATION_ASSERTION_LEVEL=2
+# 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
+# CONFIG_STACK_CHECK_ALL is not set
+# CONFIG_WARN_WRITE_STRINGS is not set
+# CONFIG_DISABLE_GCC8_WARNINGS is not set
+# CONFIG_ESP32_APPTRACE_DEST_TRAX is not set
+CONFIG_ESP32_APPTRACE_DEST_NONE=y
+CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y
+CONFIG_ADC2_DISABLE_DAC=y
+# CONFIG_SPIRAM_SUPPORT is not set
+CONFIG_TRACEMEM_RESERVE_DRAM=0x0
+# CONFIG_ULP_COPROC_ENABLED is not set
+CONFIG_ULP_COPROC_RESERVE_MEM=0
+CONFIG_BROWNOUT_DET=y
+CONFIG_BROWNOUT_DET_LVL_SEL_0=y
+# CONFIG_BROWNOUT_DET_LVL_SEL_1 is not set
+# CONFIG_BROWNOUT_DET_LVL_SEL_2 is not set
+# CONFIG_BROWNOUT_DET_LVL_SEL_3 is not set
+# CONFIG_BROWNOUT_DET_LVL_SEL_4 is not set
+# CONFIG_BROWNOUT_DET_LVL_SEL_5 is not set
+# CONFIG_BROWNOUT_DET_LVL_SEL_6 is not set
+# CONFIG_BROWNOUT_DET_LVL_SEL_7 is not set
+CONFIG_BROWNOUT_DET_LVL=0
+CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC=y
+# CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL is not set
+# CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_OSC is not set
+# CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_8MD256 is not set
+# CONFIG_DISABLE_BASIC_ROM_CONSOLE is not set
+# CONFIG_NO_BLOBS is not set
+# CONFIG_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set
+# CONFIG_EVENT_LOOP_PROFILING is not set
+CONFIG_POST_EVENTS_FROM_ISR=y
+CONFIG_POST_EVENTS_FROM_IRAM_ISR=y
+# CONFIG_TWO_UNIVERSAL_MAC_ADDRESS is not set
+CONFIG_FOUR_UNIVERSAL_MAC_ADDRESS=y
+CONFIG_NUMBER_OF_UNIVERSAL_MAC_ADDRESS=4
+CONFIG_ESP_SYSTEM_PD_FLASH=y
+# CONFIG_ESP32C3_LIGHTSLEEP_GPIO_RESET_WORKAROUND is not set
+CONFIG_IPC_TASK_STACK_SIZE=1024
+CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y
+# CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set
+CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20
+CONFIG_ESP32_PHY_MAX_TX_POWER=20
+CONFIG_ESP32_REDUCE_PHY_TX_POWER=y
+# CONFIG_ESP32S2_PANIC_PRINT_HALT is not set
+CONFIG_ESP32S2_PANIC_PRINT_REBOOT=y
+# CONFIG_ESP32S2_PANIC_SILENT_REBOOT is not set
+# CONFIG_ESP32S2_PANIC_GDBSTUB is not set
+CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32
+CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304
+CONFIG_MAIN_TASK_STACK_SIZE=3584
+CONFIG_CONSOLE_UART_DEFAULT=y
+# CONFIG_CONSOLE_UART_CUSTOM is not set
+# CONFIG_ESP_CONSOLE_UART_NONE is not set
+CONFIG_CONSOLE_UART=y
+CONFIG_CONSOLE_UART_NUM=0
+CONFIG_CONSOLE_UART_BAUDRATE=115200
+CONFIG_INT_WDT=y
+CONFIG_INT_WDT_TIMEOUT_MS=300
+CONFIG_INT_WDT_CHECK_CPU1=y
+CONFIG_TASK_WDT=y
+# CONFIG_TASK_WDT_PANIC is not set
+CONFIG_TASK_WDT_TIMEOUT_S=5
+CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y
+CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1=y
+CONFIG_TIMER_TASK_STACK_SIZE=3584
+# CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set
+# CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set
+CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y
+CONFIG_MB_MASTER_TIMEOUT_MS_RESPOND=150
+CONFIG_MB_MASTER_DELAY_MS_CONVERT=200
+CONFIG_MB_QUEUE_LENGTH=20
+CONFIG_MB_SERIAL_TASK_STACK_SIZE=4096
+CONFIG_MB_SERIAL_BUF_SIZE=256
+CONFIG_MB_SERIAL_TASK_PRIO=10
+CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT=y
+CONFIG_MB_CONTROLLER_SLAVE_ID=0x00112233
+CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT=20
+CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE=20
+CONFIG_MB_CONTROLLER_STACK_SIZE=4096
+CONFIG_MB_EVENT_QUEUE_TIMEOUT=20
+# CONFIG_MB_TIMER_PORT_ENABLED is not set
+CONFIG_MB_TIMER_GROUP=0
+CONFIG_MB_TIMER_INDEX=0
+# CONFIG_ENABLE_STATIC_TASK_CLEAN_UP_HOOK is not set
+CONFIG_TIMER_TASK_PRIORITY=1
+CONFIG_TIMER_TASK_STACK_DEPTH=2048
+CONFIG_TIMER_QUEUE_LENGTH=10
+# CONFIG_L2_TO_L3_COPY is not set
+# CONFIG_USE_ONLY_LWIP_SELECT is not set
+CONFIG_ESP_GRATUITOUS_ARP=y
+CONFIG_GARP_TMR_INTERVAL=60
+CONFIG_TCPIP_RECVMBOX_SIZE=32
+CONFIG_TCP_MAXRTX=12
+CONFIG_TCP_SYNMAXRTX=12
+CONFIG_TCP_MSS=1440
+CONFIG_TCP_MSL=60000
+CONFIG_TCP_SND_BUF_DEFAULT=5744
+CONFIG_TCP_WND_DEFAULT=5744
+CONFIG_TCP_RECVMBOX_SIZE=6
+CONFIG_TCP_QUEUE_OOSEQ=y
+# CONFIG_ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set
+CONFIG_TCP_OVERSIZE_MSS=y
+# CONFIG_TCP_OVERSIZE_QUARTER_MSS is not set
+# CONFIG_TCP_OVERSIZE_DISABLE is not set
+CONFIG_UDP_RECVMBOX_SIZE=6
+CONFIG_TCPIP_TASK_STACK_SIZE=3072
+CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY=y
+# CONFIG_TCPIP_TASK_AFFINITY_CPU0 is not set
+# CONFIG_TCPIP_TASK_AFFINITY_CPU1 is not set
+CONFIG_TCPIP_TASK_AFFINITY=0x7FFFFFFF
+# CONFIG_PPP_SUPPORT is not set
+CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5
+CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072
+CONFIG_ESP32_PTHREAD_STACK_MIN=768
+CONFIG_ESP32_DEFAULT_PTHREAD_CORE_NO_AFFINITY=y
+# CONFIG_ESP32_DEFAULT_PTHREAD_CORE_0 is not set
+# CONFIG_ESP32_DEFAULT_PTHREAD_CORE_1 is not set
+CONFIG_ESP32_PTHREAD_TASK_CORE_DEFAULT=-1
+CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT="pthread"
+CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y
+# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS is not set
+# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED is not set
+CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT=y
+CONFIG_SUPPORT_TERMIOS=y
+CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS=1
+CONFIG_SEMIHOSTFS_HOST_PATH_MAX_LEN=128
+# End of deprecated options
diff --git a/software/sdkconfig.defaults b/software/sdkconfig.defaults
new file mode 100644
index 0000000..2facc67
--- /dev/null
+++ b/software/sdkconfig.defaults
@@ -0,0 +1 @@
+CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER=n
diff --git a/software/sdkconfig.old b/software/sdkconfig.old
new file mode 100644
index 0000000..6b8a12b
--- /dev/null
+++ b/software/sdkconfig.old
@@ -0,0 +1,1221 @@
+#
+# Automatically generated file. DO NOT EDIT.
+# Espressif IoT Development Framework (ESP-IDF) Project Configuration
+#
+CONFIG_IDF_CMAKE=y
+CONFIG_IDF_TARGET_ARCH_XTENSA=y
+CONFIG_IDF_TARGET="esp32"
+CONFIG_IDF_TARGET_ESP32=y
+CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000
+
+#
+# SDK tool configuration
+#
+CONFIG_SDK_TOOLPREFIX="xtensa-esp32-elf-"
+# CONFIG_SDK_TOOLCHAIN_SUPPORTS_TIME_WIDE_64_BITS is not set
+# end of SDK tool configuration
+
+#
+# Build type
+#
+CONFIG_APP_BUILD_TYPE_APP_2NDBOOT=y
+# CONFIG_APP_BUILD_TYPE_ELF_RAM is not set
+CONFIG_APP_BUILD_GENERATE_BINARIES=y
+CONFIG_APP_BUILD_BOOTLOADER=y
+CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y
+# end of Build type
+
+#
+# Application manager
+#
+CONFIG_APP_COMPILE_TIME_DATE=y
+# CONFIG_APP_EXCLUDE_PROJECT_VER_VAR is not set
+# CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR is not set
+# CONFIG_APP_PROJECT_VER_FROM_CONFIG is not set
+CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16
+# end of Application manager
+
+#
+# Bootloader config
+#
+CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x1000
+CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
+# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set
+# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF is not set
+# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set
+# CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set
+# CONFIG_BOOTLOADER_LOG_LEVEL_ERROR is not set
+# CONFIG_BOOTLOADER_LOG_LEVEL_WARN is not set
+CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y
+# CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG is not set
+# CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE is not set
+CONFIG_BOOTLOADER_LOG_LEVEL=3
+# CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_8V is not set
+CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V=y
+# CONFIG_BOOTLOADER_FACTORY_RESET is not set
+# CONFIG_BOOTLOADER_APP_TEST is not set
+CONFIG_BOOTLOADER_WDT_ENABLE=y
+# CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE is not set
+CONFIG_BOOTLOADER_WDT_TIME_MS=9000
+# CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE is not set
+# CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP is not set
+# CONFIG_BOOTLOADER_SKIP_VALIDATE_ON_POWER_ON is not set
+# CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS is not set
+CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0
+# CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set
+CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT=y
+# end of Bootloader config
+
+#
+# Security features
+#
+# CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT is not set
+# CONFIG_SECURE_BOOT is not set
+# CONFIG_SECURE_FLASH_ENC_ENABLED is not set
+# end of Security features
+
+#
+# Serial flasher config
+#
+CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200
+# CONFIG_ESPTOOLPY_NO_STUB is not set
+# CONFIG_ESPTOOLPY_FLASHMODE_QIO is not set
+# CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set
+CONFIG_ESPTOOLPY_FLASHMODE_DIO=y
+# CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set
+CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y
+CONFIG_ESPTOOLPY_FLASHMODE="dio"
+# CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set
+CONFIG_ESPTOOLPY_FLASHFREQ_40M=y
+# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set
+# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set
+CONFIG_ESPTOOLPY_FLASHFREQ="40m"
+# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set
+# CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set
+CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
+# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set
+# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set
+CONFIG_ESPTOOLPY_FLASHSIZE="4MB"
+CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y
+CONFIG_ESPTOOLPY_BEFORE_RESET=y
+# CONFIG_ESPTOOLPY_BEFORE_NORESET is not set
+CONFIG_ESPTOOLPY_BEFORE="default_reset"
+CONFIG_ESPTOOLPY_AFTER_RESET=y
+# CONFIG_ESPTOOLPY_AFTER_NORESET is not set
+CONFIG_ESPTOOLPY_AFTER="hard_reset"
+# CONFIG_ESPTOOLPY_MONITOR_BAUD_CONSOLE is not set
+# CONFIG_ESPTOOLPY_MONITOR_BAUD_9600B is not set
+# CONFIG_ESPTOOLPY_MONITOR_BAUD_57600B is not set
+CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y
+# CONFIG_ESPTOOLPY_MONITOR_BAUD_230400B is not set
+# CONFIG_ESPTOOLPY_MONITOR_BAUD_921600B is not set
+# CONFIG_ESPTOOLPY_MONITOR_BAUD_2MB is not set
+# CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER is not set
+CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER_VAL=115200
+CONFIG_ESPTOOLPY_MONITOR_BAUD=115200
+# end of Serial flasher config
+
+#
+# Partition Table
+#
+# CONFIG_PARTITION_TABLE_SINGLE_APP is not set
+# CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE is not set
+# CONFIG_PARTITION_TABLE_TWO_OTA is not set
+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 is not set
+# end of Partition Table
+
+#
+# Example Configuration
+#
+CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=y
+# CONFIG_EXAMPLE_USE_DM9051 is not set
+# CONFIG_EXAMPLE_USE_W5500 is not set
+# CONFIG_EXAMPLE_USE_KSZ8851SNL is not set
+# CONFIG_EXAMPLE_ETH_PHY_IP101 is not set
+# CONFIG_EXAMPLE_ETH_PHY_RTL8201 is not set
+CONFIG_EXAMPLE_ETH_PHY_LAN8720=y
+# CONFIG_EXAMPLE_ETH_PHY_DP83848 is not set
+# CONFIG_EXAMPLE_ETH_PHY_KSZ8041 is not set
+# CONFIG_EXAMPLE_ETH_PHY_KSZ8081 is not set
+CONFIG_EXAMPLE_ETH_MDC_GPIO=23
+CONFIG_EXAMPLE_ETH_MDIO_GPIO=18
+CONFIG_EXAMPLE_ETH_PHY_RST_GPIO=14
+CONFIG_EXAMPLE_ETH_PHY_ADDR=1
+# end of Example Configuration
+
+#
+# Compiler options
+#
+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=y
+# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set
+# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set
+CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL=2
+# CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT is not set
+CONFIG_COMPILER_HIDE_PATHS_MACROS=y
+# 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
+# CONFIG_COMPILER_STACK_CHECK_MODE_STRONG is not set
+# CONFIG_COMPILER_STACK_CHECK_MODE_ALL is not set
+# CONFIG_COMPILER_WARN_WRITE_STRINGS is not set
+# CONFIG_COMPILER_DISABLE_GCC8_WARNINGS is not set
+# CONFIG_COMPILER_DUMP_RTL_FILES is not set
+# end of Compiler options
+
+#
+# Component config
+#
+
+#
+# Application Level Tracing
+#
+# CONFIG_APPTRACE_DEST_JTAG is not set
+CONFIG_APPTRACE_DEST_NONE=y
+CONFIG_APPTRACE_LOCK_ENABLE=y
+# end of Application Level Tracing
+
+#
+# ESP-ASIO
+#
+# CONFIG_ASIO_SSL_SUPPORT is not set
+# end of ESP-ASIO
+
+#
+# Bluetooth
+#
+# CONFIG_BT_ENABLED is not set
+# end of Bluetooth
+
+#
+# CoAP Configuration
+#
+CONFIG_COAP_MBEDTLS_PSK=y
+# CONFIG_COAP_MBEDTLS_PKI is not set
+# CONFIG_COAP_MBEDTLS_DEBUG is not set
+CONFIG_COAP_LOG_DEFAULT_LEVEL=0
+# end of CoAP Configuration
+
+#
+# Driver configurations
+#
+
+#
+# ADC configuration
+#
+# CONFIG_ADC_FORCE_XPD_FSM is not set
+CONFIG_ADC_DISABLE_DAC=y
+# end of ADC configuration
+
+#
+# MCPWM configuration
+#
+# CONFIG_MCPWM_ISR_IN_IRAM is not set
+# end of MCPWM configuration
+
+#
+# SPI configuration
+#
+# CONFIG_SPI_MASTER_IN_IRAM is not set
+CONFIG_SPI_MASTER_ISR_IN_IRAM=y
+# CONFIG_SPI_SLAVE_IN_IRAM is not set
+CONFIG_SPI_SLAVE_ISR_IN_IRAM=y
+# end of SPI configuration
+
+#
+# TWAI configuration
+#
+# CONFIG_TWAI_ISR_IN_IRAM is not set
+# CONFIG_TWAI_ERRATA_FIX_BUS_OFF_REC is not set
+# CONFIG_TWAI_ERRATA_FIX_TX_INTR_LOST is not set
+# CONFIG_TWAI_ERRATA_FIX_RX_FRAME_INVALID is not set
+# CONFIG_TWAI_ERRATA_FIX_RX_FIFO_CORRUPT is not set
+# end of TWAI configuration
+
+#
+# UART configuration
+#
+CONFIG_UART_ISR_IN_IRAM=y
+# end of UART configuration
+
+#
+# RTCIO configuration
+#
+# CONFIG_RTCIO_SUPPORT_RTC_GPIO_DESC is not set
+# end of RTCIO configuration
+
+#
+# GPIO Configuration
+#
+# CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL is not set
+# end of GPIO Configuration
+
+#
+# GDMA Configuration
+#
+# CONFIG_GDMA_CTRL_FUNC_IN_IRAM is not set
+# CONFIG_GDMA_ISR_IRAM_SAFE is not set
+# end of GDMA Configuration
+# end of Driver configurations
+
+#
+# eFuse Bit Manager
+#
+# CONFIG_EFUSE_CUSTOM_TABLE is not set
+# CONFIG_EFUSE_VIRTUAL is not set
+# CONFIG_EFUSE_CODE_SCHEME_COMPAT_NONE is not set
+CONFIG_EFUSE_CODE_SCHEME_COMPAT_3_4=y
+# CONFIG_EFUSE_CODE_SCHEME_COMPAT_REPEAT is not set
+CONFIG_EFUSE_MAX_BLK_LEN=192
+# end of eFuse Bit Manager
+
+#
+# ESP-TLS
+#
+CONFIG_ESP_TLS_USING_MBEDTLS=y
+# CONFIG_ESP_TLS_USE_SECURE_ELEMENT is not set
+# CONFIG_ESP_TLS_SERVER is not set
+# CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set
+# CONFIG_ESP_TLS_PSK_VERIFICATION is not set
+# CONFIG_ESP_TLS_INSECURE is not set
+# end of ESP-TLS
+
+#
+# ESP32-specific
+#
+CONFIG_ESP32_REV_MIN_0=y
+# CONFIG_ESP32_REV_MIN_1 is not set
+# CONFIG_ESP32_REV_MIN_2 is not set
+# CONFIG_ESP32_REV_MIN_3 is not set
+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=y
+# CONFIG_ESP32_DEFAULT_CPU_FREQ_240 is not set
+CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=160
+# CONFIG_ESP32_SPIRAM_SUPPORT is not set
+# CONFIG_ESP32_TRAX is not set
+CONFIG_ESP32_TRACEMEM_RESERVE_DRAM=0x0
+# CONFIG_ESP32_ULP_COPROC_ENABLED is not set
+CONFIG_ESP32_ULP_COPROC_RESERVE_MEM=0
+CONFIG_ESP32_DEBUG_OCDAWARE=y
+CONFIG_ESP32_BROWNOUT_DET=y
+CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_0=y
+# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_1 is not set
+# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_2 is not set
+# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_3 is not set
+# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_4 is not set
+# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_5 is not set
+# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_6 is not set
+# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_7 is not set
+CONFIG_ESP32_BROWNOUT_DET_LVL=0
+CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y
+# CONFIG_ESP32_TIME_SYSCALL_USE_RTC is not set
+# CONFIG_ESP32_TIME_SYSCALL_USE_FRC1 is not set
+# CONFIG_ESP32_TIME_SYSCALL_USE_NONE is not set
+CONFIG_ESP32_RTC_CLK_SRC_INT_RC=y
+# CONFIG_ESP32_RTC_CLK_SRC_EXT_CRYS is not set
+# CONFIG_ESP32_RTC_CLK_SRC_EXT_OSC is not set
+# CONFIG_ESP32_RTC_CLK_SRC_INT_8MD256 is not set
+CONFIG_ESP32_RTC_CLK_CAL_CYCLES=1024
+CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=2000
+CONFIG_ESP32_XTAL_FREQ_40=y
+# CONFIG_ESP32_XTAL_FREQ_26 is not set
+# CONFIG_ESP32_XTAL_FREQ_AUTO is not set
+CONFIG_ESP32_XTAL_FREQ=40
+# CONFIG_ESP32_DISABLE_BASIC_ROM_CONSOLE is not set
+# CONFIG_ESP32_NO_BLOBS is not set
+# CONFIG_ESP32_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set
+# CONFIG_ESP32_COMPATIBLE_PRE_V3_1_BOOTLOADERS is not set
+# CONFIG_ESP32_USE_FIXED_STATIC_RAM_SIZE is not set
+CONFIG_ESP32_DPORT_DIS_INTERRUPT_LVL=5
+# end of ESP32-specific
+
+#
+# ADC-Calibration
+#
+CONFIG_ADC_CAL_EFUSE_TP_ENABLE=y
+CONFIG_ADC_CAL_EFUSE_VREF_ENABLE=y
+CONFIG_ADC_CAL_LUT_ENABLE=y
+# end of ADC-Calibration
+
+#
+# Common ESP-related
+#
+CONFIG_ESP_ERR_TO_NAME_LOOKUP=y
+# end of Common ESP-related
+
+#
+# Ethernet
+#
+CONFIG_ETH_ENABLED=y
+CONFIG_ETH_USE_ESP32_EMAC=y
+CONFIG_ETH_PHY_INTERFACE_RMII=y
+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 is not set
+# CONFIG_ETH_USE_OPENETH is not set
+# end of Ethernet
+
+#
+# Event Loop Library
+#
+# CONFIG_ESP_EVENT_LOOP_PROFILING is not set
+CONFIG_ESP_EVENT_POST_FROM_ISR=y
+CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y
+# end of Event Loop Library
+
+#
+# GDB Stub
+#
+# end of GDB Stub
+
+#
+# ESP HTTP client
+#
+CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y
+CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH=y
+CONFIG_ESP_HTTP_CLIENT_ENABLE_DIGEST_AUTH=y
+# end of ESP HTTP client
+
+#
+# HTTP Server
+#
+CONFIG_HTTPD_MAX_REQ_HDR_LEN=512
+CONFIG_HTTPD_MAX_URI_LEN=512
+CONFIG_HTTPD_ERR_RESP_NO_DELAY=y
+CONFIG_HTTPD_PURGE_BUF_LEN=32
+# CONFIG_HTTPD_LOG_PURGE_DATA is not set
+# CONFIG_HTTPD_WS_SUPPORT is not set
+# end of HTTP Server
+
+#
+# ESP HTTPS OTA
+#
+# CONFIG_OTA_ALLOW_HTTP is not set
+# end of ESP HTTPS OTA
+
+#
+# ESP HTTPS server
+#
+# CONFIG_ESP_HTTPS_SERVER_ENABLE is not set
+# end of ESP HTTPS server
+
+#
+# Hardware Settings
+#
+
+#
+# MAC Config
+#
+CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA=y
+CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP=y
+CONFIG_ESP_MAC_ADDR_UNIVERSE_BT=y
+CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y
+# CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_TWO is not set
+CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR=y
+CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES=4
+# end of MAC Config
+
+#
+# Sleep Config
+#
+CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y
+CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND=y
+# CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND is not set
+# CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND is not set
+# end of Sleep Config
+# end of Hardware Settings
+
+#
+# IPC (Inter-Processor Call)
+#
+CONFIG_ESP_IPC_TASK_STACK_SIZE=1024
+CONFIG_ESP_IPC_USES_CALLERS_PRIORITY=y
+CONFIG_ESP_IPC_ISR_ENABLE=y
+# end of IPC (Inter-Processor Call)
+
+#
+# LCD and Touch Panel
+#
+
+#
+# LCD Peripheral Configuration
+#
+CONFIG_LCD_PANEL_IO_FORMAT_BUF_SIZE=32
+# end of LCD Peripheral Configuration
+# end of LCD and Touch Panel
+
+#
+# ESP NETIF Adapter
+#
+CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120
+CONFIG_ESP_NETIF_TCPIP_LWIP=y
+# CONFIG_ESP_NETIF_LOOPBACK is not set
+# CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER is not set
+# end of ESP NETIF Adapter
+
+#
+# PHY
+#
+CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y
+# CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION is not set
+CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=20
+CONFIG_ESP_PHY_MAX_TX_POWER=20
+CONFIG_ESP_PHY_REDUCE_TX_POWER=y
+# end of PHY
+
+#
+# Power Management
+#
+# CONFIG_PM_ENABLE is not set
+# end of Power Management
+
+#
+# ESP System Settings
+#
+# CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set
+CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y
+# CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set
+# CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set
+# CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set
+
+#
+# Memory protection
+#
+# end of Memory protection
+
+CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE=32
+CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2304
+CONFIG_ESP_MAIN_TASK_STACK_SIZE=3584
+CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0=y
+# CONFIG_ESP_MAIN_TASK_AFFINITY_CPU1 is not set
+# CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY is not set
+CONFIG_ESP_MAIN_TASK_AFFINITY=0x0
+CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE=2048
+CONFIG_ESP_CONSOLE_UART_DEFAULT=y
+# CONFIG_ESP_CONSOLE_UART_CUSTOM is not set
+# CONFIG_ESP_CONSOLE_NONE is not set
+CONFIG_ESP_CONSOLE_UART=y
+CONFIG_ESP_CONSOLE_MULTIPLE_UART=y
+CONFIG_ESP_CONSOLE_UART_NUM=0
+CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200
+CONFIG_ESP_INT_WDT=y
+CONFIG_ESP_INT_WDT_TIMEOUT_MS=300
+CONFIG_ESP_INT_WDT_CHECK_CPU1=y
+CONFIG_ESP_TASK_WDT=y
+# CONFIG_ESP_TASK_WDT_PANIC is not set
+CONFIG_ESP_TASK_WDT_TIMEOUT_S=5
+CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y
+CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=y
+# CONFIG_ESP_PANIC_HANDLER_IRAM is not set
+# CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_5 is not set
+CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4=y
+# end of ESP System Settings
+
+#
+# High resolution timer (esp_timer)
+#
+# CONFIG_ESP_TIMER_PROFILING is not set
+CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER=y
+CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER=y
+CONFIG_ESP_TIMER_TASK_STACK_SIZE=3584
+CONFIG_ESP_TIMER_INTERRUPT_LEVEL=1
+# CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD is not set
+# CONFIG_ESP_TIMER_IMPL_FRC2 is not set
+CONFIG_ESP_TIMER_IMPL_TG0_LAC=y
+# end of High resolution timer (esp_timer)
+
+#
+# Wi-Fi
+#
+CONFIG_ESP32_WIFI_ENABLED=y
+CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10
+CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32
+# CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set
+CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y
+CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1
+CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32
+# CONFIG_ESP32_WIFI_CSI_ENABLED is not set
+CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y
+CONFIG_ESP32_WIFI_TX_BA_WIN=6
+CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y
+CONFIG_ESP32_WIFI_RX_BA_WIN=6
+CONFIG_ESP32_WIFI_NVS_ENABLED=y
+CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y
+# CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 is not set
+CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752
+CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32
+CONFIG_ESP32_WIFI_IRAM_OPT=y
+CONFIG_ESP32_WIFI_RX_IRAM_OPT=y
+CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y
+# CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set
+# CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is not set
+# CONFIG_ESP_WIFI_GMAC_SUPPORT is not set
+CONFIG_ESP_WIFI_SOFTAP_SUPPORT=y
+# end of Wi-Fi
+
+#
+# Core dump
+#
+# CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH is not set
+# CONFIG_ESP_COREDUMP_ENABLE_TO_UART is not set
+CONFIG_ESP_COREDUMP_ENABLE_TO_NONE=y
+# end of Core dump
+
+#
+# FAT Filesystem support
+#
+# CONFIG_FATFS_CODEPAGE_DYNAMIC is not set
+CONFIG_FATFS_CODEPAGE_437=y
+# CONFIG_FATFS_CODEPAGE_720 is not set
+# CONFIG_FATFS_CODEPAGE_737 is not set
+# CONFIG_FATFS_CODEPAGE_771 is not set
+# CONFIG_FATFS_CODEPAGE_775 is not set
+# CONFIG_FATFS_CODEPAGE_850 is not set
+# CONFIG_FATFS_CODEPAGE_852 is not set
+# CONFIG_FATFS_CODEPAGE_855 is not set
+# CONFIG_FATFS_CODEPAGE_857 is not set
+# CONFIG_FATFS_CODEPAGE_860 is not set
+# CONFIG_FATFS_CODEPAGE_861 is not set
+# CONFIG_FATFS_CODEPAGE_862 is not set
+# CONFIG_FATFS_CODEPAGE_863 is not set
+# CONFIG_FATFS_CODEPAGE_864 is not set
+# CONFIG_FATFS_CODEPAGE_865 is not set
+# CONFIG_FATFS_CODEPAGE_866 is not set
+# CONFIG_FATFS_CODEPAGE_869 is not set
+# CONFIG_FATFS_CODEPAGE_932 is not set
+# CONFIG_FATFS_CODEPAGE_936 is not set
+# CONFIG_FATFS_CODEPAGE_949 is not set
+# CONFIG_FATFS_CODEPAGE_950 is not set
+CONFIG_FATFS_CODEPAGE=437
+CONFIG_FATFS_LFN_NONE=y
+# CONFIG_FATFS_LFN_HEAP is not set
+# CONFIG_FATFS_LFN_STACK is not set
+CONFIG_FATFS_FS_LOCK=0
+CONFIG_FATFS_TIMEOUT_MS=10000
+CONFIG_FATFS_PER_FILE_CACHE=y
+# CONFIG_FATFS_USE_FASTSEEK is not set
+# end of FAT Filesystem support
+
+#
+# Modbus configuration
+#
+CONFIG_FMB_COMM_MODE_TCP_EN=y
+CONFIG_FMB_TCP_PORT_DEFAULT=502
+CONFIG_FMB_TCP_PORT_MAX_CONN=5
+CONFIG_FMB_TCP_CONNECTION_TOUT_SEC=20
+CONFIG_FMB_COMM_MODE_RTU_EN=y
+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_PORT_TASK_STACK_SIZE=4096
+CONFIG_FMB_SERIAL_BUF_SIZE=256
+CONFIG_FMB_SERIAL_ASCII_BITS_PER_SYMB=8
+CONFIG_FMB_SERIAL_ASCII_TIMEOUT_RESPOND_MS=1000
+CONFIG_FMB_PORT_TASK_PRIO=10
+# CONFIG_FMB_PORT_TASK_AFFINITY_NO_AFFINITY is not set
+CONFIG_FMB_PORT_TASK_AFFINITY_CPU0=y
+# CONFIG_FMB_PORT_TASK_AFFINITY_CPU1 is not set
+CONFIG_FMB_PORT_TASK_AFFINITY=0x0
+CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT=y
+CONFIG_FMB_CONTROLLER_SLAVE_ID=0x00112233
+CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT=20
+CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE=20
+CONFIG_FMB_CONTROLLER_STACK_SIZE=4096
+CONFIG_FMB_EVENT_QUEUE_TIMEOUT=20
+# CONFIG_FMB_TIMER_PORT_ENABLED is not set
+CONFIG_FMB_TIMER_GROUP=0
+CONFIG_FMB_TIMER_INDEX=0
+CONFIG_FMB_MASTER_TIMER_GROUP=0
+CONFIG_FMB_MASTER_TIMER_INDEX=0
+# CONFIG_FMB_TIMER_ISR_IN_IRAM is not set
+# end of Modbus configuration
+
+#
+# FreeRTOS
+#
+# CONFIG_FREERTOS_UNICORE is not set
+CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF
+CONFIG_FREERTOS_TICK_SUPPORT_CORETIMER=y
+CONFIG_FREERTOS_CORETIMER_0=y
+# CONFIG_FREERTOS_CORETIMER_1 is not set
+CONFIG_FREERTOS_SYSTICK_USES_CCOUNT=y
+CONFIG_FREERTOS_HZ=100
+CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y
+# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE is not set
+# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL is not set
+CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY=y
+# CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set
+CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y
+CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=1
+CONFIG_FREERTOS_ASSERT_FAIL_ABORT=y
+# CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE is not set
+# CONFIG_FREERTOS_ASSERT_DISABLE is not set
+CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1536
+CONFIG_FREERTOS_ISR_STACKSIZE=1536
+# CONFIG_FREERTOS_LEGACY_HOOKS is not set
+CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16
+CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
+# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set
+CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1
+CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048
+CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10
+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_TASK_FUNCTION_WRAPPER=y
+CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y
+# CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set
+# CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set
+CONFIG_FREERTOS_DEBUG_OCDAWARE=y
+# CONFIG_FREERTOS_FPU_IN_ISR is not set
+CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT=y
+# CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH is not set
+# end of FreeRTOS
+
+#
+# Hardware Abstraction Layer (HAL) and Low Level (LL)
+#
+CONFIG_HAL_ASSERTION_EQUALS_SYSTEM=y
+# CONFIG_HAL_ASSERTION_DISABLE is not set
+# CONFIG_HAL_ASSERTION_SILIENT is not set
+# CONFIG_HAL_ASSERTION_ENABLE is not set
+CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=2
+# end of Hardware Abstraction Layer (HAL) and Low Level (LL)
+
+#
+# Heap memory debugging
+#
+CONFIG_HEAP_POISONING_DISABLED=y
+# CONFIG_HEAP_POISONING_LIGHT is not set
+# CONFIG_HEAP_POISONING_COMPREHENSIVE is not set
+CONFIG_HEAP_TRACING_OFF=y
+# CONFIG_HEAP_TRACING_STANDALONE is not set
+# CONFIG_HEAP_TRACING_TOHOST is not set
+# CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS is not set
+# end of Heap memory debugging
+
+#
+# jsmn
+#
+# CONFIG_JSMN_PARENT_LINKS is not set
+# CONFIG_JSMN_STRICT is not set
+# end of jsmn
+
+#
+# libsodium
+#
+# end of libsodium
+
+#
+# Log output
+#
+# CONFIG_LOG_DEFAULT_LEVEL_NONE is not set
+# CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set
+# CONFIG_LOG_DEFAULT_LEVEL_WARN is not set
+CONFIG_LOG_DEFAULT_LEVEL_INFO=y
+# CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set
+# CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set
+CONFIG_LOG_DEFAULT_LEVEL=3
+CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=y
+# CONFIG_LOG_MAXIMUM_LEVEL_DEBUG is not set
+# CONFIG_LOG_MAXIMUM_LEVEL_VERBOSE is not set
+CONFIG_LOG_MAXIMUM_LEVEL=3
+CONFIG_LOG_COLORS=y
+CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y
+# CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set
+# end of Log output
+
+#
+# LWIP
+#
+CONFIG_LWIP_LOCAL_HOSTNAME="espressif"
+# CONFIG_LWIP_NETIF_API is not set
+# CONFIG_LWIP_TCPIP_CORE_LOCKING is not set
+CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y
+# CONFIG_LWIP_L2_TO_L3_COPY is not set
+# CONFIG_LWIP_IRAM_OPTIMIZATION is not set
+CONFIG_LWIP_TIMERS_ONDEMAND=y
+CONFIG_LWIP_MAX_SOCKETS=10
+# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set
+# CONFIG_LWIP_SO_LINGER is not set
+CONFIG_LWIP_SO_REUSE=y
+CONFIG_LWIP_SO_REUSE_RXTOALL=y
+# CONFIG_LWIP_SO_RCVBUF is not set
+# CONFIG_LWIP_NETBUF_RECVINFO is not set
+CONFIG_LWIP_IP4_FRAG=y
+CONFIG_LWIP_IP6_FRAG=y
+# CONFIG_LWIP_IP4_REASSEMBLY is not set
+# CONFIG_LWIP_IP6_REASSEMBLY is not set
+# CONFIG_LWIP_IP_FORWARD is not set
+# CONFIG_LWIP_STATS is not set
+# CONFIG_LWIP_ETHARP_TRUST_IP_MAC is not set
+CONFIG_LWIP_ESP_GRATUITOUS_ARP=y
+CONFIG_LWIP_GARP_TMR_INTERVAL=60
+CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32
+CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y
+# CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID is not set
+CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID=y
+# CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set
+CONFIG_LWIP_DHCP_OPTIONS_LEN=68
+
+#
+# DHCP server
+#
+# CONFIG_LWIP_DHCPS is not set
+# end of DHCP server
+
+# CONFIG_LWIP_AUTOIP is not set
+CONFIG_LWIP_IPV6=y
+# CONFIG_LWIP_IPV6_AUTOCONFIG is not set
+CONFIG_LWIP_IPV6_NUM_ADDRESSES=3
+# CONFIG_LWIP_IPV6_FORWARD is not set
+# CONFIG_LWIP_NETIF_STATUS_CALLBACK is not set
+CONFIG_LWIP_NETIF_LOOPBACK=y
+CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8
+
+#
+# TCP
+#
+CONFIG_LWIP_MAX_ACTIVE_TCP=16
+CONFIG_LWIP_MAX_LISTENING_TCP=16
+CONFIG_LWIP_TCP_HIGH_SPEED_RETRANSMISSION=y
+CONFIG_LWIP_TCP_MAXRTX=12
+CONFIG_LWIP_TCP_SYNMAXRTX=12
+CONFIG_LWIP_TCP_MSS=1440
+CONFIG_LWIP_TCP_TMR_INTERVAL=250
+CONFIG_LWIP_TCP_MSL=60000
+CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5744
+CONFIG_LWIP_TCP_WND_DEFAULT=5744
+CONFIG_LWIP_TCP_RECVMBOX_SIZE=6
+CONFIG_LWIP_TCP_QUEUE_OOSEQ=y
+# CONFIG_LWIP_TCP_SACK_OUT is not set
+# CONFIG_LWIP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set
+CONFIG_LWIP_TCP_OVERSIZE_MSS=y
+# CONFIG_LWIP_TCP_OVERSIZE_QUARTER_MSS is not set
+# CONFIG_LWIP_TCP_OVERSIZE_DISABLE is not set
+CONFIG_LWIP_TCP_RTO_TIME=1500
+# end of TCP
+
+#
+# UDP
+#
+CONFIG_LWIP_MAX_UDP_PCBS=16
+CONFIG_LWIP_UDP_RECVMBOX_SIZE=6
+# end of UDP
+
+#
+# Checksums
+#
+# CONFIG_LWIP_CHECKSUM_CHECK_IP is not set
+# CONFIG_LWIP_CHECKSUM_CHECK_UDP is not set
+CONFIG_LWIP_CHECKSUM_CHECK_ICMP=y
+# end of Checksums
+
+CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=3072
+CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y
+# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set
+# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU1 is not set
+CONFIG_LWIP_TCPIP_TASK_AFFINITY=0x7FFFFFFF
+# CONFIG_LWIP_PPP_SUPPORT is not set
+CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE=3
+CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS=5
+# CONFIG_LWIP_SLIP_SUPPORT is not set
+
+#
+# ICMP
+#
+CONFIG_LWIP_ICMP=y
+# CONFIG_LWIP_MULTICAST_PING is not set
+# CONFIG_LWIP_BROADCAST_PING is not set
+# end of ICMP
+
+#
+# LWIP RAW API
+#
+CONFIG_LWIP_MAX_RAW_PCBS=16
+# end of LWIP RAW API
+
+#
+# SNTP
+#
+CONFIG_LWIP_SNTP_MAX_SERVERS=1
+# CONFIG_LWIP_DHCP_GET_NTP_SRV is not set
+CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000
+# end of SNTP
+
+CONFIG_LWIP_ESP_LWIP_ASSERT=y
+
+#
+# Hooks
+#
+# CONFIG_LWIP_HOOK_TCP_ISN_NONE is not set
+CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT=y
+# CONFIG_LWIP_HOOK_TCP_ISN_CUSTOM is not set
+CONFIG_LWIP_HOOK_IP6_ROUTE_NONE=y
+# CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT is not set
+# CONFIG_LWIP_HOOK_IP6_ROUTE_CUSTOM is not set
+CONFIG_LWIP_HOOK_ND6_GET_GW_NONE=y
+# CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT is not set
+# CONFIG_LWIP_HOOK_ND6_GET_GW_CUSTOM is not set
+CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y
+# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_DEFAULT is not set
+# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM is not set
+# end of Hooks
+
+# CONFIG_LWIP_DEBUG is not set
+# end of LWIP
+
+#
+# mbedTLS
+#
+CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y
+# CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set
+# CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set
+CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y
+CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384
+CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096
+# CONFIG_MBEDTLS_DYNAMIC_BUFFER is not set
+# CONFIG_MBEDTLS_DEBUG is not set
+
+#
+# Certificate Bundle
+#
+CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y
+CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y
+# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set
+# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set
+# CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set
+# end of Certificate Bundle
+
+# CONFIG_MBEDTLS_ECP_RESTARTABLE is not set
+# CONFIG_MBEDTLS_CMAC_C is not set
+CONFIG_MBEDTLS_HARDWARE_AES=y
+CONFIG_MBEDTLS_HARDWARE_MPI=y
+CONFIG_MBEDTLS_HARDWARE_SHA=y
+CONFIG_MBEDTLS_ROM_MD5=y
+# CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set
+# CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set
+CONFIG_MBEDTLS_HAVE_TIME=y
+# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set
+CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y
+CONFIG_MBEDTLS_SHA512_C=y
+CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y
+# CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set
+# CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set
+# CONFIG_MBEDTLS_TLS_DISABLED is not set
+CONFIG_MBEDTLS_TLS_SERVER=y
+CONFIG_MBEDTLS_TLS_CLIENT=y
+CONFIG_MBEDTLS_TLS_ENABLED=y
+
+#
+# TLS Key Exchange Methods
+#
+# CONFIG_MBEDTLS_PSK_MODES is not set
+CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y
+CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA=y
+CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE=y
+CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=y
+CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=y
+CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y
+CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y
+# end of TLS Key Exchange Methods
+
+CONFIG_MBEDTLS_SSL_RENEGOTIATION=y
+# CONFIG_MBEDTLS_SSL_PROTO_SSL3 is not set
+CONFIG_MBEDTLS_SSL_PROTO_TLS1=y
+CONFIG_MBEDTLS_SSL_PROTO_TLS1_1=y
+CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y
+# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set
+# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set
+CONFIG_MBEDTLS_SSL_ALPN=y
+CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y
+CONFIG_MBEDTLS_X509_CHECK_KEY_USAGE=y
+CONFIG_MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE=y
+CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=y
+
+#
+# Symmetric Ciphers
+#
+CONFIG_MBEDTLS_AES_C=y
+# CONFIG_MBEDTLS_CAMELLIA_C is not set
+# CONFIG_MBEDTLS_DES_C is not set
+CONFIG_MBEDTLS_RC4_DISABLED=y
+# CONFIG_MBEDTLS_RC4_ENABLED_NO_DEFAULT is not set
+# CONFIG_MBEDTLS_RC4_ENABLED is not set
+# CONFIG_MBEDTLS_BLOWFISH_C is not set
+# CONFIG_MBEDTLS_XTEA_C is not set
+CONFIG_MBEDTLS_CCM_C=y
+CONFIG_MBEDTLS_GCM_C=y
+# CONFIG_MBEDTLS_NIST_KW_C is not set
+# end of Symmetric Ciphers
+
+# CONFIG_MBEDTLS_RIPEMD160_C is not set
+
+#
+# Certificates
+#
+CONFIG_MBEDTLS_PEM_PARSE_C=y
+CONFIG_MBEDTLS_PEM_WRITE_C=y
+CONFIG_MBEDTLS_X509_CRL_PARSE_C=y
+CONFIG_MBEDTLS_X509_CSR_PARSE_C=y
+# end of Certificates
+
+CONFIG_MBEDTLS_ECP_C=y
+CONFIG_MBEDTLS_ECDH_C=y
+CONFIG_MBEDTLS_ECDSA_C=y
+# CONFIG_MBEDTLS_ECJPAKE_C is not set
+CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y
+CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y
+CONFIG_MBEDTLS_ECP_NIST_OPTIM=y
+# CONFIG_MBEDTLS_POLY1305_C is not set
+# CONFIG_MBEDTLS_CHACHA20_C is not set
+# CONFIG_MBEDTLS_HKDF_C is not set
+# CONFIG_MBEDTLS_THREADING_C is not set
+# CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI is not set
+# CONFIG_MBEDTLS_SECURITY_RISKS is not set
+# end of mbedTLS
+
+#
+# mDNS
+#
+CONFIG_MDNS_MAX_SERVICES=10
+CONFIG_MDNS_TASK_PRIORITY=1
+CONFIG_MDNS_TASK_STACK_SIZE=4096
+# CONFIG_MDNS_TASK_AFFINITY_NO_AFFINITY is not set
+CONFIG_MDNS_TASK_AFFINITY_CPU0=y
+# CONFIG_MDNS_TASK_AFFINITY_CPU1 is not set
+CONFIG_MDNS_TASK_AFFINITY=0x0
+CONFIG_MDNS_SERVICE_ADD_TIMEOUT_MS=2000
+# CONFIG_MDNS_STRICT_MODE is not set
+CONFIG_MDNS_TIMER_PERIOD_MS=100
+# CONFIG_MDNS_NETWORKING_SOCKET is not set
+CONFIG_MDNS_MULTIPLE_INSTANCE=y
+# end of mDNS
+
+#
+# ESP-MQTT Configurations
+#
+CONFIG_MQTT_PROTOCOL_311=y
+CONFIG_MQTT_TRANSPORT_SSL=y
+CONFIG_MQTT_TRANSPORT_WEBSOCKET=y
+CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE=y
+# CONFIG_MQTT_MSG_ID_INCREMENTAL is not set
+# CONFIG_MQTT_SKIP_PUBLISH_IF_DISCONNECTED is not set
+# CONFIG_MQTT_REPORT_DELETED_MESSAGES is not set
+# CONFIG_MQTT_USE_CUSTOM_CONFIG is not set
+# CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED is not set
+# CONFIG_MQTT_CUSTOM_OUTBOX is not set
+# end of ESP-MQTT Configurations
+
+#
+# Newlib
+#
+CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y
+# CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF is not set
+# CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR is not set
+# CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF is not set
+# CONFIG_NEWLIB_STDIN_LINE_ENDING_LF is not set
+CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y
+# CONFIG_NEWLIB_NANO_FORMAT is not set
+# end of Newlib
+
+#
+# NVS
+#
+# end of NVS
+
+#
+# OpenSSL
+#
+# CONFIG_OPENSSL_DEBUG is not set
+CONFIG_OPENSSL_ERROR_STACK=y
+# CONFIG_OPENSSL_ASSERT_DO_NOTHING is not set
+CONFIG_OPENSSL_ASSERT_EXIT=y
+# end of OpenSSL
+
+#
+# OpenThread
+#
+# CONFIG_OPENTHREAD_ENABLED is not set
+# end of OpenThread
+
+#
+# PThreads
+#
+CONFIG_PTHREAD_TASK_PRIO_DEFAULT=5
+CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072
+CONFIG_PTHREAD_STACK_MIN=768
+CONFIG_PTHREAD_DEFAULT_CORE_NO_AFFINITY=y
+# CONFIG_PTHREAD_DEFAULT_CORE_0 is not set
+# CONFIG_PTHREAD_DEFAULT_CORE_1 is not set
+CONFIG_PTHREAD_TASK_CORE_DEFAULT=-1
+CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread"
+# end of PThreads
+
+#
+# SPI Flash driver
+#
+# CONFIG_SPI_FLASH_VERIFY_WRITE is not set
+# CONFIG_SPI_FLASH_ENABLE_COUNTERS is not set
+CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y
+CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS=y
+# CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS is not set
+# CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED is not set
+# CONFIG_SPI_FLASH_USE_LEGACY_IMPL is not set
+# CONFIG_SPI_FLASH_SHARE_SPI1_BUS is not set
+# CONFIG_SPI_FLASH_BYPASS_BLOCK_ERASE is not set
+CONFIG_SPI_FLASH_YIELD_DURING_ERASE=y
+CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS=20
+CONFIG_SPI_FLASH_ERASE_YIELD_TICKS=1
+CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=8192
+# CONFIG_SPI_FLASH_SIZE_OVERRIDE is not set
+# CONFIG_SPI_FLASH_CHECK_ERASE_TIMEOUT_DISABLED is not set
+# CONFIG_SPI_FLASH_OVERRIDE_CHIP_DRIVER_LIST is not set
+
+#
+# Auto-detect flash chips
+#
+CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP=y
+CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP=y
+CONFIG_SPI_FLASH_SUPPORT_GD_CHIP=y
+CONFIG_SPI_FLASH_SUPPORT_WINBOND_CHIP=y
+# end of Auto-detect flash chips
+
+CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE=y
+# end of SPI Flash driver
+
+#
+# SPIFFS Configuration
+#
+CONFIG_SPIFFS_MAX_PARTITIONS=3
+
+#
+# SPIFFS Cache Configuration
+#
+CONFIG_SPIFFS_CACHE=y
+CONFIG_SPIFFS_CACHE_WR=y
+# CONFIG_SPIFFS_CACHE_STATS is not set
+# end of SPIFFS Cache Configuration
+
+CONFIG_SPIFFS_PAGE_CHECK=y
+CONFIG_SPIFFS_GC_MAX_RUNS=10
+# CONFIG_SPIFFS_GC_STATS is not set
+CONFIG_SPIFFS_PAGE_SIZE=256
+CONFIG_SPIFFS_OBJ_NAME_LEN=32
+# CONFIG_SPIFFS_FOLLOW_SYMLINKS is not set
+CONFIG_SPIFFS_USE_MAGIC=y
+CONFIG_SPIFFS_USE_MAGIC_LENGTH=y
+CONFIG_SPIFFS_META_LENGTH=4
+CONFIG_SPIFFS_USE_MTIME=y
+
+#
+# Debug Configuration
+#
+# CONFIG_SPIFFS_DBG is not set
+# CONFIG_SPIFFS_API_DBG is not set
+# CONFIG_SPIFFS_GC_DBG is not set
+# CONFIG_SPIFFS_CACHE_DBG is not set
+# CONFIG_SPIFFS_CHECK_DBG is not set
+# CONFIG_SPIFFS_TEST_VISUALISATION is not set
+# end of Debug Configuration
+# end of SPIFFS Configuration
+
+#
+# TCP Transport
+#
+
+#
+# Websocket
+#
+CONFIG_WS_TRANSPORT=y
+CONFIG_WS_BUFFER_SIZE=1024
+# end of Websocket
+# end of TCP Transport
+
+#
+# Unity unit testing library
+#
+CONFIG_UNITY_ENABLE_FLOAT=y
+CONFIG_UNITY_ENABLE_DOUBLE=y
+# CONFIG_UNITY_ENABLE_64BIT is not set
+# CONFIG_UNITY_ENABLE_COLOR is not set
+CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y
+# CONFIG_UNITY_ENABLE_FIXTURE is not set
+# CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL is not set
+# end of Unity unit testing library
+
+#
+# Virtual file system
+#
+CONFIG_VFS_SUPPORT_IO=y
+CONFIG_VFS_SUPPORT_DIR=y
+CONFIG_VFS_SUPPORT_SELECT=y
+CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y
+CONFIG_VFS_SUPPORT_TERMIOS=y
+
+#
+# Host File System I/O (Semihosting)
+#
+CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1
+CONFIG_VFS_SEMIHOSTFS_HOST_PATH_MAX_LEN=128
+# end of Host File System I/O (Semihosting)
+# end of Virtual file system
+
+#
+# Wear Levelling
+#
+# CONFIG_WL_SECTOR_SIZE_512 is not set
+CONFIG_WL_SECTOR_SIZE_4096=y
+CONFIG_WL_SECTOR_SIZE=4096
+# end of Wear Levelling
+
+#
+# Wi-Fi Provisioning Manager
+#
+CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16
+CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30
+# end of Wi-Fi Provisioning Manager
+
+#
+# Supplicant
+#
+CONFIG_WPA_MBEDTLS_CRYPTO=y
+# CONFIG_WPA_WAPI_PSK is not set
+# CONFIG_WPA_SUITE_B_192 is not set
+# CONFIG_WPA_DEBUG_PRINT is not set
+# CONFIG_WPA_TESTING_OPTIONS is not set
+# CONFIG_WPA_WPS_STRICT is not set
+# CONFIG_WPA_11KV_SUPPORT is not set
+# end of Supplicant
+# end of Component config
+
+#
+# Compatibility options
+#
+# CONFIG_LEGACY_INCLUDE_COMMON_HEADERS is not set
+# end of Compatibility options
diff --git a/software/spiffs_image/parameter.dat b/software/spiffs_image/parameter.dat
new file mode 100644
index 0000000..1619f82
--- /dev/null
+++ b/software/spiffs_image/parameter.dat
@@ -0,0 +1,8 @@
+netip=192.168.178.222
+netma=255.255.255.0
+netgw=192.168.178.1
+srvip=192.168.178.115
+srvpo=5432
+boxid=1
+subbx=2
+dbnam=scaladis