-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwifitest.lua
70 lines (54 loc) · 1.64 KB
/
wifitest.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
--print stored access point info
do
for k,v in pairs(wifi.sta.getapinfo()) do
if (type(v)=="table") then
print(" "..k.." : "..type(v))
for k,v in pairs(v) do
print("\t\t"..k.." : "..v)
end
else
print(" "..k.." : "..v)
end
end
end
--Get default Station configuration (NEW FORMAT)
do
local def_sta_config=wifi.sta.getdefaultconfig(true)
print(string.format("\tDefault station config\n\tssid:\"%s\"\tpassword:\"%s\"\n\tbssid:\"%s\"\tbssid_set:%s", def_sta_config.ssid, def_sta_config.pwd, def_sta_config.bssid, (def_sta_config.bssid_set and "true" or "false")))
end
--Get RSSI(Received Signal Strength Indicator) of the Access Point which ESP8266 station connected to.
print("RSSI is", wifi.sta.getrssi())
--wifi details
print(wifi.getmode())
print(wifi.getphymode())
print(wifi.getchannel())
print(wifi.sta.getmac())
print(wifi.sta.status())
print(wifi.sta.getip())
print(wifi.sta.gethostname())
-------------------------------------------------------------
SET UP
-------------------------------------------------------------
--Hostname
if (wifi.sta.sethostname("WaterNode1") == true) then
print("hostname was successfully changed")
else
print("hostname was not changed")
end
--Set the current country info.
do
country_info={}
country_info.country="IN"
country_info.start_ch=1
country_info.end_ch=13
country_info.policy=wifi.COUNTRY_AUTO;
wifi.setcountry(country_info)
end
--Station mode
wifi.setmode(wifi.STATION, true)
--wifi set
station_cfg={}
station_cfg.ssid="SSID"
station_cfg.pwd="password"
wifi.sta.config(station_cfg)
-------------------------------------------------------------