-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,333 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
|
||
-- | ||
-- File: _init.lua | ||
--[[ | ||
This is a template for the LFS equivalent of the SPIFFS init.lua. | ||
It is a good idea to such an _init.lua module to your LFS and do most of the LFS | ||
module related initialisaion in this. This example uses standard Lua features to | ||
simplify the LFS API. | ||
The first section adds a 'LFS' table to _G and uses the __index metamethod to | ||
resolve functions in the LFS, so you can execute the main function of module | ||
'fred' by executing LFS.fred(params), etc. It also implements some standard | ||
readonly properties: | ||
LFS._time The Unix Timestamp when the luac.cross was executed. This can be | ||
used as a version identifier. | ||
LFS._config This returns a table of useful configuration parameters, hence | ||
print (("0x%6x"):format(LFS._config.lfs_base)) | ||
gives you the parameter to use in the luac.cross -a option. | ||
LFS._list This returns a table of the LFS modules, hence | ||
print(table.concat(LFS._list,'\n')) | ||
gives you a single column listing of all modules in the LFS. | ||
---------------------------------------------------------------------------------]] | ||
|
||
local index = node.flashindex | ||
|
||
local lfs_t = { | ||
__index = function(_, name) | ||
local fn_ut, ba, ma, size, modules = index(name) | ||
if not ba then | ||
return fn_ut | ||
elseif name == '_time' then | ||
return fn_ut | ||
elseif name == '_config' then | ||
local fs_ma, fs_size = file.fscfg() | ||
return {lfs_base = ba, lfs_mapped = ma, lfs_size = size, | ||
fs_mapped = fs_ma, fs_size = fs_size} | ||
elseif name == '_list' then | ||
return modules | ||
else | ||
return nil | ||
end | ||
end, | ||
|
||
__newindex = function(_, name, value) -- luacheck: no unused | ||
error("LFS is readonly. Invalid write to LFS." .. name, 2) | ||
end, | ||
|
||
} | ||
|
||
local G=getfenv() | ||
G.LFS = setmetatable(lfs_t,lfs_t) | ||
|
||
--[[------------------------------------------------------------------------------- | ||
The second section adds the LFS to the require searchlist, so that you can | ||
require a Lua module 'jean' in the LFS by simply doing require "jean". However | ||
note that this is at the search entry following the FS searcher, so if you also | ||
have jean.lc or jean.lua in SPIFFS, then this SPIFFS version will get loaded into | ||
RAM instead of using. (Useful, for development). | ||
See docs/en/lfs.md and the 'loaders' array in app/lua/loadlib.c for more details. | ||
---------------------------------------------------------------------------------]] | ||
|
||
package.loaders[3] = function(module) -- loader_flash | ||
local fn, ba = index(module) | ||
return ba and "Module not in LFS" or fn | ||
end | ||
|
||
--[[------------------------------------------------------------------------------- | ||
You can add any other initialisation here, for example a couple of the globals | ||
are never used, so setting them to nil saves a couple of global entries | ||
---------------------------------------------------------------------------------]] | ||
|
||
G.module = nil -- disable Lua 5.0 style modules to save RAM | ||
package.seeall = nil | ||
|
||
--[[------------------------------------------------------------------------------- | ||
These replaces the builtins loadfile & dofile with ones which preferentially | ||
loads the corresponding module from LFS if present. Flipping the search order | ||
is an exercise left to the reader.- | ||
---------------------------------------------------------------------------------]] | ||
|
||
local lf, df = loadfile, dofile | ||
G.loadfile = function(n) | ||
local mod, ext = n:match("(.*)%.(l[uc]a?)"); | ||
local fn, ba = index(mod) | ||
if ba or (ext ~= 'lc' and ext ~= 'lua') then return lf(n) else return fn end | ||
end | ||
|
||
G.dofile = function(n) | ||
local mod, ext = n:match("(.*)%.(l[uc]a?)"); | ||
local fn, ba = index(mod) | ||
if ba or (ext ~= 'lc' and ext ~= 'lua') then return df(n) else return fn() end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
aplist = {} | ||
|
||
wifi.sta.getap( | ||
function(t) | ||
local k, v | ||
local i = 0 | ||
for k,v in pairs(t) do | ||
cprint("cfgsvr", k, v) | ||
aplist[i] = k | ||
i = i + 1 | ||
end | ||
end | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
cfg = {} | ||
--cfg.Mode = "AP" | ||
cfg.Mode = "Station" | ||
cfg.APServerSSID = "espfilemgr" | ||
cfg.APServerChannel = 6 | ||
cfg.APServerPwd = nil | ||
cfg.APServerIP = "192.168.4.1" | ||
cfg.StationWiFiSSID = "YourWiFiSSID" | ||
cfg.StationWiFiPwd = "password" | ||
cfg.DebugLevel = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
|
||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title></title> | ||
</head> | ||
<body> | ||
File not found (name is case sensitive) | ||
</body> | ||
</html> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
<!DOCTYPE html> | ||
|
||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title></title> | ||
<script src="files.js"></script> | ||
</head> | ||
<body style="font-family: sans-serif; font-size: small;"> | ||
ESP IP or host: <input type="text" id="ESPServerElement" style="width: 350px;" onchange="confirmCookie(this)" /> | ||
<a href="help.html" target="_blank">Help</a><br /><br /> | ||
<table> | ||
<tr> | ||
<td> | ||
<!--div style="width: 100px; display: inline-block;"></!div --> | ||
<button onclick="restartESP()">Restart ESP</button> | ||
<button onclick="getheap()">Heap</button> | ||
<label id="heapElement"></label> | ||
<br /><br /> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td style="border: solid gray 1px;padding: 5px;"> | ||
<table cellspacing="2" cellpadding="4" border="0" style="width: 325px;"> | ||
<tr> | ||
<th colspan="2" style="text-align:left;"> | ||
Files to send: | ||
</th> | ||
<th style="text-align:left;"> | ||
If file exists: | ||
</th> | ||
</tr> | ||
<tr> | ||
<td colspan="2"> | ||
<input id="File1" type="file" multiple /> | ||
</td> | ||
<td> | ||
<select id="optionsList"> | ||
<option value="Backup">Backup</option> | ||
<option value="Overwrite">Overwrite</option> | ||
<option value="Abort">Abort</option> | ||
<!--option value="Ignore">Ignore</option --> | ||
</select> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td style="width:155px; text-align:center;"> | ||
<button onclick="sendFiles(document.getElementById('File1'));" style="height:30px;width:80px;">Upload</button> | ||
</td> | ||
<td colspan="2" style="text-align:left;"> | ||
Progress: <input type="text" id="statusElement" style="border: none; width: 175px;" /><br /> | ||
<div style="width:125px; border: solid gray 1px; "> | ||
<div style="height: 10px; width: 0px; color: white; font-size: xx-small; text-align: center; background-color: green; margin-top: 1px; margin-bottom: 1px;" id="progressBar"></div> | ||
</div> | ||
|
||
</td> | ||
</tr> | ||
</table> | ||
|
||
</td> | ||
</tr> | ||
</table> | ||
<hr /> | ||
|
||
|
||
<button onclick="getFileList()">Refresh File List</button> | ||
<button onclick="getCfg()">Edit Config</button> | ||
<br /><br /> | ||
<div id="configDiv" style="display:none; border: solid gray 1px; width: 360px; padding: 5px;"> | ||
<button onclick="sendCfg()">Save Config</button> <button onclick="this.parentElement.style.display = 'none'">Cancel</button><br /><br /> | ||
<textarea id="configElement" style="width: 350px; height: 220px;"></textarea> | ||
</div> | ||
<table> | ||
<tr> | ||
<td> | ||
<div style="overflow-y: auto;"> | ||
<table id="fileList" border="0"></table> | ||
</div> | ||
</td> | ||
<td valign="top"> | ||
<div style="border: solid gray 1px; padding: 5px; margin-left:25px;"> | ||
<select id="fileDropdown"></select><br /><br /> | ||
<button id="deleteFileBtn" onclick="deleteSelectedFile(this)">Delete Selected File</button><br /> | ||
<div id="deleteConfirmDiv" style="display:none;"> | ||
<br /> | ||
Delete the selected file?<br /> | ||
Click the Delete button again to confirm | ||
</div> | ||
<br /> | ||
<button id="renameFileBtn" onclick="renameSelectedFile(this)">Rename Selected File</button><br /> | ||
<div id="newNameDiv" style="display:none;"> | ||
<br /> | ||
New file name <input type="text" id="newFileNameInput" /><br /><br /> | ||
(Enter new name and click the Rename button again.) | ||
</div> | ||
<button id="cancelFileOpBtn" style="display:none;" onclick="cancelDeleteRename(this)">Cancel</button> | ||
</div> | ||
</td> | ||
</tr> | ||
</table> | ||
|
||
<script> | ||
var cookiebuf = document.cookie; | ||
var tempcookie = cookiebuf.substring(cookiebuf.indexOf("espserver")) + ";"; | ||
var temparr = tempcookie.split(";"); | ||
cookiebuf = temparr[0]; | ||
var serverElement = document.getElementById('ESPServerElement'); | ||
if (cookiebuf && cookiebuf.length) { | ||
var tempArray = cookiebuf.split("="); | ||
if (tempArray[1].length) | ||
serverElement.value = tempArray[1]; | ||
else | ||
serverElement.value = location.hostname + ":" + window.location.port; | ||
} | ||
else { | ||
serverElement.value = location.hostname; | ||
} | ||
|
||
var initObj = { | ||
"serverElement": serverElement, | ||
"statusElement": document.getElementById("statusElement"), | ||
"optionsListElement": document.getElementById("optionsList"), | ||
"progressElement": document.getElementById("progressBar"), | ||
"fileListElement": document.getElementById("fileList"), | ||
"fileDropdownElement": document.getElementById("fileDropdown"), | ||
"newNameDivElement": document.getElementById("newNameDiv"), | ||
"newFileNameInputElement": document.getElementById("newFileNameInput"), | ||
"deleteConfirmDivElement": document.getElementById("deleteConfirmDiv"), | ||
"cancelFileOpBtnElement": document.getElementById("cancelFileOpBtn"), | ||
"deleteFileBtnElement": document.getElementById("deleteFileBtn"), | ||
"renameFileBtnElement": document.getElementById("renameFileBtn"), | ||
"configElement": document.getElementById("configElement"), | ||
"configDiv": document.getElementById("configDiv"), | ||
"heapElement": document.getElementById("heapElement") | ||
} | ||
|
||
fileJsInit(initObj); | ||
getFileList(); | ||
|
||
function confirmCookie(that) { | ||
if (confirm("Save changes in a cookie?")) { | ||
setCookie(that); | ||
} | ||
} | ||
function setCookie(serverElement) { | ||
document.cookie = "espserver=" + serverElement.value + "; expires=Thu, 18 Dec 2023 12:00:00 UTC; path=/"; | ||
} | ||
</script> | ||
|
||
</body> | ||
</html> |
Oops, something went wrong.