From 563957f2d39c730dd6757b395b807e4edc684091 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 15:24:50 -0500 Subject: [PATCH 01/64] Update home.html Updates for changing/selecting telnet ports --- html/home.html | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/html/home.html b/html/home.html index de9862f2..4cdc0e0b 100644 --- a/html/home.html +++ b/html/home.html @@ -50,6 +50,28 @@

Info

the online README for up-to-date help.

+
+

Telnet Serial-Bridge

+

There are two ports available for telnet to use by default: 23   2323

+
+ + + + + +
@@ -152,9 +174,12 @@

System details

onLoad(function() { makeAjaxInput("system", "description"); makeAjaxInput("system", "name"); + makeAjaxInput("telnet", "port1"); + makeAjaxInput("telnet", "port2"); fetchPins(); getWifiInfo(); getSystemInfo(); + getTelnetInfo(); bnd($("#pinform"), "submit", setPins); }); From 143eb24c24534ece72d15c4c92cd08c47c9a7f92 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 15:24:55 -0500 Subject: [PATCH 02/64] Update ui.js Updates for changing/selecting telnet ports --- html/ui.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/html/ui.js b/html/ui.js index 67361c9b..810d96a2 100644 --- a/html/ui.js +++ b/html/ui.js @@ -302,6 +302,22 @@ function getWifiInfo() { function(s, st) { window.setTimeout(getWifiInfo, 1000); }); } +//===== Telnet info + +function showTelnetInfo(data) { + Object.keys(data).forEach(function(v) { + setEditToClick("telnet-"+v, data[v]); + }); + $("#telnet-spinner").setAttribute("hidden", ""); + $("#telnet-table").removeAttribute("hidden"); + currAp = data.ssid; +} + +function getTelnetInfo() { + ajaxJson('GET', "/telnet/info", showTelnetInfo, + function(s, st) { window.setTimeout(getTelnetInfo, 1000); }); +} + //===== System info function showSystemInfo(data) { From eb7fde73675446cc8b70c2fadf06657b7d80af11 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 15:50:29 -0500 Subject: [PATCH 03/64] Update cgipins.c Fixed formatting/extra space --- esp-link/cgipins.c | 1 - 1 file changed, 1 deletion(-) diff --git a/esp-link/cgipins.c b/esp-link/cgipins.c index b763d125..0f62212d 100644 --- a/esp-link/cgipins.c +++ b/esp-link/cgipins.c @@ -1,4 +1,3 @@ - #include #include "cgi.h" #include "espfs.h" From 5cb0350d7e3de48455635f54f5a62f7523e7b637 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 15:55:05 -0500 Subject: [PATCH 04/64] Update config.h Updates for changing/selecting telnet ports. Fixed formatting. --- esp-link/config.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/esp-link/config.h b/esp-link/config.h index 65195d29..ccefd5ee 100644 --- a/esp-link/config.h +++ b/esp-link/config.h @@ -13,8 +13,10 @@ typedef struct { char hostname[32]; // if using DHCP uint32_t staticip, netmask, gateway; // using DHCP if staticip==0 uint8_t log_mode; // UART log debug mode - uint8_t swap_uart; // swap uart0 to gpio 13&15 + uint8_t swap_uart; // swap uart0 to gpio 13&15 uint8_t tcp_enable, rssi_enable; // TCP client settings + uint8_t telnet_port1, // Telnet port settings + telnet_port2; char api_key[48]; // RSSI submission API key (Grovestreams for now) uint8_t slip_enable, mqtt_enable, // SLIP protocol, MQTT client mqtt_status_enable, // MQTT status reporting From fb1bbd34dcae9518b61792f83dfbbc91c474ae37 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 15:57:14 -0500 Subject: [PATCH 05/64] Update config.h Moved new variable at bottom as requested in this header comments. --- esp-link/config.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esp-link/config.h b/esp-link/config.h index ccefd5ee..2b1f93e7 100644 --- a/esp-link/config.h +++ b/esp-link/config.h @@ -15,8 +15,6 @@ typedef struct { uint8_t log_mode; // UART log debug mode uint8_t swap_uart; // swap uart0 to gpio 13&15 uint8_t tcp_enable, rssi_enable; // TCP client settings - uint8_t telnet_port1, // Telnet port settings - telnet_port2; char api_key[48]; // RSSI submission API key (Grovestreams for now) uint8_t slip_enable, mqtt_enable, // SLIP protocol, MQTT client mqtt_status_enable, // MQTT status reporting @@ -43,6 +41,8 @@ typedef struct { int8_t data_bits; int8_t parity; int8_t stop_bits; + uint8_t telnet_port1, // Telnet port settings + telnet_port2; } FlashConfig; extern FlashConfig flashConfig; From 93ca100b1f379984af5320b20309c105d0de7af8 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 15:59:08 -0500 Subject: [PATCH 06/64] Update config.c Updates for changing/selecting telnet ports --- esp-link/config.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/esp-link/config.c b/esp-link/config.c index d12f7a78..8afedbc3 100644 --- a/esp-link/config.c +++ b/esp-link/config.c @@ -35,6 +35,8 @@ FlashConfig flashDefault = { .data_bits = EIGHT_BITS, .parity = NONE_BITS, .stop_bits = ONE_STOP_BIT, + .telnet_port1 = 23, + .telnet_port2 = 2323, }; typedef union { From 02197a9275d7e0cbb4e8ac23d79a4356d1c1e667 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 16:03:28 -0500 Subject: [PATCH 07/64] Create cgitelnet.h Updates for changing/selecting telnet ports --- esp-link/cgitelnet.h | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 esp-link/cgitelnet.h diff --git a/esp-link/cgitelnet.h b/esp-link/cgitelnet.h new file mode 100644 index 00000000..234581ab --- /dev/null +++ b/esp-link/cgitelnet.h @@ -0,0 +1,9 @@ +#ifndef CGITELNET_H +#define CGITELNET_H + +#include "httpd.h" + +int cgiTelnetSet(HttpdConnData *connData); +int cgiTelnetInfo(HttpdConnData *connData); + +#endif // CGITELNET_H From 8919ff6a87bbeab28711d31d7fe21ee480b75395 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 16:28:41 -0500 Subject: [PATCH 08/64] Update cgitelnet.h --- esp-link/cgitelnet.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esp-link/cgitelnet.h b/esp-link/cgitelnet.h index 234581ab..1f160a70 100644 --- a/esp-link/cgitelnet.h +++ b/esp-link/cgitelnet.h @@ -3,7 +3,7 @@ #include "httpd.h" -int cgiTelnetSet(HttpdConnData *connData); -int cgiTelnetInfo(HttpdConnData *connData); +int cgiTelnet(HttpdConnData *connData); +// int8_t telnet_port1, telnet_port2; #endif // CGITELNET_H From f315385534dff36f4019409228730f5a7b9f8cef Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 16:28:44 -0500 Subject: [PATCH 09/64] Create cgitelnet.c Todo: Missing function for init in serbridge? --- esp-link/cgitelnet.c | 79 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 esp-link/cgitelnet.c diff --git a/esp-link/cgitelnet.c b/esp-link/cgitelnet.c new file mode 100644 index 00000000..c65cdf2a --- /dev/null +++ b/esp-link/cgitelnet.c @@ -0,0 +1,79 @@ +#include +#include "cgi.h" +#include "config.h" +#include "serbridge.h" + +// Cgi to return choice of Telnet ports +int ICACHE_FLASH_ATTR cigTelnetGet(HttpdConnData *connData) { + if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted + + char buff[1024]; + int len; + + len = os_sprintf(buff, + "{ \"telnet-port1\":%d, \"telnet-port2\":%d }", + flashConfig.telnet_port1, flashConfig.telnet_port2); + + jsonHeader(connData, 200); + httpdSend(connData, buff, len); + return HTTPD_CGI_DONE; +} + +// Cgi to change choice of Telnet ports +int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { + if (connData->conn==NULL) { + return HTTPD_CGI_DONE; // Connection aborted + } + + int8_t ok = 0; + int8_t port1, port2; + ok |= getInt8Arg(connData, "port1", &port1); + ok |= getInt8Arg(connData, "port2", &port2); + if (ok < 0) return HTTPD_CGI_DONE; + + char *coll; + if (ok > 0) { + // check whether ports are different + uint16_t pins = 0; + if (port1 == port2) { coll = "Ports cannot be the same!"; goto collision; } + + // we're good, set flashconfig + flashConfig.telnet_port1 = port1; + flashConfig.telnet_port2 = port2; + os_printf("Ports changed: port1=%d port2=%d\n", + port1, port2); + + // apply the changes + serbridgeInitPins(); + + // save to flash + if (configSave()) { + httpdStartResponse(connData, 204); + httpdEndHeaders(connData); + } else { + httpdStartResponse(connData, 500); + httpdEndHeaders(connData); + httpdSend(connData, "Failed to save config", -1); + } + } + return HTTPD_CGI_DONE; + +collision: { + char buff[128]; + os_sprintf(buff, "Ports assignment for %s collides with another assignment", coll); + errorResponse(connData, 400, buff); + return HTTPD_CGI_DONE; + } +} + +int ICACHE_FLASH_ATTR cgiTelnet(HttpdConnData *connData) { + if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. + if (connData->requestType == HTTPD_METHOD_GET) { + return cgiTelnetGet(connData); + } else if (connData->requestType == HTTPD_METHOD_POST) { + return cgiTelnetSet(connData); + } else { + jsonHeader(connData, 404); + return HTTPD_CGI_DONE; + } +} From 59edf885e6b46fea5593b0d90b41553d583afa71 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 16:37:03 -0500 Subject: [PATCH 10/64] Update serbridge.c Updates for changing/selecting telnet ports -Add function to reinit serbridge after change Telnet ports. --- serial/serbridge.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/serial/serbridge.c b/serial/serbridge.c index cebc5615..ce4693fd 100644 --- a/serial/serbridge.c +++ b/serial/serbridge.c @@ -469,6 +469,8 @@ serbridgeInitPins() } // Start transparent serial bridge TCP server on specified port (typ. 23) +// Here is where we need to change the ports. But how do we do this from the Ajax call? + void ICACHE_FLASH_ATTR serbridgeInit(int port1, int port2) { @@ -501,6 +503,12 @@ serbridgeInit(int port1, int port2) espconn_regist_time(&serbridgeConn2, SER_BRIDGE_TIMEOUT, 0); } +//Reinit serial bridge after changing telnet ports +serbridgeReinit() +{ + serbridgeInit(flashConfig.telnet_port1, flashConfig.telnet_port2); +} + int ICACHE_FLASH_ATTR serbridgeInMCUFlashing() { return in_mcu_flashing; From 6054496e3d78fe80aab9aa1bc8d5c6644658a71e Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 16:38:12 -0500 Subject: [PATCH 11/64] Update serbridge.c --- serial/serbridge.c | 1 + 1 file changed, 1 insertion(+) diff --git a/serial/serbridge.c b/serial/serbridge.c index ce4693fd..f99c7082 100644 --- a/serial/serbridge.c +++ b/serial/serbridge.c @@ -504,6 +504,7 @@ serbridgeInit(int port1, int port2) } //Reinit serial bridge after changing telnet ports +void ICACHE_FLASH_ATTR serbridgeReinit() { serbridgeInit(flashConfig.telnet_port1, flashConfig.telnet_port2); From a230f4262cf9b48ded3b5485ac585458a3aaa5ee Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 16:44:25 -0500 Subject: [PATCH 12/64] Update main.c Updates for changing/selecting telnet ports --- esp-link/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/esp-link/main.c b/esp-link/main.c index e775de9d..020d9838 100644 --- a/esp-link/main.c +++ b/esp-link/main.c @@ -32,6 +32,7 @@ #include "gpio.h" #include "cgiservices.h" #include "web-server.h" +#include "cgitelnet.h" #ifdef SYSLOG #include "syslog.h" @@ -96,6 +97,7 @@ HttpdBuiltInUrl builtInUrls[] = { { "/services/info", cgiServicesInfo, NULL }, { "/services/update", cgiServicesSet, NULL }, { "/pins", cgiPins, NULL }, + { "/telnet", cigTelnet, NULL}, #ifdef MQTT { "/mqtt", cgiMqtt, NULL }, #endif From 4bddea7caccfe13986f798a321af8ac05dbb6ff6 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 16:48:37 -0500 Subject: [PATCH 13/64] Update main.c --- esp-link/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/esp-link/main.c b/esp-link/main.c index 020d9838..8086b57a 100644 --- a/esp-link/main.c +++ b/esp-link/main.c @@ -97,7 +97,8 @@ HttpdBuiltInUrl builtInUrls[] = { { "/services/info", cgiServicesInfo, NULL }, { "/services/update", cgiServicesSet, NULL }, { "/pins", cgiPins, NULL }, - { "/telnet", cigTelnet, NULL}, + { "/telnet", cgiTelnet, NULL}, + { "/telnet/update", cgiTelnet, NULL}, #ifdef MQTT { "/mqtt", cgiMqtt, NULL }, #endif From 04bbccb6af51b7fa1cf2d1035ef14f1903fac288 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 16:49:47 -0500 Subject: [PATCH 14/64] Update main.c --- esp-link/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esp-link/main.c b/esp-link/main.c index 8086b57a..c89bcb43 100644 --- a/esp-link/main.c +++ b/esp-link/main.c @@ -97,7 +97,7 @@ HttpdBuiltInUrl builtInUrls[] = { { "/services/info", cgiServicesInfo, NULL }, { "/services/update", cgiServicesSet, NULL }, { "/pins", cgiPins, NULL }, - { "/telnet", cgiTelnet, NULL}, + { "/telnet/info", cgiTelnet, NULL}, { "/telnet/update", cgiTelnet, NULL}, #ifdef MQTT { "/mqtt", cgiMqtt, NULL }, From 936951d8819bc8b4cea55f66b9795fe4ed2644b9 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 16:54:41 -0500 Subject: [PATCH 15/64] Update main.c Make sure we use our custom telnet ports at bootup --- esp-link/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esp-link/main.c b/esp-link/main.c index c89bcb43..8315ff90 100644 --- a/esp-link/main.c +++ b/esp-link/main.c @@ -182,7 +182,7 @@ user_init(void) { WEB_Init(); // init the wifi-serial transparent bridge (port 23) - serbridgeInit(23, 2323); + serbridgeInit(flashConfig.telnet_port1, flashConfig.telnet_port1); uart_add_recv_cb(&serbridgeUartCb); #ifdef SHOW_HEAP_USE os_timer_disarm(&prHeapTimer); From 0009d8f6aa9e7ff902d813270c230dd92563d71b Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 17:04:05 -0500 Subject: [PATCH 16/64] Update cgitelnet.c Fixed bad variable reference --- esp-link/cgitelnet.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/esp-link/cgitelnet.c b/esp-link/cgitelnet.c index c65cdf2a..60ac7671 100644 --- a/esp-link/cgitelnet.c +++ b/esp-link/cgitelnet.c @@ -34,7 +34,6 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { char *coll; if (ok > 0) { // check whether ports are different - uint16_t pins = 0; if (port1 == port2) { coll = "Ports cannot be the same!"; goto collision; } // we're good, set flashconfig @@ -44,7 +43,7 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { port1, port2); // apply the changes - serbridgeInitPins(); + serbridgeReinit(); // save to flash if (configSave()) { From bead65fbb9612bb2f25ff1d2c43f21d46e45f2d2 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 17:14:58 -0500 Subject: [PATCH 17/64] Update cgitelnet.c Fix implicit function call. --- esp-link/cgitelnet.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/esp-link/cgitelnet.c b/esp-link/cgitelnet.c index 60ac7671..719ae27a 100644 --- a/esp-link/cgitelnet.c +++ b/esp-link/cgitelnet.c @@ -43,7 +43,8 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { port1, port2); // apply the changes - serbridgeReinit(); + //serbridgeReinit(); + serbridgeInit(flashConfig.telnet_port1, flashConfig.telnet_port2); // save to flash if (configSave()) { From c3a3b06bb4c3f2fadc014dfacc391139054c86cb Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 17:15:34 -0500 Subject: [PATCH 18/64] Update serbridge.c Remove unecssary function --- serial/serbridge.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/serial/serbridge.c b/serial/serbridge.c index f99c7082..1a0646a8 100644 --- a/serial/serbridge.c +++ b/serial/serbridge.c @@ -503,13 +503,6 @@ serbridgeInit(int port1, int port2) espconn_regist_time(&serbridgeConn2, SER_BRIDGE_TIMEOUT, 0); } -//Reinit serial bridge after changing telnet ports -void ICACHE_FLASH_ATTR -serbridgeReinit() -{ - serbridgeInit(flashConfig.telnet_port1, flashConfig.telnet_port2); -} - int ICACHE_FLASH_ATTR serbridgeInMCUFlashing() { return in_mcu_flashing; From 67a05de430471866af199c5a9fdb56e7685e33c9 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 17:17:40 -0500 Subject: [PATCH 19/64] Update cgitelnet.c Fixed a stupid typo in a function name. --- esp-link/cgitelnet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esp-link/cgitelnet.c b/esp-link/cgitelnet.c index 719ae27a..7033fdcf 100644 --- a/esp-link/cgitelnet.c +++ b/esp-link/cgitelnet.c @@ -4,7 +4,7 @@ #include "serbridge.h" // Cgi to return choice of Telnet ports -int ICACHE_FLASH_ATTR cigTelnetGet(HttpdConnData *connData) { +int ICACHE_FLASH_ATTR cgiTelnetGet(HttpdConnData *connData) { if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted char buff[1024]; From 1cf190a1c3c7efadc349fb7f9af8f5fe9edc451d Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 17:25:14 -0500 Subject: [PATCH 20/64] Update cgitelnet.c Changed function for unsigned integers. --- esp-link/cgitelnet.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/esp-link/cgitelnet.c b/esp-link/cgitelnet.c index 7033fdcf..aa4b9633 100644 --- a/esp-link/cgitelnet.c +++ b/esp-link/cgitelnet.c @@ -26,9 +26,9 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { } int8_t ok = 0; - int8_t port1, port2; - ok |= getInt8Arg(connData, "port1", &port1); - ok |= getInt8Arg(connData, "port2", &port2); + uint8_t port1, port2; + ok |= getUInt8Arg(connData, "port1", &port1); + ok |= getUInt8Arg(connData, "port2", &port2); if (ok < 0) return HTTPD_CGI_DONE; char *coll; From 6fb97bdf6dbcfd795304d36eb6158506fcfe9e31 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 17:32:35 -0500 Subject: [PATCH 21/64] Update config.h Changed flashconfig.telnet_port to unsigned 16bit integer. --- esp-link/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esp-link/config.h b/esp-link/config.h index 2b1f93e7..2f5aede8 100644 --- a/esp-link/config.h +++ b/esp-link/config.h @@ -41,7 +41,7 @@ typedef struct { int8_t data_bits; int8_t parity; int8_t stop_bits; - uint8_t telnet_port1, // Telnet port settings + uint16_t telnet_port1, // Telnet port settings telnet_port2; } FlashConfig; extern FlashConfig flashConfig; From a01db3260db263dd6e9882b31f46a916ee939695 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2016 17:33:12 -0500 Subject: [PATCH 22/64] Update cgitelnet.c Changed functions for unsigned 16bit integer. --- esp-link/cgitelnet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esp-link/cgitelnet.c b/esp-link/cgitelnet.c index aa4b9633..7f8d3de3 100644 --- a/esp-link/cgitelnet.c +++ b/esp-link/cgitelnet.c @@ -27,8 +27,8 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { int8_t ok = 0; uint8_t port1, port2; - ok |= getUInt8Arg(connData, "port1", &port1); - ok |= getUInt8Arg(connData, "port2", &port2); + ok |= getUInt16Arg(connData, "port1", &port1); + ok |= getUInt16Arg(connData, "port2", &port2); if (ok < 0) return HTTPD_CGI_DONE; char *coll; From 157569e47987c9c217d52304c1f271bc16fd0aaf Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 28 Oct 2016 10:07:44 -0500 Subject: [PATCH 23/64] Cgitelnet changes/fixes Corrected several mistakes (16 vs 8bit int) Check to see which variable we are modifying & fill the other one from flag so we can make sure they do NOT conflict. Added return error http header using existing collision goto. --- esp-link/cgitelnet.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/esp-link/cgitelnet.c b/esp-link/cgitelnet.c index 7f8d3de3..9070f993 100644 --- a/esp-link/cgitelnet.c +++ b/esp-link/cgitelnet.c @@ -26,13 +26,17 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { } int8_t ok = 0; - uint8_t port1, port2; + uint16_t port1, port2; ok |= getUInt16Arg(connData, "port1", &port1); ok |= getUInt16Arg(connData, "port2", &port2); - if (ok < 0) return HTTPD_CGI_DONE; + if (ok < 0) { coll = "Failed to set ports. Ports appear to be invalid"; goto collision; } char *coll; if (ok > 0) { + // fill both port variables from flash or ajax provided value + if (!port1) port1 = flashConfig.telnet_port1; + if (!port2) port2 = flashConfig.telnet_port2; + // check whether ports are different if (port1 == port2) { coll = "Ports cannot be the same!"; goto collision; } @@ -40,11 +44,7 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { flashConfig.telnet_port1 = port1; flashConfig.telnet_port2 = port2; os_printf("Ports changed: port1=%d port2=%d\n", - port1, port2); - - // apply the changes - //serbridgeReinit(); - serbridgeInit(flashConfig.telnet_port1, flashConfig.telnet_port2); + flashConfig.telnet_port1, flashConfig.telnet_port2); // save to flash if (configSave()) { @@ -55,10 +55,13 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { httpdEndHeaders(connData); httpdSend(connData, "Failed to save config", -1); } + + // apply the changes + serbridgeInit(flashConfig.telnet_port1, flashConfig.telnet_port2); } return HTTPD_CGI_DONE; -collision: { + collision: { char buff[128]; os_sprintf(buff, "Ports assignment for %s collides with another assignment", coll); errorResponse(connData, 400, buff); From fe95b4bc509f174d398a185180f80a401bf6a053 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 28 Oct 2016 10:08:14 -0500 Subject: [PATCH 24/64] Cleanup Remove unecessary comments --- esp-link/cgitelnet.h | 1 - serial/serbridge.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/esp-link/cgitelnet.h b/esp-link/cgitelnet.h index 1f160a70..516d5d9f 100644 --- a/esp-link/cgitelnet.h +++ b/esp-link/cgitelnet.h @@ -4,6 +4,5 @@ #include "httpd.h" int cgiTelnet(HttpdConnData *connData); -// int8_t telnet_port1, telnet_port2; #endif // CGITELNET_H diff --git a/serial/serbridge.c b/serial/serbridge.c index 1a0646a8..cebc5615 100644 --- a/serial/serbridge.c +++ b/serial/serbridge.c @@ -469,8 +469,6 @@ serbridgeInitPins() } // Start transparent serial bridge TCP server on specified port (typ. 23) -// Here is where we need to change the ports. But how do we do this from the Ajax call? - void ICACHE_FLASH_ATTR serbridgeInit(int port1, int port2) { From ffd13c6e0ae493b56a5353dac9814506fa31b30e Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 28 Oct 2016 10:09:28 -0500 Subject: [PATCH 25/64] Ajax/Html changes Changes made so we can use a single namespace "/telnet" vs two. Somewhat dirty fix inserted into existing ajax function. --- esp-link/main.c | 3 +-- html/ui.js | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/esp-link/main.c b/esp-link/main.c index 8315ff90..d70e86ae 100644 --- a/esp-link/main.c +++ b/esp-link/main.c @@ -97,8 +97,7 @@ HttpdBuiltInUrl builtInUrls[] = { { "/services/info", cgiServicesInfo, NULL }, { "/services/update", cgiServicesSet, NULL }, { "/pins", cgiPins, NULL }, - { "/telnet/info", cgiTelnet, NULL}, - { "/telnet/update", cgiTelnet, NULL}, + { "/telnet", cgiTelnet, NULL}, #ifdef MQTT { "/mqtt", cgiMqtt, NULL }, #endif diff --git a/html/ui.js b/html/ui.js index 810d96a2..f4f1cd97 100644 --- a/html/ui.js +++ b/html/ui.js @@ -314,7 +314,7 @@ function showTelnetInfo(data) { } function getTelnetInfo() { - ajaxJson('GET', "/telnet/info", showTelnetInfo, + ajaxJson('GET', "/telnet", showTelnetInfo, function(s, st) { window.setTimeout(getTelnetInfo, 1000); }); } @@ -339,6 +339,8 @@ function makeAjaxInput(klass, field) { var eon = $(".edit-on", div); var eoff = $(".edit-off", div)[0]; var url = "/"+klass+"/update?"+field; + //Dirty fix to avoid to seperate name spaces to GET or PUT telnet ports + if (klass == "telnet") { var url = "/"+klass+"?"+field; } if (eoff === undefined || eon == undefined) return; From 3cb3804a9fe5cd470952819931df44fb44b9e284 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 28 Oct 2016 10:14:51 -0500 Subject: [PATCH 26/64] Cgitelnet update Place variable declartion in correct place. --- esp-link/cgitelnet.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/esp-link/cgitelnet.c b/esp-link/cgitelnet.c index 9070f993..7895bf0f 100644 --- a/esp-link/cgitelnet.c +++ b/esp-link/cgitelnet.c @@ -24,14 +24,13 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { if (connData->conn==NULL) { return HTTPD_CGI_DONE; // Connection aborted } - + char *coll; int8_t ok = 0; uint16_t port1, port2; ok |= getUInt16Arg(connData, "port1", &port1); ok |= getUInt16Arg(connData, "port2", &port2); if (ok < 0) { coll = "Failed to set ports. Ports appear to be invalid"; goto collision; } - char *coll; if (ok > 0) { // fill both port variables from flash or ajax provided value if (!port1) port1 = flashConfig.telnet_port1; From a9f583e0775c6af6729cdb4fe18d83ec11065a92 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 28 Oct 2016 10:24:39 -0500 Subject: [PATCH 27/64] Update cgitelnet.c --- esp-link/cgitelnet.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/esp-link/cgitelnet.c b/esp-link/cgitelnet.c index 7895bf0f..8c489856 100644 --- a/esp-link/cgitelnet.c +++ b/esp-link/cgitelnet.c @@ -24,12 +24,13 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { if (connData->conn==NULL) { return HTTPD_CGI_DONE; // Connection aborted } + char *coll; int8_t ok = 0; uint16_t port1, port2; ok |= getUInt16Arg(connData, "port1", &port1); ok |= getUInt16Arg(connData, "port2", &port2); - if (ok < 0) { coll = "Failed to set ports. Ports appear to be invalid"; goto collision; } + if (ok < 0) { coll = "Failed to fetch ports. Are they valid?"; goto collision; } if (ok > 0) { // fill both port variables from flash or ajax provided value From 7a93821c4c1c657e967fadccdd4dc9fb0ff24d93 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 28 Oct 2016 10:31:23 -0500 Subject: [PATCH 28/64] Update cgitelnet.c --- esp-link/cgitelnet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esp-link/cgitelnet.c b/esp-link/cgitelnet.c index 8c489856..117a80c2 100644 --- a/esp-link/cgitelnet.c +++ b/esp-link/cgitelnet.c @@ -25,7 +25,7 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { return HTTPD_CGI_DONE; // Connection aborted } - char *coll; + char coll[64]; int8_t ok = 0; uint16_t port1, port2; ok |= getUInt16Arg(connData, "port1", &port1); From 00d8b9ff83d540cc121c2df47382e1f82b92a474 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 28 Oct 2016 10:33:44 -0500 Subject: [PATCH 29/64] Update cgitelnet.c --- esp-link/cgitelnet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esp-link/cgitelnet.c b/esp-link/cgitelnet.c index 117a80c2..8c489856 100644 --- a/esp-link/cgitelnet.c +++ b/esp-link/cgitelnet.c @@ -25,7 +25,7 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { return HTTPD_CGI_DONE; // Connection aborted } - char coll[64]; + char *coll; int8_t ok = 0; uint16_t port1, port2; ok |= getUInt16Arg(connData, "port1", &port1); From 973e4fbda923d5d3223d3be93ea62179eb7ba7ee Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 28 Oct 2016 10:48:20 -0500 Subject: [PATCH 30/64] Update .travis.yml From b79a6d6a5d0189a86801fc24bf70556e4c81b944 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 28 Oct 2016 11:45:49 -0500 Subject: [PATCH 31/64] update for s3 --- .travis.yml | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index 008251c9..d7fb9f3a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,31 +1,27 @@ -# Travis-CI file for Esp-Link - language: c - before_install: - - curl -Ls http://s3.voneicken.com/xtensa-lx106-elf-20160330.tgx | tar Jxf - - - curl -Ls http://s3.voneicken.com/esp_iot_sdk_v2.0.0.p1.tgx | tar -C .. -Jxf - - +- curl -Ls http://s3.voneicken.com/xtensa-lx106-elf-20160330.tgx | tar Jxf - +- curl -Ls http://s3.voneicken.com/esp_iot_sdk_v2.0.0.p1.tgx | tar -C .. -Jxf - after_script: - # upload to an S3 bucket, requires S3_BUCKET, AWS_ACCESS_KEY_ID and AWS_SECRET_KEY to be set - # in environment using travis' repository settings - - "if [[ -n \"$S3_BUCKET\" && -n \"$AWS_ACCESS_KEY_ID\" ]]; then - echo Uploading *.tgz to $S3_BUCKET; - curl -Ls https://github.com/rlmcpherson/s3gof3r/releases/download/v0.5.0/gof3r_0.5.0_linux_amd64.tar.gz | tar zxf - gof3r_0.5.0_linux_amd64/gof3r; - mv gof3r*/gof3r .; - ls *.tgz | xargs -I {} ./gof3r put -b $S3_BUCKET -k esp-link/{} --acl public-read -p {}; - ls *.tgz | xargs -I {} echo \"URL: http://$S3_BUCKET/esp-link/{}\"; - fi" - +- 'if [[ -n "$S3_BUCKET" && -n "$AWS_ACCESS_KEY_ID" ]]; then echo Uploading *.tgz + to $S3_BUCKET; curl -Ls https://github.com/rlmcpherson/s3gof3r/releases/download/v0.5.0/gof3r_0.5.0_linux_amd64.tar.gz + | tar zxf - gof3r_0.5.0_linux_amd64/gof3r; mv gof3r*/gof3r .; ls *.tgz | xargs -I + {} ./gof3r put -b $S3_BUCKET -k esp-link/{} --acl public-read -p {}; ls *.tgz | + xargs -I {} echo "URL: http://$S3_BUCKET/esp-link/{}"; fi' compiler: gcc - -env: - +env: script: - - export XTENSA_TOOLS_ROOT=$PWD/xtensa-lx106-elf/bin/ - - export BRANCH=$TRAVIS_BRANCH - #- export SDK_BASE=$PWD/esp_iot_sdk_v2.0.0.p1 - - make release - +- export XTENSA_TOOLS_ROOT=$PWD/xtensa-lx106-elf/bin/ +- export BRANCH=$TRAVIS_BRANCH +- make release notifications: email: false +deploy: + provider: s3 + access_key_id: AKIAJMURU2SAG7X3FHEQ + secret_access_key: + secure: ppGD7SLjj1VAVDQQi7gAHCSbpJjJPHCdUS1DXMzNRaCHMnYibMbU2qlKW8aOiMtYQJ2/VkXWUWmu20iebN4Y2qN315v7D2eQLacUvkuAxTKXsZbqvHJ/q+z3Kjdb6RagymQ5gNvEjkPqddrp2FSTtWLE6l0ddh+/kSbY0Ia6Jju1rL0ayNrRvy9gzkeY8U5d/1qjfC8PIrvXY+/2NNqvTM11igVcaFnFFKXDXpwkDU/nVvrBcZK5HstiI98IlJz7okmPoMf5SbXPsCUCPumDHxexaAyOtdrnhvnixEzDTeVUjhwOgtMqkf+NV5PddmiQ1OOEOci4QmdIt6895F4zS9s+WU770Mek9pKW5FmTAzPauwevARGXv8kD2FZp53Vinei5haESBTkLer40WGpbh+DDuDoKIflgJICbSXCr78bojrTW507sg5QqSrXclPI5nRQs3n+vUNE2yniWuxfNiCe5kc9+bsGQDWNQqwvaPeZF4FDTyi+2u52WS5vabhjnxnl7iK9NQzlYagXRQUOb5QOBtxZkyy46azLXdqMx9ihlkdbLNFkNou0wqXPKQIFj3RgcjQx3Wx18kuypqn13C2v4w0L9aL2WtDfEQFEwX/8bUcYwzJNtFmq+2pRXmJG+kkoSzhxHRwN54gdlBiIOjJnJTFCoH0GWp6uG6pN+7BA= + bucket: http://s3.amazonaws.com/esp-link + acl: public_read + on: + repo: fuzzball03/esp-link From d887febb3ecd3ecf9fb5cd0228a1c79ec9664fb2 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 28 Oct 2016 12:07:25 -0500 Subject: [PATCH 32/64] Update .travis.yml --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index d7fb9f3a..a4b0fa07 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,11 +17,11 @@ script: notifications: email: false deploy: - provider: s3 - access_key_id: AKIAJMURU2SAG7X3FHEQ - secret_access_key: - secure: ppGD7SLjj1VAVDQQi7gAHCSbpJjJPHCdUS1DXMzNRaCHMnYibMbU2qlKW8aOiMtYQJ2/VkXWUWmu20iebN4Y2qN315v7D2eQLacUvkuAxTKXsZbqvHJ/q+z3Kjdb6RagymQ5gNvEjkPqddrp2FSTtWLE6l0ddh+/kSbY0Ia6Jju1rL0ayNrRvy9gzkeY8U5d/1qjfC8PIrvXY+/2NNqvTM11igVcaFnFFKXDXpwkDU/nVvrBcZK5HstiI98IlJz7okmPoMf5SbXPsCUCPumDHxexaAyOtdrnhvnixEzDTeVUjhwOgtMqkf+NV5PddmiQ1OOEOci4QmdIt6895F4zS9s+WU770Mek9pKW5FmTAzPauwevARGXv8kD2FZp53Vinei5haESBTkLer40WGpbh+DDuDoKIflgJICbSXCr78bojrTW507sg5QqSrXclPI5nRQs3n+vUNE2yniWuxfNiCe5kc9+bsGQDWNQqwvaPeZF4FDTyi+2u52WS5vabhjnxnl7iK9NQzlYagXRQUOb5QOBtxZkyy46azLXdqMx9ihlkdbLNFkNou0wqXPKQIFj3RgcjQx3Wx18kuypqn13C2v4w0L9aL2WtDfEQFEwX/8bUcYwzJNtFmq+2pRXmJG+kkoSzhxHRwN54gdlBiIOjJnJTFCoH0GWp6uG6pN+7BA= - bucket: http://s3.amazonaws.com/esp-link - acl: public_read + provider: releases + api_key: + secure: unYyTCLpk1ixcNOyoUwroBqqx0yBhii56IXm57kjo5kl3umf1GRb3FUIE6la+B0njsNwAUNR/uLn6wF4FqYTUJzNQZskJDJfZjb53vwuoHaoa5j4K/bWB9zRlQ1XZBTkV48cxz8Ef2KyNduK2IciOHwsw3LQS0em3dpK7oG/20VzELt23Gx8uhBYa+OUzlr3Y+PYPynkwM30YwVQXpCy/GMgEbrcKheGbLTAIp7tms0KDAvbb98U0BI3tWBckE5GzAYYAmrXgyDXtEsU/poCMqUj/lpPl1s/5uxGVevTO7XuL4AYtF//AixsM20bPKtIZDHZS9b7JHtVhU655bY2aAfpMgf7xzkKbJkRzeAzT9HucFDjLY48yW4vztdJxBgkAL9d064gTHhThtn4hylZAYpHnqUiM0j4DKil5A0VG2F8EVEqZ7Q2tNzy6aqq37wzTuYXsYpz3mglpazaXXp/LoSurDHy1gz6aB/mdaeBoL3MX1q09LBE8lFGYBILQ8KUkrLyJathxAVvDBnl7nXFv2NWoZ2i7CfXdpCwmOVUN2WhudNfgbbaMung+voTFB+yLq9PBQP5gdP0MKU3zDTB/msmZo1pp/SbnNETCrKAdRtxNI+bxTQ98njAIkxI+7ZiVV8SMNEPyNcWq/6ViYDcIHJMR4Gq0DZunre1voEs1F4= + file_glob: true + file: esp-link-master-*.t*gz on: + tags: true repo: fuzzball03/esp-link From e25d8960fa6474b44b5e538ab6969f3636128648 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 28 Oct 2016 12:10:40 -0500 Subject: [PATCH 33/64] Update .travis.yml --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a4b0fa07..ea71de15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,5 +23,4 @@ deploy: file_glob: true file: esp-link-master-*.t*gz on: - tags: true repo: fuzzball03/esp-link From 30658c567362c764bcc338c3908cdefde2eba007 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 28 Oct 2016 12:15:33 -0500 Subject: [PATCH 34/64] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index ea71de15..94cddc44 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ script: notifications: email: false deploy: + skip_cleanup: true provider: releases api_key: secure: unYyTCLpk1ixcNOyoUwroBqqx0yBhii56IXm57kjo5kl3umf1GRb3FUIE6la+B0njsNwAUNR/uLn6wF4FqYTUJzNQZskJDJfZjb53vwuoHaoa5j4K/bWB9zRlQ1XZBTkV48cxz8Ef2KyNduK2IciOHwsw3LQS0em3dpK7oG/20VzELt23Gx8uhBYa+OUzlr3Y+PYPynkwM30YwVQXpCy/GMgEbrcKheGbLTAIp7tms0KDAvbb98U0BI3tWBckE5GzAYYAmrXgyDXtEsU/poCMqUj/lpPl1s/5uxGVevTO7XuL4AYtF//AixsM20bPKtIZDHZS9b7JHtVhU655bY2aAfpMgf7xzkKbJkRzeAzT9HucFDjLY48yW4vztdJxBgkAL9d064gTHhThtn4hylZAYpHnqUiM0j4DKil5A0VG2F8EVEqZ7Q2tNzy6aqq37wzTuYXsYpz3mglpazaXXp/LoSurDHy1gz6aB/mdaeBoL3MX1q09LBE8lFGYBILQ8KUkrLyJathxAVvDBnl7nXFv2NWoZ2i7CfXdpCwmOVUN2WhudNfgbbaMung+voTFB+yLq9PBQP5gdP0MKU3zDTB/msmZo1pp/SbnNETCrKAdRtxNI+bxTQ98njAIkxI+7ZiVV8SMNEPyNcWq/6ViYDcIHJMR4Gq0DZunre1voEs1F4= From 8cd915ff6bb01d7c5b74b28c5ebb191876647c67 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 28 Oct 2016 13:02:40 -0500 Subject: [PATCH 35/64] Cgitelnet reform json output --- esp-link/cgitelnet.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/esp-link/cgitelnet.c b/esp-link/cgitelnet.c index 8c489856..a00078dc 100644 --- a/esp-link/cgitelnet.c +++ b/esp-link/cgitelnet.c @@ -9,9 +9,12 @@ int ICACHE_FLASH_ATTR cgiTelnetGet(HttpdConnData *connData) { char buff[1024]; int len; - + + os_printf("Current telnet ports: port1=%d port2=%d\n", + flashConfig.telnet_port1, flashConfig.telnet_port2); + len = os_sprintf(buff, - "{ \"telnet-port1\":%d, \"telnet-port2\":%d }", + "{ \"telnet-port1\" \":%d\", \"telnet-port2\": \"%d\" }", flashConfig.telnet_port1, flashConfig.telnet_port2); jsonHeader(connData, 200); @@ -43,7 +46,7 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { // we're good, set flashconfig flashConfig.telnet_port1 = port1; flashConfig.telnet_port2 = port2; - os_printf("Ports changed: port1=%d port2=%d\n", + os_printf("Telnet ports changed: port1=%d port2=%d\n", flashConfig.telnet_port1, flashConfig.telnet_port2); // save to flash From 1da3ce7ac9513c516e7bcb786e619e7b8e7edd0f Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 28 Oct 2016 13:10:21 -0500 Subject: [PATCH 36/64] Update cgitelnet.c --- esp-link/cgitelnet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esp-link/cgitelnet.c b/esp-link/cgitelnet.c index a00078dc..1c53b16a 100644 --- a/esp-link/cgitelnet.c +++ b/esp-link/cgitelnet.c @@ -14,7 +14,7 @@ int ICACHE_FLASH_ATTR cgiTelnetGet(HttpdConnData *connData) { flashConfig.telnet_port1, flashConfig.telnet_port2); len = os_sprintf(buff, - "{ \"telnet-port1\" \":%d\", \"telnet-port2\": \"%d\" }", + "{ \"telnet-port1\": \"%d\", \"telnet-port2\": \"%d\" }", flashConfig.telnet_port1, flashConfig.telnet_port2); jsonHeader(connData, 200); From 6a730e7539fed29b84aca899066774f5e40b3861 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 28 Oct 2016 13:15:32 -0500 Subject: [PATCH 37/64] Update cgitelnet.c --- esp-link/cgitelnet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esp-link/cgitelnet.c b/esp-link/cgitelnet.c index 1c53b16a..1ffe3f9b 100644 --- a/esp-link/cgitelnet.c +++ b/esp-link/cgitelnet.c @@ -14,7 +14,7 @@ int ICACHE_FLASH_ATTR cgiTelnetGet(HttpdConnData *connData) { flashConfig.telnet_port1, flashConfig.telnet_port2); len = os_sprintf(buff, - "{ \"telnet-port1\": \"%d\", \"telnet-port2\": \"%d\" }", + "{ \"port1\": \"%d\", \"port2\": \"%d\" }", flashConfig.telnet_port1, flashConfig.telnet_port2); jsonHeader(connData, 200); From 7d605209c91d7bfedd9f682e7b67e231bce307ed Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 28 Oct 2016 14:41:21 -0500 Subject: [PATCH 38/64] Update home.html --- html/home.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/html/home.html b/html/home.html index 4cdc0e0b..d2c9791c 100644 --- a/html/home.html +++ b/html/home.html @@ -52,21 +52,22 @@

Info

Telnet Serial-Bridge

-

There are two ports available for telnet to use by default: 23   2323

+

There are two ports available for telnet to use by default: 23 & 2323
+ Note - this time, only port1 may be changed & used sucessfully.

From 338f9838b2ea94bd6cd1adc4e41b4912e1058b39 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 30 Oct 2016 22:43:36 -0500 Subject: [PATCH 39/64] Update readme to reflect changes --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 17ef3a0d..3bda6151 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,8 @@ From there, more advanced steps are: ### Serial bridge +Note that the default ports of 23 & 2323 may be changed via the webinterface. + In order to connect through the esp-link to a microcontroller use port 23. For example, on linux you can use `nc esp-hostname 23` or `telnet esp-hostname 23`. From 3fdfe93bd4c470a78133503640588d606cf2e145 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 30 Oct 2016 22:45:14 -0500 Subject: [PATCH 40/64] Various changes Added new function to reset serial bridge. Modified other serial bridge functions. Add variables to later allow for the connection type to be changed(secured, etc). Set flash values for telnet to defaults if they are not set or =0. --- esp-link/cgitelnet.c | 28 +++++++++++-------- esp-link/config.c | 5 ++++ esp-link/config.h | 4 ++- esp-link/main.c | 5 +++- html/home.html | 2 +- serial/serbridge.c | 66 +++++++++++++++++++++++++------------------- serial/serbridge.h | 4 +-- 7 files changed, 70 insertions(+), 44 deletions(-) diff --git a/esp-link/cgitelnet.c b/esp-link/cgitelnet.c index 1ffe3f9b..c3a8c00d 100644 --- a/esp-link/cgitelnet.c +++ b/esp-link/cgitelnet.c @@ -28,12 +28,16 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { return HTTPD_CGI_DONE; // Connection aborted } - char *coll; int8_t ok = 0; uint16_t port1, port2; ok |= getUInt16Arg(connData, "port1", &port1); ok |= getUInt16Arg(connData, "port2", &port2); - if (ok < 0) { coll = "Failed to fetch ports. Are they valid?"; goto collision; } + if (ok <= 0) { //If we get at least one good value, this should be >= 1 + os_printf("Unable to fetch telnet ports.\n Received: port1=%d port2=%d\n", + flashConfig.telnet_port1, flashConfig.telnet_port2); + errorResponse(connData, 400, buff); + return HTTPD_CGI_DONE; + } if (ok > 0) { // fill both port variables from flash or ajax provided value @@ -41,13 +45,18 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { if (!port2) port2 = flashConfig.telnet_port2; // check whether ports are different - if (port1 == port2) { coll = "Ports cannot be the same!"; goto collision; } + if (port1 == port2) { + os_printf("Ports cannot be the same.\n Tried to set: port1=%d port2=%d\n", + flashConfig.telnet_port1, flashConfig.telnet_port2); + errorResponse(connData, 400, buff); + return HTTPD_CGI_DONE; + } // we're good, set flashconfig flashConfig.telnet_port1 = port1; flashConfig.telnet_port2 = port2; os_printf("Telnet ports changed: port1=%d port2=%d\n", - flashConfig.telnet_port1, flashConfig.telnet_port2); + flashConfig.telnet_port1, flashConfig.telnet_port2); // save to flash if (configSave()) { @@ -60,16 +69,13 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { } // apply the changes - serbridgeInit(flashConfig.telnet_port1, flashConfig.telnet_port2); + serbridgeInit(); + serbridgeStart(1, flashConfig.telnet_port1, flashDefault.telnet_port1mode); + serbridgeStart(2, flashConfig.telnet_port2, flashDefault.telnet_port2mode); + } return HTTPD_CGI_DONE; - collision: { - char buff[128]; - os_sprintf(buff, "Ports assignment for %s collides with another assignment", coll); - errorResponse(connData, 400, buff); - return HTTPD_CGI_DONE; - } } int ICACHE_FLASH_ATTR cgiTelnet(HttpdConnData *connData) { diff --git a/esp-link/config.c b/esp-link/config.c index 8afedbc3..bb31af5a 100644 --- a/esp-link/config.c +++ b/esp-link/config.c @@ -37,6 +37,8 @@ FlashConfig flashDefault = { .stop_bits = ONE_STOP_BIT, .telnet_port1 = 23, .telnet_port2 = 2323, + .telnet_port1Mode = 0, + .telnet_port2Mode = 0, }; typedef union { @@ -163,6 +165,9 @@ bool ICACHE_FLASH_ATTR configRestore(void) { flashConfig.parity = flashDefault.parity; flashConfig.stop_bits = flashDefault.stop_bits; } + + if (flashConfig.telnet_port1 == 0) { flashConfig.telnet_port1 = flashDefault.telnet_port1; } + if (flashConfig.telnet_port2 == 0) { flashConfig.telnet_port2 = flashDefault.telnet_port2; } return true; } diff --git a/esp-link/config.h b/esp-link/config.h index 2f5aede8..c1c1f68e 100644 --- a/esp-link/config.h +++ b/esp-link/config.h @@ -41,8 +41,10 @@ typedef struct { int8_t data_bits; int8_t parity; int8_t stop_bits; - uint16_t telnet_port1, // Telnet port settings + uint16_t telnet_port1, // Telnet port settings telnet_port2; + int8_t telnet_port1mode, + telnet_port2mode; } FlashConfig; extern FlashConfig flashConfig; diff --git a/esp-link/main.c b/esp-link/main.c index d70e86ae..54fa0754 100644 --- a/esp-link/main.c +++ b/esp-link/main.c @@ -181,7 +181,10 @@ user_init(void) { WEB_Init(); // init the wifi-serial transparent bridge (port 23) - serbridgeInit(flashConfig.telnet_port1, flashConfig.telnet_port1); + serbridgeInit(); + serbridgeStart(1, flashConfig.telnet_port1, flashDefault.telnet_port1mode); + serbridgeStart(2, flashConfig.telnet_port2, flashDefault.telnet_port2mode); + uart_add_recv_cb(&serbridgeUartCb); #ifdef SHOW_HEAP_USE os_timer_disarm(&prHeapTimer); diff --git a/html/home.html b/html/home.html index d2c9791c..a3d2b87e 100644 --- a/html/home.html +++ b/html/home.html @@ -50,7 +50,7 @@

Info

the online README for up-to-date help.

-
+

Telnet Serial-Bridge

There are two ports available for telnet to use by default: 23 & 2323
Note - this time, only port1 may be changed & used sucessfully.

diff --git a/serial/serbridge.c b/serial/serbridge.c index cebc5615..e82e3b4b 100644 --- a/serial/serbridge.c +++ b/serial/serbridge.c @@ -16,8 +16,9 @@ #define syslog(X1...) #endif -static struct espconn serbridgeConn1; // plain bridging port -static struct espconn serbridgeConn2; // programming port +static struct espconn serbridgeConn[1]; // plain bridging port +static struct espconn serbridgeConn[2]; // programming port +static esp_tcp serbridgeTcp[1], serbridgeTcp[2]; static esp_tcp serbridgeTcp1, serbridgeTcp2; static int8_t mcu_reset_pin, mcu_isp_pin; @@ -421,7 +422,7 @@ serbridgeConnectCb(void *arg) connData[i].readytosend = true; connData[i].conn_mode = cmInit; // if it's the second port we start out in programming mode - if (conn->proto.tcp->local_port == serbridgeConn2.proto.tcp->local_port) + if (conn->proto.tcp->local_port == serbridgeConn[2].proto.tcp->local_port) connData[i].conn_mode = cmPGMInit; espconn_regist_recvcb(conn, serbridgeRecvCb); @@ -470,35 +471,44 @@ serbridgeInitPins() // Start transparent serial bridge TCP server on specified port (typ. 23) void ICACHE_FLASH_ATTR -serbridgeInit(int port1, int port2) +serbridgeInit() { serbridgeInitPins(); os_memset(connData, 0, sizeof(connData)); - os_memset(&serbridgeTcp1, 0, sizeof(serbridgeTcp1)); - os_memset(&serbridgeTcp2, 0, sizeof(serbridgeTcp2)); - - // set-up the primary port for plain bridging - serbridgeConn1.type = ESPCONN_TCP; - serbridgeConn1.state = ESPCONN_NONE; - serbridgeTcp1.local_port = port1; - serbridgeConn1.proto.tcp = &serbridgeTcp1; - - espconn_regist_connectcb(&serbridgeConn1, serbridgeConnectCb); - espconn_accept(&serbridgeConn1); - espconn_tcp_set_max_con_allow(&serbridgeConn1, MAX_CONN); - espconn_regist_time(&serbridgeConn1, SER_BRIDGE_TIMEOUT, 0); - - // set-up the secondary port for programming - serbridgeConn2.type = ESPCONN_TCP; - serbridgeConn2.state = ESPCONN_NONE; - serbridgeTcp2.local_port = port2; - serbridgeConn2.proto.tcp = &serbridgeTcp2; - - espconn_regist_connectcb(&serbridgeConn2, serbridgeConnectCb); - espconn_accept(&serbridgeConn2); - espconn_tcp_set_max_con_allow(&serbridgeConn2, MAX_CONN); - espconn_regist_time(&serbridgeConn2, SER_BRIDGE_TIMEOUT, 0); + os_memset(&serbridgeTcp[1], 0, sizeof(serbridgeTcp[1])); + os_memset(&serbridgeTcp[2], 0, sizeof(serbridgeTcp[2])); +} + +// Start transparent serial bridge TCP server on specified port (typ. 23) +void ICACHE_FLASH_ATTR +serbridgeStart(int ix, int port, int mode) +{ + + if (ix < 0 || ix > 2) // FIXME hardcoded limit + return; + if (serbridgeConn[ix] != NULL) { serbridgeCleanup(serbridgeConn[ix]); } //If we are already initialized, let's clean it up. + if (0 < port && port < 65536 && port != 80) { + serbridgeConn[ix].type = ESPCONN_TCP; + serbridgeConn[ix].state = ESPCONN_NONE; + serbridgeTcp[ix].local_port = port; + serbridgeConn[ix].proto.tcp = &serbridgeTcp[ix]; + + espconn_regist_connectcb(&serbridgeConn[ix], serbridgeConnectCb); + espconn_accept(&serbridgeConn[ix]); + espconn_tcp_set_max_con_allow(&serbridgeConn[ix], MAX_CONN); + espconn_regist_time(&serbridgeConn[ix], SER_BRIDGE_TIMEOUT, 0); + } +} + +static void ICACHE_FLASH_ATTR +serbridgeCleanup(void *arg) +{ + serbridgeConnData *conn = ((struct espconn*)arg)->reverse; + if (conn == NULL) return; + // Free memory & set to NULL + os_free(conn); + conn = NULL; } int ICACHE_FLASH_ATTR serbridgeInMCUFlashing() diff --git a/serial/serbridge.h b/serial/serbridge.h index ed661e1c..a1122ef7 100644 --- a/serial/serbridge.h +++ b/serial/serbridge.h @@ -31,11 +31,11 @@ typedef struct serbridgeConnData { } serbridgeConnData; // port1 is transparent&programming, second port is programming only -void ICACHE_FLASH_ATTR serbridgeInit(int port1, int port2); +void ICACHE_FLASH_ATTR serbridgeInit(); +void ICACHE_FLASH_ATTR serbridgeStart(int ix, int port, int mode); void ICACHE_FLASH_ATTR serbridgeInitPins(void); void ICACHE_FLASH_ATTR serbridgeUartCb(char *buf, short len); void ICACHE_FLASH_ATTR serbridgeReset(); - int ICACHE_FLASH_ATTR serbridgeInMCUFlashing(); // callback when receiving UART chars when in programming mode From 3f161215dd12276db6344758320d466050725bcb Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 30 Oct 2016 23:03:43 -0500 Subject: [PATCH 41/64] Fix a few errors.. --- serial/serbridge.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/serial/serbridge.c b/serial/serbridge.c index e82e3b4b..875481c6 100644 --- a/serial/serbridge.c +++ b/serial/serbridge.c @@ -19,7 +19,6 @@ static struct espconn serbridgeConn[1]; // plain bridging port static struct espconn serbridgeConn[2]; // programming port static esp_tcp serbridgeTcp[1], serbridgeTcp[2]; -static esp_tcp serbridgeTcp1, serbridgeTcp2; static int8_t mcu_reset_pin, mcu_isp_pin; uint8_t in_mcu_flashing; // for disabling slip during MCU flashing @@ -487,7 +486,7 @@ serbridgeStart(int ix, int port, int mode) if (ix < 0 || ix > 2) // FIXME hardcoded limit return; - if (serbridgeConn[ix] != NULL) { serbridgeCleanup(serbridgeConn[ix]); } //If we are already initialized, let's clean it up. + if (serbridgeConn[ix] != NULL) { serbridgeCleanup(ix); } //If we are already initialized, let's clean it up. if (0 < port && port < 65536 && port != 80) { serbridgeConn[ix].type = ESPCONN_TCP; serbridgeConn[ix].state = ESPCONN_NONE; @@ -502,13 +501,12 @@ serbridgeStart(int ix, int port, int mode) } static void ICACHE_FLASH_ATTR -serbridgeCleanup(void *arg) +serbridgeCleanup(int ix) { - serbridgeConnData *conn = ((struct espconn*)arg)->reverse; - if (conn == NULL) return; + if (serbridgeConn[ix] == NULL) return; // Free memory & set to NULL - os_free(conn); - conn = NULL; + os_free(serbridgeConn[ix]); + serbridgeConn[ix] = NULL; } int ICACHE_FLASH_ATTR serbridgeInMCUFlashing() From 2458e116b0bbc23ccc8e50f234d37d7086ed8369 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 30 Oct 2016 23:11:04 -0500 Subject: [PATCH 42/64] Serialbridge.c update --- serial/serbridge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serial/serbridge.c b/serial/serbridge.c index 875481c6..2d63128b 100644 --- a/serial/serbridge.c +++ b/serial/serbridge.c @@ -500,7 +500,7 @@ serbridgeStart(int ix, int port, int mode) } } -static void ICACHE_FLASH_ATTR +void ICACHE_FLASH_ATTR serbridgeCleanup(int ix) { if (serbridgeConn[ix] == NULL) return; From 27e6b5d4306f216dbc4de1425d48cc26055a0c83 Mon Sep 17 00:00:00 2001 From: dannybackx Date: Tue, 1 Nov 2016 09:43:24 +0100 Subject: [PATCH 43/64] Fix compile errors --- serial/serbridge.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/serial/serbridge.c b/serial/serbridge.c index 2d63128b..74b88464 100644 --- a/serial/serbridge.c +++ b/serial/serbridge.c @@ -16,14 +16,14 @@ #define syslog(X1...) #endif -static struct espconn serbridgeConn[1]; // plain bridging port -static struct espconn serbridgeConn[2]; // programming port -static esp_tcp serbridgeTcp[1], serbridgeTcp[2]; +static struct espconn serbridgeConn[2]; // 0 = plain bridging port, 1 = programming port +static esp_tcp serbridgeTcp[2]; static int8_t mcu_reset_pin, mcu_isp_pin; uint8_t in_mcu_flashing; // for disabling slip during MCU flashing void (*programmingCB)(char *buffer, short length) = NULL; +void ICACHE_FLASH_ATTR serbridgeCleanup(int ix); // Connection pool serbridgeConnData connData[MAX_CONN]; @@ -421,7 +421,7 @@ serbridgeConnectCb(void *arg) connData[i].readytosend = true; connData[i].conn_mode = cmInit; // if it's the second port we start out in programming mode - if (conn->proto.tcp->local_port == serbridgeConn[2].proto.tcp->local_port) + if (conn->proto.tcp->local_port == serbridgeConn[1].proto.tcp->local_port) connData[i].conn_mode = cmPGMInit; espconn_regist_recvcb(conn, serbridgeRecvCb); @@ -475,8 +475,8 @@ serbridgeInit() serbridgeInitPins(); os_memset(connData, 0, sizeof(connData)); + os_memset(&serbridgeTcp[0], 0, sizeof(serbridgeTcp[0])); os_memset(&serbridgeTcp[1], 0, sizeof(serbridgeTcp[1])); - os_memset(&serbridgeTcp[2], 0, sizeof(serbridgeTcp[2])); } // Start transparent serial bridge TCP server on specified port (typ. 23) @@ -486,7 +486,12 @@ serbridgeStart(int ix, int port, int mode) if (ix < 0 || ix > 2) // FIXME hardcoded limit return; - if (serbridgeConn[ix] != NULL) { serbridgeCleanup(ix); } //If we are already initialized, let's clean it up. + + // If we are already initialized, let's clean it up. + if (serbridgeConn[ix].type != 0) { + serbridgeCleanup(ix); + } + if (0 < port && port < 65536 && port != 80) { serbridgeConn[ix].type = ESPCONN_TCP; serbridgeConn[ix].state = ESPCONN_NONE; @@ -503,10 +508,8 @@ serbridgeStart(int ix, int port, int mode) void ICACHE_FLASH_ATTR serbridgeCleanup(int ix) { - if (serbridgeConn[ix] == NULL) return; - // Free memory & set to NULL - os_free(serbridgeConn[ix]); - serbridgeConn[ix] = NULL; + os_memset(&serbridgeTcp[ix], 0, sizeof(serbridgeTcp[ix])); + // FIX ME need to clean up the actions in serbridgeStart() ? (e.g. espconn_regist_connectcb) } int ICACHE_FLASH_ATTR serbridgeInMCUFlashing() From 36f15c9baa43a3e242a3533d04f3901b9a3f7e99 Mon Sep 17 00:00:00 2001 From: dannybackx Date: Tue, 1 Nov 2016 09:45:44 +0100 Subject: [PATCH 44/64] Fix compile errors --- esp-link/config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esp-link/config.c b/esp-link/config.c index bb31af5a..98fcd218 100644 --- a/esp-link/config.c +++ b/esp-link/config.c @@ -37,8 +37,8 @@ FlashConfig flashDefault = { .stop_bits = ONE_STOP_BIT, .telnet_port1 = 23, .telnet_port2 = 2323, - .telnet_port1Mode = 0, - .telnet_port2Mode = 0, + .telnet_port1mode = 0, + .telnet_port2mode = 0, }; typedef union { From 59a4707b5e9c1c6769b7381ed4ca45952627f200 Mon Sep 17 00:00:00 2001 From: dannybackx Date: Tue, 1 Nov 2016 09:45:56 +0100 Subject: [PATCH 45/64] Fix compile errors --- esp-link/config.h | 1 + 1 file changed, 1 insertion(+) diff --git a/esp-link/config.h b/esp-link/config.h index c1c1f68e..6cbff12c 100644 --- a/esp-link/config.h +++ b/esp-link/config.h @@ -47,6 +47,7 @@ typedef struct { telnet_port2mode; } FlashConfig; extern FlashConfig flashConfig; +extern FlashConfig flashDefault; bool configSave(void); bool configRestore(void); From 654f2ef6301e0df5cea714f5e225a5c659464d6d Mon Sep 17 00:00:00 2001 From: dannybackx Date: Tue, 1 Nov 2016 09:51:40 +0100 Subject: [PATCH 46/64] Fix compile errors --- esp-link/cgitelnet.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/esp-link/cgitelnet.c b/esp-link/cgitelnet.c index c3a8c00d..f8d20684 100644 --- a/esp-link/cgitelnet.c +++ b/esp-link/cgitelnet.c @@ -7,7 +7,7 @@ int ICACHE_FLASH_ATTR cgiTelnetGet(HttpdConnData *connData) { if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted - char buff[1024]; + char buff[80]; int len; os_printf("Current telnet ports: port1=%d port2=%d\n", @@ -27,15 +27,17 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { if (connData->conn==NULL) { return HTTPD_CGI_DONE; // Connection aborted } - + int8_t ok = 0; uint16_t port1, port2; ok |= getUInt16Arg(connData, "port1", &port1); ok |= getUInt16Arg(connData, "port2", &port2); if (ok <= 0) { //If we get at least one good value, this should be >= 1 - os_printf("Unable to fetch telnet ports.\n Received: port1=%d port2=%d\n", + char buf[80]; + sprintf(buf, "Unable to fetch telnet ports.\n Received: port1=%d port2=%d\n", flashConfig.telnet_port1, flashConfig.telnet_port2); - errorResponse(connData, 400, buff); + os_printf(buf); + errorResponse(connData, 400, buf); return HTTPD_CGI_DONE; } @@ -46,9 +48,11 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { // check whether ports are different if (port1 == port2) { - os_printf("Ports cannot be the same.\n Tried to set: port1=%d port2=%d\n", - flashConfig.telnet_port1, flashConfig.telnet_port2); - errorResponse(connData, 400, buff); + char buf[80]; + sprintf(buf, "Ports cannot be the same.\n Tried to set: port1=%d port2=%d\n", + flashConfig.telnet_port1, flashConfig.telnet_port2); + os_printf(buf); + errorResponse(connData, 400, buf); return HTTPD_CGI_DONE; } @@ -74,6 +78,7 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { serbridgeStart(2, flashConfig.telnet_port2, flashDefault.telnet_port2mode); } + return HTTPD_CGI_DONE; } From 4b3293eac441b01da512dde9abecd762fa430f3f Mon Sep 17 00:00:00 2001 From: dannybackx Date: Tue, 1 Nov 2016 16:30:17 +0100 Subject: [PATCH 47/64] Change comment --- serial/serbridge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serial/serbridge.c b/serial/serbridge.c index 74b88464..8e9e0411 100644 --- a/serial/serbridge.c +++ b/serial/serbridge.c @@ -509,7 +509,7 @@ void ICACHE_FLASH_ATTR serbridgeCleanup(int ix) { os_memset(&serbridgeTcp[ix], 0, sizeof(serbridgeTcp[ix])); - // FIX ME need to clean up the actions in serbridgeStart() ? (e.g. espconn_regist_connectcb) + // Looks like none of the espconn_..() calls in serbridgeStart() needs cleanup here. } int ICACHE_FLASH_ATTR serbridgeInMCUFlashing() From 547540d0d1f445aad08a477508379e15c46ad922 Mon Sep 17 00:00:00 2001 From: dannybackx Date: Tue, 1 Nov 2016 16:53:45 +0100 Subject: [PATCH 48/64] Fix the build problem : don't call sprintf. --- esp-link/cgitelnet.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/esp-link/cgitelnet.c b/esp-link/cgitelnet.c index f8d20684..552f839c 100644 --- a/esp-link/cgitelnet.c +++ b/esp-link/cgitelnet.c @@ -5,9 +5,10 @@ // Cgi to return choice of Telnet ports int ICACHE_FLASH_ATTR cgiTelnetGet(HttpdConnData *connData) { + char buff[80]; + if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted - char buff[80]; int len; os_printf("Current telnet ports: port1=%d port2=%d\n", @@ -19,6 +20,7 @@ int ICACHE_FLASH_ATTR cgiTelnetGet(HttpdConnData *connData) { jsonHeader(connData, 200); httpdSend(connData, buff, len); + return HTTPD_CGI_DONE; } @@ -32,12 +34,11 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { uint16_t port1, port2; ok |= getUInt16Arg(connData, "port1", &port1); ok |= getUInt16Arg(connData, "port2", &port2); + if (ok <= 0) { //If we get at least one good value, this should be >= 1 - char buf[80]; - sprintf(buf, "Unable to fetch telnet ports.\n Received: port1=%d port2=%d\n", + os_printf("Unable to fetch telnet ports.\n Received: port1=%d port2=%d\n", flashConfig.telnet_port1, flashConfig.telnet_port2); - os_printf(buf); - errorResponse(connData, 400, buf); + errorResponse(connData, 400, "Unable to fetch telnet ports."); return HTTPD_CGI_DONE; } @@ -48,14 +49,12 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { // check whether ports are different if (port1 == port2) { - char buf[80]; - sprintf(buf, "Ports cannot be the same.\n Tried to set: port1=%d port2=%d\n", + os_printf("Ports cannot be the same.\n Tried to set: port1=%d port2=%d\n", flashConfig.telnet_port1, flashConfig.telnet_port2); - os_printf(buf); - errorResponse(connData, 400, buf); + errorResponse(connData, 400, "Ports cannot be the same."); return HTTPD_CGI_DONE; } - + // we're good, set flashconfig flashConfig.telnet_port1 = port1; flashConfig.telnet_port2 = port2; @@ -74,13 +73,12 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { // apply the changes serbridgeInit(); - serbridgeStart(1, flashConfig.telnet_port1, flashDefault.telnet_port1mode); - serbridgeStart(2, flashConfig.telnet_port2, flashDefault.telnet_port2mode); + serbridgeStart(0, flashConfig.telnet_port1, flashDefault.telnet_port1mode); + serbridgeStart(1, flashConfig.telnet_port2, flashDefault.telnet_port2mode); } return HTTPD_CGI_DONE; - } int ICACHE_FLASH_ATTR cgiTelnet(HttpdConnData *connData) { From 589158eb5bdd79341c385aa9548b19c66f4db23b Mon Sep 17 00:00:00 2001 From: dannybackx Date: Tue, 1 Nov 2016 17:14:57 +0100 Subject: [PATCH 49/64] Aha --- esp-link/cgitelnet.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/esp-link/cgitelnet.c b/esp-link/cgitelnet.c index 552f839c..0b3d0c9e 100644 --- a/esp-link/cgitelnet.c +++ b/esp-link/cgitelnet.c @@ -26,6 +26,8 @@ int ICACHE_FLASH_ATTR cgiTelnetGet(HttpdConnData *connData) { // Cgi to change choice of Telnet ports int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { + char buf[80]; + if (connData->conn==NULL) { return HTTPD_CGI_DONE; // Connection aborted } @@ -36,9 +38,10 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { ok |= getUInt16Arg(connData, "port2", &port2); if (ok <= 0) { //If we get at least one good value, this should be >= 1 - os_printf("Unable to fetch telnet ports.\n Received: port1=%d port2=%d\n", + ets_sprintf(buf, "Unable to fetch telnet ports.\n Received: port1=%d port2=%d\n", flashConfig.telnet_port1, flashConfig.telnet_port2); - errorResponse(connData, 400, "Unable to fetch telnet ports."); + os_printf(buf); + errorResponse(connData, 400, buf); return HTTPD_CGI_DONE; } @@ -49,9 +52,10 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { // check whether ports are different if (port1 == port2) { - os_printf("Ports cannot be the same.\n Tried to set: port1=%d port2=%d\n", + os_sprintf(buf, "Ports cannot be the same.\n Tried to set: port1=%d port2=%d\n", flashConfig.telnet_port1, flashConfig.telnet_port2); - errorResponse(connData, 400, "Ports cannot be the same."); + os_printf(buf); + errorResponse(connData, 400, buf); return HTTPD_CGI_DONE; } From f3060e68722811f42b17b06ffcecbb801521a121 Mon Sep 17 00:00:00 2001 From: dannybackx Date: Tue, 1 Nov 2016 17:22:24 +0100 Subject: [PATCH 50/64] Change call to 0/1 instead of 1/2 --- esp-link/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esp-link/main.c b/esp-link/main.c index 54fa0754..49982f44 100644 --- a/esp-link/main.c +++ b/esp-link/main.c @@ -182,8 +182,8 @@ user_init(void) { // init the wifi-serial transparent bridge (port 23) serbridgeInit(); - serbridgeStart(1, flashConfig.telnet_port1, flashDefault.telnet_port1mode); - serbridgeStart(2, flashConfig.telnet_port2, flashDefault.telnet_port2mode); + serbridgeStart(0, flashConfig.telnet_port1, flashDefault.telnet_port1mode); + serbridgeStart(1, flashConfig.telnet_port2, flashDefault.telnet_port2mode); uart_add_recv_cb(&serbridgeUartCb); #ifdef SHOW_HEAP_USE From 286e8865ebd60d17d050d948160095725a12f897 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 3 Nov 2016 01:49:37 -0500 Subject: [PATCH 51/64] Makefile/Build file changes --- Makefile | 68 +++++++++++++++++++++++++++++++---------------------- espmake.cmd | 3 ++- 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 4172785d..2a187d7f 100644 --- a/Makefile +++ b/Makefile @@ -52,12 +52,13 @@ ESP_HOSTNAME ?= esp-link # Base directory for the compiler. Needs a / at the end. # Typically you'll install https://github.com/pfalcon/esp-open-sdk # IMPORTANT: use esp-open-sdk `make STANDALONE=n`: the SDK bundled with esp-open-sdk will *not* work! -XTENSA_TOOLS_ROOT ?= $(abspath ../esp-open-sdk/xtensa-lx106-elf/bin)/ +XTENSA_TOOLS_ROOT ?= $(abspath ../espressif/xtensa-lx106-elf/bin)/ +$(warning Using XTENSA TOOLS from $(XTENSA_TOOLS_ROOT)) # Firmware version # WARNING: if you change this expect to make code adjustments elsewhere, don't expect # that esp-link will magically work with a different version of the SDK!!! -SDK_VERS ?= esp_iot_sdk_v2.0.0.p1 +SDK_VERS ?= ESP8266_SDK # Try to find the firmware manually extracted, e.g. after downloading from Espressif's BBS, # http://bbs.espressif.com/viewforum.php?f=46 @@ -66,16 +67,17 @@ SDK_BASE ?= $(wildcard ../$(SDK_VERS)) # If the firmware isn't there, see whether it got downloaded as part of esp-open-sdk # This used to work at some point, but is not supported, uncomment if you feel lucky ;-) -#ifeq ($(SDK_BASE),) -#SDK_BASE := $(wildcard $(XTENSA_TOOLS_ROOT)/../../$(SDK_VERS)) -#endif +ifeq ($(SDK_BASE),) +SDK_BASE := $(wildcard $(XTENSA_TOOLS_ROOT)/../../$(SDK_VERS)) +endif # Clean up SDK path SDK_BASE := $(abspath $(SDK_BASE)) $(warning Using SDK from $(SDK_BASE)) # Path to bootloader file -BOOTFILE ?= $(SDK_BASE/bin/boot_v1.6.bin) +BOOTFILE ?= $(SDK_BASE)/bin/boot_v1.6.bin +$(warning Using boot file-> $(BOOTFILE)) # Esptool.py path and port, only used for 1-time serial flashing # Typically you'll use https://github.com/themadinventor/esptool @@ -127,8 +129,10 @@ GZIP_COMPRESSION ?= yes # http://yui.github.io/yuicompressor/ # enabled by default. COMPRESS_W_HTMLCOMPRESSOR ?= yes -HTML_COMPRESSOR ?= htmlcompressor-1.5.3.jar -YUI_COMPRESSOR ?= yuicompressor-2.4.8.jar +HTML_COMPRESSOR_VER ?= htmlcompressor-1.5.3.jar +HTML_COMPRESSOR = tools/$(HTML_COMPRESSOR_VER) +YUI_COMPRESSOR_VER ?= yuicompressor-2.4.8.jar +YUI_COMPRESSOR = tools/$(YUI_COMPRESSOR_VER) # -------------- End of config options ------------- @@ -296,6 +300,13 @@ Q := @ vecho := @echo endif +#Fix for issues on some windows systems that call non GNU FIND +FIND ?= $(which FIND) +ifeq (,$(findstring system32,$(FIND))) + $(warning Non GNU 'find' called. Trying alternate path /usr/bin/find) + FIND = /usr/bin/find +endif + ifneq ($(strip $(STA_SSID)),) CFLAGS += -DSTA_SSID="$(STA_SSID)" endif @@ -387,6 +398,7 @@ $(FW_BASE)/user2.bin: $(USER2_OUT) $(FW_BASE) $(Q) COMPILE=gcc PATH=$(XTENSA_TOOLS_ROOT):$(PATH) python $(APPGEN_TOOL) $(USER2_OUT) 2 $(ESP_FLASH_MODE) $(ESP_FLASH_FREQ_DIV) $(ESP_SPI_SIZE) 1 >/dev/null $(Q) rm -f eagle.app.v6.*.bin $(Q) mv eagle.app.flash.bin $@ + @echo "** user2.bin uses $$(stat -c '%s' $@) bytes of" $(ESP_FLASH_MAX) "available" $(Q) if [ $$(stat -c '%s' $@) -gt $$(( $(ESP_FLASH_MAX) )) ]; then echo "$@ too big!"; false; fi $(APP_AR): $(OBJ) @@ -406,18 +418,18 @@ baseflash: all flash: all $(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) write_flash -fs $(ET_FS) -ff $(ET_FF) \ - 0x00000 "$(SDK_BASE)/bin/boot_v1.5.bin" 0x01000 $(FW_BASE)/user1.bin \ + 0x00000 "$(BOOTFILE)" 0x01000 $(FW_BASE)/user1.bin \ $(ET_BLANK) $(SDK_BASE)/bin/blank.bin tools/$(HTML_COMPRESSOR): $(Q) echo "The jar files in the tools dir are missing, they should be in the source repo" $(Q) echo "The following commands can be used to fetch them, but the URLs have changed..." $(Q) echo mkdir -p tools - $(Q) echo "cd tools; wget --no-check-certificate https://github.com/yui/yuicompressor/releases/download/v2.4.8/$(YUI_COMPRESSOR) -O $(YUI_COMPRESSOR)" - $(Q) echo "cd tools; wget --no-check-certificate https://htmlcompressor.googlecode.com/files/$(HTML_COMPRESSOR) -O $(HTML_COMPRESSOR)" + $(Q) echo "cd tools; wget --no-check-certificate https://github.com/yui/yuicompressor/releases/download/v2.4.8/$(YUI_COMPRESSOR_VER) -O $(YUI_COMPRESSOR_VER)" + $(Q) echo "cd tools; wget --no-check-certificate https://htmlcompressor.googlecode.com/files/$(HTML_COMPRESSOR_VER) -O $(HTML_COMPRESSOR_VER)" ifeq ("$(COMPRESS_W_HTMLCOMPRESSOR)","yes") -$(BUILD_BASE)/espfs_img.o: tools/$(HTML_COMPRESSOR) +$(BUILD_BASE)/espfs_img.o: $(HTML_COMPRESSOR) endif $(BUILD_BASE)/espfs_img.o: html/ html/wifi/ espfs/mkespfsimage/mkespfsimage @@ -428,38 +440,38 @@ $(BUILD_BASE)/espfs_img.o: html/ html/wifi/ espfs/mkespfsimage/mkespfsimage $(Q) cp -r html/wifi/*.png html_compressed/wifi; $(Q) cp -r html/wifi/*.js html_compressed/wifi; ifeq ("$(COMPRESS_W_HTMLCOMPRESSOR)","yes") - $(Q) echo "Compressing assets with htmlcompressor. This may take a while..." - $(Q) java -jar tools/$(HTML_COMPRESSOR) \ + $(Q) echo "Compressing assets with htmlcompressor. This may take a while..."; + $(Q) java -jar $(HTML_COMPRESSOR) \ -t html --remove-surrounding-spaces max --remove-quotes --remove-intertag-spaces \ -o $(abspath ./html_compressed)/ \ $(HTML_PATH)head- \ $(HTML_PATH)*.html - $(Q) java -jar tools/$(HTML_COMPRESSOR) \ + $(Q) java -jar $(HTML_COMPRESSOR) \ -t html --remove-surrounding-spaces max --remove-quotes --remove-intertag-spaces \ -o $(abspath ./html_compressed)/wifi/ \ $(WIFI_PATH)*.html $(Q) echo "Compressing assets with yui-compressor. This may take a while..." - $(Q) for file in `find html_compressed -type f -name "*.js"`; do \ - java -jar tools/$(YUI_COMPRESSOR) $$file --line-break 0 -o $$file; \ - done - $(Q) for file in `find html_compressed -type f -name "*.css"`; do \ - java -jar tools/$(YUI_COMPRESSOR) $$file -o $$file; \ - done + $(Q) java -jar $(YUI_COMPRESSOR) ./html_compressed/*.css -o '.css$:.css' + $(Q) java -jar $(YUI_COMPRESSOR) ./html_compressed/*.js -o '.js$:.js' + $(Q) java -jar $(YUI_COMPRESSOR) ./html_compressed/wifi/*.js -o '.js$:.js' else $(Q) cp -r html/head- html_compressed; $(Q) cp -r html/*.html html_compressed; $(Q) cp -r html/wifi/*.html html_compressed/wifi; endif + ifeq (,$(findstring mqtt,$(MODULES))) - $(Q) rm -rf html_compressed/mqtt.html - $(Q) rm -rf html_compressed/mqtt.js + $(Q) rm -rf html_compressed/mqtt.html; + $(Q) rm -rf html_compressed/mqtt.js; endif - $(Q) for file in `find html_compressed -type f -name "*.htm*"`; do \ + + $(Q) for file in `$(FIND) html_compressed -type f -name "*.htm*"`; do \ cat html_compressed/head- $$file >$${file}-; \ mv $$file- $$file; \ done $(Q) rm html_compressed/head- - $(Q) cd html_compressed; find . \! -name \*- | ../espfs/mkespfsimage/mkespfsimage > ../build/espfs.img; cd ..; + $(Q) echo "Compressing assets into espfs.img with Gzip. This may take a while..." + $(Q) cd html_compressed; $(FIND) . \! -name \*- | ../espfs/mkespfsimage/mkespfsimage > ../build/espfs.img; cd ..; $(Q) ls -sl build/espfs.img $(Q) cd build; $(OBJCP) -I binary -O elf32-xtensa-le -B xtensa --rename-section .data=.espfs \ espfs.img espfs_img.o; cd .. @@ -483,7 +495,7 @@ release: all $(Q) egrep -a 'esp-link [a-z0-9.]+ - 201' $(FW_BASE)/user1.bin | cut -b 1-80 $(Q) egrep -a 'esp-link [a-z0-9.]+ - 201' $(FW_BASE)/user2.bin | cut -b 1-80 $(Q) cp $(FW_BASE)/user1.bin $(FW_BASE)/user2.bin $(SDK_BASE)/bin/blank.bin \ - "$(SDK_BASE)/bin/boot_v1.6.bin" "$(SDK_BASE)/bin/esp_init_data_default.bin" \ + "$(BOOTFILE)" "$(SDK_BASE)/bin/esp_init_data_default.bin" \ wiflash avrflash release/esp-link-$(BRANCH) $(Q) tar zcf esp-link-$(BRANCH)-$(SHA).tgz -C release esp-link-$(BRANCH) $(Q) echo "Release file: esp-link-$(BRANCH)-$(SHA).tgz" @@ -494,7 +506,7 @@ docker: clean: $(Q) rm -f $(APP_AR) $(Q) rm -f $(TARGET_OUT) - $(Q) find $(BUILD_BASE) -type f | xargs rm -f + $(Q) $(FIND) $(BUILD_BASE) -type f | xargs rm -f $(Q) make -C espfs/mkespfsimage/ clean $(Q) rm -rf $(FW_BASE) $(Q) rm -f webpages.espfs @@ -502,4 +514,4 @@ ifeq ("$(COMPRESS_W_HTMLCOMPRESSOR)","yes") $(Q) rm -rf html_compressed endif -$(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir)))) +$(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir)))) \ No newline at end of file diff --git a/espmake.cmd b/espmake.cmd index 42e25a65..f475e01c 100644 --- a/espmake.cmd +++ b/espmake.cmd @@ -1,5 +1,6 @@ @echo off - +SETLOCAL +REM LOCAL IS NEEDED ELSE WE KEEP ADDING TO WINDOW PATH EACH TIME SCRIPT IS CALLED. REM remove automatic created obj folder rd obj /S /Q >nul 2>&1 From 6596883fb194e58a4ff482959c18ac243b62b48c Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 3 Nov 2016 02:01:02 -0500 Subject: [PATCH 52/64] Formatting cleanup --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2a187d7f..d191e161 100644 --- a/Makefile +++ b/Makefile @@ -461,8 +461,8 @@ else endif ifeq (,$(findstring mqtt,$(MODULES))) - $(Q) rm -rf html_compressed/mqtt.html; - $(Q) rm -rf html_compressed/mqtt.js; + $(Q) rm -rf html_compressed/mqtt.html + $(Q) rm -rf html_compressed/mqtt.js endif $(Q) for file in `$(FIND) html_compressed -type f -name "*.htm*"`; do \ From 0b8368af2401bf21ff00dcf75a030ad0f8bfb749 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 3 Nov 2016 02:02:30 -0500 Subject: [PATCH 53/64] Modify all calls to port variables to match. Espconn1 = TelnetPort1 Should make code more fluid & inuitive. All code changes made to reflect javascrupt, html, and C. --- esp-link/cgi.c | 2 +- esp-link/cgitelnet.c | 34 +++++++++++++++++----------------- esp-link/config.c | 8 ++++---- esp-link/config.h | 8 ++++---- esp-link/main.c | 4 ++-- html/home.html | 8 ++++---- html/ui.js | 1 + 7 files changed, 33 insertions(+), 32 deletions(-) diff --git a/esp-link/cgi.c b/esp-link/cgi.c index d667be3f..6d0d79e6 100644 --- a/esp-link/cgi.c +++ b/esp-link/cgi.c @@ -190,7 +190,7 @@ int ICACHE_FLASH_ATTR printGlobalInfo(char *buff, int buflen, char *token) { extern char *esp_link_version; // in user_main.c -int ICACHE_FLASH_ATTR cgiMenu(HttpdConnData *connData) { +int ICACHE_FLASH_ATTR cgiMenu(HttpdConnData *connData) { //This is where we can modify the navigation that is auto generated if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. char buff[1024]; // don't use jsonHeader so the response does get cached diff --git a/esp-link/cgitelnet.c b/esp-link/cgitelnet.c index 0b3d0c9e..0530fc82 100644 --- a/esp-link/cgitelnet.c +++ b/esp-link/cgitelnet.c @@ -11,12 +11,12 @@ int ICACHE_FLASH_ATTR cgiTelnetGet(HttpdConnData *connData) { int len; - os_printf("Current telnet ports: port1=%d port2=%d\n", - flashConfig.telnet_port1, flashConfig.telnet_port2); + os_printf("Current telnet ports: port0=%d port1=%d\n", + flashConfig.telnet_port0, flashConfig.telnet_port1); len = os_sprintf(buff, - "{ \"port1\": \"%d\", \"port2\": \"%d\" }", - flashConfig.telnet_port1, flashConfig.telnet_port2); + "{ \"port0\": \"%d\", \"port1\": \"%d\" }", + flashConfig.telnet_port0, flashConfig.telnet_port1); jsonHeader(connData, 200); httpdSend(connData, buff, len); @@ -33,13 +33,13 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { } int8_t ok = 0; - uint16_t port1, port2; + uint16_t port0, port1; + ok |= getUInt16Arg(connData, "port0", &port0); ok |= getUInt16Arg(connData, "port1", &port1); - ok |= getUInt16Arg(connData, "port2", &port2); if (ok <= 0) { //If we get at least one good value, this should be >= 1 - ets_sprintf(buf, "Unable to fetch telnet ports.\n Received: port1=%d port2=%d\n", - flashConfig.telnet_port1, flashConfig.telnet_port2); + ets_sprintf(buf, "Unable to fetch telnet ports.\n Received: port0=%d port1=%d\n", + flashConfig.telnet_port0, flashConfig.telnet_port1); os_printf(buf); errorResponse(connData, 400, buf); return HTTPD_CGI_DONE; @@ -47,23 +47,23 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { if (ok > 0) { // fill both port variables from flash or ajax provided value + if (!port0) port0 = flashConfig.telnet_port0; if (!port1) port1 = flashConfig.telnet_port1; - if (!port2) port2 = flashConfig.telnet_port2; // check whether ports are different - if (port1 == port2) { - os_sprintf(buf, "Ports cannot be the same.\n Tried to set: port1=%d port2=%d\n", - flashConfig.telnet_port1, flashConfig.telnet_port2); + if (port0 == port1) { + os_sprintf(buf, "Ports cannot be the same.\n Tried to set: port0=%d port1=%d\n", + flashConfig.telnet_port0, flashConfig.telnet_port1); os_printf(buf); errorResponse(connData, 400, buf); return HTTPD_CGI_DONE; } // we're good, set flashconfig + flashConfig.telnet_port0 = port0; flashConfig.telnet_port1 = port1; - flashConfig.telnet_port2 = port2; - os_printf("Telnet ports changed: port1=%d port2=%d\n", - flashConfig.telnet_port1, flashConfig.telnet_port2); + os_printf("Telnet ports changed: port0=%d port1=%d\n", + flashConfig.telnet_port0, flashConfig.telnet_port1); // save to flash if (configSave()) { @@ -77,8 +77,8 @@ int ICACHE_FLASH_ATTR cgiTelnetSet(HttpdConnData *connData) { // apply the changes serbridgeInit(); - serbridgeStart(0, flashConfig.telnet_port1, flashDefault.telnet_port1mode); - serbridgeStart(1, flashConfig.telnet_port2, flashDefault.telnet_port2mode); + serbridgeStart(0, flashConfig.telnet_port0, flashDefault.telnet_port0mode); + serbridgeStart(1, flashConfig.telnet_port1, flashDefault.telnet_port1mode); } diff --git a/esp-link/config.c b/esp-link/config.c index 98fcd218..ab0f385b 100644 --- a/esp-link/config.c +++ b/esp-link/config.c @@ -35,10 +35,10 @@ FlashConfig flashDefault = { .data_bits = EIGHT_BITS, .parity = NONE_BITS, .stop_bits = ONE_STOP_BIT, - .telnet_port1 = 23, - .telnet_port2 = 2323, + .telnet_port0 = 23, + .telnet_port1 = 2323, + .telnet_port0mode = 0, .telnet_port1mode = 0, - .telnet_port2mode = 0, }; typedef union { @@ -166,8 +166,8 @@ bool ICACHE_FLASH_ATTR configRestore(void) { flashConfig.stop_bits = flashDefault.stop_bits; } + if (flashConfig.telnet_port0 == 0) { flashConfig.telnet_port0 = flashDefault.telnet_port0; } if (flashConfig.telnet_port1 == 0) { flashConfig.telnet_port1 = flashDefault.telnet_port1; } - if (flashConfig.telnet_port2 == 0) { flashConfig.telnet_port2 = flashDefault.telnet_port2; } return true; } diff --git a/esp-link/config.h b/esp-link/config.h index 6cbff12c..094c044e 100644 --- a/esp-link/config.h +++ b/esp-link/config.h @@ -41,10 +41,10 @@ typedef struct { int8_t data_bits; int8_t parity; int8_t stop_bits; - uint16_t telnet_port1, // Telnet port settings - telnet_port2; - int8_t telnet_port1mode, - telnet_port2mode; + uint16_t telnet_port0, // Telnet port settings + telnet_port1; + int8_t telnet_port0mode, + telnet_port1mode; } FlashConfig; extern FlashConfig flashConfig; extern FlashConfig flashDefault; diff --git a/esp-link/main.c b/esp-link/main.c index 49982f44..90202fad 100644 --- a/esp-link/main.c +++ b/esp-link/main.c @@ -182,8 +182,8 @@ user_init(void) { // init the wifi-serial transparent bridge (port 23) serbridgeInit(); - serbridgeStart(0, flashConfig.telnet_port1, flashDefault.telnet_port1mode); - serbridgeStart(1, flashConfig.telnet_port2, flashDefault.telnet_port2mode); + serbridgeStart(0, flashConfig.telnet_port0, flashDefault.telnet_port0mode); + serbridgeStart(1, flashConfig.telnet_port1, flashDefault.telnet_port1mode); uart_add_recv_cb(&serbridgeUartCb); #ifdef SHOW_HEAP_USE diff --git a/html/home.html b/html/home.html index a3d2b87e..5bce56be 100644 --- a/html/home.html +++ b/html/home.html @@ -53,19 +53,19 @@

Info

Telnet Serial-Bridge

There are two ports available for telnet to use by default: 23 & 2323
- Note - this time, only port1 may be changed & used sucessfully.

+ Note - this time, only port0 may be changed & used sucessfully.

+
@@ -177,6 +186,7 @@

System details

makeAjaxInput("system", "name"); makeAjaxInput("telnet", "port0"); makeAjaxInput("telnet", "port1"); + makeAjaxInput("telnet", "port0mode"); fetchPins(); getWifiInfo(); getSystemInfo(); diff --git a/html/ui.js b/html/ui.js index 5e83babc..3a00ef83 100644 --- a/html/ui.js +++ b/html/ui.js @@ -401,7 +401,7 @@ function showNotification(text) { var el = $("#notification"); el.innerHTML = text; el.removeAttribute('hidden'); - // window.scrollTo(0, 0); //Uncomment this line so window will scroll up on regular notifications + window.scrollTo(0, 0); //Uncomment this line so window will scroll up on regular notifications if (notifTimeout != null) clearTimeout(notifTimeout); notifTimout = setTimeout(function() { el.setAttribute('hidden', ''); From 6fd5938882fe1fa2fcd78f96f0e4d7d242cccb0c Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 16 Nov 2016 08:14:40 -0600 Subject: [PATCH 59/64] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 94cddc44..fcea7fc3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,3 +25,4 @@ deploy: file: esp-link-master-*.t*gz on: repo: fuzzball03/esp-link + all_branches: true From 25feca55e751626e471cd0d5d93f65d0bdaf4149 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 22 Nov 2016 22:19:04 -0600 Subject: [PATCH 60/64] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fcea7fc3..41f1d814 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,4 +25,4 @@ deploy: file: esp-link-master-*.t*gz on: repo: fuzzball03/esp-link - all_branches: true + branch: master From 23a904ffab6375cf4060c933a2df3deb747f06fa Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 22 Nov 2016 22:27:51 -0600 Subject: [PATCH 61/64] 5 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 41f1d814..591e795f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,5 +24,6 @@ deploy: file_glob: true file: esp-link-master-*.t*gz on: + tags: true repo: fuzzball03/esp-link branch: master From 1df972bb598f684237005cf20938f9e77bac50da Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 22 Nov 2016 22:36:26 -0600 Subject: [PATCH 62/64] 9 --- .travis.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 591e795f..50cf42c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,21 +2,19 @@ language: c before_install: - curl -Ls http://s3.voneicken.com/xtensa-lx106-elf-20160330.tgx | tar Jxf - - curl -Ls http://s3.voneicken.com/esp_iot_sdk_v2.0.0.p1.tgx | tar -C .. -Jxf - -after_script: -- 'if [[ -n "$S3_BUCKET" && -n "$AWS_ACCESS_KEY_ID" ]]; then echo Uploading *.tgz - to $S3_BUCKET; curl -Ls https://github.com/rlmcpherson/s3gof3r/releases/download/v0.5.0/gof3r_0.5.0_linux_amd64.tar.gz - | tar zxf - gof3r_0.5.0_linux_amd64/gof3r; mv gof3r*/gof3r .; ls *.tgz | xargs -I - {} ./gof3r put -b $S3_BUCKET -k esp-link/{} --acl public-read -p {}; ls *.tgz | - xargs -I {} echo "URL: http://$S3_BUCKET/esp-link/{}"; fi' -compiler: gcc -env: script: - export XTENSA_TOOLS_ROOT=$PWD/xtensa-lx106-elf/bin/ - export BRANCH=$TRAVIS_BRANCH +- echo "Travis Branch is $TRAVIS_BRANCH" +- echo "Travis Tag is $TRAVIS_TAG" +- echo "Travis COMMIT is $TRAVIS_COMMIT" +- echo "Travis COMMIT is $TRAVIS_COMMIT_RANGE" +- echo "Dont forget to set VARIABLES for S3 to function. SEE gof3r README" - make release notifications: email: false deploy: + overwrite: true skip_cleanup: true provider: releases api_key: @@ -25,5 +23,5 @@ deploy: file: esp-link-master-*.t*gz on: tags: true - repo: fuzzball03/esp-link branch: master + repo: fuzzball03/esp-link From 153f4707f4d925d1ae307604854407490c85830a Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 22 Nov 2016 22:43:26 -0600 Subject: [PATCH 63/64] 10 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 50cf42c5..3c07aab3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,6 @@ deploy: file_glob: true file: esp-link-master-*.t*gz on: - tags: true branch: master repo: fuzzball03/esp-link + condition: "$TRAVIS_BRANCH = master" From 9fcee90baffaaa26d4ed6054da6af828e5af0f61 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 22 Nov 2016 22:55:50 -0600 Subject: [PATCH 64/64] 12 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 3c07aab3..6ce3d58d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ before_install: - curl -Ls http://s3.voneicken.com/xtensa-lx106-elf-20160330.tgx | tar Jxf - - curl -Ls http://s3.voneicken.com/esp_iot_sdk_v2.0.0.p1.tgx | tar -C .. -Jxf - script: +- printenv - export XTENSA_TOOLS_ROOT=$PWD/xtensa-lx106-elf/bin/ - export BRANCH=$TRAVIS_BRANCH - echo "Travis Branch is $TRAVIS_BRANCH"