Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
dff32e89
Commit
dff32e89
authored
Jul 28, 2021
by
Johny Mattsson
Browse files
WiFi module updates.
- Added support for WPA3 - Evicted left-over broken WiFi auto-reconnect - Updated docs
parent
bce134b5
Changes
3
Hide whitespace changes
Inline
Side-by-side
components/modules/wifi.c
View file @
dff32e89
...
@@ -132,6 +132,10 @@ LROT_BEGIN(wifi)
...
@@ -132,6 +132,10 @@ LROT_BEGIN(wifi)
LROT_NUMENTRY
(
AUTH_WPA_PSK
,
WIFI_AUTH_WPA_PSK
)
LROT_NUMENTRY
(
AUTH_WPA_PSK
,
WIFI_AUTH_WPA_PSK
)
LROT_NUMENTRY
(
AUTH_WPA2_PSK
,
WIFI_AUTH_WPA2_PSK
)
LROT_NUMENTRY
(
AUTH_WPA2_PSK
,
WIFI_AUTH_WPA2_PSK
)
LROT_NUMENTRY
(
AUTH_WPA_WPA2_PSK
,
WIFI_AUTH_WPA_WPA2_PSK
)
LROT_NUMENTRY
(
AUTH_WPA_WPA2_PSK
,
WIFI_AUTH_WPA_WPA2_PSK
)
LROT_NUMENTRY
(
AUTH_WPA2_ENTERPRISE
,
WIFI_AUTH_WPA2_ENTERPRISE
)
LROT_NUMENTRY
(
AUTH_WPA3_PSK
,
WIFI_AUTH_WPA3_PSK
)
LROT_NUMENTRY
(
AUTH_WPA2_WPA3_PSK
,
WIFI_AUTH_WPA2_WPA3_PSK
)
LROT_NUMENTRY
(
AUTH_WAPI_PSK
,
WIFI_AUTH_WAPI_PSK
)
LROT_NUMENTRY
(
STR_WIFI_SECOND_CHAN_NONE
,
WIFI_SECOND_CHAN_NONE
)
LROT_NUMENTRY
(
STR_WIFI_SECOND_CHAN_NONE
,
WIFI_SECOND_CHAN_NONE
)
LROT_NUMENTRY
(
STR_WIFI_SECOND_CHAN_ABOVE
,
WIFI_SECOND_CHAN_ABOVE
)
LROT_NUMENTRY
(
STR_WIFI_SECOND_CHAN_ABOVE
,
WIFI_SECOND_CHAN_ABOVE
)
...
...
components/modules/wifi_sta.c
View file @
dff32e89
...
@@ -280,6 +280,18 @@ static int wifi_sta_config (lua_State *L)
...
@@ -280,6 +280,18 @@ static int wifi_sta_config (lua_State *L)
return
luaL_error
(
L
,
"invalid BSSID: %s"
,
bssid
);
return
luaL_error
(
L
,
"invalid BSSID: %s"
,
bssid
);
}
}
lua_getfield
(
L
,
1
,
"pmf"
);
if
(
lua_isnumber
(
L
,
-
1
))
{
int
pmf_mode
=
lua_tointeger
(
L
,
-
1
);
if
(
pmf_mode
)
cfg
.
sta
.
pmf_cfg
.
capable
=
true
;
if
(
pmf_mode
==
2
)
cfg
.
sta
.
pmf_cfg
.
required
=
true
;
}
else
cfg
.
sta
.
pmf_cfg
.
capable
=
true
;
SET_SAVE_MODE
(
save
);
SET_SAVE_MODE
(
save
);
esp_err_t
err
=
esp_wifi_set_config
(
WIFI_IF_STA
,
&
cfg
);
esp_err_t
err
=
esp_wifi_set_config
(
WIFI_IF_STA
,
&
cfg
);
if
(
err
!=
ESP_OK
)
if
(
err
!=
ESP_OK
)
...
@@ -446,10 +458,10 @@ LROT_PUBLIC_BEGIN(wifi_sta)
...
@@ -446,10 +458,10 @@ LROT_PUBLIC_BEGIN(wifi_sta)
LROT_FUNCENTRY
(
getmac
,
wifi_sta_getmac
)
LROT_FUNCENTRY
(
getmac
,
wifi_sta_getmac
)
LROT_FUNCENTRY
(
on
,
wifi_sta_on
)
LROT_FUNCENTRY
(
on
,
wifi_sta_on
)
LROT_FUNCENTRY
(
scan
,
wifi_sta_scan
)
LROT_FUNCENTRY
(
scan
,
wifi_sta_scan
)
LROT_END
(
wifi_sta
,
NULL
,
0
)
LROT_NUMENTRY
(
PMF_OFF
,
0
)
LROT_NUMENTRY
(
PMF_AVAILABLE
,
1
)
LROT_NUMENTRY
(
PMF_REQUIRED
,
2
)
LROT_END
(
wifi_sta
,
NULL
,
0
)
// Currently no auto-connect, so do that in response to events
NODEMCU_ESP_EVENT
(
WIFI_EVENT
,
WIFI_EVENT_STA_START
,
do_connect
);
NODEMCU_ESP_EVENT
(
WIFI_EVENT
,
WIFI_EVENT_STA_DISCONNECTED
,
do_connect
);
NODEMCU_ESP_EVENT
(
WIFI_EVENT
,
WIFI_EVENT_SCAN_DONE
,
on_scan_done
);
NODEMCU_ESP_EVENT
(
WIFI_EVENT
,
WIFI_EVENT_SCAN_DONE
,
on_scan_done
);
docs/modules/wifi.md
View file @
dff32e89
...
@@ -147,6 +147,13 @@ being removed in the SDK/IDF. After start-up it is necessary to call
...
@@ -147,6 +147,13 @@ being removed in the SDK/IDF. After start-up it is necessary to call
-
"AC-1D-1C-B1-0B-22"
-
"AC-1D-1C-B1-0B-22"
-
"DE AD BE EF 7A C0"
-
"DE AD BE EF 7A C0"
-
"AcDc0123c0DE"
-
"AcDc0123c0DE"
-
`pmf`
an optional setting to control whether Protected Management Frames
are supported and/or required. One of:
-
`wifi.sta.PMF_OFF`
-
`wifi.sta.PMF_AVAILABLE`
-
`wifi.sta.PMF_REQUIRED`
.
Defaults to
`wifi.sta.PMF_AVAILABLE`
. PMF is required when joining to
WPA3-Personal access points.
-
`save`
Save station configuration to flash.
-
`save`
Save station configuration to flash.
-
`true`
configuration
**will**
be retained through power cycle.
-
`true`
configuration
**will**
be retained through power cycle.
...
@@ -186,10 +193,8 @@ wifi.sta.config(station_cfg)
...
@@ -186,10 +193,8 @@ wifi.sta.config(station_cfg)
## wifi.sta.connect()
## wifi.sta.connect()
Connects to the configured AP in station mode. You will want to call this
Connects to the configured AP in station mode. You will want to call this
on start-up after
[
`wifi.start()`
](
#wifistart
)
. The system will attempt
on start-up after
[
`wifi.start()`
](
#wifistart
)
, and quite possibly also
to connect until it succeeds or
[
`wifi.sta.disconnect()`
](
#wifistadisconnect
)
in response to
`disconnected`
events.
is called. Each failed connect attempt will fire the
`disconnected`
event.
#### Syntax
#### Syntax
`wifi.sta.connect()`
`wifi.sta.connect()`
...
@@ -203,6 +208,7 @@ event.
...
@@ -203,6 +208,7 @@ event.
#### See also
#### See also
-
[
`wifi.sta.disconnect()`
](
#wifistadisconnect
)
-
[
`wifi.sta.disconnect()`
](
#wifistadisconnect
)
-
[
`wifi.sta.config()`
](
#wifistaconfig
)
-
[
`wifi.sta.config()`
](
#wifistaconfig
)
-
[
`wifi.sta.on()`
](
#wifistaon
)
## wifi.sta.disconnect()
## wifi.sta.disconnect()
...
@@ -255,7 +261,7 @@ Event information provided for each event is as follows:
...
@@ -255,7 +261,7 @@ Event information provided for each event is as follows:
-
`ssid`
: the SSID of the network
-
`ssid`
: the SSID of the network
-
`bssid`
: the BSSID of the AP
-
`bssid`
: the BSSID of the AP
-
`channel`
: the primary channel of the network
-
`channel`
: the primary channel of the network
-
`auth`
authentication method, one of
`wifi.OPEN`
,
`wifi.WPA_PSK`
,
`wifi.WPA2_PSK`
(default)
,
`wifi.WPA_WPA2_PSK`
-
`auth`
authentication method, one of
`wifi.
AUTH_
OPEN`
,
`wifi.
AUTH_
WPA_PSK`
,
`wifi.
AUTH_
WPA2_PSK`
,
`wifi.WPA_WPA2
_PSK`
,
`wifi.AUTH_WPA3_PSK`
,
`wifi.AUTH_WAPI
_PSK`
-
`disconnected`
: information about the network/AP that was disconnected from:
-
`disconnected`
: information about the network/AP that was disconnected from:
-
`ssid`
: the SSID of the network
-
`ssid`
: the SSID of the network
-
`bssid`
: the BSSID of the AP
-
`bssid`
: the BSSID of the AP
...
@@ -347,7 +353,7 @@ The following fields are provided for each scanned AP:
...
@@ -347,7 +353,7 @@ The following fields are provided for each scanned AP:
-
`bssid`
: the BSSID of the AP
-
`bssid`
: the BSSID of the AP
-
`channel`
: primary WiFi channel of the AP
-
`channel`
: primary WiFi channel of the AP
-
`rssi`
: Received Signal Strength Indicator value
-
`rssi`
: Received Signal Strength Indicator value
-
`auth`
authentication method, one of
`wifi.OPEN`
,
`wifi.WPA_PSK`
,
`wifi.WPA2_PSK`
(default),
`wifi.WPA_WPA2
_PSK`
-
`auth`
authentication method, one of
`wifi.
AUTH_
OPEN`
,
`wifi.
AUTH_
WPA_PSK`
,
`wifi.
AUTH_
WPA2_PSK`
,
`wifi.AUTH_WPA_WPA2_PSK`
,
`wifi.AUTH_WPA2_ENTERPRISE`
,
`wifi.AUTH_WPA2_WPA3_PSK`
,
`wifi.AUTH_WPA3_PSK`
,
`wifi.AUTH_WAPI
_PSK`
-
`bandwidth`
: one of the following constants:
-
`bandwidth`
: one of the following constants:
-
`wifi.HT20`
-
`wifi.HT20`
-
`wifi.HT40_ABOVE`
-
`wifi.HT40_ABOVE`
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment