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
0020c1d1
Commit
0020c1d1
authored
Jul 13, 2015
by
dnc40085
Browse files
added code to check if in softap mode before continuing event monitor
callback
parent
be79d1d3
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/modules/wifi.c
View file @
0020c1d1
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
static
int
wifi_smart_succeed
=
LUA_NOREF
;
static
int
wifi_smart_succeed
=
LUA_NOREF
;
static
uint8
getap_output_format
=
0
;
static
uint8
getap_output_format
=
0
;
//variables for wifi event monitor
//variables for wifi event monitor
static
sint32_t
wifi_status_cb_ref
[
6
]
=
{
LUA_NOREF
,
LUA_NOREF
,
LUA_NOREF
,
LUA_NOREF
,
LUA_NOREF
,
LUA_NOREF
};
static
sint32_t
wifi_status_cb_ref
[
6
]
=
{
LUA_NOREF
,
LUA_NOREF
,
LUA_NOREF
,
LUA_NOREF
,
LUA_NOREF
,
LUA_NOREF
};
static
volatile
os_timer_t
wifi_sta_status_timer
;
static
volatile
os_timer_t
wifi_sta_status_timer
;
...
@@ -858,8 +859,53 @@ static int wifi_station_status( lua_State* L )
...
@@ -858,8 +859,53 @@ static int wifi_station_status( lua_State* L )
return
1
;
return
1
;
}
}
/**
* wifi.sta.eventMonStop()
* Description:
* Stop wifi station event monitor
* Syntax:
* wifi.sta.eventMonStop()
* wifi.sta.eventMonStop("unreg all")
* Parameters:
* "unreg all": unregister all previously registered functions
* Returns:
* Nothing.
*
* Example:
--stop wifi event monitor
wifi.sta.eventMonStop()
--stop wifi event monitor and unregister all callbacks
wifi.sta.eventMonStop("unreg all")
*/
static
void
wifi_station_event_mon_stop
(
lua_State
*
L
)
{
os_timer_disarm
(
&
wifi_sta_status_timer
);
if
(
lua_isstring
(
L
,
1
))
{
if
(
c_strcmp
(
luaL_checkstring
(
L
,
1
),
"unreg all"
)
==
0
)
{
int
i
;
for
(
i
=
0
;
i
<
6
;
i
++
)
{
if
(
wifi_status_cb_ref
[
i
]
!=
LUA_NOREF
)
{
luaL_unref
(
L
,
LUA_REGISTRYINDEX
,
wifi_status_cb_ref
[
i
]);
wifi_status_cb_ref
[
i
]
=
LUA_NOREF
;
}
}
}
}
}
static
void
wifi_status_cb
(
int
arg
)
static
void
wifi_status_cb
(
int
arg
)
{
{
if
(
wifi_get_opmode
()
==
2
)
{
os_timer_disarm
(
&
wifi_sta_status_timer
);
return
;
}
int
wifi_status
=
wifi_station_get_connect_status
();
int
wifi_status
=
wifi_station_get_connect_status
();
if
(
wifi_status
!=
prev_wifi_status
)
if
(
wifi_status
!=
prev_wifi_status
)
{
{
...
@@ -882,12 +928,12 @@ static void wifi_status_cb(int arg)
...
@@ -882,12 +928,12 @@ static void wifi_status_cb(int arg)
* Parameters:
* Parameters:
* wifi_status: wifi status you would like to set callback for
* wifi_status: wifi status you would like to set callback for
* Valid wifi states:
* Valid wifi states:
wifi.STA_IDLE
*
wifi.STA_IDLE
wifi.STA_CONNECTING
*
wifi.STA_CONNECTING
wifi.STA_WRONGPWD
*
wifi.STA_WRONGPWD
wifi.STA_APNOTFOUND
*
wifi.STA_APNOTFOUND
wifi.STA_FAIL
*
wifi.STA_FAIL
wifi.STA_GOTIP
*
wifi.STA_GOTIP
* function: function to perform
* function: function to perform
* "unreg": unregister previously registered function
* "unreg": unregister previously registered function
* Returns:
* Returns:
...
@@ -978,46 +1024,6 @@ static int wifi_station_event_mon_start(lua_State* L)
...
@@ -978,46 +1024,6 @@ static int wifi_station_event_mon_start(lua_State* L)
return
0
;
return
0
;
}
}
/**
* wifi.sta.eventMonStart()
* Description:
* Stop wifi station event monitor
* Syntax:
* wifi.sta.eventMonStop()
* wifi.sta.eventMonStop("unreg all")
* Parameters:
* "unreg all": unregister all previously registered functions
* Returns:
* Nothing.
*
* Example:
--stop wifi event monitor
wifi.sta.eventMonStop()
--stop wifi event monitor and unregister all callbacks
wifi.sta.eventMonStop("unreg all")
*/
static
void
wifi_station_event_mon_stop
(
lua_State
*
L
)
{
os_timer_disarm
(
&
wifi_sta_status_timer
);
if
(
lua_isstring
(
L
,
1
))
{
if
(
c_strcmp
(
luaL_checkstring
(
L
,
1
),
"unreg all"
)
==
0
)
{
int
i
;
for
(
i
=
0
;
i
<
6
;
i
++
)
{
if
(
wifi_status_cb_ref
[
i
]
!=
LUA_NOREF
)
{
luaL_unref
(
L
,
LUA_REGISTRYINDEX
,
wifi_status_cb_ref
[
i
]);
wifi_status_cb_ref
[
i
]
=
LUA_NOREF
;
}
}
}
}
}
// Lua: wifi.ap.getmac()
// Lua: wifi.ap.getmac()
static
int
wifi_ap_getmac
(
lua_State
*
L
){
static
int
wifi_ap_getmac
(
lua_State
*
L
){
return
wifi_getmac
(
L
,
SOFTAP_IF
);
return
wifi_getmac
(
L
,
SOFTAP_IF
);
...
...
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