|
|
@ -15,6 +15,165 @@ |
|
|
|
var found = false; |
|
|
|
var c = document.getElementById("con"); |
|
|
|
|
|
|
|
/*IF_ESP32*/ |
|
|
|
var pinList = [ |
|
|
|
[255, "{#PIN_OFF}"], |
|
|
|
[0, "GPIO0"], |
|
|
|
[1, "TX (GPIO1)"], |
|
|
|
[2, "GPIO2 (LED)"], |
|
|
|
[3, "RX (GPIO3)"], |
|
|
|
[4, "GPIO4"], |
|
|
|
[5, "GPIO5"], |
|
|
|
[12, "GPIO12 (HSPI MISO)"], |
|
|
|
[13, "GPIO13 (HSPI MOSI)"], |
|
|
|
[14, "GPIO14 (HSPI SCLK)"], |
|
|
|
[15, "GPIO15"], |
|
|
|
[16, "GPIO16"], |
|
|
|
[17, "GPIO17"], |
|
|
|
[18, "GPIO18 (VSPI SCLK)"], |
|
|
|
[19, "GPIO19 (VSPI MISO)"], |
|
|
|
[21, "GPIO21 (SDA)"], |
|
|
|
[22, "GPIO22 (SCL)"], |
|
|
|
[23, "GPIO23 (VSPI MOSI)"], |
|
|
|
[25, "GPIO25"], |
|
|
|
[26, "GPIO26"], |
|
|
|
[27, "GPIO27"], |
|
|
|
[32, "GPIO32"], |
|
|
|
[33, "GPIO33"], |
|
|
|
[34, "GPIO34 ({#PIN_INPUT_ONLY})"], |
|
|
|
[35, "GPIO35 ({#PIN_INPUT_ONLY})"], |
|
|
|
[36, "VP (GPIO36, {#PIN_INPUT_ONLY})"], |
|
|
|
[39, "VN (GPIO39, {#PIN_INPUT_ONLY})"] |
|
|
|
]; |
|
|
|
/*IF_ESP32-S2*/ |
|
|
|
pinList = [ |
|
|
|
[255, "off / default"], |
|
|
|
[0, "GPIO0 ({#PIN_DONT_USE} - BOOT)"], |
|
|
|
[1, "GPIO1"], |
|
|
|
[2, "GPIO2"], |
|
|
|
[3, "GPIO3"], |
|
|
|
[4, "GPIO4"], |
|
|
|
[5, "GPIO5"], |
|
|
|
[6, "GPIO6"], |
|
|
|
[7, "GPIO7"], |
|
|
|
[8, "GPIO8"], |
|
|
|
[9, "GPIO9"], |
|
|
|
[10, "GPIO10"], |
|
|
|
[11, "GPIO11"], |
|
|
|
[12, "GPIO12"], |
|
|
|
[13, "GPIO13"], |
|
|
|
[14, "GPIO14"], |
|
|
|
[15, "GPIO15"], |
|
|
|
[16, "GPIO16"], |
|
|
|
[17, "GPIO17"], |
|
|
|
[18, "GPIO18"], |
|
|
|
[19, "GPIO19 ({#PIN_DONT_USE} - USB-)"], |
|
|
|
[20, "GPIO20 ({#PIN_DONT_USE} - USB+)"], |
|
|
|
[21, "GPIO21"], |
|
|
|
[26, "GPIO26 (PSRAM - {#PIN_NOT_AVAIL})"], |
|
|
|
[27, "GPIO27 (FLASH - {#PIN_NOT_AVAIL})"], |
|
|
|
[28, "GPIO28 (FLASH - {#PIN_NOT_AVAIL})"], |
|
|
|
[29, "GPIO29 (FLASH - {#PIN_NOT_AVAIL})"], |
|
|
|
[30, "GPIO30 (FLASH - {#PIN_NOT_AVAIL})"], |
|
|
|
[31, "GPIO31 (FLASH - {#PIN_NOT_AVAIL})"], |
|
|
|
[32, "GPIO32 (FLASH - {#PIN_NOT_AVAIL})"], |
|
|
|
[33, "GPIO33 (not exposed on S3-WROOM modules)"], |
|
|
|
[34, "GPIO34 (not exposed on S3-WROOM modules)"], |
|
|
|
[35, "GPIO35"], |
|
|
|
[36, "GPIO36"], |
|
|
|
[37, "GPIO37"], |
|
|
|
[38, "GPIO38"], |
|
|
|
[39, "GPIO39"], |
|
|
|
[40, "GPIO40"], |
|
|
|
[41, "GPIO41"], |
|
|
|
[42, "GPIO42"], |
|
|
|
[43, "GPIO43"], |
|
|
|
[44, "GPIO44"], |
|
|
|
[45, "GPIO45 ({#PIN_DONT_USE} - STRAPPING PIN)"], |
|
|
|
[46, "GPIO46 ({#PIN_DONT_USE} - STRAPPING PIN)"], |
|
|
|
[47, "GPIO47"], |
|
|
|
[48, "GPIO48"], |
|
|
|
]; |
|
|
|
/*ENDIF_ESP32-S2*/ |
|
|
|
/*IF_ESP32-S3*/ |
|
|
|
pinList = [ |
|
|
|
[255, "off / default"], |
|
|
|
[0, "GPIO0 ({#PIN_DONT_USE} - BOOT)"], |
|
|
|
[1, "GPIO1"], |
|
|
|
[2, "GPIO2"], |
|
|
|
[3, "GPIO3"], |
|
|
|
[4, "GPIO4"], |
|
|
|
[5, "GPIO5"], |
|
|
|
[6, "GPIO6"], |
|
|
|
[7, "GPIO7"], |
|
|
|
[8, "GPIO8"], |
|
|
|
[9, "GPIO9"], |
|
|
|
[10, "GPIO10"], |
|
|
|
[11, "GPIO11"], |
|
|
|
[12, "GPIO12"], |
|
|
|
[13, "GPIO13"], |
|
|
|
[14, "GPIO14"], |
|
|
|
[15, "GPIO15"], |
|
|
|
[16, "GPIO16"], |
|
|
|
[17, "GPIO17"], |
|
|
|
[18, "GPIO18"], |
|
|
|
[19, "GPIO19 ({#PIN_DONT_USE} - USB-)"], |
|
|
|
[20, "GPIO20 ({#PIN_DONT_USE} - USB+)"], |
|
|
|
[21, "GPIO21"], |
|
|
|
[26, "GPIO26 (PSRAM - {#PIN_NOT_AVAIL})"], |
|
|
|
[27, "GPIO27 (FLASH - {#PIN_NOT_AVAIL})"], |
|
|
|
[28, "GPIO28 (FLASH - {#PIN_NOT_AVAIL})"], |
|
|
|
[29, "GPIO29 (FLASH - {#PIN_NOT_AVAIL})"], |
|
|
|
[30, "GPIO30 (FLASH - {#PIN_NOT_AVAIL})"], |
|
|
|
[31, "GPIO31 (FLASH - {#PIN_NOT_AVAIL})"], |
|
|
|
[32, "GPIO32 (FLASH - {#PIN_NOT_AVAIL})"], |
|
|
|
[33, "GPIO33 (not exposed on S3-WROOM modules)"], |
|
|
|
[34, "GPIO34 (not exposed on S3-WROOM modules)"], |
|
|
|
[35, "GPIO35"], |
|
|
|
[36, "GPIO36"], |
|
|
|
[37, "GPIO37"], |
|
|
|
[38, "GPIO38"], |
|
|
|
[39, "GPIO39"], |
|
|
|
[40, "GPIO40"], |
|
|
|
[41, "GPIO41"], |
|
|
|
[42, "GPIO42"], |
|
|
|
[43, "GPIO43"], |
|
|
|
[44, "GPIO44"], |
|
|
|
[45, "GPIO45 ({#PIN_DONT_USE} - STRAPPING PIN)"], |
|
|
|
[46, "GPIO46 ({#PIN_DONT_USE} - STRAPPING PIN)"], |
|
|
|
[47, "GPIO47"], |
|
|
|
[48, "GPIO48"], |
|
|
|
]; |
|
|
|
/*ENDIF_ESP32-S3*/ |
|
|
|
/*IF_ESP32-C3*/ |
|
|
|
pinList = [ |
|
|
|
[255, "off / default"], |
|
|
|
[0, "GPIO0"], |
|
|
|
[1, "GPIO1"], |
|
|
|
[2, "GPIO2"], |
|
|
|
[3, "GPIO3"], |
|
|
|
[4, "GPIO4"], |
|
|
|
[5, "GPIO5"], |
|
|
|
[6, "GPIO6"], |
|
|
|
[7, "GPIO7"], |
|
|
|
[8, "GPIO8"], |
|
|
|
[9, "GPIO9"], |
|
|
|
[10, "GPIO10"], |
|
|
|
[11, "GPIO11"], |
|
|
|
[12, "GPIO12 (PSRAM/FLASH)"], |
|
|
|
[13, "GPIO13 (PSRAM/FLASH)"], |
|
|
|
[14, "GPIO14 (PSRAM/FLASH)"], |
|
|
|
[15, "GPIO15 (PSRAM/FLASH)"], |
|
|
|
[16, "GPIO16 (PSRAM/FLASH)"], |
|
|
|
[17, "GPIO17 (PSRAM/FLASH)"], |
|
|
|
[18, "GPIO18 ({#PIN_DONT_USE} - USB-)"], |
|
|
|
[19, "GPIO19 ({#PIN_DONT_USE} - USB+)"], |
|
|
|
[20, "GPIO20 (RX)"], |
|
|
|
[21, "GPIO21 (TX)"], |
|
|
|
]; |
|
|
|
/*ENDIF_ESP32-C3*/ |
|
|
|
/*ENDIF_ESP32*/ |
|
|
|
|
|
|
|
function sect(e1, e2) { |
|
|
|
return ml("div", {class: "row"}, [ |
|
|
|
ml("div", {class: "col-12"}, ml("p", {}, e1)), |
|
|
@ -22,7 +181,36 @@ |
|
|
|
]) |
|
|
|
} |
|
|
|
|
|
|
|
function wifi() { |
|
|
|
/*IF_ETHERNET*/ |
|
|
|
var pins = ['cs', 'sclk', 'miso', 'mosi', 'irq', 'reset'] |
|
|
|
function step1(obj) { |
|
|
|
console.log(obj) |
|
|
|
lst = [] |
|
|
|
for(p of pins) { |
|
|
|
lst.push( |
|
|
|
ml("div", {class: "row mb-3"}, [ |
|
|
|
ml("div", {class: "col-12 col-sm-3 my-2"}, p.toUpperCase()), |
|
|
|
ml("div", {class: "col-12 col-sm-9"}, |
|
|
|
sel(p, pinList, obj[p]) |
|
|
|
) |
|
|
|
]) |
|
|
|
) |
|
|
|
} |
|
|
|
let en = inp("en", null, null, ["cb"], "en", "checkbox"); |
|
|
|
en.checked = obj["en"]; |
|
|
|
|
|
|
|
return sect("{#NETWORK_SETUP}", [ |
|
|
|
ml("div", {class: "row mb-3"}, [ |
|
|
|
ml("div", {class: "col-8"}, "{#ETH_ENABLE}"), |
|
|
|
ml("div", {class: "col-4"}, en) |
|
|
|
]), |
|
|
|
...lst, |
|
|
|
ml("div", {class: "row my-4"}, ml("div", {class: "col a-r"}, ml("input", {type: "button", class:"btn", value: "{#BTN_REBOOT}", onclick: () => {saveEth()}}, null))), |
|
|
|
ml("div", {class: "row mt-5"}, ml("div", {class: "col a-c"}, ml("a", {href: "http://192.168.4.1/"}, "{#STOP_WIZARD}"))) |
|
|
|
]) |
|
|
|
} |
|
|
|
/*ELSE*/ |
|
|
|
function step1() { |
|
|
|
return ml("div", {}, [ |
|
|
|
ml("div", {class: "row my-5"}, ml("div", {class: "col"}, ml("span", {class: "fs-1"}, "{#WELCOME}"))), |
|
|
|
ml("div", {class: "row"}, ml("div", {class: "col"}, ml("span", {class: "fs-5"}, "{#NETWORK_SETUP}"))), |
|
|
@ -33,6 +221,7 @@ |
|
|
|
ml("div", {class: "row mt-5"}, ml("div", {class: "col a-c"}, ml("a", {href: "http://192.168.4.1/"}, "{#STOP_WIZARD}"))) |
|
|
|
]) |
|
|
|
} |
|
|
|
/*ENDIF_ETHERNET*/ |
|
|
|
|
|
|
|
function checkWifi() { |
|
|
|
c.replaceChildren( |
|
|
@ -57,13 +246,29 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*IF_ETHERNET*/ |
|
|
|
function saveEth() { |
|
|
|
let o = { |
|
|
|
cmd: "save_eth", |
|
|
|
en: document.getElementsByName("en")[0].checked |
|
|
|
} |
|
|
|
for(p of pins) { |
|
|
|
o[p] = document.getElementsByName(p)[0].value |
|
|
|
} |
|
|
|
getAjax("/api/setup", ((o) => {}), "POST", JSON.stringify(o)); |
|
|
|
} |
|
|
|
/*ELSE*/ |
|
|
|
function saveWifi() { |
|
|
|
var ssid = document.getElementById("net").value; |
|
|
|
if(-1 == ssid) |
|
|
|
ssid = document.getElementById("man").value; |
|
|
|
getAjax("/api/setup", ((o) => {if(!o.error) checkWifi()}), "POST", JSON.stringify({cmd: "save_wifi", ssid: ssid, pwd: document.getElementById("pwd").value})); |
|
|
|
} |
|
|
|
/*ENDIF_ETHERNET*/ |
|
|
|
|
|
|
|
/*IF_ETHERNET*/ |
|
|
|
getAjax("/api/setup", ((o) => c.append(step1(o.eth)))); |
|
|
|
/*ELSE*/ |
|
|
|
function nets(obj) { |
|
|
|
var e = document.getElementById("net"); |
|
|
|
if(obj.networks.length > 0) { |
|
|
@ -79,9 +284,10 @@ |
|
|
|
} |
|
|
|
|
|
|
|
getAjax("/api/setup", ((o) => {}), "POST", JSON.stringify({cmd: "scan_wifi"})); |
|
|
|
c.append(wifi()) |
|
|
|
|
|
|
|
c.append(step1()) |
|
|
|
v = setInterval(() => {getAjax('/api/setup/networks', nets)}, 2500); |
|
|
|
/*ENDIF_ETHERNET*/ |
|
|
|
|
|
|
|
</script> |
|
|
|
</body> |
|
|
|
</html> |
|
|
|