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
91ee5c08
Commit
91ee5c08
authored
Oct 01, 2015
by
Johny Mattsson
Browse files
Wifi module update to new smartconfig API.
Needs testing.
parent
38cc84d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/modules/wifi.c
View file @
91ee5c08
...
...
@@ -28,12 +28,18 @@ static uint8 prev_wifi_status=0;
#else
static
lua_State
*
smart_L
=
NULL
;
#endif
static
void
wifi_smart_succeed_cb
(
void
*
arg
){
static
void
wifi_smart_succeed_cb
(
sc_status
status
,
void
*
pdata
){
NODE_DBG
(
"wifi_smart_succeed_cb is called.
\n
"
);
if
(
status
==
SC_STATUS_LINK_OVER
)
{
smartconfig_stop
();
return
;
}
#if defined( NODE_SMART_OLDSTYLE )
if
(
!
arg
)
if
(
status
!=
SC_STATUS_LINK
||
!
pdata
)
return
;
if
(
wifi_smart_succeed
==
LUA_NOREF
)
return
;
...
...
@@ -44,10 +50,10 @@ static void wifi_smart_succeed_cb(void *arg){
#else
if
(
!
arg
)
if
(
status
!=
SC_STATUS_LINK
||
!
pdata
)
return
;
struct
station_config
*
sta_conf
=
arg
;
struct
station_config
*
sta_conf
=
pdata
;
wifi_station_set_config
(
sta_conf
);
wifi_station_disconnect
();
wifi_station_connect
();
...
...
@@ -63,7 +69,6 @@ static void wifi_smart_succeed_cb(void *arg){
luaL_unref
(
smart_L
,
LUA_REGISTRYINDEX
,
wifi_smart_succeed
);
wifi_smart_succeed
=
LUA_NOREF
;
}
smartconfig_stop
();
#endif // defined( NODE_SMART_OLDSTYLE )
}
...
...
@@ -195,7 +200,8 @@ static int wifi_start_smart( lua_State* L )
if
(
smart_type
>
1
)
return
luaL_error
(
L
,
"wrong arg range"
);
smartconfig_start
(
smart_type
,
wifi_smart_succeed_cb
);
smartconfig_set_type
(
smart_type
);
smartconfig_start
(
wifi_smart_succeed_cb
);
#endif // defined( NODE_SMART_OLDSTYLE )
...
...
@@ -333,7 +339,7 @@ static int wifi_setmac( lua_State* L, uint8_t mode )
if
(
len
!=
17
)
return
luaL_error
(
L
,
"wrong arg type"
);
o
s_str2macaddr
(
mac
,
macaddr
);
et
s_str2macaddr
(
mac
,
macaddr
);
lua_pushboolean
(
L
,
wifi_set_macaddr
(
mode
,
(
uint8
*
)
mac
));
return
1
;
}
...
...
@@ -591,7 +597,7 @@ static int wifi_station_config( lua_State* L )
if
(
ml
!=
17
)
return
luaL_error
(
L
,
"MAC:FF:FF:FF:FF:FF:FF"
);
c_memset
(
sta_conf
.
bssid
,
0
,
6
);
o
s_str2macaddr
(
sta_conf
.
bssid
,
macaddr
);
et
s_str2macaddr
(
sta_conf
.
bssid
,
macaddr
);
sta_conf
.
bssid_set
=
1
;
}
else
...
...
@@ -743,7 +749,7 @@ static int wifi_station_listap( lua_State* L )
if
(
len
!=
17
)
return
luaL_error
(
L
,
"bssid: FF:FF:FF:FF:FF:FF"
);
c_memset
(
bssid
,
0
,
6
);
o
s_str2macaddr
(
bssid
,
macaddr
);
et
s_str2macaddr
(
bssid
,
macaddr
);
scan_cfg
.
bssid
=
bssid
;
NODE_DBG
(
MACSTR
,
MAC2STR
(
scan_cfg
.
bssid
));
NODE_DBG
(
"
\n
"
);
...
...
@@ -1229,7 +1235,7 @@ static int wifi_ap_dhcp_config( lua_State* L )
if
(
ip
==
0
)
return
luaL_error
(
L
,
"wrong arg type"
);
lease
.
start_ip
=
ip
;
lease
.
start_ip
.
addr
=
ip
;
NODE_DBG
(
IPSTR
,
IP2STR
(
&
lease
.
start_ip
));
NODE_DBG
(
"
\n
"
);
...
...
@@ -1335,9 +1341,9 @@ const LUA_REG_TYPE wifi_map[] =
{
LSTRKEY
(
"SOFTAP"
),
LNUMVAL
(
SOFTAP_MODE
)
},
{
LSTRKEY
(
"STATIONAP"
),
LNUMVAL
(
STATIONAP_MODE
)
},
{
LSTRKEY
(
"PHYMODE_B"
),
LNUMVAL
(
PHY_MODE_B
)
},
{
LSTRKEY
(
"PHYMODE_G"
),
LNUMVAL
(
PHY_MODE_G
)
},
{
LSTRKEY
(
"PHYMODE_N"
),
LNUMVAL
(
PHY_MODE_N
)
},
{
LSTRKEY
(
"PHYMODE_B"
),
LNUMVAL
(
PHY_MODE_
11
B
)
},
{
LSTRKEY
(
"PHYMODE_G"
),
LNUMVAL
(
PHY_MODE_
11
G
)
},
{
LSTRKEY
(
"PHYMODE_N"
),
LNUMVAL
(
PHY_MODE_
11
N
)
},
{
LSTRKEY
(
"NONE_SLEEP"
),
LNUMVAL
(
NONE_SLEEP_T
)
},
{
LSTRKEY
(
"LIGHT_SLEEP"
),
LNUMVAL
(
LIGHT_SLEEP_T
)
},
...
...
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