I have a ESP8266 module with nodemcu firmware that must be programmed using lua. I wrote some code to save username/password credentials that are entered from a html page in a file.
This is the lua function and it works fine
function parse_wifi_credentials(vars)
if vars == nil or vars == "" then
return false
end
local _, _, wifi_ssid = string.find(vars, "wifi_ssid\=([^&]+)")
local _, _, wifi_password = string.find(vars, "wifi_password\=([^&]+)")
if wifi_ssid == nil or wifi_ssid == "" or wifi_password == nil then
return false
end
pwd_len = string.len(wifi_password)
if pwd_len ~= 0 and (pwd_len < 8 or pwd_len > 64) then
return false
end
file.open("credentials.txt", "a")
file.write(wifi_ssid)
file.write(wifi_password)
file.flush()
file.close()
return true
end
It all works but my output file is something like
usernamepasswordotherusernameotherpassword
So I inserted values to separate fields like
file.write(wifi_ssid)
file.write(":")
file.write(wifi_password)
and many other ways like this but my code does not work on my ESP8266 because I get not enough memory error but if I don't print the : I have something like 10 kb free.
I also tried file.write(wifi_ssid, "\n") and it works but the output doesn't change.
Annyone knows what should I do to insert a character beetwen fields?