From 154c64a454394b4db056eaa3cf2a80d2e4612f8f Mon Sep 17 00:00:00 2001 From: Benjamin Runnels Date: Sat, 9 Apr 2016 15:51:12 -0500 Subject: [PATCH 1/4] windows and visual studio fixes and updates --- esp-link.vcxproj | 3 ++- include/c_types.h | 17 ++++++++--------- include/espmissingincludes.h | 3 --- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/esp-link.vcxproj b/esp-link.vcxproj index 4a1ef3a..9b50cfc 100644 --- a/esp-link.vcxproj +++ b/esp-link.vcxproj @@ -72,6 +72,7 @@ + @@ -140,7 +141,7 @@ __ets__;_STDINT_H;ICACHE_FLASH;__MINGW32__;__WIN32__;MQTT;REST;SYSLOG;FIRMWARE_SIZE - .\syslog;.\rest;.\esp-link;.\mqtt;.\cmd;.\serial;.\user;.\espfs;.\httpd;.\include;..\esp_iot_sdk_v1.5.0\include;..\xtensa-lx106-elf\xtensa-lx106-elf\include;c:\tools\mingw64\x86_64-w64-mingw32\include;c:\tools\mingw64\lib\gcc\x86_64-w64-mingw32\4.8.3\include + .\syslog;.\rest;.\esp-link;.\mqtt;.\cmd;.\serial;.\user;.\espfs;.\httpd;.\include;..\esp_iot_sdk_v1.5.2\include;..\xtensa-lx106-elf\xtensa-lx106-elf\include;c:\tools\mingw64\x86_64-w64-mingw32\include;c:\tools\mingw64\lib\gcc\x86_64-w64-mingw32\4.8.3\include diff --git a/include/c_types.h b/include/c_types.h index 6c4cfbd..673519b 100644 --- a/include/c_types.h +++ b/include/c_types.h @@ -12,20 +12,19 @@ #ifndef _C_TYPES_H_ #define _C_TYPES_H_ -#include #include -//typedef unsigned char uint8_t; +typedef unsigned char uint8_t; typedef signed char sint8_t; -//typedef signed char int8_t; -//typedef unsigned short uint16_t; +typedef signed char int8_t; +typedef unsigned short uint16_t; typedef signed short sint16_t; -//typedef signed short int16_t; -//typedef unsigned long uint32_t; -typedef signed long sint32_t; -//typedef signed long int32_t; +typedef signed short int16_t; +typedef unsigned int uint32_t; +typedef signed int sint32_t; +typedef signed int int32_t; typedef signed long long sint64_t; -//typedef unsigned long long uint64_t; +typedef unsigned long long uint64_t; typedef unsigned long long u_int64_t; typedef float real32_t; typedef double real64_t; diff --git a/include/espmissingincludes.h b/include/espmissingincludes.h index 2c35965..cdc15dd 100644 --- a/include/espmissingincludes.h +++ b/include/espmissingincludes.h @@ -3,9 +3,6 @@ #include #include -#include -#include -#include #include //Missing function prototypes in include folders. Gcc will warn on these if we don't define 'em anywhere. From 41d42babe6c29739cf2dfdab2c8251b7d42081f3 Mon Sep 17 00:00:00 2001 From: Benjamin Runnels Date: Tue, 12 Apr 2016 16:08:02 -0500 Subject: [PATCH 2/4] Restored ability to remove syslog from CFLAGS in Makefile --- esp-link.vcxproj | 7 +++++++ esp-link/cgiservices.c | 4 ++++ esp-link/main.c | 10 ++++++++++ serial/serbridge.c | 6 ++++++ 4 files changed, 27 insertions(+) diff --git a/esp-link.vcxproj b/esp-link.vcxproj index 9b50cfc..88d7277 100644 --- a/esp-link.vcxproj +++ b/esp-link.vcxproj @@ -111,8 +111,14 @@ + + + + + + @@ -122,6 +128,7 @@ + {A92F0CAA-F89B-4F78-AD2A-A042429BD87F} diff --git a/esp-link/cgiservices.c b/esp-link/cgiservices.c index 6b3f553..8718c28 100644 --- a/esp-link/cgiservices.c +++ b/esp-link/cgiservices.c @@ -2,7 +2,9 @@ #include "cgiwifi.h" #include "cgi.h" #include "config.h" +#ifdef SYSLOG #include "syslog.h" +#endif #include "sntp.h" #include "cgimqtt.h" @@ -152,7 +154,9 @@ int ICACHE_FLASH_ATTR cgiServicesSet(HttpdConnData *connData) { if (syslog < 0) return HTTPD_CGI_DONE; if (syslog > 0) { +#ifdef SYSLOG syslog_init(flashConfig.syslog_host); +#endif } int8_t sntp = 0; diff --git a/esp-link/main.c b/esp-link/main.c index bf8c6ef..1094628 100644 --- a/esp-link/main.c +++ b/esp-link/main.c @@ -29,13 +29,23 @@ #include "config.h" #include "log.h" #include "gpio.h" +#ifdef SYSLOG #include "syslog.h" +#endif #include "cgiservices.h" + +#ifdef SYSLOG #define NOTICE(format, ...) do { \ LOG_NOTICE(format, ## __VA_ARGS__ ); \ os_printf(format "\n", ## __VA_ARGS__); \ } while ( 0 ) +#else +#define NOTICE(format, ...) do { \ + os_printf(format "\n", ## __VA_ARGS__); \ +} while ( 0 ) +#endif + /* This is the main url->function dispatching data struct. diff --git a/serial/serbridge.c b/serial/serbridge.c index 1e82e3d..93d3328 100644 --- a/serial/serbridge.c +++ b/serial/serbridge.c @@ -10,7 +10,9 @@ #include "console.h" #include "slip.h" #include "cmd.h" +#ifdef SYSLOG #include "syslog.h" +#endif #define SKIP_AT_RESET @@ -405,12 +407,16 @@ serbridgeConnectCb(void *arg) #ifdef SERBR_DBG os_printf("Accept port %d, conn=%p, pool slot %d\n", conn->proto.tcp->local_port, conn, i); #endif +#ifdef SYSLOG syslog(SYSLOG_FAC_USER, SYSLOG_PRIO_NOTICE, "esp-link", "Accept port %d, conn=%p, pool slot %d\n", conn->proto.tcp->local_port, conn, i); +#endif if (i==MAX_CONN) { #ifdef SERBR_DBG os_printf("Aiee, conn pool overflow!\n"); #endif +#ifdef SYSLOG syslog(SYSLOG_FAC_USER, SYSLOG_PRIO_WARNING, "esp-link", "Aiee, conn pool overflow!\n"); +#endif espconn_disconnect(conn); return; } From 8d803522161bba3bc3a12634b5467032087fd810 Mon Sep 17 00:00:00 2001 From: Benjamin Runnels Date: Tue, 12 Apr 2016 16:17:05 -0500 Subject: [PATCH 3/4] Incorporated changes from #128 --- esp-link/cgiservices.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/esp-link/cgiservices.c b/esp-link/cgiservices.c index 8718c28..1a1b208 100644 --- a/esp-link/cgiservices.c +++ b/esp-link/cgiservices.c @@ -111,21 +111,25 @@ int ICACHE_FLASH_ATTR cgiServicesInfo(HttpdConnData *connData) { os_sprintf(buff, "{ " +#ifdef SYSLOG "\"syslog_host\": \"%s\", " "\"syslog_minheap\": %d, " "\"syslog_filter\": %d, " "\"syslog_showtick\": \"%s\", " "\"syslog_showdate\": \"%s\", " +#endif "\"timezone_offset\": %d, " "\"sntp_server\": \"%s\", " "\"mdns_enable\": \"%s\", " "\"mdns_servername\": \"%s\"" - " }", + " }", +#ifdef SYSLOG flashConfig.syslog_host, flashConfig.syslog_minheap, flashConfig.syslog_filter, flashConfig.syslog_showtick ? "enabled" : "disabled", flashConfig.syslog_showdate ? "enabled" : "disabled", +#endif flashConfig.timezone_offset, flashConfig.sntp_server, flashConfig.mdns_enable ? "enabled" : "disabled", @@ -140,6 +144,7 @@ int ICACHE_FLASH_ATTR cgiServicesInfo(HttpdConnData *connData) { int ICACHE_FLASH_ATTR cgiServicesSet(HttpdConnData *connData) { if (connData->conn == NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. +#ifdef SYSLOG int8_t syslog = 0; syslog |= getStringArg(connData, "syslog_host", flashConfig.syslog_host, sizeof(flashConfig.syslog_host)); @@ -154,10 +159,9 @@ int ICACHE_FLASH_ATTR cgiServicesSet(HttpdConnData *connData) { if (syslog < 0) return HTTPD_CGI_DONE; if (syslog > 0) { -#ifdef SYSLOG syslog_init(flashConfig.syslog_host); -#endif } +#endif int8_t sntp = 0; sntp |= getInt8Arg(connData, "timezone_offset", &flashConfig.timezone_offset); From 3a57e20fa24379f1deb70494851e9c7402c3c697 Mon Sep 17 00:00:00 2001 From: Benjamin Runnels Date: Tue, 12 Apr 2016 16:57:43 -0500 Subject: [PATCH 4/4] Need to hide syslog on the services page if it's not enabled in Makefile modules --- html/services.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/html/services.js b/html/services.js index 17075ff..3d994de 100644 --- a/html/services.js +++ b/html/services.js @@ -51,7 +51,12 @@ function displayServices(data) { $("#sntp-spinner").setAttribute("hidden", ""); $("#mdns-spinner").setAttribute("hidden", ""); - $("#Syslog-form").removeAttribute("hidden"); + if (data.syslog_host) { + $("#Syslog-form").removeAttribute("hidden"); + } else { + $("#Syslog-form").parentNode.setAttribute("hidden", ""); + } + $("#SNTP-form").removeAttribute("hidden"); $("#mDNS-form").removeAttribute("hidden");