Continue à bosser sur le tri de mon tableau d'adresses de sniffage. Mais cela prend beaucoup trop de place !
This commit is contained in:
69
Tests/a_test_ram.lua
Normal file
69
Tests/a_test_ram.lua
Normal file
@@ -0,0 +1,69 @@
|
||||
-- Scripts pour tester l'occupation méroire des différents modules
|
||||
-- source:
|
||||
|
||||
print("\n a_test_ram.lua zf190127.1014 \n")
|
||||
|
||||
test_ram_alarm1=tmr.create()
|
||||
test_ram_alarm2=tmr.create()
|
||||
zram0=node.heap() zram1=node.heap()
|
||||
|
||||
tmr.alarm(test_ram_alarm1, 1*1000, tmr.ALARM_AUTO, function()
|
||||
zram2=node.heap() print(zram0, zram1, zram2, zram1-zram2, zram0-zram2)
|
||||
end)
|
||||
|
||||
--[[
|
||||
file.remove("telnet_srv2.lc")
|
||||
file.remove("web_ide2.lc")
|
||||
file.remove("web_srv.lc")
|
||||
file.remove("set_time.lc")
|
||||
|
||||
node.compile("telnet_srv2.lua")
|
||||
node.compile("web_ide2.lua")
|
||||
node.compile("web_srv.lua")
|
||||
node.compile("set_time.lua")
|
||||
|
||||
file.remove("telnet_srv2.lua")
|
||||
file.remove("web_ide2.lua")
|
||||
file.remove("web_srv.lua")
|
||||
file.remove("set_time.lua")
|
||||
]]
|
||||
|
||||
tmr.alarm(test_ram_alarm2, 2.5*1000, tmr.ALARM_SINGLE, function()
|
||||
zram1=node.heap()
|
||||
-- dofile("telnet_srv2.lua")
|
||||
-- dofile("web_ide2.lua")
|
||||
dofile("web_srv2.lua")
|
||||
-- dofile("set_time.lua")
|
||||
-- dofile("web_html.lua")
|
||||
|
||||
|
||||
-- dofile("telnet_srv2.lc")
|
||||
-- dofile("web_ide2.lc")
|
||||
-- dofile("web_srv.lc")
|
||||
-- dofile("set_time.lc")
|
||||
|
||||
zram2=node.heap()
|
||||
end)
|
||||
|
||||
f= "wifi_ap_start.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
|
||||
|
||||
--[[
|
||||
tmr.stop(test_ram_alarm1)
|
||||
package.loaded ["telnet_srv2.lua.lua"] = nil
|
||||
package.loaded ["wifi_ap_start.lua"] = nil
|
||||
|
||||
|
||||
]]
|
||||
|
||||
|
||||
--[[
|
||||
f= "wifi_ap_start.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= "web_srv.lua" if file.exists(f) then dofile(f) end
|
||||
f= "set_time.lua" if file.exists(f) then dofile(f) end
|
||||
]]
|
||||
15
Tests/a_tst_timer.lua
Normal file
15
Tests/a_tst_timer.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
-- Scripts pour tester le timer dans sa plus simple expression
|
||||
|
||||
print("\n a_tst_timer.lua zf190209.1519 \n")
|
||||
|
||||
|
||||
test_1=tmr.create()
|
||||
tmr.alarm(test_1, 1*1000, tmr.ALARM_AUTO, function()
|
||||
--tmr.alarm(test_1, 2.5*1000, tmr.ALARM_SINGLE, function()
|
||||
print("coucou")
|
||||
end)
|
||||
|
||||
--[[
|
||||
tmr.stop(test_1)
|
||||
tmr.start(test_1)
|
||||
]]
|
||||
@@ -3,9 +3,20 @@
|
||||
-- source: https://wxlua.developpez.com/tutoriels/lua/general/cours-complet/#L6-f
|
||||
-- source: https://wxlua.developpez.com/tutoriels/lua/general/cours-complet/#L13-g
|
||||
|
||||
print("\n a_tst_sort.lua zf190202.1904 \n")
|
||||
print("\n a_tst_sort.lua zf190209.1512 \n")
|
||||
|
||||
zmac_adrs={}
|
||||
zmac_adrs_index={}
|
||||
|
||||
|
||||
|
||||
function zshow()
|
||||
i=1
|
||||
for k, v in ipairs(zmac_adrs) do
|
||||
print(i..", "..k, zmac_adrs[k]["adrs"]..", ".. zmac_adrs[k]["zname"], zmac_adrs[k]["zrssi"], zmac_adrs[k]["ztime"])
|
||||
i=i+1
|
||||
end
|
||||
end
|
||||
|
||||
function zload_tableau()
|
||||
filename="tst_sniffer_wifi1.csv"
|
||||
@@ -13,12 +24,15 @@ function zload_tableau()
|
||||
repeat
|
||||
local line=file.read('\n')
|
||||
if line then
|
||||
print("line: "..line)
|
||||
-- print("line: "..line)
|
||||
local zfield = {} local zpart=""
|
||||
for zpart in line:gmatch("[^,]+") do
|
||||
zfield[#zfield+1] = zpart
|
||||
end
|
||||
zmac_adrs[zfield[2]]={["zname"]=zfield[3],["zrssi"]=zfield[4], ["ztime"]=zfield[5]}
|
||||
-- :sub(1, -2) , ça enlève le \n à la fin de la ligne lors de la lecture du fichier !
|
||||
zmac_adrs[zfield[2]]={["zname"]=zfield[3],["zrssi"]=zfield[4], ["ztime"]=zfield[5]:sub(1, -2)}
|
||||
-- zmac_adrs[#zmac_adrs+1]={["adrs"]=zfield[2], ["zname"]=zfield[3], ["zrssi"]=zfield[4], ["ztime"]=zfield[5]:sub(1, -2)}
|
||||
-- zmac_adrs_index[zfield[2]]=#zmac_adrs
|
||||
end
|
||||
until not line
|
||||
file.close()
|
||||
@@ -28,47 +42,42 @@ end
|
||||
|
||||
zload_tableau()
|
||||
|
||||
print("tableau chargé") --important, c'est pour attendre que le tableau soit complètement chargé !
|
||||
zshow()
|
||||
|
||||
|
||||
function zsort_tableau()
|
||||
|
||||
table.sort(zmac_adrs, function([zrssi], [zrssi])
|
||||
return ([zrssi] > [zrssi])
|
||||
end)
|
||||
|
||||
print("tri du tableau")
|
||||
table.sort(zmac_adrs, function(a,b) return a.zrssi < b.zrssi end)
|
||||
end
|
||||
|
||||
|
||||
--[[
|
||||
zload_tableau()
|
||||
zshow()
|
||||
zsort_tableau()
|
||||
]]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function zshow()
|
||||
i=1
|
||||
for k, v in pairs(zmac_adrs) do
|
||||
print(i..", ", k..", ", zmac_adrs[k]["zname"], zmac_adrs[k]["zrssi"], zmac_adrs[k]["ztime"])
|
||||
i=i+1
|
||||
end
|
||||
end
|
||||
--[[
|
||||
zshow()
|
||||
|
||||
print(zmac_adrs_index["02:ec:f1:a1:c8:29"])
|
||||
print(zmac_adrs[70].adrs)
|
||||
|
||||
zmac_adrs=nil
|
||||
zmac_adrs_index=nil
|
||||
|
||||
|
||||
zmac_adrs_index={}
|
||||
zmac_adrs_index["toto"]=3
|
||||
print(zmac_adrs_index["toto"])
|
||||
|
||||
|
||||
]]
|
||||
|
||||
|
||||
|
||||
|
||||
function zround(num, dec)
|
||||
local mult = 10^(dec or 0)
|
||||
return math.floor(num * mult + 0.5) / mult
|
||||
end
|
||||
|
||||
|
||||
--[[
|
||||
zload_tableau()
|
||||
zshow()
|
||||
]]
|
||||
|
||||
|
||||
|
||||
118
WIFI_sniffer/a_tst_sort.lua.190209.1507
Normal file
118
WIFI_sniffer/a_tst_sort.lua.190209.1507
Normal file
@@ -0,0 +1,118 @@
|
||||
-- Scripts pour tester le tri (sort) d'un tableau d'adresse MAC en fonction du signal de réception
|
||||
-- pour les tests on charge un fichier CSV de d'adresse MAC sniffées précédemment
|
||||
-- source: https://wxlua.developpez.com/tutoriels/lua/general/cours-complet/#L6-f
|
||||
-- source: https://wxlua.developpez.com/tutoriels/lua/general/cours-complet/#L13-g
|
||||
|
||||
print("\n a_tst_sort.lua zf190208.1734 \n")
|
||||
|
||||
zmac_adrs={}
|
||||
|
||||
|
||||
function zshow()
|
||||
i=1
|
||||
for k, v in pairs(zmac_adrs) do
|
||||
print(i..", ", k..", ", zmac_adrs[k]["zname"], zmac_adrs[k]["zrssi"], zmac_adrs[k]["ztime"])
|
||||
i=i+1
|
||||
end
|
||||
end
|
||||
|
||||
function zload_tableau()
|
||||
filename="tst_sniffer_wifi1.csv"
|
||||
if file.open(filename, "r") then
|
||||
repeat
|
||||
local line=file.read('\n')
|
||||
if line then
|
||||
-- print("line: "..line)
|
||||
local zfield = {} local zpart=""
|
||||
for zpart in line:gmatch("[^,]+") do
|
||||
zfield[#zfield+1] = zpart
|
||||
end
|
||||
-- :sub(1, -2) , ça enlève le \n à la fin de la ligne lors de la lecture du fichier !
|
||||
zmac_adrs[zfield[2]]={["zname"]=zfield[3],["zrssi"]=zfield[4], ["ztime"]=zfield[5]:sub(1, -2)}
|
||||
end
|
||||
until not line
|
||||
file.close()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
zload_tableau()
|
||||
--zshow()
|
||||
|
||||
print("tableau chargé") --important, c'est pour attendre que le tableau soit complètement chargé !
|
||||
zshow()
|
||||
|
||||
--[[
|
||||
test_sort1=tmr.create()
|
||||
tmr.alarm(test_sort1, 2.5*1000, tmr.ALARM_SINGLE, function()
|
||||
zshow()
|
||||
end)
|
||||
]]
|
||||
|
||||
|
||||
|
||||
function zsort_tableau()
|
||||
print("tri du tableau")
|
||||
table.sort(zmac_adrs, function(a,b) return a.zrssi < b.zrssi end)
|
||||
|
||||
|
||||
end
|
||||
|
||||
function zshow2()
|
||||
i=1
|
||||
|
||||
--for i,v in ipairs(zmac_adrs) do print(v.zrssi) end
|
||||
for j,v in pairs(zmac_adrs) do
|
||||
print(i,j)
|
||||
i=i+1
|
||||
end
|
||||
|
||||
-- i=1
|
||||
-- for k, v in pairs(zmac_adrs) do
|
||||
-- print(i..", ", k..", ", zmac_adrs[k]["zname"], zmac_adrs[k]["zrssi"], zmac_adrs[k]["ztime"])
|
||||
-- i=i+1
|
||||
-- end
|
||||
end
|
||||
|
||||
|
||||
function toto()
|
||||
local animals = {
|
||||
{name = "bunny", size = 4},
|
||||
{name = "mouse", size = 1},
|
||||
{name = "cow", size = 30}
|
||||
}
|
||||
-- sort animals by size descending
|
||||
table.sort(animals, function(a,b) return a.size > b.size end)
|
||||
|
||||
for i,v in ipairs(animals) do print(v.name) end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
--[[
|
||||
zload_tableau()
|
||||
zsort_tableau()
|
||||
zshow()
|
||||
zshow2()
|
||||
|
||||
]]
|
||||
|
||||
|
||||
|
||||
--[[
|
||||
zshow()
|
||||
]]
|
||||
|
||||
function zround(num, dec)
|
||||
local mult = 10^(dec or 0)
|
||||
return math.floor(num * mult + 0.5) / mult
|
||||
end
|
||||
|
||||
|
||||
--[[
|
||||
zload_tableau()
|
||||
zshow()
|
||||
]]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user