diff --git a/Makefile b/Makefile
index 7969417..070a1f5 100644
--- a/Makefile
+++ b/Makefile
@@ -142,7 +142,7 @@ TARGET = httpd
APPGEN_TOOL ?= gen_appbin.py
# which modules (subdirectories) of the project to include in compiling
-MODULES = espfs httpd user serial cmd mqtt
+MODULES = espfs httpd user serial cmd mqtt esp-link
EXTRA_INCDIR = include .
# libraries used in this project, mainly provided by the SDK
diff --git a/esp-link.vcxproj b/esp-link.vcxproj
index ce508d0..760a8ef 100644
--- a/esp-link.vcxproj
+++ b/esp-link.vcxproj
@@ -105,6 +105,7 @@
+
diff --git a/user/cgi.c b/esp-link/cgi.c
similarity index 100%
rename from user/cgi.c
rename to esp-link/cgi.c
diff --git a/user/cgi.h b/esp-link/cgi.h
similarity index 100%
rename from user/cgi.h
rename to esp-link/cgi.h
diff --git a/user/cgiflash.c b/esp-link/cgiflash.c
similarity index 100%
rename from user/cgiflash.c
rename to esp-link/cgiflash.c
diff --git a/user/cgiflash.h b/esp-link/cgiflash.h
similarity index 100%
rename from user/cgiflash.h
rename to esp-link/cgiflash.h
diff --git a/user/cgipins.c b/esp-link/cgipins.c
similarity index 100%
rename from user/cgipins.c
rename to esp-link/cgipins.c
diff --git a/user/cgipins.h b/esp-link/cgipins.h
similarity index 100%
rename from user/cgipins.h
rename to esp-link/cgipins.h
diff --git a/user/cgitcp.c b/esp-link/cgitcp.c
similarity index 100%
rename from user/cgitcp.c
rename to esp-link/cgitcp.c
diff --git a/user/cgitcp.h b/esp-link/cgitcp.h
similarity index 100%
rename from user/cgitcp.h
rename to esp-link/cgitcp.h
diff --git a/user/cgiwifi.c b/esp-link/cgiwifi.c
similarity index 100%
rename from user/cgiwifi.c
rename to esp-link/cgiwifi.c
diff --git a/user/cgiwifi.h b/esp-link/cgiwifi.h
similarity index 100%
rename from user/cgiwifi.h
rename to esp-link/cgiwifi.h
diff --git a/user/config.c b/esp-link/config.c
similarity index 100%
rename from user/config.c
rename to esp-link/config.c
diff --git a/user/config.h b/esp-link/config.h
similarity index 100%
rename from user/config.h
rename to esp-link/config.h
diff --git a/user/log.c b/esp-link/log.c
similarity index 100%
rename from user/log.c
rename to esp-link/log.c
diff --git a/user/log.h b/esp-link/log.h
similarity index 100%
rename from user/log.h
rename to esp-link/log.h
diff --git a/esp-link/main.c b/esp-link/main.c
new file mode 100644
index 0000000..417a1b2
--- /dev/null
+++ b/esp-link/main.c
@@ -0,0 +1,168 @@
+/*
+* ----------------------------------------------------------------------------
+* "THE BEER-WARE LICENSE" (Revision 42):
+* Jeroen Domburg wrote this file. As long as you retain
+* this notice you can do whatever you want with this stuff. If we meet some day,
+* and you think this stuff is worth it, you can buy me a beer in return.
+* ----------------------------------------------------------------------------
+* Heavily modified and enhanced by Thorsten von Eicken in 2015
+* ----------------------------------------------------------------------------
+*/
+
+
+#include
+#include "httpd.h"
+#include "httpdespfs.h"
+#include "cgi.h"
+#include "cgiwifi.h"
+#include "cgipins.h"
+#include "cgitcp.h"
+#include "cgiflash.h"
+#include "auth.h"
+#include "espfs.h"
+#include "uart.h"
+#include "serbridge.h"
+#include "status.h"
+#include "serled.h"
+#include "console.h"
+#include "config.h"
+#include "log.h"
+#include
+
+//#define SHOW_HEAP_USE
+
+//Function that tells the authentication system what users/passwords live on the system.
+//This is disabled in the default build; if you want to try it, enable the authBasic line in
+//the builtInUrls below.
+int myPassFn(HttpdConnData *connData, int no, char *user, int userLen, char *pass, int passLen) {
+ if (no == 0) {
+ os_strcpy(user, "admin");
+ os_strcpy(pass, "s3cr3t");
+ return 1;
+ //Add more users this way. Check against incrementing no for each user added.
+ // } else if (no==1) {
+ // os_strcpy(user, "user1");
+ // os_strcpy(pass, "something");
+ // return 1;
+ }
+ return 0;
+}
+
+
+/*
+This is the main url->function dispatching data struct.
+In short, it's a struct with various URLs plus their handlers. The handlers can
+be 'standard' CGI functions you wrote, or 'special' CGIs requiring an argument.
+They can also be auth-functions. An asterisk will match any url starting with
+everything before the asterisks; "*" matches everything. The list will be
+handled top-down, so make sure to put more specific rules above the more
+general ones. Authorization things (like authBasic) act as a 'barrier' and
+should be placed above the URLs they protect.
+*/
+HttpdBuiltInUrl builtInUrls[] = {
+ { "/", cgiRedirect, "/home.html" },
+ { "/menu", cgiMenu, NULL },
+ { "/flash/next", cgiGetFirmwareNext, NULL },
+ { "/flash/upload", cgiUploadFirmware, NULL },
+ { "/flash/reboot", cgiRebootFirmware, NULL },
+ //{"/home.html", cgiEspFsHtml, NULL},
+ //{"/log.html", cgiEspFsHtml, NULL},
+ { "/log/text", ajaxLog, NULL },
+ { "/log/dbg", ajaxLogDbg, NULL },
+ //{"/console.html", cgiEspFsHtml, NULL},
+ { "/console/reset", ajaxConsoleReset, NULL },
+ { "/console/baud", ajaxConsoleBaud, NULL },
+ { "/console/text", ajaxConsole, NULL },
+
+ //Routines to make the /wifi URL and everything beneath it work.
+
+ //Enable the line below to protect the WiFi configuration with an username/password combo.
+ // {"/wifi/*", authBasic, myPassFn},
+
+ { "/wifi", cgiRedirect, "/wifi/wifi.html" },
+ { "/wifi/", cgiRedirect, "/wifi/wifi.html" },
+ //{"/wifi/wifi.html", cgiEspFsHtml, NULL},
+ { "/wifi/info", cgiWifiInfo, NULL },
+ { "/wifi/scan", cgiWiFiScan, NULL },
+ { "/wifi/connect", cgiWiFiConnect, NULL },
+ { "/wifi/connstatus", cgiWiFiConnStatus, NULL },
+ { "/wifi/setmode", cgiWiFiSetMode, NULL },
+ { "/wifi/special", cgiWiFiSpecial, NULL },
+ { "/pins", cgiPins, NULL },
+ { "/tcpclient", cgiTcp, NULL },
+
+ { "*", cgiEspFsHook, NULL }, //Catch-all cgi function for the filesystem
+ { NULL, NULL, NULL }
+};
+
+
+//#define SHOW_HEAP_USE
+
+#ifdef SHOW_HEAP_USE
+static ETSTimer prHeapTimer;
+
+static void ICACHE_FLASH_ATTR prHeapTimerCb(void *arg) {
+ os_printf("Heap: %ld\n", (unsigned long)system_get_free_heap_size());
+}
+#endif
+
+void user_rf_pre_init(void) {
+}
+
+// address of espfs binary blob
+extern uint32_t _binary_espfs_img_start;
+
+static char *rst_codes[] = {
+ "normal", "wdt reset", "exception", "soft wdt", "restart", "deep sleep", "external",
+};
+
+# define VERS_STR_STR(V) #V
+# define VERS_STR(V) VERS_STR_STR(V)
+char *esp_link_version = VERS_STR(VERSION);
+
+//Main routine. Initialize stdout, the I/O, filesystem and the webserver and we're done.
+void user_init(void) {
+ // get the flash config so we know how to init things
+ //configWipe(); // uncomment to reset the config for testing purposes
+ bool restoreOk = configRestore();
+ // init gpio pin registers
+ gpio_init();
+ // init UART
+ uart_init(flashConfig.baud_rate, 115200);
+ logInit(); // must come after init of uart
+ // say hello (leave some time to cause break in TX after boot loader's msg
+ os_delay_us(10000L);
+ os_printf("\n\n** %s\n", esp_link_version);
+ os_printf("Flash config restore %s\n", restoreOk ? "ok" : "*FAILED*");
+ // Status LEDs
+ statusInit();
+ serledInit();
+ // Wifi
+ wifiInit();
+ // init the flash filesystem with the html stuff
+ espFsInit(&_binary_espfs_img_start);
+ //EspFsInitResult res = espFsInit(&_binary_espfs_img_start);
+ //os_printf("espFsInit %s\n", res?"ERR":"ok");
+ // mount the http handlers
+ httpdInit(builtInUrls, 80);
+ // init the wifi-serial transparent bridge (port 23)
+ serbridgeInit(23);
+ uart_add_recv_cb(&serbridgeUartCb);
+#ifdef SHOW_HEAP_USE
+ os_timer_disarm(&prHeapTimer);
+ os_timer_setfn(&prHeapTimer, prHeapTimerCb, NULL);
+ os_timer_arm(&prHeapTimer, 10000, 1);
+#endif
+
+ struct rst_info *rst_info = system_get_rst_info();
+ os_printf("Reset cause: %d=%s\n", rst_info->reason, rst_codes[rst_info->reason]);
+ os_printf("exccause=%d epc1=0x%x epc2=0x%x epc3=0x%x excvaddr=0x%x depc=0x%x\n",
+ rst_info->exccause, rst_info->epc1, rst_info->epc2, rst_info->epc3,
+ rst_info->excvaddr, rst_info->depc);
+ os_printf("Flash map %d, chip %08X\n", system_get_flash_size_map(), spi_flash_get_id());
+
+ os_printf("** esp-link ready\n");
+
+ // call user_main init
+ init();
+}
\ No newline at end of file
diff --git a/user/status.c b/esp-link/status.c
similarity index 100%
rename from user/status.c
rename to esp-link/status.c
diff --git a/user/status.h b/esp-link/status.h
similarity index 100%
rename from user/status.h
rename to esp-link/status.h
diff --git a/include/esp8266.h b/include/esp8266.h
index 535dfeb..d1f5cc4 100644
--- a/include/esp8266.h
+++ b/include/esp8266.h
@@ -17,7 +17,7 @@
#include "espmissingincludes.h"
#include "uart_hw.h"
-//void init(void);
+void ICACHE_FLASH_ATTR init(void);
#ifdef __WIN32__
#include <_mingw.h>
diff --git a/include/user_config.h b/include/user_config.h
index d38c637..16f7f9c 100644
--- a/include/user_config.h
+++ b/include/user_config.h
@@ -36,4 +36,5 @@
#define PROTOCOL_NAMEv31 /*MQTT version 3.1 compatible with Mosquitto v0.15*/
//PROTOCOL_NAMEv311 /*MQTT version 3.11 compatible with https://eclipse.org/paho/clients/testing/*/
+
#endif
\ No newline at end of file
diff --git a/user/user_main.c b/user/user_main.c
index db5db0f..31e62a1 100644
--- a/user/user_main.c
+++ b/user/user_main.c
@@ -1,168 +1,5 @@
-/*
-* ----------------------------------------------------------------------------
-* "THE BEER-WARE LICENSE" (Revision 42):
-* Jeroen Domburg wrote this file. As long as you retain
-* this notice you can do whatever you want with this stuff. If we meet some day,
-* and you think this stuff is worth it, you can buy me a beer in return.
-* ----------------------------------------------------------------------------
-* Heavily modified and enhanced by Thorsten von Eicken in 2015
-* ----------------------------------------------------------------------------
-*/
-
-
#include
-#include "httpd.h"
-#include "httpdespfs.h"
-#include "cgi.h"
-#include "cgiwifi.h"
-#include "cgipins.h"
-#include "cgitcp.h"
-#include "cgiflash.h"
-#include "auth.h"
-#include "espfs.h"
-#include "uart.h"
-#include "serbridge.h"
-#include "status.h"
-#include "serled.h"
-#include "console.h"
-#include "config.h"
-#include "log.h"
-#include
-
-//#define SHOW_HEAP_USE
-
-//Function that tells the authentication system what users/passwords live on the system.
-//This is disabled in the default build; if you want to try it, enable the authBasic line in
-//the builtInUrls below.
-int myPassFn(HttpdConnData *connData, int no, char *user, int userLen, char *pass, int passLen) {
- if (no == 0) {
- os_strcpy(user, "admin");
- os_strcpy(pass, "s3cr3t");
- return 1;
- //Add more users this way. Check against incrementing no for each user added.
- // } else if (no==1) {
- // os_strcpy(user, "user1");
- // os_strcpy(pass, "something");
- // return 1;
- }
- return 0;
-}
-
-
-/*
-This is the main url->function dispatching data struct.
-In short, it's a struct with various URLs plus their handlers. The handlers can
-be 'standard' CGI functions you wrote, or 'special' CGIs requiring an argument.
-They can also be auth-functions. An asterisk will match any url starting with
-everything before the asterisks; "*" matches everything. The list will be
-handled top-down, so make sure to put more specific rules above the more
-general ones. Authorization things (like authBasic) act as a 'barrier' and
-should be placed above the URLs they protect.
-*/
-HttpdBuiltInUrl builtInUrls[] = {
- { "/", cgiRedirect, "/home.html" },
- { "/menu", cgiMenu, NULL },
- { "/flash/next", cgiGetFirmwareNext, NULL },
- { "/flash/upload", cgiUploadFirmware, NULL },
- { "/flash/reboot", cgiRebootFirmware, NULL },
- //{"/home.html", cgiEspFsHtml, NULL},
- //{"/log.html", cgiEspFsHtml, NULL},
- { "/log/text", ajaxLog, NULL },
- { "/log/dbg", ajaxLogDbg, NULL },
- //{"/console.html", cgiEspFsHtml, NULL},
- { "/console/reset", ajaxConsoleReset, NULL },
- { "/console/baud", ajaxConsoleBaud, NULL },
- { "/console/text", ajaxConsole, NULL },
-
- //Routines to make the /wifi URL and everything beneath it work.
-
- //Enable the line below to protect the WiFi configuration with an username/password combo.
- // {"/wifi/*", authBasic, myPassFn},
-
- { "/wifi", cgiRedirect, "/wifi/wifi.html" },
- { "/wifi/", cgiRedirect, "/wifi/wifi.html" },
- //{"/wifi/wifi.html", cgiEspFsHtml, NULL},
- { "/wifi/info", cgiWifiInfo, NULL },
- { "/wifi/scan", cgiWiFiScan, NULL },
- { "/wifi/connect", cgiWiFiConnect, NULL },
- { "/wifi/connstatus", cgiWiFiConnStatus, NULL },
- { "/wifi/setmode", cgiWiFiSetMode, NULL },
- { "/wifi/special", cgiWiFiSpecial, NULL },
- { "/pins", cgiPins, NULL },
- { "/tcpclient", cgiTcp, NULL },
-
- { "*", cgiEspFsHook, NULL }, //Catch-all cgi function for the filesystem
- { NULL, NULL, NULL }
-};
-
-
-//#define SHOW_HEAP_USE
-
-#ifdef SHOW_HEAP_USE
-static ETSTimer prHeapTimer;
-
-static void ICACHE_FLASH_ATTR prHeapTimerCb(void *arg) {
- os_printf("Heap: %ld\n", (unsigned long)system_get_free_heap_size());
-}
-#endif
-
-void user_rf_pre_init(void) {
-}
-
-// address of espfs binary blob
-extern uint32_t _binary_espfs_img_start;
-
-static char *rst_codes[] = {
- "normal", "wdt reset", "exception", "soft wdt", "restart", "deep sleep", "external",
-};
-
-# define VERS_STR_STR(V) #V
-# define VERS_STR(V) VERS_STR_STR(V)
-char *esp_link_version = VERS_STR(VERSION);
-
-//Main routine. Initialize stdout, the I/O, filesystem and the webserver and we're done.
-void user_init(void) {
- // get the flash config so we know how to init things
- //configWipe(); // uncomment to reset the config for testing purposes
- bool restoreOk = configRestore();
- // init gpio pin registers
- gpio_init();
- // init UART
- uart_init(flashConfig.baud_rate, 115200);
- logInit(); // must come after init of uart
- // say hello (leave some time to cause break in TX after boot loader's msg
- os_delay_us(10000L);
- os_printf("\n\n** %s\n", esp_link_version);
- os_printf("Flash config restore %s\n", restoreOk ? "ok" : "*FAILED*");
- // Status LEDs
- statusInit();
- serledInit();
- // Wifi
- wifiInit();
- // init the flash filesystem with the html stuff
- espFsInit(&_binary_espfs_img_start);
- //EspFsInitResult res = espFsInit(&_binary_espfs_img_start);
- //os_printf("espFsInit %s\n", res?"ERR":"ok");
- // mount the http handlers
- httpdInit(builtInUrls, 80);
- // init the wifi-serial transparent bridge (port 23)
- serbridgeInit(23);
- uart_add_recv_cb(&serbridgeUartCb);
-#ifdef SHOW_HEAP_USE
- os_timer_disarm(&prHeapTimer);
- os_timer_setfn(&prHeapTimer, prHeapTimerCb, NULL);
- os_timer_arm(&prHeapTimer, 10000, 1);
-#endif
-
- struct rst_info *rst_info = system_get_rst_info();
- os_printf("Reset cause: %d=%s\n", rst_info->reason, rst_codes[rst_info->reason]);
- os_printf("exccause=%d epc1=0x%x epc2=0x%x epc3=0x%x excvaddr=0x%x depc=0x%x\n",
- rst_info->exccause, rst_info->epc1, rst_info->epc2, rst_info->epc3,
- rst_info->excvaddr, rst_info->depc);
- os_printf("Flash map %d, chip %08X\n", system_get_flash_size_map(), spi_flash_get_id());
-
- os_printf("** esp-link ready\n");
- // call user_main init
-// init();
+void init() {
+
}
\ No newline at end of file