From 5a437287e8cf41a629ad142884ec8731f18bf01b Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Sun, 16 Dec 2018 00:37:08 +0100 Subject: [PATCH] wpi --- .../guirlandes noël/a_guirlande.lua | 68 ++++---- LED_RGB_WS2812/guirlandes noël/boot.lua | 44 +++-- .../guirlandes noël/credentials.lua | 9 + .../guirlandes noël/flash_led_xfois.lua | 32 ++++ LED_RGB_WS2812/guirlandes noël/index.html | 75 +++++++++ .../guirlandes noël/telnet_srv2.lua | 88 ++++++++++ LED_RGB_WS2812/guirlandes noël/vide.lua | 2 + LED_RGB_WS2812/guirlandes noël/web_ide2.lua | 159 ++++++++++++++++++ LED_RGB_WS2812/guirlandes noël/webleds.lua | 84 +++++++++ .../guirlandes noël/wifi_ap_stop.lua | 10 ++ .../guirlandes noël/wifi_cli_conf.lua | 12 ++ .../guirlandes noël/wifi_cli_start.lua | 14 ++ .../guirlandes noël/wifi_get_ip.lua | 12 ++ LED_RGB_WS2812/guirlandes noël/wifi_info.lua | 31 ++++ 14 files changed, 578 insertions(+), 62 deletions(-) create mode 100644 LED_RGB_WS2812/guirlandes noël/credentials.lua create mode 100644 LED_RGB_WS2812/guirlandes noël/flash_led_xfois.lua create mode 100644 LED_RGB_WS2812/guirlandes noël/index.html create mode 100644 LED_RGB_WS2812/guirlandes noël/telnet_srv2.lua create mode 100644 LED_RGB_WS2812/guirlandes noël/vide.lua create mode 100644 LED_RGB_WS2812/guirlandes noël/web_ide2.lua create mode 100644 LED_RGB_WS2812/guirlandes noël/webleds.lua create mode 100644 LED_RGB_WS2812/guirlandes noël/wifi_ap_stop.lua create mode 100644 LED_RGB_WS2812/guirlandes noël/wifi_cli_conf.lua create mode 100644 LED_RGB_WS2812/guirlandes noël/wifi_cli_start.lua create mode 100644 LED_RGB_WS2812/guirlandes noël/wifi_get_ip.lua create mode 100644 LED_RGB_WS2812/guirlandes noël/wifi_info.lua diff --git a/LED_RGB_WS2812/guirlandes noël/a_guirlande.lua b/LED_RGB_WS2812/guirlandes noël/a_guirlande.lua index ba9f483..9ce7bff 100644 --- a/LED_RGB_WS2812/guirlandes noël/a_guirlande.lua +++ b/LED_RGB_WS2812/guirlandes noël/a_guirlande.lua @@ -2,15 +2,17 @@ -- tout sur la couleur: https://www.w3schools.com/colors/default.asp -- roue des couleurs: https://iro.js.org/?ref=oldsite -print("\n a_guirlande.lua zf181215.2027 \n") +print("\n a_guirlande.lua zf181216.0020 \n") +znbleds_max=300 znbleds=300 -zstep=5 -zpower=0.5 +zstep=1 +zpower=1 function RGB_clear() ws2812.init() - buffer = ws2812.newBuffer(znbleds, 3) + buffer = ws2812.newBuffer(znbleds_max, 3) + buffer_reg = ws2812.newBuffer(znbleds_max, 3) buffer:fill(0, 0, 0) ws2812.write(buffer) end @@ -31,23 +33,13 @@ function zfaderando() end end -function zlog(l) - a=2 - l=0.3+l^a/310^a - return l -end - -print(zlog(0)) -print(zlog(128)) -print(zlog(255)) - function zrando() a=10 zr=math.random(a)+5 if math.random()<0.5 then zr=zr*-1 end - print(zr) +-- print(zr) return zr end @@ -58,19 +50,6 @@ function zincfill() end end -function zledfill() - for i=1, znbleds, zstep do - a=30 - l=math.random(0,255/a)*a --- l=i*(255/znbleds) - k=zlog(l) --- print(i,l,l*k,k) - l=l*k - l=255 - buffer:set(i, l*zpower, l*zpower, l*zpower) - end -end - function zeffect_stop() tmr.unregister(effect_tmr1) RGB_clear() @@ -78,24 +57,39 @@ end function zeffect_start() effect_tmr1=tmr.create() - tmr.alarm(effect_tmr1, 300, tmr.ALARM_AUTO, function() + tmr.alarm(effect_tmr1, 200, tmr.ALARM_AUTO, function() zfaderando() - ws2812.write(buffer) + zpower_reg() + ws2812.write(buffer_reg) end) end +function zpower_reg() + psu_current_ma = 1000 + led_current_ma = 35 + led_sum_current_ma = (znbleds/zstep) * led_current_ma +-- print(znbleds, zstep, led_sum_current_ma) + + led_sum = (znbleds/zstep) * 255 * 3 +-- print(led_sum) + + led_sum=led_sum*psu_current_ma/led_sum_current_ma +-- print(led_sum) + + p = buffer:power() +-- print(p,led_sum) + if p > led_sum then + buffer_reg:mix(256 * led_sum / p, buffer) -- power is now limited + else + buffer_reg:mix(255, buffer) + end +end + RGB_clear() -zledfill() -ws2812.write(buffer) - zincfill() - zeffect_start() - - - diff --git a/LED_RGB_WS2812/guirlandes noël/boot.lua b/LED_RGB_WS2812/guirlandes noël/boot.lua index a6fe229..eb5bbdd 100644 --- a/LED_RGB_WS2812/guirlandes noël/boot.lua +++ b/LED_RGB_WS2812/guirlandes noël/boot.lua @@ -1,33 +1,27 @@ -- Scripts à charger après le boot pour démarrer son appli -print("\n boot.lua zf181125.1635 \n") +print("\n boot.lua zf181216.0028 \n") ---f= "wifi_ap_stop.lua" if file.exists(f) then dofile(f) end ---f= "wifi_cli_conf.lua" if file.exists(f) then dofile(f) end ---f= "wifi_cli_start.lua" if file.exists(f) then dofile(f) end ---f= "telnet_srv.lua" if file.exists(f) then dofile(f) end ---f= "web_ide2.lua" if file.exists(f) then dofile(f) end ---f= "dsleep.lua" if file.exists(f) then dofile(f) end +function heartbeat() + f= "flash_led_xfois.lua" if file.exists(f) then dofile(f) end + boottimer1=tmr.create() + tmr.alarm(boottimer1, 1*1000, tmr.ALARM_AUTO, function() + xfois =2 + blink_LED () + end) +end -f= "a_test_train.lua" if file.exists(f) then dofile(f) end ---f= "a_test_fill.lua" if file.exists(f) then dofile(f) end +f= "wifi_ap_stop.lua" if file.exists(f) then dofile(f) end +f= "wifi_cli_conf.lua" if file.exists(f) then dofile(f) end +f= "wifi_cli_start.lua" if file.exists(f) then dofile(f) end +f= "telnet_srv2.lua" if file.exists(f) then dofile(f) end +f= "web_ide2.lua" if file.exists(f) then dofile(f) end +--f= "az_init_led.lua" if file.exists(f) then dofile(f) end +--f= "webleds.lua" if file.exists(f) then dofile(f) end +f= "a_guirlande.lua" if file.exists(f) then dofile(f) end + +heartbeat() ---[[ -x_dsleep=7 y_dsleep=30 dsleep() - -i=1 -jobtimer1=tmr.create() -tmr.alarm(jobtimer1, 1*1000, tmr.ALARM_AUTO, function() - print(i) i=i+1 - if wifi.sta.getip() ~= nil then - tmr.stop(jobtimer1) - tmr.stop(ztmr_SLEEP) - x_dsleep=300 y_dsleep=30 dsleep() - print("c'est connecté...") - end -end) -]] - diff --git a/LED_RGB_WS2812/guirlandes noël/credentials.lua b/LED_RGB_WS2812/guirlandes noël/credentials.lua new file mode 100644 index 0000000..8a98512 --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/credentials.lua @@ -0,0 +1,9 @@ +-- Petit script pour configurer les choses secrètes que l'on n'aimerait +-- pas être exportées sur Internet (github) +-- faut donc le mettre ailleurs que dans le dépôt ! + +print("\n credentials.lua zf181215.1328 \n") + +cli_ssid="3g-s7" +cli_pwd="12234567" + diff --git a/LED_RGB_WS2812/guirlandes noël/flash_led_xfois.lua b/LED_RGB_WS2812/guirlandes noël/flash_led_xfois.lua new file mode 100644 index 0000000..afc4adb --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/flash_led_xfois.lua @@ -0,0 +1,32 @@ +-- programme pour faire clignoter x fois une LED avec un rapport on/off +print("\n flash_led_xfois.lua zf181204.1955 \n") + +zLED=0 +zTm_On_LED = 50 --> en ms +zTm_Off_LED = 100 --> en ms +nbfois = 0 +gpio.write(zLED, gpio.HIGH) +gpio.mode(zLED, gpio.OUTPUT) +ztmr_Flash_LED = tmr.create() + +function blink_LED () + if nbfois >= xfois then +-- print(nbfois) + nbfois = 0 + else + if gpio.read(zLED)==gpio.HIGH then + gpio.write(zLED, gpio.LOW) + tmr.alarm(ztmr_Flash_LED, zTm_Off_LED, tmr.ALARM_SINGLE, blink_LED) + else + gpio.write(zLED, gpio.HIGH) + nbfois = nbfois+1 + tmr.alarm(ztmr_Flash_LED, zTm_On_LED, tmr.ALARM_SINGLE, blink_LED) + end + end +end + +xfois =2 +blink_LED () + + + diff --git a/LED_RGB_WS2812/guirlandes noël/index.html b/LED_RGB_WS2812/guirlandes noël/index.html new file mode 100644 index 0000000..b30af7d --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/index.html @@ -0,0 +1,75 @@ + + + + + +LED RGB + + + + +

Contrôle des effets des LED's RGB du chapeau

+ +Home + +

Start & Stop:

+ + +

Vitesse de l'effet:

+ + +

Couleurs des trains:

+ + + + WEBIDE +
+Restart

+zf181215.1451
+ + + + diff --git a/LED_RGB_WS2812/guirlandes noël/telnet_srv2.lua b/LED_RGB_WS2812/guirlandes noël/telnet_srv2.lua new file mode 100644 index 0000000..16a7deb --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/telnet_srv2.lua @@ -0,0 +1,88 @@ +-- Serveur telnet pour connexion en remote WIFI, NOUVELLE VERSION ! +-- source: https://github.com/nodemcu/nodemcu-firmware/blob/master/lua_examples/telnet/telnet.lua + +print("\n telnet_srv2.lua zf181215.1326 \n") + +local node, table, tmr, wifi, uwrite, tostring = + node, table, tmr, wifi, uart.write, tostring + +local function telnet_listener(socket) + local insert, remove, concat, heap, gc = + table.insert, table.remove, table.concat, node.heap, collectgarbage + local fifo1, fifo1l, fifo2, fifo2l = {}, 0, {}, 0 + local s -- s is a copy of the TCP socket if and only if sending is in progress + local wdclr, cnt = tmr.wdclr, 0 + local function debug(fmt, ...) + if (...) then fmt = fmt:format(...) end + uwrite(0, "\r\nDBG: ",fmt,"\r\n" ) + cnt = cnt + 1 + if cnt % 10 then wdclr() end + end + + local function flushGarbage() + if heap() < 13440 then gc() end + end + + local function sendLine() + if not s then return end + + if fifo2l + fifo1l == 0 then -- both FIFOs empty, so clear down s + s = nil + return + end + flushGarbage() + if #fifo2 < 4 then -- Flush FIFO1 into FIFO2 + insert(fifo2,concat(fifo1)) + fifo2l, fifo1, fifo1l = fifo2l + fifo1l, {}, 0 + end + local rec = remove(fifo2,1) .. (remove(fifo2,1) or '') .. + (remove(fifo2,1) or '') .. (remove(fifo2,1) or '') + fifo2l = fifo2l - #rec + flushGarbage() + s:send(rec) + end + + local F1_SIZE = 256 + + local function queueLine(str) + while #str > 0 do -- this is because str might be longer than the packet size! + local k, l = F1_SIZE - fifo1l, #str + local chunk + if #fifo1 >= 32 or (k < l and k < 16) then + insert(fifo2, concat(fifo1)) + fifo2l, fifo1, fifo1l, k = fifo2l + fifo1l, {}, 0, F1_SIZE + end + if l > k+16 then -- also tolerate a size overrun of 16 bytes to avoid a split + chunk, str = str:sub(1,k), str:sub(k+1) + else + chunk, str = str, '' + end + insert(fifo1, chunk) + fifo1l = fifo1l + #chunk + end + if not s and socket then + s = socket + sendLine() + else + flushGarbage() + end + end + + local function receiveLine(s, line) + node.input(line) + end + + local function disconnect(s) + fifo1, fifo1l, fifo2, fifo2l, s = {}, 0, {}, 0, nil + node.output(nil) + end + + socket:on("receive", receiveLine) + socket:on("disconnection", disconnect) + socket:on("sent", sendLine) + node.output(queueLine, 0) +end + +net.createServer(net.TCP, 180):listen(23, telnet_listener) +print("Telnet server running...\nUsage: telnet -rN ip\n") + diff --git a/LED_RGB_WS2812/guirlandes noël/vide.lua b/LED_RGB_WS2812/guirlandes noël/vide.lua new file mode 100644 index 0000000..642f2fe --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/vide.lua @@ -0,0 +1,2 @@ +--fichier vide + diff --git a/LED_RGB_WS2812/guirlandes noël/web_ide2.lua b/LED_RGB_WS2812/guirlandes noël/web_ide2.lua new file mode 100644 index 0000000..16d00f2 --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/web_ide2.lua @@ -0,0 +1,159 @@ +-- Petit WEB IDE tout simple autonome +-- ATTENTION: tourne sur le port 88 ! + +print("\n _web_ide2.lua zf181210.1516 \n") + +--[[ +XChip's NodeMCU IDE + +Create, Edit and run NodeMCU files using your webbrowser. +Examples: +http:/// will list all the files in the MCU +http:///newfile.lua displays the file on your browser +http:///newfile.lua?edit allows to creates or edits the specified script in your browser +http:///newfile.lua?run it will run the specified script and will show the returned value +]]-- + +srv=net.createServer(net.TCP) +srv:listen(88,function(conn) + + local rnrn=0 + local Status = 0 + local DataToGet = 0 + local method="" + local url="" + local vars="" + + conn:on("receive",function(conn,payload) + + if Status==0 then + _, _, method, url, vars = string.find(payload, "([A-Z]+) /([^?]*)%??(.*) HTTP") + print(method, url, vars) + end + + if method=="POST" then + + if Status==0 then + --print("status", Status) + _,_,DataToGet, payload = string.find(payload, "Content%-Length: (%d+)(.+)") + if DataToGet~=nil then + DataToGet = tonumber(DataToGet) + --print(DataToGet) + rnrn=1 + Status = 1 + else + print("bad length") + end + end + + -- find /r/n/r/n + if Status==1 then + --print("status", Status) + local payloadlen = string.len(payload) + local mark = "\r\n\r\n" + local i + for i=1, payloadlen do + if string.byte(mark, rnrn) == string.byte(payload, i) then + rnrn=rnrn+1 + if rnrn==5 then + payload = string.sub(payload, i+1,payloadlen) + file.open(url, "w") + file.close() + Status=2 + break + end + else + rnrn=1 + end + end + if Status==1 then + return + end + end + + if Status==2 then + --print("status", Status) + if payload~=nil then + DataToGet=DataToGet-string.len(payload) + --print("DataToGet:", DataToGet, "payload len:", string.len(payload)) + file.open(url, "a+") + file.write(payload) + file.close() + else + conn:send("HTTP/1.1 200 OK\r\n\r\nERROR") + Status=0 + end + + if DataToGet==0 then + conn:send("HTTP/1.1 200 OK\r\n\r\nOK") + Status=0 + end + end + + return + end + + DataToGet = -1 + + if url == "favicon.ico" then + conn:send("HTTP/1.1 404 file not found") + return + end + + conn:send("HTTP/1.1 200 OK\r\n\r\n") + + -- it wants a file in particular + if url~="" and vars=="" then + DataToGet = 0 + return + end + + conn:send("

NodeMCU IDE

") + + if vars=="edit" then + conn:send("") + conn:send("

Back to file list\n") + conn:send("

run") + conn:send("



") + end + + if vars=="run" then + conn:send("") + local st, result=pcall(dofile, url) + conn:send(tostring(result)) + conn:send("") + end + + if url=="" then + local l = file.list(); + for k,v in pairs(l) do + conn:send(""..k..", size:"..v.."
") + end + end + + conn:send("") + + end) + conn:on("sent",function(conn) + if DataToGet>=0 and method=="GET" then + if file.open(url, "r") then + file.seek("set", DataToGet) + local line=file.read(512) + file.close() + if line then + conn:send(line) + DataToGet = DataToGet + 512 + + if (string.len(line)==512) then + return + end + end + end + end + + conn:close() + end) +end) +print("listening, free:", node.heap()) + diff --git a/LED_RGB_WS2812/guirlandes noël/webleds.lua b/LED_RGB_WS2812/guirlandes noël/webleds.lua new file mode 100644 index 0000000..dbdc716 --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/webleds.lua @@ -0,0 +1,84 @@ +-- Petit script de serveur WEB pour piloter les effets des LED RGB +-- source: https://github.com/nodemcu/nodemcu-firmware/blob/master/lua_examples/webap_toggle_pin.lua + +print("\n webleds.lua zf181215.1447 \n") + + +-- send a file from memory to the client; max. line length = 1024 bytes! +function send_file(client, filename) + if file.open(filename, "r") then + repeat + local line=file.read('\n') + if line then + client:send(line) + end + until not line + file.close() + end +end + +-- web server +srv = net.createServer(net.TCP) +srv:listen(80, function(conn) + conn:on("receive", function(client, request) + local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP") + if not string.find(request, "/favicon.ico") then + --print("coucou") + if (method == nil) then + _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP") + end + _GET = {} + if (vars ~= nil) then + for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do + _GET[k] = v + print(k..": "..v) + end + end + + if (_GET.fonction == "start") then + train_start() + end + + if (_GET.fonction == "stop") then + train_stop() + end + + if (_GET.set == "speed") then + train_stop() + if (_GET.speed == "inc") then + train_speed=train_speed*0.8 + elseif (_GET.speed == "dec") then + train_speed=train_speed*1.2 + elseif (_GET.speed == "tresvite") then + train_speed=7 + elseif (_GET.speed == "treslent") then + train_speed=77 + end + train_start() + end + + if (_GET.set == "color") then + print("setting color (RGB)", _GET.R1, _GET.G1, _GET.B1) + train_stop() + R1=_GET.R1 G1=_GET.G1 B1=_GET.B1 + R2=_GET.R2 G2=_GET.G2 B2=_GET.B2 + train1_fill() + train2_fill() + train_start() + end + + if (_GET.restart == "1") then + restarttimer1=tmr.create() + tmr.alarm(restarttimer1, 2*1000, tmr.ALARM_SINGLE, function() + node.restart() + end) + end + + + print("send html...") + send_file(client, 'index.html') + end + end) + conn:on("sent", function(c) c:close() end) +end) + diff --git a/LED_RGB_WS2812/guirlandes noël/wifi_ap_stop.lua b/LED_RGB_WS2812/guirlandes noël/wifi_ap_stop.lua new file mode 100644 index 0000000..2738627 --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/wifi_ap_stop.lua @@ -0,0 +1,10 @@ +-- Démarre le WIFI en mode AP +print("\n wifi_ap_stop.lua zf180824.2000 \n") + +local zmodewifi=wifi.getmode() +if zmodewifi == wifi.SOFTAP then + wifi.setmode(wifi.NULLMODE) +elseif zmodewifi == wifi.STATIONAP then + wifi.setmode(wifi.STATION) +end +print("WIFI AP arrêté") diff --git a/LED_RGB_WS2812/guirlandes noël/wifi_cli_conf.lua b/LED_RGB_WS2812/guirlandes noël/wifi_cli_conf.lua new file mode 100644 index 0000000..6726313 --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/wifi_cli_conf.lua @@ -0,0 +1,12 @@ +-- Petit script pour configurer le client WIFI du NodeMCU + +print("\n wifi_cli_conf.lua zf181205.1931 \n") + +--credentials par défaut +cli_ssid="3g-s7" +cli_pwd="12234567" + +--ses propre credentials +f= "credentials.lua" if file.exists(f) then dofile(f) end + +wifi.sta.config{ssid=cli_ssid, pwd=cli_pwd, save=true} diff --git a/LED_RGB_WS2812/guirlandes noël/wifi_cli_start.lua b/LED_RGB_WS2812/guirlandes noël/wifi_cli_start.lua new file mode 100644 index 0000000..f1091ac --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/wifi_cli_start.lua @@ -0,0 +1,14 @@ +-- Petit script pour connecter le NodeMCU sur un AP Wifi avec l'accompte sauvé en EEPROM +print("\n wifi_cli_start.lua zf181119.2359 \n") + +local zmodewifi=wifi.getmode() +if zmodewifi == wifi.NULLMODE then + print("WIFI mode CLI only") + wifi.setmode(wifi.STATION) +elseif zmodewifi == wifi.SOFTAP then + print("WIFI mode AP+CLI") + wifi.setmode(wifi.STATIONAP) +end +wifi.sta.autoconnect(1) +wifi.sta.connect() +f= "wifi_get_ip.lua" if file.exists(f) then dofile(f) end diff --git a/LED_RGB_WS2812/guirlandes noël/wifi_get_ip.lua b/LED_RGB_WS2812/guirlandes noël/wifi_get_ip.lua new file mode 100644 index 0000000..82bcdc2 --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/wifi_get_ip.lua @@ -0,0 +1,12 @@ +-- Petit script pour obtenir l'adresse IP du NodeMCU connecté sur un AP Wifi +print("\n wifi_get_ip.lua zf181119.2318 \n") + +wifitimer1=tmr.create() +tmr.alarm(wifitimer1, 1000, tmr.ALARM_AUTO , function() + if wifi.sta.getip() == nil then + print("Connecting to AP...") + else + tmr.stop(wifitimer1) + f= "wifi_info.lua" if file.exists(f) then dofile(f) end + end +end) diff --git a/LED_RGB_WS2812/guirlandes noël/wifi_info.lua b/LED_RGB_WS2812/guirlandes noël/wifi_info.lua new file mode 100644 index 0000000..5062fcf --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/wifi_info.lua @@ -0,0 +1,31 @@ +-- Petit script pour afficher les infos actuel du WIFI +print("\n wifi_info.lua zf181119.0014 \n") + +local zmodewifi=wifi.getmode() + +--wifi.NULLMODE, wifi.STATION, wifi.SOFTAP, wifi.STATIONAP + +if zmodewifi == wifi.NULLMODE then + print("WIFI OFF") +elseif zmodewifi == wifi.STATION then + print("WIFI mode CLI") + print("Connected IP:\n",wifi.sta.getip()) + do + local sta_config=wifi.sta.getconfig(true) + print(string.format("Current client config:\n\tssid:\"%s\"\tpassword:\"%s\"\n\tbssid:\"%s\"\tbssid_set:%s", sta_config.ssid, sta_config.pwd, sta_config.bssid, (sta_config.bssid_set and "true" or "false"))) + end +elseif zmodewifi == wifi.SOFTAP then + print("WIFI mode AP") + print("AP MAC:\n",wifi.ap.getmac()) + print("AP IP:\n",wifi.ap.getip()) + print("AP Connect:\n",wifi.ap.getconfig()) +elseif zmodewifi == wifi.STATIONAP then + print("WIFI mode CLI+AP") + print("Connected IP:\n",wifi.sta.getip()) + do + local sta_config=wifi.sta.getconfig(true) + print(string.format("Current client config:\n\tssid:\"%s\"\tpassword:\"%s\"\n\tbssid:\"%s\"\tbssid_set:%s", sta_config.ssid, sta_config.pwd, sta_config.bssid, (sta_config.bssid_set and "true" or "false"))) + end + print("AP MAC: "..wifi.ap.getmac()) + print("AP IP: "..wifi.ap.getip()) +end