Skip to content

Commit 8e20007

Browse files
committed
Updated wifi.sta.config to save configuration to flash by default
Removed argument style station configuration option
1 parent 216b820 commit 8e20007

File tree

3 files changed

+7
-59
lines changed

3 files changed

+7
-59
lines changed

app/modules/wifi.c

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ static int wifi_station_config( lua_State* L )
829829
}
830830
else
831831
{
832-
save_to_flash=false;
832+
save_to_flash = TRUE;
833833
}
834834
lua_pop(L, 1);
835835

@@ -930,61 +930,9 @@ static int wifi_station_config( lua_State* L )
930930
#endif
931931

932932
}
933-
else //to be deprecated
933+
else
934934
{
935-
platform_print_deprecation_note("Argument style station configuration is replaced by table style station configuration", "in the next version");
936-
937-
const char *ssid = luaL_checklstring( L, 1, &sl );
938-
luaL_argcheck(L, (sl>=0 && sl<sizeof(sta_conf.ssid)), 1, "length:0-32"); /* Zero-length SSID is valid as a way to clear config */
939-
940-
memcpy(sta_conf.ssid, ssid, sl);
941-
942-
const char *password = luaL_checklstring( L, 2, &pl );
943-
luaL_argcheck(L, (pl>=0 && pl<=sizeof(sta_conf.password)), 2, "length:0-64"); /* WPA = min 8, WEP = min 5 ASCII characters for a 40-bit key */
944-
945-
memcpy(sta_conf.password, password, pl);
946-
947-
if(lua_isnumber(L, 3))
948-
{
949-
lua_Integer lint=luaL_checkinteger( L, 3 );
950-
if ( lint != 0 && lint != 1)
951-
return luaL_error( L, "wrong arg type" );
952-
auto_connect=(bool)lint;
953-
}
954-
else if (lua_isstring(L, 3)&& !(lua_isnumber(L, 3)))
955-
{
956-
lua_pushnil(L);
957-
lua_insert(L, 3);
958-
959-
}
960-
else
961-
{
962-
if(lua_isnil(L, 3))
963-
return luaL_error( L, "wrong arg type" );
964-
auto_connect=1;
965-
}
966-
967-
if(lua_isnumber(L, 4))
968-
{
969-
sta_conf.bssid_set = 0;
970-
memset(sta_conf.bssid, 0, sizeof(sta_conf.bssid));
971-
}
972-
else
973-
{
974-
if (lua_isstring(L, 4))
975-
{
976-
const char *macaddr = luaL_checklstring( L, 4, &ml );
977-
luaL_argcheck(L, ml==sizeof("AA:BB:CC:DD:EE:FF")-1, 1, INVALID_MAC_STR);
978-
memset(sta_conf.bssid, 0, sizeof(sta_conf.bssid));
979-
ets_str2macaddr(sta_conf.bssid, macaddr);
980-
sta_conf.bssid_set = 1;
981-
}
982-
else
983-
{
984-
sta_conf.bssid_set = 0;
985-
memset(sta_conf.bssid, 0, sizeof(sta_conf.bssid));
986-
}
987-
}
935+
return luaL_argerror(L, 1, "configuration table not found!");
988936
}
989937

990938
#if defined(WIFI_DEBUG)

docs/en/modules/wifi.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,8 @@ Sets the WiFi station configuration.
410410
- "AC-1D-1C-B1-0B-22"
411411
- "DE AD BE EF 7A C0"
412412
- `save` Save station configuration to flash.
413-
- `true` configuration **will** be retained through power cycle.
414-
- `false` configuration **will not** be retained through power cycle. (Default).
413+
- `true` configuration **will** be retained through power cycle. (Default).
414+
- `false` configuration **will not** be retained through power cycle.
415415
- Event callbacks will only be available if `WIFI_SDK_EVENT_MONITOR_ENABLE` is uncommented in `user_config.h`
416416
- Please note: To ensure all station events are handled at boot time, all relevant callbacks must be registered as early as possible in `init.lua` with either `wifi.sta.config()` or `wifi.eventmon.register()`.
417417
- `connected_cb`: Callback to execute when station is connected to an access point. (Optional)
@@ -447,13 +447,13 @@ Sets the WiFi station configuration.
447447
station_cfg={}
448448
station_cfg.ssid="NODE-AABBCC"
449449
station_cfg.pwd="password"
450+
station_cfg.save=false
450451
wifi.sta.config(station_cfg)
451452

452453
--connect to Access Point (DO save config to flash)
453454
station_cfg={}
454455
station_cfg.ssid="NODE-AABBCC"
455456
station_cfg.pwd="password"
456-
station_cfg.save=true
457457
wifi.sta.config(station_cfg)
458458

459459
--connect to Access Point with specific MAC address

docs/en/upload.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ wifi.eventmon.register(wifi.eventmon.STA_DISCONNECTED, wifi_disconnect_event)
111111

112112
print("Connecting to WiFi access point...")
113113
wifi.setmode(wifi.STATION)
114-
wifi.sta.config({ssid=SSID, pwd=PASSWORD, save=true})
114+
wifi.sta.config({ssid=SSID, pwd=PASSWORD})
115115
-- wifi.sta.connect() not necessary because config() uses auto-connect=true by default
116116

117117
```

0 commit comments

Comments
 (0)