From 0a73be298342d27b7503fee25c0c477cc375f3b8 Mon Sep 17 00:00:00 2001 From: Thorsten von Eicken Date: Wed, 17 Oct 2018 14:04:18 -0700 Subject: [PATCH] compile under platformio --- {html => data/html}/console.html | 0 {html => data/html}/console.js | 0 {html => data/html}/favicon.ico | Bin {html => data/html}/flash.html | 0 {html => data/html}/flash.js | 0 {html => data/html}/head- | 0 {html => data/html}/home.html | 0 {html => data/html}/jl-400x110.png- | Bin {html => data/html}/log.html | 0 {html => data/html}/mqtt.html | 0 {html => data/html}/mqtt.js | 0 {html => data/html}/pure.css | 0 {html => data/html}/services.html | 0 {html => data/html}/services.js | 0 {html => data/html}/style.css | 0 {html => data/html}/ui.js | 0 {html => data/html}/userpage.js | 0 {html => data/html}/web-server.html | 0 {html => data/html}/wifi/icons.png | Bin {html => data/html}/wifi/wifiAp.html | 0 {html => data/html}/wifi/wifiAp.js | 0 {html => data/html}/wifi/wifiSta.html | 0 {html => data/html}/wifi/wifiSta.js | 0 data/spiffs/console.html | 56 +++++ data/spiffs/console.js | 72 ++++++ data/spiffs/favicon.ico | Bin 0 -> 874 bytes data/spiffs/flash.html | 6 + data/spiffs/flash.js | 20 ++ data/spiffs/home.html | 10 + data/spiffs/log.html | 31 +++ data/spiffs/mqtt.html | 7 + data/spiffs/mqtt.js | 46 ++++ data/spiffs/pure.css | 9 + data/spiffs/services.html | 8 + data/spiffs/services.js | 47 ++++ data/spiffs/style.css | 1 + data/spiffs/ui.js | 213 ++++++++++++++++++ data/spiffs/userpage.js | 115 ++++++++++ data/spiffs/web-server.html | 10 + data/spiffs/wifi/icons.png | Bin 0 -> 425 bytes data/spiffs/wifi/wifiAp.html | 10 + data/spiffs/wifi/wifiAp.js | 53 +++++ data/spiffs/wifi/wifiSta.html | 10 + data/spiffs/wifi/wifiSta.js | 134 +++++++++++ {espfs/mkespfsimage => mkespfsimage}/Makefile | 0 mkespfsimage/heatshrink_encoder.o | Bin 0 -> 942 bytes {espfs/mkespfsimage => mkespfsimage}/main.c | 0 mkespfsimage/main.o | Bin 0 -> 9400 bytes mkespfsimage/mkespfsimage | Bin 0 -> 18280 bytes .../mman-win32/Makefile | 0 .../mman-win32/config.mak | 0 .../mman-win32/configure | 0 .../mman-win32/mman.c | 0 .../mman-win32/mman.h | 0 .../mman-win32/test.c | 0 platformio.ini | 24 ++ {esp-link => src}/cgi.c | 2 +- {esp-link => src}/cgi.h | 2 +- {esp-link => src}/cgiflash.c | 0 {esp-link => src}/cgiflash.h | 2 +- {esp-link => src}/cgimega.c | 6 +- {esp-link => src}/cgimega.h | 2 +- {esp-link => src}/cgimqtt.c | 0 {esp-link => src}/cgimqtt.h | 2 +- {esp-link => src}/cgioptiboot.c | 8 +- {esp-link => src}/cgioptiboot.h | 2 +- {esp-link => src}/cgipins.c | 6 +- {esp-link => src}/cgipins.h | 2 +- {esp-link => src}/cgiservices.c | 2 +- {esp-link => src}/cgiservices.h | 2 +- {esp-link => src}/cgitcp.c | 0 {esp-link => src}/cgitcp.h | 2 +- {esp-link => src}/cgiwebserversetup.c | 16 +- {esp-link => src}/cgiwebserversetup.h | 2 +- {esp-link => src}/cgiwifi.c | 0 {esp-link => src}/cgiwifi.h | 2 +- {cmd => src/cmd}/cmd.c | 4 +- {cmd => src/cmd}/cmd.h | 0 {cmd => src/cmd}/handlers.c | 12 +- {esp-link => src}/config.c | 4 +- {esp-link => src}/config.h | 0 {espfs => src/espfs}/espfs.c | 0 {espfs => src/espfs}/espfs.h | 0 {espfs => src/espfs}/espfsformat.h | 0 {httpd => src/httpd}/auth.c | 0 {httpd => src/httpd}/auth.h | 0 {httpd => src/httpd}/base64.c | 0 {httpd => src/httpd}/base64.h | 0 {httpd => src/httpd}/httpd.c | 0 {httpd => src/httpd}/httpd.h | 0 {httpd => src/httpd}/httpdespfs.c | 0 {httpd => src/httpd}/httpdespfs.h | 6 +- {httpd => src/httpd}/multipart.c | 0 {httpd => src/httpd}/multipart.h | 2 +- {include => src/include}/c_types.h | 0 {include => src/include}/esp8266.h | 0 {include => src/include}/espmissingincludes.h | 0 {include => src/include}/uart_hw.h | 0 {include => src/include}/user_config.h | 0 {esp-link => src}/log.c | 2 +- {esp-link => src}/log.h | 2 +- {esp-link => src}/main.c | 24 +- {mqtt => src/mqtt}/mqtt.c | 0 {mqtt => src/mqtt}/mqtt.h | 0 {mqtt => src/mqtt}/mqtt_cmd.c | 4 +- {mqtt => src/mqtt}/mqtt_cmd.h | 2 +- {mqtt => src/mqtt}/mqtt_msg.c | 0 {mqtt => src/mqtt}/mqtt_msg.h | 0 {mqtt => src/mqtt}/pktbuf.c | 0 {mqtt => src/mqtt}/pktbuf.h | 0 {esp-link => src}/mqtt_client.c | 2 +- {esp-link => src}/mqtt_client.h | 2 +- {esp-link => src}/pgmshared.c | 6 +- {esp-link => src}/pgmshared.h | 0 {rest => src/rest}/rest.c | 2 +- {rest => src/rest}/rest.h | 2 +- {serial => src/serial}/console.c | 0 {serial => src/serial}/console.h | 2 +- {serial => src/serial}/crc16.c | 0 {serial => src/serial}/crc16.h | 0 {serial => src/serial}/serbridge.c | 2 +- {serial => src/serial}/serbridge.h | 0 {serial => src/serial}/serled.c | 2 +- {serial => src/serial}/serled.h | 0 {serial => src/serial}/slip.c | 2 +- {serial => src/serial}/slip.h | 0 {serial => src/serial}/uart.c | 0 {serial => src/serial}/uart.h | 0 {socket => src/socket}/socket.c | 0 {socket => src/socket}/socket.h | 2 +- {esp-link => src}/status.c | 4 +- {esp-link => src}/status.h | 0 {esp-link => src}/stk500.h | 0 {esp-link => src}/stk500v2.h | 0 {syslog => src/syslog}/syslog.c | 0 {syslog => src/syslog}/syslog.h | 0 {syslog => src/syslog}/syslog.md | 0 {esp-link => src}/task.c | 0 {esp-link => src}/task.h | 0 {user => src/user}/user_main.c | 0 {web-server => src/web-server}/web-server.c | 136 +++++------ {web-server => src/web-server}/web-server.h | 4 +- 142 files changed, 1029 insertions(+), 143 deletions(-) rename {html => data/html}/console.html (100%) rename {html => data/html}/console.js (100%) rename {html => data/html}/favicon.ico (100%) rename {html => data/html}/flash.html (100%) rename {html => data/html}/flash.js (100%) rename {html => data/html}/head- (100%) rename {html => data/html}/home.html (100%) rename {html => data/html}/jl-400x110.png- (100%) rename {html => data/html}/log.html (100%) rename {html => data/html}/mqtt.html (100%) rename {html => data/html}/mqtt.js (100%) rename {html => data/html}/pure.css (100%) rename {html => data/html}/services.html (100%) rename {html => data/html}/services.js (100%) rename {html => data/html}/style.css (100%) rename {html => data/html}/ui.js (100%) rename {html => data/html}/userpage.js (100%) rename {html => data/html}/web-server.html (100%) rename {html => data/html}/wifi/icons.png (100%) rename {html => data/html}/wifi/wifiAp.html (100%) rename {html => data/html}/wifi/wifiAp.js (100%) rename {html => data/html}/wifi/wifiSta.html (100%) rename {html => data/html}/wifi/wifiSta.js (100%) create mode 100644 data/spiffs/console.html create mode 100644 data/spiffs/console.js create mode 100755 data/spiffs/favicon.ico create mode 100644 data/spiffs/flash.html create mode 100644 data/spiffs/flash.js create mode 100644 data/spiffs/home.html create mode 100644 data/spiffs/log.html create mode 100644 data/spiffs/mqtt.html create mode 100644 data/spiffs/mqtt.js create mode 100644 data/spiffs/pure.css create mode 100644 data/spiffs/services.html create mode 100644 data/spiffs/services.js create mode 100644 data/spiffs/style.css create mode 100644 data/spiffs/ui.js create mode 100644 data/spiffs/userpage.js create mode 100644 data/spiffs/web-server.html create mode 100644 data/spiffs/wifi/icons.png create mode 100644 data/spiffs/wifi/wifiAp.html create mode 100644 data/spiffs/wifi/wifiAp.js create mode 100644 data/spiffs/wifi/wifiSta.html create mode 100644 data/spiffs/wifi/wifiSta.js rename {espfs/mkespfsimage => mkespfsimage}/Makefile (100%) create mode 100644 mkespfsimage/heatshrink_encoder.o rename {espfs/mkespfsimage => mkespfsimage}/main.c (100%) create mode 100644 mkespfsimage/main.o create mode 100755 mkespfsimage/mkespfsimage rename {espfs/mkespfsimage => mkespfsimage}/mman-win32/Makefile (100%) rename {espfs/mkespfsimage => mkespfsimage}/mman-win32/config.mak (100%) rename {espfs/mkespfsimage => mkespfsimage}/mman-win32/configure (100%) rename {espfs/mkespfsimage => mkespfsimage}/mman-win32/mman.c (100%) rename {espfs/mkespfsimage => mkespfsimage}/mman-win32/mman.h (100%) rename {espfs/mkespfsimage => mkespfsimage}/mman-win32/test.c (100%) create mode 100644 platformio.ini rename {esp-link => src}/cgi.c (99%) rename {esp-link => src}/cgi.h (98%) rename {esp-link => src}/cgiflash.c (100%) rename {esp-link => src}/cgiflash.h (91%) rename {esp-link => src}/cgimega.c (99%) rename {esp-link => src}/cgimega.h (94%) rename {esp-link => src}/cgimqtt.c (100%) rename {esp-link => src}/cgimqtt.h (85%) rename {esp-link => src}/cgioptiboot.c (99%) rename {esp-link => src}/cgioptiboot.h (91%) rename {esp-link => src}/cgipins.c (97%) rename {esp-link => src}/cgipins.h (83%) rename {esp-link => src}/cgiservices.c (99%) rename {esp-link => src}/cgiservices.h (93%) rename {esp-link => src}/cgitcp.c (100%) rename {esp-link => src}/cgitcp.h (76%) rename {esp-link => src}/cgiwebserversetup.c (97%) rename {esp-link => src}/cgiwebserversetup.h (85%) rename {esp-link => src}/cgiwifi.c (100%) rename {esp-link => src}/cgiwifi.h (97%) rename {cmd => src/cmd}/cmd.c (98%) rename {cmd => src/cmd}/cmd.h (100%) rename {cmd => src/cmd}/handlers.c (98%) rename {esp-link => src}/config.c (99%) rename {esp-link => src}/config.h (100%) rename {espfs => src/espfs}/espfs.c (100%) rename {espfs => src/espfs}/espfs.h (100%) rename {espfs => src/espfs}/espfsformat.h (100%) rename {httpd => src/httpd}/auth.c (100%) rename {httpd => src/httpd}/auth.h (100%) rename {httpd => src/httpd}/base64.c (100%) rename {httpd => src/httpd}/base64.h (100%) rename {httpd => src/httpd}/httpd.c (100%) rename {httpd => src/httpd}/httpd.h (100%) rename {httpd => src/httpd}/httpdespfs.c (100%) rename {httpd => src/httpd}/httpdespfs.h (75%) rename {httpd => src/httpd}/multipart.c (100%) rename {httpd => src/httpd}/multipart.h (97%) rename {include => src/include}/c_types.h (100%) rename {include => src/include}/esp8266.h (100%) rename {include => src/include}/espmissingincludes.h (100%) rename {include => src/include}/uart_hw.h (100%) rename {include => src/include}/user_config.h (100%) rename {esp-link => src}/log.c (99%) rename {esp-link => src}/log.h (94%) rename {esp-link => src}/main.c (96%) rename {mqtt => src/mqtt}/mqtt.c (100%) rename {mqtt => src/mqtt}/mqtt.h (100%) rename {mqtt => src/mqtt}/mqtt_cmd.c (99%) rename {mqtt => src/mqtt}/mqtt_cmd.h (95%) rename {mqtt => src/mqtt}/mqtt_msg.c (100%) rename {mqtt => src/mqtt}/mqtt_msg.h (100%) rename {mqtt => src/mqtt}/pktbuf.c (100%) rename {mqtt => src/mqtt}/pktbuf.h (100%) rename {esp-link => src}/mqtt_client.c (99%) rename {esp-link => src}/mqtt_client.h (94%) rename {esp-link => src}/pgmshared.c (98%) rename {esp-link => src}/pgmshared.h (100%) rename {rest => src/rest}/rest.c (99%) rename {rest => src/rest}/rest.h (92%) rename {serial => src/serial}/console.c (100%) rename {serial => src/serial}/console.h (94%) rename {serial => src/serial}/crc16.c (100%) rename {serial => src/serial}/crc16.h (100%) rename {serial => src/serial}/serbridge.c (99%) rename {serial => src/serial}/serbridge.h (100%) rename {serial => src/serial}/serled.c (98%) rename {serial => src/serial}/serled.h (100%) rename {serial => src/serial}/slip.c (99%) rename {serial => src/serial}/slip.h (100%) rename {serial => src/serial}/uart.c (100%) rename {serial => src/serial}/uart.h (100%) rename {socket => src/socket}/socket.c (100%) rename {socket => src/socket}/socket.h (97%) rename {esp-link => src}/status.c (98%) rename {esp-link => src}/status.h (100%) rename {esp-link => src}/stk500.h (100%) rename {esp-link => src}/stk500v2.h (100%) rename {syslog => src/syslog}/syslog.c (100%) rename {syslog => src/syslog}/syslog.h (100%) rename {syslog => src/syslog}/syslog.md (100%) rename {esp-link => src}/task.c (100%) rename {esp-link => src}/task.h (100%) rename {user => src/user}/user_main.c (100%) rename {web-server => src/web-server}/web-server.c (97%) rename {web-server => src/web-server}/web-server.h (94%) diff --git a/html/console.html b/data/html/console.html similarity index 100% rename from html/console.html rename to data/html/console.html diff --git a/html/console.js b/data/html/console.js similarity index 100% rename from html/console.js rename to data/html/console.js diff --git a/html/favicon.ico b/data/html/favicon.ico similarity index 100% rename from html/favicon.ico rename to data/html/favicon.ico diff --git a/html/flash.html b/data/html/flash.html similarity index 100% rename from html/flash.html rename to data/html/flash.html diff --git a/html/flash.js b/data/html/flash.js similarity index 100% rename from html/flash.js rename to data/html/flash.js diff --git a/html/head- b/data/html/head- similarity index 100% rename from html/head- rename to data/html/head- diff --git a/html/home.html b/data/html/home.html similarity index 100% rename from html/home.html rename to data/html/home.html diff --git a/html/jl-400x110.png- b/data/html/jl-400x110.png- similarity index 100% rename from html/jl-400x110.png- rename to data/html/jl-400x110.png- diff --git a/html/log.html b/data/html/log.html similarity index 100% rename from html/log.html rename to data/html/log.html diff --git a/html/mqtt.html b/data/html/mqtt.html similarity index 100% rename from html/mqtt.html rename to data/html/mqtt.html diff --git a/html/mqtt.js b/data/html/mqtt.js similarity index 100% rename from html/mqtt.js rename to data/html/mqtt.js diff --git a/html/pure.css b/data/html/pure.css similarity index 100% rename from html/pure.css rename to data/html/pure.css diff --git a/html/services.html b/data/html/services.html similarity index 100% rename from html/services.html rename to data/html/services.html diff --git a/html/services.js b/data/html/services.js similarity index 100% rename from html/services.js rename to data/html/services.js diff --git a/html/style.css b/data/html/style.css similarity index 100% rename from html/style.css rename to data/html/style.css diff --git a/html/ui.js b/data/html/ui.js similarity index 100% rename from html/ui.js rename to data/html/ui.js diff --git a/html/userpage.js b/data/html/userpage.js similarity index 100% rename from html/userpage.js rename to data/html/userpage.js diff --git a/html/web-server.html b/data/html/web-server.html similarity index 100% rename from html/web-server.html rename to data/html/web-server.html diff --git a/html/wifi/icons.png b/data/html/wifi/icons.png similarity index 100% rename from html/wifi/icons.png rename to data/html/wifi/icons.png diff --git a/html/wifi/wifiAp.html b/data/html/wifi/wifiAp.html similarity index 100% rename from html/wifi/wifiAp.html rename to data/html/wifi/wifiAp.html diff --git a/html/wifi/wifiAp.js b/data/html/wifi/wifiAp.js similarity index 100% rename from html/wifi/wifiAp.js rename to data/html/wifi/wifiAp.js diff --git a/html/wifi/wifiSta.html b/data/html/wifi/wifiSta.html similarity index 100% rename from html/wifi/wifiSta.html rename to data/html/wifi/wifiSta.html diff --git a/html/wifi/wifiSta.js b/data/html/wifi/wifiSta.js similarity index 100% rename from html/wifi/wifiSta.js rename to data/html/wifi/wifiSta.js diff --git a/data/spiffs/console.html b/data/spiffs/console.html new file mode 100644 index 0000000..d811640 --- /dev/null +++ b/data/spiffs/console.html @@ -0,0 +1,56 @@ +esp-link

Microcontroller Console

Reset µC   Clear Log   Baud:   Fmt:

Console
--- No Content ---
Console entry
(ENTER to submit, ESC to clear)
Add:
History buffer
(UP/DOWN arrows to select)
\ No newline at end of file diff --git a/data/spiffs/console.js b/data/spiffs/console.js new file mode 100644 index 0000000..e2451ff --- /dev/null +++ b/data/spiffs/console.js @@ -0,0 +1,72 @@ +function fetchText(a,c){var b=$("#console"); +if(b.textEnd==undefined){b.textEnd=0; +b.innerHTML="" +}window.setTimeout(function(){ajaxJson("GET",console_url+"?start="+b.textEnd,function(e){var d=updateText(e); +if(c){fetchText(d,c) +}},function(){retryLoad(c) +}) +},a) +}function updateText(d){var b=$("#console"); +var a=3000; +if(d!=null&&d.len>0){var c=b.scrollHeight-b.clientHeight<=b.scrollTop+1; +if(d.start>b.textEnd){b.innerHTML=b.innerHTML.concat("\r\n/g,">").replace(/"/g,""")); +b.textEnd=d.start+d.len; +a=500; +if(c){b.scrollTop=b.scrollHeight-b.clientHeight +}}return a +}function retryLoad(a){fetchText(1000,a) +}function consoleSendInit(){var e=$("#send-history"); +var h=$("#input-text"); +var d=$("#input-add-cr"); +var b=$("#input-add-lf"); +function g(k){for(var j=0; +j=e.children.length){i=0 +}a(i) +}e.addEventListener("change",function(i){h.value=e.value +}); +function c(k){var i=g(k); +if(i!==null){a(i); +return false +}var j=m(""); +j.value=k; +e.appendChild(j); +e.value=k; +for(; +e.children.length>15; +){e.removeChild(e.children[0]) +}return true +}h.addEventListener("keydown",function(i){switch(i.keyCode){case 38:i.preventDefault(); +f(-1); +break; +case 40:i.preventDefault(); +f(+1); +break; +case 27:i.preventDefault(); +h.value=""; +e.value=""; +break; +case 13:i.preventDefault(); +var j=h.value; +if(d.checked){j+="\r" +}if(b.checked){j+="\n" +}c(h.value); +h.value=""; +ajaxSpin("POST","/console/send?text="+encodeURIComponent(j),function(k){showNotification("Text sent") +},function(l,k){showWarning("Error sending text") +}); +break +}}) +}function showDbgMode(c){var b=$(".dbg-btn"); +for(var a=0; +aNktgRs>r5G6Aq^!kV zV*l^&R#sN6EiJ7W7^MspA^8LW00031EC2ui06+jh000F4Fvv-(wIb^+uK!?I6(nbp zg{ZEh>Aoo|Tg+?U-OMrt?w>kU4OcK2kA|Kv__-AcfT(l|AS7?h%FVE#dc6w+Hf!U4 z&tI`Crc-hX==j;aVYBEOs64Kp64o*=U3+K*3||Cz87wD+az$v0D~*nE0)1bSA$V|= z01B83nn0Vsd5Sf0|x^NqKAZkbsj?+ot_Q50}oP3m1-Lo zCZ16V2)wn zS4jY|&=Txy^$gv*0*c4URS~k3zN^KqjE4Lefdvb$f5En_*)gyK;$ocs4mq#|tPmh@ z;H7t1;Nl2OmA7<)OSgW#s5a`g@h;QUxWfkj9i4D@04Ai#)J#D84ImF56h!oi1NkVB zKmrO}lM+Y3*+kNXAchzsCbVQ_*8jg_yR@t#1B&+Nf3(Q9PEVR)wlH3m^RQsz9+IH(L1rY!MJGW+g AmH+?% literal 0 HcmV?d00001 diff --git a/data/spiffs/flash.html b/data/spiffs/flash.html new file mode 100644 index 0000000..fd26c58 --- /dev/null +++ b/data/spiffs/flash.html @@ -0,0 +1,6 @@ +esp-link

Upgrade Firmware

Upgrade Firmware

\ No newline at end of file diff --git a/data/spiffs/flash.js b/data/spiffs/flash.js new file mode 100644 index 0000000..b1ff173 --- /dev/null +++ b/data/spiffs/flash.js @@ -0,0 +1,20 @@ +function flashFirmware(b){b.preventDefault(); +var a=document.getElementById("fw-file").files[0]; +$("#fw-form").setAttribute("hidden",""); +$("#fw-spinner").removeAttribute("hidden"); +showNotification("Firmware is being updated ..."); +ajaxReq("POST","/flash/upload",function(c){ajaxReq("GET","/flash/reboot",function(d){showNotification("Firmware has been successfully updated!"); +setTimeout(function(){window.location.reload() +},4000); +$("#fw-spinner").setAttribute("hidden",""); +$("#fw-form").removeAttribute("hidden") +}) +},null,a) +}function fetchFlash(){ajaxReq("GET","/flash/next",function(a){$("#fw-slot").innerHTML=a; +$("#fw-spinner").setAttribute("hidden",""); +$("#fw-form").removeAttribute("hidden") +}); +ajaxJson("GET","/menu",function(b){var a=$("#current-fw"); +if(a!=null){a.innerHTML=b.version +}}) +}; \ No newline at end of file diff --git a/data/spiffs/home.html b/data/spiffs/home.html new file mode 100644 index 0000000..3f14706 --- /dev/null +++ b/data/spiffs/home.html @@ -0,0 +1,10 @@ +esp-link
JEELABS

esp-link

System overview

Info

The JeeLabs esp-link firmware bridges the ESP8266 serial port to WiFi and can program microcontrollers over the serial port, in particular Arduinos, AVRs, and NXP's LPC800 and other ARM processors. Typical avrdude command line to program an Arduino:

/home/arduino/hardware/tools/avrdude \
  -DV -patmega328p \
  -Pnet:esp-link.local:23 \
  -carduino -b115200 \
  -U flash:w:my_sketch.hex:i\
  -C /home/arduino/hardware/tools/avrdude.conf

where -Pnet:esp-link.local:23 tells avrdude to connect to port 23 of esp-link. You can substitute the IP address of your esp-link for esp-link.local if necessary. Please refer to the online README for up-to-date help.

Pin assignment

System details

\ No newline at end of file diff --git a/data/spiffs/log.html b/data/spiffs/log.html new file mode 100644 index 0000000..b50e772 --- /dev/null +++ b/data/spiffs/log.html @@ -0,0 +1,31 @@ +esp-link

Debug Log

The debug log shows the most recent characters printed by the esp-link software itself to its own debug log.

\ No newline at end of file diff --git a/data/spiffs/mqtt.html b/data/spiffs/mqtt.html new file mode 100644 index 0000000..4c4537d --- /dev/null +++ b/data/spiffs/mqtt.html @@ -0,0 +1,7 @@ +esp-link

REST & MQTT

The REST & MQTT support uses the SLIP protocol over the serial port to enable the attached microcontroller to initiate outbound connections. The REST support lets the uC initiate simple HTTP requests while the MQTT support lets it communicate with an MQTT server bidirectionally at QoS 0 thru 2.

The MQTT support is in the form of a built-in client that connects to a server using parameters set below and stored in esp-link's flash settings. This allows esp-link to take care of connection parameters and disconnect/reconnect operations.

The MQTT client also supports sending periodic status messages about esp-link itself, including WiFi RSSI, and free heap memory.

MQTT

Status reporting

REST

REST requests are enabled as soon as SLIP is enabled. There are no REST-specific settings.

\ No newline at end of file diff --git a/data/spiffs/mqtt.js b/data/spiffs/mqtt.js new file mode 100644 index 0000000..1b3ffb1 --- /dev/null +++ b/data/spiffs/mqtt.js @@ -0,0 +1,46 @@ +function changeMqtt(f){f.preventDefault(); +var c="mqtt?1=1"; +var d,b=document.querySelectorAll("#mqtt-form input"); +for(d=0; +d0 +}else{el.value=c[d] +}}}); +$("#mqtt-spinner").setAttribute("hidden",""); +$("#mqtt-status-spinner").setAttribute("hidden",""); +$("#mqtt-form").removeAttribute("hidden"); +$("#mqtt-status-form").removeAttribute("hidden"); +var b,a=$("input"); +for(b=0; +b.pure-menu-children,.pure-menu-active>.pure-menu-children{display:block;position:absolute}.pure-menu-has-children>.pure-menu-link:after{padding-left:.5em;content:"\25B8";font-size:small}.pure-menu-horizontal .pure-menu-has-children>.pure-menu-link:after{content:"\25BE"}.pure-menu-scrollable{overflow-y:scroll;overflow-x:hidden}.pure-menu-scrollable .pure-menu-list{display:block}.pure-menu-horizontal.pure-menu-scrollable .pure-menu-list{display:inline-block}.pure-menu-horizontal.pure-menu-scrollable{white-space:nowrap;overflow-y:hidden;overflow-x:auto;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;padding:.5em 0}.pure-menu-horizontal.pure-menu-scrollable::-webkit-scrollbar{display:none}.pure-menu-separator{background-color:#ccc;height:1px;margin:.3em 0}.pure-menu-horizontal .pure-menu-separator{width:1px;height:1.3em;margin:0 .3em}.pure-menu-heading{text-transform:uppercase;color:#565d64}.pure-menu-link{color:#777}.pure-menu-children{background-color:#fff}.pure-menu-link,.pure-menu-disabled,.pure-menu-heading{padding:.5em 1em}.pure-menu-disabled{opacity:.5}.pure-menu-disabled .pure-menu-link:hover{background-color:transparent}.pure-menu-active>.pure-menu-link,.pure-menu-link:hover,.pure-menu-link:focus{background-color:#eee}.pure-menu-selected .pure-menu-link,.pure-menu-selected .pure-menu-link:visited{color:#000}.pure-table{border-collapse:collapse;border-spacing:0;empty-cells:show;border:1px solid #cbcbcb}.pure-table caption{color:#000;font:italic 85%/1 arial,sans-serif;padding:1em 0;text-align:center}.pure-table td,.pure-table th{border-left:1px solid #cbcbcb;border-width:0 0 0 1px;font-size:inherit;margin:0;overflow:visible;padding:.5em 1em}.pure-table td:first-child,.pure-table th:first-child{border-left-width:0}.pure-table thead{background-color:#e0e0e0;color:#000;text-align:left;vertical-align:bottom}.pure-table td{background-color:transparent}.pure-table-odd td{background-color:#f2f2f2}.pure-table-striped tr:nth-child(2n-1) td{background-color:#f2f2f2}.pure-table-bordered td{border-bottom:1px solid #cbcbcb}.pure-table-bordered tbody>tr:last-child>td{border-bottom-width:0}.pure-table-horizontal td,.pure-table-horizontal th{border-width:0 0 1px 0;border-bottom:1px solid #cbcbcb}.pure-table-horizontal tbody>tr:last-child>td{border-bottom-width:0} \ No newline at end of file diff --git a/data/spiffs/services.html b/data/spiffs/services.html new file mode 100644 index 0000000..ee84f4e --- /dev/null +++ b/data/spiffs/services.html @@ -0,0 +1,8 @@ +esp-link

Services

Syslog

mDNS

SNTP

\ No newline at end of file diff --git a/data/spiffs/services.js b/data/spiffs/services.js new file mode 100644 index 0000000..5786505 --- /dev/null +++ b/data/spiffs/services.js @@ -0,0 +1,47 @@ +function changeServices(f){f.preventDefault(); +var c="services/update?1=1"; +var d,b=document.querySelectorAll("#"+f.target.id+" input,select"); +for(d=0; +d=200&&g.status<300){h(g.responseText) +}else{console.log("XHR ERR :",i,a,"->",g.status,g.responseText,g); +c(g.status,g.responseText) +}}; +try{g.send(f) +}catch(b){console.log("XHR EXC :",i,a,"->",b); +c(599,b) +}}function dispatchJson(f,d,c){var a; +try{a=JSON.parse(f) +}catch(b){console.log("JSON parse error: "+b+". In: "+f); +c(500,"JSON parse error: "+b); +return +}d(a) +}function ajaxJson(d,a,c,b){ajaxReq(d,a,function(f){dispatchJson(f,c,b) +},b) +}function ajaxSpin(d,a,c,b){$("#spinner").removeAttribute("hidden"); +ajaxReq(d,a,function(f){$("#spinner").setAttribute("hidden",""); +c(f) +},function(f,g){$("#spinner").setAttribute("hidden",""); +b(f,g) +}) +}function ajaxJsonSpin(d,a,c,b){ajaxSpin(d,a,function(f){dispatchJson(f,c,b) +},b) +}function hidePopup(a){addClass(a,"popup-hidden"); +addClass(a.parentNode,"popup-target") +}onLoad(function(){var a=$("#layout"); +var d=a.childNodes[0]; +a.insertBefore(m(''),d); +a.insertBefore(m('
'),d); +a.insertBefore(m(''),d); +var c=m(' '); +a.insertBefore(c,d); +var f=$("#menuLink"),c=$("#menu"); +bnd(f,"click",function(h){var g="active"; +h.preventDefault(); +toggleClass(a,g); +toggleClass(c,g); +toggleClass(f,g) +}); +domForEach($(".popup"),function(g){hidePopup(g) +}); +var b=function(){ajaxJson("GET","/menu",function(n){var l="",o=window.location.pathname; +for(var k=0; +k'+n.menu[k]+"") +}$("#menu-list").innerHTML=l; +var g=$("#version"); +if(g!=null){g.innerHTML=n.version +}$("title")[0].innerHTML=n.name; +setEditToClick("system-name",n.name) +},function(){setTimeout(b,1000) +}) +}; +b() +}); +function showWifiInfo(b){Object.keys(b).forEach(function(c){el=$("#wifi-"+c); +if(el!=null){if(el.nodeName==="INPUT"){el.value=b[c] +}else{el.innerHTML=b[c] +}}}); +var a=$("#dhcp-r"+b.dhcp); +if(a){a.click() +}$("#wifi-spinner").setAttribute("hidden",""); +$("#wifi-table").removeAttribute("hidden"); +currAp=b.ssid +}function getWifiInfo(){ajaxJson("GET","/wifi/info",showWifiInfo,function(b,a){window.setTimeout(getWifiInfo,1000) +}) +}function showSystemInfo(a){Object.keys(a).forEach(function(b){setEditToClick("system-"+b,a[b]) +}); +$("#system-spinner").setAttribute("hidden",""); +$("#system-table").removeAttribute("hidden"); +currAp=a.ssid +}function getSystemInfo(){ajaxJson("GET","/system/info",showSystemInfo,function(b,a){window.setTimeout(getSystemInfo,1000) +}) +}function makeAjaxInput(a,b){domForEach($("."+a+"-"+b),function(i){var f=$(".edit-on",i); +var d=$(".edit-off",i)[0]; +var c="/"+a+"/update?"+b; +if(d===undefined||f==undefined){return +}var h=function(){d.setAttribute("hidden",""); +domForEach(f,function(k){k.removeAttribute("hidden") +}); +f[0].select(); +return false +}; +var g=function(k){ajaxSpin("POST",c+"="+k,function(){domForEach(f,function(l){l.setAttribute("hidden","") +}); +d.removeAttribute("hidden"); +setEditToClick(a+"-"+b,k); +showNotification(b+" changed to "+k) +},function(){showWarning(b+" change failed") +}); +return false +}; +bnd(d,"click",function(){return h() +}); +bnd(f[0],"blur",function(){return g(f[0].value) +}); +bnd(f[0],"keyup",function(k){if((k||window.event).keyCode==13){return g(f[0].value) +}}) +}) +}function setEditToClick(a,b){domForEach($("."+a),function(c){if(c.children.length>0){domForEach(c.children,function(d){if(d.nodeName==="INPUT"){d.value=b +}else{if(d.nodeName!=="DIV"){d.innerHTML=b +}}}) +}else{c.innerHTML=b +}}) +}function showWarning(b){var a=$("#warning"); +a.innerHTML=b; +a.removeAttribute("hidden"); +window.scrollTo(0,0) +}function hideWarning(){el=$("#warning").setAttribute("hidden","") +}var notifTimeout=null; +function showNotification(b){var a=$("#notification"); +a.innerHTML=b; +a.removeAttribute("hidden"); +if(notifTimeout!=null){clearTimeout(notifTimeout) +}notifTimout=setTimeout(function(){a.setAttribute("hidden",""); +notifTimout=null +},4000) +}var pinPresets={"esp-01":[0,-1,2,-1,0,1],"esp-12":[12,14,0,2,0,1],"esp-12 swap":[1,3,0,2,1,1],"esp-bridge":[12,13,0,14,0,0],"wifi-link-12":[1,3,0,2,1,0]}; +function createPresets(c){for(var d in pinPresets){var a=m('"); +c.appendChild(a) +}function b(h){var f=pinPresets[h]; +if(f===undefined){return f +}function g(l,i){$("#pin-"+l).value=i +}g("reset",f[0]); +g("isp",f[1]); +g("conn",f[2]); +g("ser",f[3]); +g("swap",f[4]); +$("#pin-rxpup").checked=!!f[5]; +c.value=0 +}bnd(c,"change",function(f){f.preventDefault(); +b(c.value) +}) +}function displayPins(b){function a(f,c){var g=$("#pin-"+f); +addClass(g,"pure-button"); +g.innerHTML=""; +[-1,0,1,2,3,4,5,12,13,14,15].forEach(function(k){var h=document.createElement("option"); +h.value=k; +if(k>=0){h.innerHTML="gpio"+k +}else{h.innerHTML="disabled" +}if(k===1){h.innerHTML+="/TX0" +}if(k===2){h.innerHTML+="/TX1" +}if(k===3){h.innerHTML+="/RX0" +}if(k==c){h.selected=true +}g.appendChild(h) +}); +var d=$(".popup",g.parentNode); +if(d!==undefined){hidePopup(d[0]) +}}a("reset",b.reset); +a("isp",b.isp); +a("conn",b.conn); +a("ser",b.ser); +$("#pin-swap").value=b.swap; +$("#pin-rxpup").checked=!!b.rxpup; +createPresets($("#pin-preset")); +$("#pin-spinner").setAttribute("hidden",""); +$("#pin-table").removeAttribute("hidden") +}function fetchPins(){ajaxJson("GET","/pins",displayPins,function(){window.setTimeout(fetchPins,1000) +}) +}function setPins(c){c.preventDefault(); +var b="/pins"; +var a="?"; +["reset","isp","conn","ser","swap"].forEach(function(d){b+=a+d+"="+$("#pin-"+d).value; +a="&" +}); +b+="&rxpup="+($("#pin-rxpup").checked?"1":"0"); +ajaxSpin("POST",b,function(){showNotification("Pin assignment changed") +},function(d,f){showWarning(f); +window.setTimeout(fetchPins,100) +}) +}; \ No newline at end of file diff --git a/data/spiffs/userpage.js b/data/spiffs/userpage.js new file mode 100644 index 0000000..adcc050 --- /dev/null +++ b/data/spiffs/userpage.js @@ -0,0 +1,115 @@ +var loadCounter=0; +var refreshRate=0; +var refreshTimer; +var hiddenInputs=[]; +function notifyResponse(a){Object.keys(a).forEach(function(m){var c=document.getElementsByName(m); +var n; +for(n=0; +n"+l[h]+"") +}e.innerHTML=k +}if(e.tagName=="TABLE"){var l=a[m]; +var k=""; +if(l.length>0){var b=l[0]; +k=k.concat(""); +for(var h=0; +h"+b[h]+"") +}k=k.concat("") +}for(var h=1; +h"); +for(var f=0; +f"+g[f]+"") +}k=k.concat("") +}e.innerHTML=k +}}}); +if(refreshRate!=0){clearTimeout(refreshTimer); +refreshTimer=setTimeout(function(){ajaxJson("GET",window.location.pathname+".json?reason=refresh",notifyResponse) +},refreshRate) +}}function notifyButtonPressed(a){ajaxJson("POST",window.location.pathname+".json?reason=button&id="+a,notifyResponse) +}function refreshFormData(){setTimeout(function(){ajaxJson("GET",window.location.pathname+".json?reason=refresh",function(a){notifyResponse(a); +if(loadCounter>0){loadCounter--; +refreshFormData() +}}) +},250) +}function recalculateHiddenInputs(){for(var f=0; +fesp-link

Web Server

User defined web pages can be uploaded to esp-link. This is useful if esp-link acts as a web server while MCU provides the measurement data.

The custom web page to upload:
\ No newline at end of file diff --git a/data/spiffs/wifi/icons.png b/data/spiffs/wifi/icons.png new file mode 100644 index 0000000000000000000000000000000000000000..08c933f490afa8a693db04ce25735bb2c52f90be GIT binary patch literal 425 zcmV;a0apHrP)V@pd*X<^C$qTT>#j{pDw09t$Kw)xrs0004WQchCg8e_v1xB``-vETqS+gs6dg*}0-2cX%Oa&O?N99WZY zSZ4}h65KF}mGA3>@Fz=lj4`eB{mD5uNZ{#czW+qm-6k+(X9o1e3|jiA09t?nh^qlC z5CBd7m}eOWFag|oP)&0YfgcHAfe6&z6F^)6V27r;%D|RNfMy*C)3P8BAp7^xI02}C z#-D)qlSFy81gL)u5LWesp-link

WiFi Soft-AP Configuration

Soft-AP State

Soft-AP Settings

\ No newline at end of file diff --git a/data/spiffs/wifi/wifiAp.js b/data/spiffs/wifi/wifiAp.js new file mode 100644 index 0000000..0740996 --- /dev/null +++ b/data/spiffs/wifi/wifiAp.js @@ -0,0 +1,53 @@ +var specials=[]; +specials.ap_ssid="SSID name"; +specials.ap_password="PASSWORD"; +specials.ap_maxconn="Max Connections number"; +specials.ap_beacon="Beacon Interval"; +function changeWifiMode(a){blockScan=1; +hideWarning(); +ajaxSpin("POST","setmode?mode="+a,function(b){showNotification("Mode changed"); +window.setTimeout(getWifiInfo,100); +blockScan=0 +},function(c,b){showWarning("Error changing mode: "+b); +window.setTimeout(getWifiInfo,100); +blockScan=0 +}) +}function changeApSettings(j){j.preventDefault(); +var a="/wifi/apchange?100=1"; +var f,h=document.querySelectorAll("#"+j.target.id+" input,select"); +for(f=0; +fesp-link

WiFi Station Configuration

WiFi State

WiFi Association

To connect to a WiFi network, please select one of the detected networks, enter the password, and hit the connect button...
Scanning...

Special Settings

Special settings, use with care!
\ No newline at end of file diff --git a/data/spiffs/wifi/wifiSta.js b/data/spiffs/wifi/wifiSta.js new file mode 100644 index 0000000..137e1a4 --- /dev/null +++ b/data/spiffs/wifi/wifiSta.js @@ -0,0 +1,134 @@ +var currAp=""; +var blockScan=0; +function createInputForAp(b){if(b.essid==""&&b.rssi==0){return +}var g=e("input"); +g.type="radio"; +g.name="essid"; +g.value=b.essid; +g.id="opt-"+b.essid; +if(currAp==b.essid){g.checked="1" +}var i=e("div"); +var j=-Math.floor(b.rssi/51)*32; +i.className="lock-icon"; +i.style.backgroundPosition="0px "+(j-1)+"px"; +var d=e("div"); +d.innerHTML=""+b.rssi+"dB"; +var c=e("div"); +var h="-65"; +if(b.enc=="0"){h="0" +}if(b.enc=="1"){h="-33" +}c.className="lock-icon"; +c.style.backgroundPosition="-32px "+h+"px"; +var f=e("div"); +f.innerHTML=b.essid; +var a=m('').childNodes[0]; +a.appendChild(g); +a.appendChild(c); +a.appendChild(i); +a.appendChild(d); +a.appendChild(f); +return a +}function getSelectedEssid(){var c=document.forms.wifiform.elements; +for(var b=0; +b60){return scanAPs() +}scanReqCnt+=1; +ajaxJson("GET","scan",function(c){currAp=getSelectedEssid(); +if(c.result.inProgress=="0"&&c.result.APs.length>0){$("#aps").innerHTML=""; +var d=0; +for(var b=0; +b'+c.ip+", else connect to network "+c.ssid+" first." +}else{blockScan=0; +showWarning("Connection failed: "+c.status+", "+c.reason); +$("#aps").innerHTML='Check password and selected AP. Go Back' +}}},function(b,a){window.setTimeout(getStatus,2000) +}) +}function changeWifiMode(a){blockScan=1; +hideWarning(); +ajaxSpin("POST","setmode?mode="+a,function(b){showNotification("Mode changed"); +window.setTimeout(getWifiInfo,100); +blockScan=0; +window.setTimeout(scanAPs,500); +$("#aps").innerHTML='Scanning...
' +},function(c,b){showWarning("Error changing mode: "+b); +window.setTimeout(getWifiInfo,100); +blockScan=0 +}) +}function changeWifiAp(d){d.preventDefault(); +var b=$("#wifi-passwd").value; +var f=getSelectedEssid(); +showNotification("Connecting to "+f); +var c="connect?essid="+encodeURIComponent(f)+"&passwd="+encodeURIComponent(b); +hideWarning(); +$("#reconnect").setAttribute("hidden",""); +$("#wifi-passwd").value=""; +var a=$("#connect-button"); +var g=a.className; +a.className+=" pure-button-disabled"; +blockScan=1; +ajaxSpin("POST",c,function(h){$("#spinner").removeAttribute("hidden"); +showNotification("Waiting for network change..."); +window.scrollTo(0,0); +window.setTimeout(getStatus,2000) +},function(i,h){showWarning("Error switching network: "+h); +a.className=g; +window.setTimeout(scanAPs,1000) +}) +}function changeSpecial(c){c.preventDefault(); +var b="special"; +b+="?dhcp="+document.querySelector('input[name="dhcp"]:checked').value; +b+="&staticip="+encodeURIComponent($("#wifi-staticip").value); +b+="&netmask="+encodeURIComponent($("#wifi-netmask").value); +b+="&gateway="+encodeURIComponent($("#wifi-gateway").value); +hideWarning(); +var a=$("#special-button"); +addClass(a,"pure-button-disabled"); +ajaxSpin("POST",b,function(d){removeClass(a,"pure-button-disabled") +},function(f,d){showWarning("Error: "+d); +removeClass(a,"pure-button-disabled"); +getWifiInfo() +}) +}function doDhcp(){$("#dhcp-on").removeAttribute("hidden"); +$("#dhcp-off").setAttribute("hidden","") +}function doStatic(){$("#dhcp-off").removeAttribute("hidden"); +$("#dhcp-on").setAttribute("hidden","") +}; \ No newline at end of file diff --git a/espfs/mkespfsimage/Makefile b/mkespfsimage/Makefile similarity index 100% rename from espfs/mkespfsimage/Makefile rename to mkespfsimage/Makefile diff --git a/mkespfsimage/heatshrink_encoder.o b/mkespfsimage/heatshrink_encoder.o new file mode 100644 index 0000000000000000000000000000000000000000..8b685587d780d10e583ea37780afa05a91ca23f7 GIT binary patch literal 942 zcmbtS%}T^D5T0)RJ$ezr%X$zM+~A6WdRPj}x)<@bXKA~E%F+~?6!he4_y`_-G<^b{ zX)`vBJ?TLBer6_<4t<&3-422PI0BeJtJnp2Zz)7Ik6;@%0Or%_&G2}URLWGt3vngR zN8{_NmgAGg01)~)H*tb!$_6uLMm`x3%h<#q60Jd`MV?EAo+^wK^ZUg}n>bxL^Z!Hl zv6;RPU*3tRqgvtb;s8_Rg>6aAB2TmQ`;RcOh3BvRr`St(p5bvLvf|J+k@I}UOUH9d zr7IlHeQfO@@!w84?w@g?MZcf)z^ftoVa+$2qaAJHA*9%A0ROrE`LFg-yS9$OpU=LJ xRJR77U%pQ|{MlkR8}@z))%R_P{PpeyR)skES7b6aIx8R5>OrcsSjtkQ@D0q2GZO#+ literal 0 HcmV?d00001 diff --git a/espfs/mkespfsimage/main.c b/mkespfsimage/main.c similarity index 100% rename from espfs/mkespfsimage/main.c rename to mkespfsimage/main.c diff --git a/mkespfsimage/main.o b/mkespfsimage/main.o new file mode 100644 index 0000000000000000000000000000000000000000..4178452f4430a7167681c06e9ea126949fda885a GIT binary patch literal 9400 zcmbtZeQXrR6`%7t0h|y!#7&)#mZh!vNbIXkjGF>MCT7D@*@V(qi5env-0k@e?!&#^ z!%l(;(Q&OeTSrzUH>sK`mQq!;p-NQ+5(tKa65CCs)QYMUwQ1v45E-5Sa6Z~NN?Q8f z?9BSHzN1Bb=yqm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P<}`3zXEMJ z-nR%&dCq%y?h-r~i9O|+AvonJ!^DHg{I>|61p>!;q&zneobo6ho~?qXme^CCI)YQ4 z4IZAT;AtiHl;;}+r#w46JhOr)NbD)k9)i$$L^7*2Ri~eOzi18JVx*pU?<~wgW&XjJYNDY5PT)! zxkT_)1Yd%eB?yM6z)$vjC&6(H5=R>pv=>9-?H2x=!{vAIP7f~6r2`&ZeqRoIaQVHM z_u%sTZ_1pg>Nqf3NVD z{YigsyAc$~N!J+KO8+5`!t0NJw?qF1bRx1CHyy|tr*NM#ep%iN8d-OZpmMM9rx@0~ zwhs!-6DHGye~rh%8~=9jFE)SM6i|TV`O|raL0{>Q@5Cth?dHur;#JG=$ym@S+@~j; kqPa)oop|Vi%m{LvPQ0?b{UcVa|83$AsrY}2R6I@gANZo9WdHyG literal 0 HcmV?d00001 diff --git a/mkespfsimage/mkespfsimage b/mkespfsimage/mkespfsimage new file mode 100755 index 0000000000000000000000000000000000000000..e06e46ee199fa7d4edac864b5762b73bd1c55d17 GIT binary patch literal 18280 zcmeHP4RBOdmcHE~5CSCOM-AW(ZybZ*k~UyqBKXsRG`?5?5sA9vVADyzB(0rvs{1tr z6ph<9n>THo)Q-$DKW@Lo-<4=vOqCgNN%+79YhSiZ7r<`c{lQy6c|AOw2{my;& zzPx_vp0R4HwrZ<#tMbl0-#zEtbI-l+zV~k5n+JS#YuzpvlgZ7lXT)up=H-xiWo+LK zoE2CVo65Xw0lSn<29l3IFE1f#<|G{vrX?*9a(SSW@K@zFfhxC`XC%GUgi(W;q=!VQ zzOm#LS(8?N&15BIOyL0Ok+00dSQAjlw>Jwct;OXzJESvLA^X9scyndQmJtLSUn) zFIQZc@Ly8VTy|AB)UcxRs&KG89BPYqly_9EC|^H{U$oJ+~! z0VFd`1FK|0ocjRRSy}L3<-mWG1Mkg&pUQy;bKvK5;NcwjYy>2m|1al|pPoa0QV#qI z*irE3Ol3LbPeU-9KRa^Z@8-ZqbKsBWz@N{7uK=##&zU{}kj>BU=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}8b|GBUy2g~iqv1^wrr3Vwz7I6c94SDJk*?yYKC{b~?`a4$gVz$6> I!#L~zAB!&}3IG5A literal 0 HcmV?d00001 diff --git a/espfs/mkespfsimage/mman-win32/Makefile b/mkespfsimage/mman-win32/Makefile similarity index 100% rename from espfs/mkespfsimage/mman-win32/Makefile rename to mkespfsimage/mman-win32/Makefile diff --git a/espfs/mkespfsimage/mman-win32/config.mak b/mkespfsimage/mman-win32/config.mak similarity index 100% rename from espfs/mkespfsimage/mman-win32/config.mak rename to mkespfsimage/mman-win32/config.mak diff --git a/espfs/mkespfsimage/mman-win32/configure b/mkespfsimage/mman-win32/configure similarity index 100% rename from espfs/mkespfsimage/mman-win32/configure rename to mkespfsimage/mman-win32/configure diff --git a/espfs/mkespfsimage/mman-win32/mman.c b/mkespfsimage/mman-win32/mman.c similarity index 100% rename from espfs/mkespfsimage/mman-win32/mman.c rename to mkespfsimage/mman-win32/mman.c diff --git a/espfs/mkespfsimage/mman-win32/mman.h b/mkespfsimage/mman-win32/mman.h similarity index 100% rename from espfs/mkespfsimage/mman-win32/mman.h rename to mkespfsimage/mman-win32/mman.h diff --git a/espfs/mkespfsimage/mman-win32/test.c b/mkespfsimage/mman-win32/test.c similarity index 100% rename from espfs/mkespfsimage/mman-win32/test.c rename to mkespfsimage/mman-win32/test.c diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..d4d013d --- /dev/null +++ b/platformio.ini @@ -0,0 +1,24 @@ +[platformio] +env_default = esp12e + +[env:esp12e] +platform = espressif8266 +board = esp12e +framework = esp8266-nonos-sdk +monitor_speed = 115200 +upload_resetmethod = ck +;build_flags = -Wl,-Teagle.flash.1m0.ld +build_flags = + -Isrc/include -I. + -DFIRMWARE_SIZE=503808 + -DMCU_RESET_PIN=12 + -DMCU_ISP_PIN=13 + -DLED_CONN_PIN=0 + -DLED_SERIAL_PIN=14 + -DMQTT -DREST -DSOCKET -DWEBSERVER -DSYSLOG + -DCHANGE_TO_STA=yes + -DESP_HOSTNAME=esp-link-v3 + +upload_speed = 460800 +#upload_speed = 230400 + diff --git a/esp-link/cgi.c b/src/cgi.c similarity index 99% rename from esp-link/cgi.c rename to src/cgi.c index d667be3..846d2dc 100644 --- a/esp-link/cgi.c +++ b/src/cgi.c @@ -16,7 +16,7 @@ Some random cgi routines. #include #include "cgi.h" #include "config.h" -#include "web-server.h" +#include "web-server/web-server.h" #ifdef CGI_DBG #define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__); } while(0) diff --git a/esp-link/cgi.h b/src/cgi.h similarity index 98% rename from esp-link/cgi.h rename to src/cgi.h index 330a5e6..b7051b8 100644 --- a/esp-link/cgi.h +++ b/src/cgi.h @@ -2,7 +2,7 @@ #define CGI_H #include -#include "httpd.h" +#include "httpd/httpd.h" void noCacheHeaders(HttpdConnData *connData, int code); void jsonHeader(HttpdConnData *connData, int code); diff --git a/esp-link/cgiflash.c b/src/cgiflash.c similarity index 100% rename from esp-link/cgiflash.c rename to src/cgiflash.c diff --git a/esp-link/cgiflash.h b/src/cgiflash.h similarity index 91% rename from esp-link/cgiflash.h rename to src/cgiflash.h index f03b8e0..f8e1913 100644 --- a/esp-link/cgiflash.h +++ b/src/cgiflash.h @@ -1,7 +1,7 @@ #ifndef CGIFLASH_H #define CGIFLASH_H -#include "httpd.h" +#include "httpd/httpd.h" int cgiReadFlash(HttpdConnData *connData); int cgiGetFirmwareNext(HttpdConnData *connData); diff --git a/esp-link/cgimega.c b/src/cgimega.c similarity index 99% rename from esp-link/cgimega.c rename to src/cgimega.c index 38fce83..dd634bd 100644 --- a/esp-link/cgimega.c +++ b/src/cgimega.c @@ -33,10 +33,10 @@ #include #include "cgi.h" #include "config.h" -#include "uart.h" +#include "serial/uart.h" #include "stk500v2.h" -#include "serbridge.h" -#include "serled.h" +#include "serial/serbridge.h" +#include "serial/serled.h" #include "pgmshared.h" #define INIT_DELAY 150 // wait this many millisecs before sending anything diff --git a/esp-link/cgimega.h b/src/cgimega.h similarity index 94% rename from esp-link/cgimega.h rename to src/cgimega.h index e30a2d1..117fa0d 100644 --- a/esp-link/cgimega.h +++ b/src/cgimega.h @@ -3,7 +3,7 @@ #ifndef CGIMEGA_H #define CGIMEGA_H -#include +#include int ICACHE_FLASH_ATTR cgiMegaSync(HttpdConnData *connData); int ICACHE_FLASH_ATTR cgiMegaData(HttpdConnData *connData); diff --git a/esp-link/cgimqtt.c b/src/cgimqtt.c similarity index 100% rename from esp-link/cgimqtt.c rename to src/cgimqtt.c diff --git a/esp-link/cgimqtt.h b/src/cgimqtt.h similarity index 85% rename from esp-link/cgimqtt.h rename to src/cgimqtt.h index b3e7809..8da712d 100644 --- a/esp-link/cgimqtt.h +++ b/src/cgimqtt.h @@ -3,7 +3,7 @@ char *mqttState(void); #ifndef CGIMQTT_H #define CGIMQTT_H -#include "httpd.h" +#include "httpd/httpd.h" int cgiMqtt(HttpdConnData *connData); #endif // CGIMQTT_H diff --git a/esp-link/cgioptiboot.c b/src/cgioptiboot.c similarity index 99% rename from esp-link/cgioptiboot.c rename to src/cgioptiboot.c index c3ca1ea..93233bb 100644 --- a/esp-link/cgioptiboot.c +++ b/src/cgioptiboot.c @@ -9,11 +9,11 @@ #include "cgi.h" #include "cgioptiboot.h" #include "config.h" -#include "uart.h" +#include "serial/uart.h" #include "stk500.h" -#include "serbridge.h" -#include "mqtt_cmd.h" -#include "serled.h" +#include "serial/serbridge.h" +#include "mqtt/mqtt_cmd.h" +#include "serial/serled.h" #include "pgmshared.h" diff --git a/esp-link/cgioptiboot.h b/src/cgioptiboot.h similarity index 91% rename from esp-link/cgioptiboot.h rename to src/cgioptiboot.h index bc4d20c..5178440 100644 --- a/esp-link/cgioptiboot.h +++ b/src/cgioptiboot.h @@ -3,7 +3,7 @@ #ifndef OPTIBOOT_H #define OPTIBOOT_H -#include +#include int ICACHE_FLASH_ATTR cgiOptibootSync(HttpdConnData *connData); int ICACHE_FLASH_ATTR cgiOptibootData(HttpdConnData *connData); diff --git a/esp-link/cgipins.c b/src/cgipins.c similarity index 97% rename from esp-link/cgipins.c rename to src/cgipins.c index b763d12..21b7921 100644 --- a/esp-link/cgipins.c +++ b/src/cgipins.c @@ -1,11 +1,11 @@ #include #include "cgi.h" -#include "espfs.h" +#include "espfs/espfs.h" #include "config.h" -#include "serled.h" +#include "serial/serled.h" #include "status.h" -#include "serbridge.h" +#include "serial/serbridge.h" #if 0 static char *map_names[] = { diff --git a/esp-link/cgipins.h b/src/cgipins.h similarity index 83% rename from esp-link/cgipins.h rename to src/cgipins.h index cacd913..2fcadeb 100644 --- a/esp-link/cgipins.h +++ b/src/cgipins.h @@ -1,7 +1,7 @@ #ifndef CGIPINS_H #define CGIPINS_H -#include "httpd.h" +#include "httpd/httpd.h" int cgiPins(HttpdConnData *connData); int8_t pin_reset, pin_isp, pin_conn, pin_ser; diff --git a/esp-link/cgiservices.c b/src/cgiservices.c similarity index 99% rename from esp-link/cgiservices.c rename to src/cgiservices.c index dddb616..c27f9ff 100644 --- a/esp-link/cgiservices.c +++ b/src/cgiservices.c @@ -6,7 +6,7 @@ #include "sntp.h" #include "cgimqtt.h" #ifdef SYSLOG -#include "syslog.h" +#include "syslog/syslog.h" #endif #ifdef CGISERVICES_DBG diff --git a/esp-link/cgiservices.h b/src/cgiservices.h similarity index 93% rename from esp-link/cgiservices.h rename to src/cgiservices.h index 9c44242..9f33503 100644 --- a/esp-link/cgiservices.h +++ b/src/cgiservices.h @@ -1,7 +1,7 @@ #ifndef CGISERVICES_H #define CGISERVICES_H -#include "httpd.h" +#include "httpd/httpd.h" int cgiSystemSet(HttpdConnData *connData); int cgiSystemInfo(HttpdConnData *connData); diff --git a/esp-link/cgitcp.c b/src/cgitcp.c similarity index 100% rename from esp-link/cgitcp.c rename to src/cgitcp.c diff --git a/esp-link/cgitcp.h b/src/cgitcp.h similarity index 76% rename from esp-link/cgitcp.h rename to src/cgitcp.h index 2b7b2a9..c06747d 100644 --- a/esp-link/cgitcp.h +++ b/src/cgitcp.h @@ -1,7 +1,7 @@ #ifndef CGITCP_H #define CGITCP_H -#include "httpd.h" +#include "httpd/httpd.h" int cgiTcp(HttpdConnData *connData); diff --git a/esp-link/cgiwebserversetup.c b/src/cgiwebserversetup.c similarity index 97% rename from esp-link/cgiwebserversetup.c rename to src/cgiwebserversetup.c index 1d1d2e6..9e95375 100644 --- a/esp-link/cgiwebserversetup.c +++ b/src/cgiwebserversetup.c @@ -4,10 +4,10 @@ #include #include "cgi.h" #include "cgioptiboot.h" -#include "multipart.h" -#include "espfsformat.h" +#include "httpd/multipart.h" +#include "espfs/espfsformat.h" #include "config.h" -#include "web-server.h" +#include "web-server/web-server.h" int header_position = 0; // flash offset of the file header int upload_position = 0; // flash offset where to store page upload @@ -107,7 +107,7 @@ int ICACHE_FLASH_ATTR webServerSetupMultipartCallback(MultipartCmd cmd, char *da if( webServerSetupWriteFlash( upload_position, (uint32_t *)(&hdr), sizeof(EspFsHeader) ) ) return 1; upload_position += sizeof(EspFsHeader); - + char nameBuf[len]; os_memset(nameBuf, 0, len); os_memcpy(nameBuf, data, dataLen); @@ -115,7 +115,7 @@ int ICACHE_FLASH_ATTR webServerSetupMultipartCallback(MultipartCmd cmd, char *da if( webServerSetupWriteFlash( upload_position, (uint32_t *)(nameBuf), len ) ) return 1; upload_position += len; - + // add header to HTML files if( ( dataLen > 5 ) && ( os_strcmp(data + dataLen - 5, ".html") == 0 ) ) // if the file ends with .html, wrap into an espfs image { @@ -145,7 +145,7 @@ int ICACHE_FLASH_ATTR webServerSetupMultipartCallback(MultipartCmd cmd, char *da } EspFsHeader hdr; - hdr.magic = ESPFS_MAGIC; + hdr.magic = ESPFS_MAGIC; hdr.fileLenComp = hdr.fileLenDecomp = position + html_header_len; // restore ESPFS magic @@ -160,7 +160,7 @@ int ICACHE_FLASH_ATTR webServerSetupMultipartCallback(MultipartCmd cmd, char *da // write the termination block EspFsHeader hdr; - hdr.magic = ESPFS_MAGIC; + hdr.magic = ESPFS_MAGIC; hdr.flags = 1; hdr.compression = 0; hdr.nameLen = 0; @@ -184,6 +184,6 @@ int ICACHE_FLASH_ATTR cgiWebServerSetupUpload(HttpdConnData *connData) { if( webServerContext == NULL ) webServerContext = multipartCreateContext( webServerSetupMultipartCallback ); - + return multipartProcess(webServerContext, connData); } diff --git a/esp-link/cgiwebserversetup.h b/src/cgiwebserversetup.h similarity index 85% rename from esp-link/cgiwebserversetup.h rename to src/cgiwebserversetup.h index ffecb82..418e5fa 100644 --- a/esp-link/cgiwebserversetup.h +++ b/src/cgiwebserversetup.h @@ -1,7 +1,7 @@ #ifndef CGIWEBSERVER_H #define CGIWEBSERVER_H -#include +#include int ICACHE_FLASH_ATTR cgiWebServerSetupUpload(HttpdConnData *connData); diff --git a/esp-link/cgiwifi.c b/src/cgiwifi.c similarity index 100% rename from esp-link/cgiwifi.c rename to src/cgiwifi.c diff --git a/esp-link/cgiwifi.h b/src/cgiwifi.h similarity index 97% rename from esp-link/cgiwifi.h rename to src/cgiwifi.h index ccae68f..dc264e6 100644 --- a/esp-link/cgiwifi.h +++ b/src/cgiwifi.h @@ -1,7 +1,7 @@ #ifndef CGIWIFI_H #define CGIWIFI_H -#include "httpd.h" +#include "httpd/httpd.h" enum { wifiIsDisconnected, wifiIsConnected, wifiGotIP }; typedef void(*WifiStateChangeCb)(uint8_t wifiStatus); diff --git a/cmd/cmd.c b/src/cmd/cmd.c similarity index 98% rename from cmd/cmd.c rename to src/cmd/cmd.c index 4a8dc64..319ab8e 100644 --- a/cmd/cmd.c +++ b/src/cmd/cmd.c @@ -4,8 +4,8 @@ #include "esp8266.h" #include "cmd.h" -#include "crc16.h" -#include "uart.h" +#include "serial/crc16.h" +#include "serial/uart.h" #ifdef CMD_DBG #define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__); } while(0) diff --git a/cmd/cmd.h b/src/cmd/cmd.h similarity index 100% rename from cmd/cmd.h rename to src/cmd/cmd.h diff --git a/cmd/handlers.c b/src/cmd/handlers.c similarity index 98% rename from cmd/handlers.c rename to src/cmd/handlers.c index 8605f68..a181e3b 100644 --- a/cmd/handlers.c +++ b/src/cmd/handlers.c @@ -5,20 +5,20 @@ #include "esp8266.h" #include "sntp.h" #include "cmd.h" -#include "uart.h" +#include "serial/uart.h" #include #ifdef MQTT -#include +#include #endif #ifdef REST -#include +#include #endif -#include +#include #ifdef SOCKET -#include +#include #endif #include -#include "esp-link/cgi.h" +#include "cgi.h" #include "config.h" diff --git a/esp-link/config.c b/src/config.c similarity index 99% rename from esp-link/config.c rename to src/config.c index 224f047..0437eb7 100644 --- a/esp-link/config.c +++ b/src/config.c @@ -3,8 +3,8 @@ #include #include "config.h" -#include "espfs.h" -#include "crc16.h" +#include "espfs/espfs.h" +#include "serial/crc16.h" FlashConfig flashConfig; FlashConfig flashDefault = { diff --git a/esp-link/config.h b/src/config.h similarity index 100% rename from esp-link/config.h rename to src/config.h diff --git a/espfs/espfs.c b/src/espfs/espfs.c similarity index 100% rename from espfs/espfs.c rename to src/espfs/espfs.c diff --git a/espfs/espfs.h b/src/espfs/espfs.h similarity index 100% rename from espfs/espfs.h rename to src/espfs/espfs.h diff --git a/espfs/espfsformat.h b/src/espfs/espfsformat.h similarity index 100% rename from espfs/espfsformat.h rename to src/espfs/espfsformat.h diff --git a/httpd/auth.c b/src/httpd/auth.c similarity index 100% rename from httpd/auth.c rename to src/httpd/auth.c diff --git a/httpd/auth.h b/src/httpd/auth.h similarity index 100% rename from httpd/auth.h rename to src/httpd/auth.h diff --git a/httpd/base64.c b/src/httpd/base64.c similarity index 100% rename from httpd/base64.c rename to src/httpd/base64.c diff --git a/httpd/base64.h b/src/httpd/base64.h similarity index 100% rename from httpd/base64.h rename to src/httpd/base64.h diff --git a/httpd/httpd.c b/src/httpd/httpd.c similarity index 100% rename from httpd/httpd.c rename to src/httpd/httpd.c diff --git a/httpd/httpd.h b/src/httpd/httpd.h similarity index 100% rename from httpd/httpd.h rename to src/httpd/httpd.h diff --git a/httpd/httpdespfs.c b/src/httpd/httpdespfs.c similarity index 100% rename from httpd/httpdespfs.c rename to src/httpd/httpdespfs.c diff --git a/httpd/httpdespfs.h b/src/httpd/httpdespfs.h similarity index 75% rename from httpd/httpdespfs.h rename to src/httpd/httpdespfs.h index 847a8b6..576bfed 100644 --- a/httpd/httpdespfs.h +++ b/src/httpd/httpdespfs.h @@ -2,10 +2,10 @@ #define HTTPDESPFS_H #include -#include "espfs.h" -#include "espfsformat.h" +#include "espfs/espfs.h" +#include "espfs/espfsformat.h" #include "cgi.h" -#include "httpd.h" +#include "httpd/httpd.h" int cgiEspFsHook(HttpdConnData *connData); //int cgiEspFsTemplate(HttpdConnData *connData); diff --git a/httpd/multipart.c b/src/httpd/multipart.c similarity index 100% rename from httpd/multipart.c rename to src/httpd/multipart.c diff --git a/httpd/multipart.h b/src/httpd/multipart.h similarity index 97% rename from httpd/multipart.h rename to src/httpd/multipart.h index a1205cd..6f664f2 100644 --- a/httpd/multipart.h +++ b/src/httpd/multipart.h @@ -1,7 +1,7 @@ #ifndef MULTIPART_H #define MULTIPART_H -#include +#include typedef enum { FILE_UPLOAD_START, // multipart: uploading files started diff --git a/include/c_types.h b/src/include/c_types.h similarity index 100% rename from include/c_types.h rename to src/include/c_types.h diff --git a/include/esp8266.h b/src/include/esp8266.h similarity index 100% rename from include/esp8266.h rename to src/include/esp8266.h diff --git a/include/espmissingincludes.h b/src/include/espmissingincludes.h similarity index 100% rename from include/espmissingincludes.h rename to src/include/espmissingincludes.h diff --git a/include/uart_hw.h b/src/include/uart_hw.h similarity index 100% rename from include/uart_hw.h rename to src/include/uart_hw.h diff --git a/include/user_config.h b/src/include/user_config.h similarity index 100% rename from include/user_config.h rename to src/include/user_config.h diff --git a/esp-link/log.c b/src/log.c similarity index 99% rename from esp-link/log.c rename to src/log.c index 821641f..ed89260 100644 --- a/esp-link/log.c +++ b/src/log.c @@ -1,7 +1,7 @@ // Copyright 2015 by Thorsten von Eicken, see LICENSE.txt #include -#include "uart.h" +#include "serial/uart.h" #include "cgi.h" #include "config.h" #include "log.h" diff --git a/esp-link/log.h b/src/log.h similarity index 94% rename from esp-link/log.h rename to src/log.h index 3b7e03a..b17b94d 100644 --- a/esp-link/log.h +++ b/src/log.h @@ -1,7 +1,7 @@ #ifndef LOG_H #define LOG_H -#include "httpd.h" +#include "httpd/httpd.h" #define LOG_MODE_AUTO 0 // start by logging to uart0, turn aff after we get an IP #define LOG_MODE_OFF 1 // always off diff --git a/esp-link/main.c b/src/main.c similarity index 96% rename from esp-link/main.c rename to src/main.c index d2a316e..3eb0180 100644 --- a/esp-link/main.c +++ b/src/main.c @@ -10,8 +10,8 @@ */ #include -#include "httpd.h" -#include "httpdespfs.h" +#include "httpd/httpd.h" +#include "httpd/httpdespfs.h" #include "cgi.h" #include "cgiwifi.h" #include "cgipins.h" @@ -21,24 +21,24 @@ #include "cgioptiboot.h" #include "cgimega.h" #include "cgiwebserversetup.h" -#include "auth.h" -#include "espfs.h" -#include "uart.h" -#include "serbridge.h" +#include "httpd/auth.h" +#include "espfs/espfs.h" +#include "serial/uart.h" +#include "serial/serbridge.h" #include "status.h" -#include "serled.h" -#include "console.h" +#include "serial/serled.h" +#include "serial/console.h" #include "config.h" #include "log.h" #include "gpio.h" #include "cgiservices.h" #ifdef WEBSERVER -#include "web-server.h" +#include "web-server/web-server.h" #endif #ifdef SYSLOG -#include "syslog.h" +#include "syslog/syslog.h" #define NOTICE(format, ...) do { \ LOG_NOTICE(format, ## __VA_ARGS__ ); \ os_printf(format "\n", ## __VA_ARGS__); \ @@ -131,7 +131,9 @@ static void ICACHE_FLASH_ATTR prHeapTimerCb(void *arg) { char* esp_link_version = VERS_STR(VERSION); // address of espfs binary blob +#if PIO_HACK extern uint32_t _binary_espfs_img_start; +#endif extern void app_init(void); extern void mqtt_client_init(void); @@ -184,8 +186,10 @@ user_init(void) { serledInit(); // Wifi wifiInit(); +#if PIO_HACK // init the flash filesystem with the html stuff espFsInit(espLinkCtx, &_binary_espfs_img_start, ESPFS_MEMORY); +#endif //EspFsInitResult res = espFsInit(&_binary_espfs_img_start); //os_printf("espFsInit %s\n", res?"ERR":"ok"); diff --git a/mqtt/mqtt.c b/src/mqtt/mqtt.c similarity index 100% rename from mqtt/mqtt.c rename to src/mqtt/mqtt.c diff --git a/mqtt/mqtt.h b/src/mqtt/mqtt.h similarity index 100% rename from mqtt/mqtt.h rename to src/mqtt/mqtt.h diff --git a/mqtt/mqtt_cmd.c b/src/mqtt/mqtt_cmd.c similarity index 99% rename from mqtt/mqtt_cmd.c rename to src/mqtt/mqtt_cmd.c index b6bb909..8450f29 100644 --- a/mqtt/mqtt_cmd.c +++ b/src/mqtt/mqtt_cmd.c @@ -3,9 +3,9 @@ // #include -#include "mqtt.h" +#include "mqtt/mqtt.h" #include "mqtt_client.h" -#include "mqtt_cmd.h" +#include "mqtt/mqtt_cmd.h" #ifdef MQTTCMD_DBG #define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__); } while(0) diff --git a/mqtt/mqtt_cmd.h b/src/mqtt/mqtt_cmd.h similarity index 95% rename from mqtt/mqtt_cmd.h rename to src/mqtt/mqtt_cmd.h index e7121c7..239f583 100644 --- a/mqtt/mqtt_cmd.h +++ b/src/mqtt/mqtt_cmd.h @@ -1,7 +1,7 @@ #ifndef MODULES_MQTT_CMD_H_ #define MODULES_MQTT_CMD_H_ -#include "cmd.h" +#include "cmd/cmd.h" typedef struct { uint32_t connectedCb; diff --git a/mqtt/mqtt_msg.c b/src/mqtt/mqtt_msg.c similarity index 100% rename from mqtt/mqtt_msg.c rename to src/mqtt/mqtt_msg.c diff --git a/mqtt/mqtt_msg.h b/src/mqtt/mqtt_msg.h similarity index 100% rename from mqtt/mqtt_msg.h rename to src/mqtt/mqtt_msg.h diff --git a/mqtt/pktbuf.c b/src/mqtt/pktbuf.c similarity index 100% rename from mqtt/pktbuf.c rename to src/mqtt/pktbuf.c diff --git a/mqtt/pktbuf.h b/src/mqtt/pktbuf.h similarity index 100% rename from mqtt/pktbuf.h rename to src/mqtt/pktbuf.h diff --git a/esp-link/mqtt_client.c b/src/mqtt_client.c similarity index 99% rename from esp-link/mqtt_client.c rename to src/mqtt_client.c index 61fec1e..0b2aa80 100644 --- a/esp-link/mqtt_client.c +++ b/src/mqtt_client.c @@ -2,7 +2,7 @@ #include #include "cgiwifi.h" #include "config.h" -#include "mqtt.h" +#include "mqtt/mqtt.h" #ifdef MQTTCLIENT_DBG diff --git a/esp-link/mqtt_client.h b/src/mqtt_client.h similarity index 94% rename from esp-link/mqtt_client.h rename to src/mqtt_client.h index 75fc8dc..34f1cf8 100644 --- a/esp-link/mqtt_client.h +++ b/src/mqtt_client.h @@ -1,7 +1,7 @@ #ifdef MQTT #ifndef MQTT_CLIENT_H #define MQTT_CLIENT_H -#include "mqtt.h" +#include "mqtt/mqtt.h" extern MQTT_Client mqttClient; extern char* statusTopicStr; diff --git a/esp-link/pgmshared.c b/src/pgmshared.c similarity index 98% rename from esp-link/pgmshared.c rename to src/pgmshared.c index 44e157a..f51173e 100644 --- a/esp-link/pgmshared.c +++ b/src/pgmshared.c @@ -5,10 +5,10 @@ #include #include "cgi.h" #include "config.h" -#include "uart.h" +#include "serial/uart.h" #include "stk500v2.h" -#include "serbridge.h" -#include "serled.h" +#include "serial/serbridge.h" +#include "serial/serled.h" #include "pgmshared.h" diff --git a/esp-link/pgmshared.h b/src/pgmshared.h similarity index 100% rename from esp-link/pgmshared.h rename to src/pgmshared.h diff --git a/rest/rest.c b/src/rest/rest.c similarity index 99% rename from rest/rest.c rename to src/rest/rest.c index 2100109..a728bd2 100644 --- a/rest/rest.c +++ b/src/rest/rest.c @@ -6,7 +6,7 @@ #include "c_types.h" #include "ip_addr.h" #include "rest.h" -#include "cmd.h" +#include "cmd/cmd.h" #ifdef REST_DBG #define DBG_REST(format, ...) os_printf(format, ## __VA_ARGS__) diff --git a/rest/rest.h b/src/rest/rest.h similarity index 92% rename from rest/rest.h rename to src/rest/rest.h index 281a9f4..09261cc 100644 --- a/rest/rest.h +++ b/src/rest/rest.h @@ -8,7 +8,7 @@ #ifndef MODULES_API_H_ #define MODULES_API_H_ -#include "cmd.h" +#include "cmd/cmd.h" void REST_Setup(CmdPacket *cmd); void REST_Request(CmdPacket *cmd); diff --git a/serial/console.c b/src/serial/console.c similarity index 100% rename from serial/console.c rename to src/serial/console.c diff --git a/serial/console.h b/src/serial/console.h similarity index 94% rename from serial/console.h rename to src/serial/console.h index 3020903..db04f42 100644 --- a/serial/console.h +++ b/src/serial/console.h @@ -1,7 +1,7 @@ #ifndef CONSOLE_H #define CONSOLE_H -#include "httpd.h" +#include "httpd/httpd.h" void consoleInit(void); void ICACHE_FLASH_ATTR console_write_char(char c); diff --git a/serial/crc16.c b/src/serial/crc16.c similarity index 100% rename from serial/crc16.c rename to src/serial/crc16.c diff --git a/serial/crc16.h b/src/serial/crc16.h similarity index 100% rename from serial/crc16.h rename to src/serial/crc16.h diff --git a/serial/serbridge.c b/src/serial/serbridge.c similarity index 99% rename from serial/serbridge.c rename to src/serial/serbridge.c index 7ba8e8e..7f738e5 100644 --- a/serial/serbridge.c +++ b/src/serial/serbridge.c @@ -10,7 +10,7 @@ #include "console.h" #include "slip.h" #ifdef SYSLOG -#include "syslog.h" +#include "syslog/syslog.h" #else #define syslog(X1...) #endif diff --git a/serial/serbridge.h b/src/serial/serbridge.h similarity index 100% rename from serial/serbridge.h rename to src/serial/serbridge.h diff --git a/serial/serled.c b/src/serial/serled.c similarity index 98% rename from serial/serled.c rename to src/serial/serled.c index 5bd66a2..cca5262 100644 --- a/serial/serled.c +++ b/src/serial/serled.c @@ -2,7 +2,7 @@ #include #include -#include +#include "serled.h" static ETSTimer serledTimer; diff --git a/serial/serled.h b/src/serial/serled.h similarity index 100% rename from serial/serled.h rename to src/serial/serled.h diff --git a/serial/slip.c b/src/serial/slip.c similarity index 99% rename from serial/slip.c rename to src/serial/slip.c index 2f15186..d3dac10 100644 --- a/serial/slip.c +++ b/src/serial/slip.c @@ -5,7 +5,7 @@ #include "crc16.h" #include "serbridge.h" #include "console.h" -#include "cmd.h" +#include "cmd/cmd.h" #ifdef SLIP_DBG #define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__); } while(0) diff --git a/serial/slip.h b/src/serial/slip.h similarity index 100% rename from serial/slip.h rename to src/serial/slip.h diff --git a/serial/uart.c b/src/serial/uart.c similarity index 100% rename from serial/uart.c rename to src/serial/uart.c diff --git a/serial/uart.h b/src/serial/uart.h similarity index 100% rename from serial/uart.h rename to src/serial/uart.h diff --git a/socket/socket.c b/src/socket/socket.c similarity index 100% rename from socket/socket.c rename to src/socket/socket.c diff --git a/socket/socket.h b/src/socket/socket.h similarity index 97% rename from socket/socket.h rename to src/socket/socket.h index 258109b..c37ad36 100644 --- a/socket/socket.h +++ b/src/socket/socket.h @@ -8,7 +8,7 @@ #ifndef MODULES_SOCKET_H_ #define MODULES_SOCKET_H_ -#include "cmd.h" +#include "cmd/cmd.h" void SOCKET_Setup(CmdPacket *cmd); void SOCKET_Send(CmdPacket *cmd); diff --git a/esp-link/status.c b/src/status.c similarity index 98% rename from esp-link/status.c rename to src/status.c index 6905850..7d1cbe8 100644 --- a/esp-link/status.c +++ b/src/status.c @@ -2,11 +2,11 @@ #include #include "config.h" -#include "serled.h" +#include "serial/serled.h" #include "cgiwifi.h" #ifdef MQTT -#include "mqtt.h" +#include "mqtt/mqtt.h" #include "mqtt_client.h" extern MQTT_Client mqttClient; diff --git a/esp-link/status.h b/src/status.h similarity index 100% rename from esp-link/status.h rename to src/status.h diff --git a/esp-link/stk500.h b/src/stk500.h similarity index 100% rename from esp-link/stk500.h rename to src/stk500.h diff --git a/esp-link/stk500v2.h b/src/stk500v2.h similarity index 100% rename from esp-link/stk500v2.h rename to src/stk500v2.h diff --git a/syslog/syslog.c b/src/syslog/syslog.c similarity index 100% rename from syslog/syslog.c rename to src/syslog/syslog.c diff --git a/syslog/syslog.h b/src/syslog/syslog.h similarity index 100% rename from syslog/syslog.h rename to src/syslog/syslog.h diff --git a/syslog/syslog.md b/src/syslog/syslog.md similarity index 100% rename from syslog/syslog.md rename to src/syslog/syslog.md diff --git a/esp-link/task.c b/src/task.c similarity index 100% rename from esp-link/task.c rename to src/task.c diff --git a/esp-link/task.h b/src/task.h similarity index 100% rename from esp-link/task.h rename to src/task.h diff --git a/user/user_main.c b/src/user/user_main.c similarity index 100% rename from user/user_main.c rename to src/user/user_main.c diff --git a/web-server/web-server.c b/src/web-server/web-server.c similarity index 97% rename from web-server/web-server.c rename to src/web-server/web-server.c index fd41486..e129fc8 100644 --- a/web-server/web-server.c +++ b/src/web-server/web-server.c @@ -2,11 +2,11 @@ #include -#include "espfs.h" +#include "espfs/espfs.h" #include "config.h" #include "cgi.h" -#include "cmd.h" -#include "serbridge.h" +#include "cmd/cmd.h" +#include "serial/serbridge.h" // the file is responsible for handling user defined web-pages // - collects HTML files from user image, shows them on the left frame @@ -34,7 +34,7 @@ static char* web_server_reasons[] = { // this variable contains the names of the user defined pages // this information appears at the left frame below of the built in URL-s -// format: ,"UserPage1", "/UserPage1.html", "UserPage2", "/UserPage2.html", +// format: ,"UserPage1", "/UserPage1.html", "UserPage2", "/UserPage2.html", char * webServerPages = NULL; char * ICACHE_FLASH_ATTR WEB_UserPages() @@ -47,7 +47,7 @@ void ICACHE_FLASH_ATTR WEB_BrowseFiles() { char buffer[1024]; buffer[0] = 0; - + if( espFsIsValid( userPageCtx ) ) { EspFsIterator it; @@ -61,23 +61,23 @@ void ICACHE_FLASH_ATTR WEB_BrowseFiles() if( os_strcmp( it.name + nameLen-5, ".html" ) == 0 ) { int slashPos = nameLen - 5; - + // chop path and .html from the name while( slashPos > 0 && it.name[slashPos-1] != '/' ) slashPos--; - + // here we check buffer overrun int maxLen = 10 + os_strlen( it.name ) + (nameLen - slashPos -5); if( maxLen >= sizeof(buffer) ) break; - + os_strcat(buffer, ", \""); - + int writePos = os_strlen(buffer); for( int i=slashPos; i < nameLen-5; i++ ) buffer[writePos++] = it.name[i]; buffer[writePos] = 0; // terminating zero - + os_strcat(buffer, "\", \"/"); os_strcat(buffer, it.name); os_strcat(buffer, "\""); @@ -85,10 +85,10 @@ void ICACHE_FLASH_ATTR WEB_BrowseFiles() } } } - + if( webServerPages != NULL ) os_free( webServerPages ); - + int len = os_strlen(buffer) + 1; webServerPages = (char *)os_malloc( len ); os_memcpy( webServerPages, buffer, len ); @@ -117,15 +117,15 @@ static int ICACHE_FLASH_ATTR WEB_addArg(struct ArgumentBuffer * argBuffer, char { if( argBuffer->argBufferPtr + argLen + sizeof(int) >= MAX_ARGUMENT_BUFFER_SIZE ) return -1; // buffer overflow - + os_memcpy(argBuffer->argBuffer + argBuffer->argBufferPtr, &argLen, sizeof(int)); - + if( argLen != 0 ) { os_memcpy( argBuffer->argBuffer + argBuffer->argBufferPtr + sizeof(int), arg, argLen ); argBuffer->numberOfArgs++; } - + argBuffer->argBufferPtr += argLen + sizeof(int); return 0; } @@ -139,18 +139,18 @@ static void ICACHE_FLASH_ATTR WEB_sendArgBuffer(struct ArgumentBuffer * argBuffe cmdResponseBody(&connData->conn->proto.tcp->remote_ip, 4); // 2nd argument: IP cmdResponseBody(&connData->conn->proto.tcp->remote_port, sizeof(uint16_t)); // 3rd argument: port cmdResponseBody(connData->url, os_strlen(connData->url)); // 4th argument: URL - + int p = 0; for( int j=0; j < argBuffer->numberOfArgs; j++ ) { int argLen; os_memcpy( &argLen, argBuffer->argBuffer + p, sizeof(int) ); - + char * arg = argBuffer->argBuffer + p + sizeof(int); cmdResponseBody(arg, argLen); p += argLen + sizeof(int); } - + cmdResponseEnd(); } @@ -163,7 +163,7 @@ static int ICACHE_FLASH_ATTR WEB_handleJSONRequest(HttpdConnData *connData) errorResponse(connData, 400, "Slip processing is disabled!"); return HTTPD_CGI_DONE; } - + if( web_server_cb == 0 ) { errorResponse(connData, 500, "No MCU callback is registered!"); @@ -174,7 +174,7 @@ static int ICACHE_FLASH_ATTR WEB_handleJSONRequest(HttpdConnData *connData) errorResponse(connData, 500, "Slip disabled at uploading program onto the MCU!"); return HTTPD_CGI_DONE; } - + char reasonBuf[16]; int i; int len = httpdFindArg(connData->getArgs, "reason", reasonBuf, sizeof(reasonBuf)); @@ -183,29 +183,29 @@ static int ICACHE_FLASH_ATTR WEB_handleJSONRequest(HttpdConnData *connData) errorResponse(connData, 400, "No reason specified!"); return HTTPD_CGI_DONE; } - + RequestReason reason = INVALID; for(i=0; i < sizeof(web_server_reasons)/sizeof(char *); i++) { if( os_strcmp( web_server_reasons[i], reasonBuf ) == 0 ) reason = (RequestReason)i; } - + if( reason == INVALID ) { errorResponse(connData, 400, "Invalid reason!"); return HTTPD_CGI_DONE; } - + struct ArgumentBuffer argBuffer; WEB_argInit( &argBuffer ); - + switch(reason) { case BUTTON: { char id_buf[40]; - + int id_len = httpdFindArg(connData->getArgs, "id", id_buf, sizeof(id_buf)); if( id_len <= 0 ) { @@ -226,15 +226,15 @@ static int ICACHE_FLASH_ATTR WEB_handleJSONRequest(HttpdConnData *connData) errorResponse(connData, 400, "Post too large!"); return HTTPD_CGI_DONE; } - + int bptr = 0; int sent_args = 0; int max_buf_size = MAX_ARGUMENT_BUFFER_SIZE - HEADER_SIZE - os_strlen(connData->url); - + while( bptr < connData->post->len ) { char * line = connData->post->buff + bptr; - + char * eo = os_strchr(line, '&' ); if( eo != NULL ) { @@ -246,12 +246,12 @@ static int ICACHE_FLASH_ATTR WEB_handleJSONRequest(HttpdConnData *connData) eo = line + os_strlen( line ); bptr = connData->post->len; } - + int len = os_strlen(line); while( len >= 1 && ( line[len-1] == '\r' || line[len-1] == '\n' )) len--; line[len] = 0; - + char * val = os_strchr(line, '='); if( val != NULL ) { @@ -260,10 +260,10 @@ static int ICACHE_FLASH_ATTR WEB_handleJSONRequest(HttpdConnData *connData) int vblen = os_strlen(val+1) * 2; char value[vblen]; httpdUrlDecode(val+1, strlen(val+1), value, vblen); - + int namLen = os_strlen(name); int valLen = os_strlen(value); - + char arg[namLen + valLen + 3]; int argPtr = 0; arg[argPtr++] = (char)WEB_STRING; @@ -272,7 +272,7 @@ static int ICACHE_FLASH_ATTR WEB_handleJSONRequest(HttpdConnData *connData) arg[argPtr++] = 0; os_strcpy( arg + argPtr, value ); argPtr += valLen; - + if( sent_args != 0 ) { if( argBuffer.argBufferPtr + argPtr >= max_buf_size ) @@ -283,7 +283,7 @@ static int ICACHE_FLASH_ATTR WEB_handleJSONRequest(HttpdConnData *connData) sent_args = 0; } } - + if( WEB_addArg(&argBuffer, arg, argPtr) ) { errorResponse(connData, 400, "Post too large!"); @@ -299,24 +299,24 @@ static int ICACHE_FLASH_ATTR WEB_handleJSONRequest(HttpdConnData *connData) default: break; } - + if( WEB_addArg(&argBuffer, NULL, 0) ) { errorResponse(connData, 400, "Post too large!"); return HTTPD_CGI_DONE; } - + os_printf("Web callback to MCU: %s\n", reasonBuf); - + WEB_sendArgBuffer(&argBuffer, connData, reason ); - + if( reason == SUBMIT ) { httpdStartResponse(connData, 204); httpdEndHeaders(connData); return HTTPD_CGI_DONE; } - + return HTTPD_CGI_MORE; } @@ -325,42 +325,42 @@ static int ICACHE_FLASH_ATTR WEB_handleMCUResponse(HttpdConnData *connData, CmdR { char jsonBuf[1500]; int jsonPtr = 0; - - + + jsonBuf[jsonPtr++] = '{'; - + int c = 2; while( c++ < cmdGetArgc(response) ) { int len = cmdArgLen(response); char buf[len+1]; buf[len] = 0; - + cmdPopArg(response, buf, len); - + if(len == 0) break; // last argument - + if( c > 3 ) // skip the first argument jsonBuf[jsonPtr++] = ','; - + if( jsonPtr + 20 + len > sizeof(jsonBuf) ) { errorResponse(connData, 500, "Response too large!"); return HTTPD_CGI_DONE; } - + WebValueType type = (WebValueType)buf[0]; - + int nameLen = os_strlen(buf+1); jsonBuf[jsonPtr++] = '"'; os_memcpy(jsonBuf + jsonPtr, buf + 1, nameLen); jsonPtr += nameLen; jsonBuf[jsonPtr++] = '"'; jsonBuf[jsonPtr++] = ':'; - + char * value = buf + 2 + nameLen; - + switch(type) { case WEB_NULL: @@ -371,7 +371,7 @@ static int ICACHE_FLASH_ATTR WEB_handleMCUResponse(HttpdConnData *connData, CmdR { int v; os_memcpy( &v, value, 4); - + char intbuf[20]; os_sprintf(intbuf, "%d", v); os_strcpy(jsonBuf + jsonPtr, intbuf); @@ -391,13 +391,13 @@ static int ICACHE_FLASH_ATTR WEB_handleMCUResponse(HttpdConnData *connData, CmdR { float f; os_memcpy( &f, value, 4); - + // os_sprintf doesn't support %f int intPart = f; int fracPart = (f - intPart) * 1000; // use 3 digit precision if( fracPart < 0 ) // for negative numbers fracPart = -fracPart; - + char floatBuf[20]; os_sprintf(floatBuf, "%d.%03d", intPart, fracPart); os_strcpy(jsonBuf + jsonPtr, floatBuf); @@ -420,17 +420,17 @@ static int ICACHE_FLASH_ATTR WEB_handleMCUResponse(HttpdConnData *connData, CmdR break; } } - + jsonBuf[jsonPtr++] = '}'; - + noCacheHeaders(connData, 200); httpdHeader(connData, "Content-Type", "application/json"); - + char cl[16]; os_sprintf(cl, "%d", jsonPtr); httpdHeader(connData, "Content-Length", cl); httpdEndHeaders(connData); - + httpdSend(connData, jsonBuf, jsonPtr); return HTTPD_CGI_DONE; } @@ -439,18 +439,18 @@ static int ICACHE_FLASH_ATTR WEB_handleMCUResponse(HttpdConnData *connData, CmdR int ICACHE_FLASH_ATTR WEB_CgiJsonHook(HttpdConnData *connData) { if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. - + void * cgiData = connData->cgiData; - + if( cgiData == NULL ) { connData->cgiData = (void *)1; // indicate, that request was processed return WEB_handleJSONRequest(connData); } - + if( connData->cgiResponse != NULL ) // data from MCU return WEB_handleMCUResponse(connData, (CmdRequest *)(connData->cgiResponse)); - + return HTTPD_CGI_MORE; } @@ -459,11 +459,11 @@ void ICACHE_FLASH_ATTR WEB_Setup(CmdPacket *cmd) { CmdRequest req; cmdRequest(&req, cmd); - + if (cmdGetArgc(&req) < 1) return; - + cmdPopArg(&req, &web_server_cb, 4); // pop the callback - + os_printf("Web-server connected, cb=0x%x\n", web_server_cb); } @@ -472,15 +472,15 @@ void ICACHE_FLASH_ATTR WEB_Data(CmdPacket *cmd) { CmdRequest req; cmdRequest(&req, cmd); - + if (cmdGetArgc(&req) < 2) return; - + uint8_t ip[4]; cmdPopArg(&req, ip, 4); // pop the IP address - + uint16_t port; cmdPopArg(&req, &port, 2); // pop the HTTP port - + HttpdConnData * conn = httpdLookUpConn(ip, port); // look up connection based on IP/port if( conn != NULL && conn->cgi == WEB_CgiJsonHook ) // make sure that the right CGI handler is configured httpdSetCGIResponse( conn, &req ); diff --git a/web-server/web-server.h b/src/web-server/web-server.h similarity index 94% rename from web-server/web-server.h rename to src/web-server/web-server.h index c6609a6..b22b181 100644 --- a/web-server/web-server.h +++ b/src/web-server/web-server.h @@ -3,8 +3,8 @@ #include -#include "httpd.h" -#include "cmd.h" +#include "httpd/httpd.h" +#include "cmd/cmd.h" typedef enum {