Wifi module update to new smartconfig API.
Needs testing.
This commit is contained in:
parent
38cc84d2fc
commit
91ee5c088c
|
@ -28,12 +28,18 @@ static uint8 prev_wifi_status=0;
|
||||||
#else
|
#else
|
||||||
static lua_State* smart_L = NULL;
|
static lua_State* smart_L = NULL;
|
||||||
#endif
|
#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");
|
NODE_DBG("wifi_smart_succeed_cb is called.\n");
|
||||||
|
|
||||||
|
if (status == SC_STATUS_LINK_OVER)
|
||||||
|
{
|
||||||
|
smartconfig_stop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined( NODE_SMART_OLDSTYLE )
|
#if defined( NODE_SMART_OLDSTYLE )
|
||||||
|
|
||||||
if( !arg )
|
if (status != SC_STATUS_LINK || !pdata)
|
||||||
return;
|
return;
|
||||||
if(wifi_smart_succeed == LUA_NOREF)
|
if(wifi_smart_succeed == LUA_NOREF)
|
||||||
return;
|
return;
|
||||||
|
@ -44,10 +50,10 @@ static void wifi_smart_succeed_cb(void *arg){
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
if( !arg )
|
if (status != SC_STATUS_LINK || !pdata)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
struct station_config *sta_conf = arg;
|
struct station_config *sta_conf = pdata;
|
||||||
wifi_station_set_config(sta_conf);
|
wifi_station_set_config(sta_conf);
|
||||||
wifi_station_disconnect();
|
wifi_station_disconnect();
|
||||||
wifi_station_connect();
|
wifi_station_connect();
|
||||||
|
@ -63,7 +69,6 @@ static void wifi_smart_succeed_cb(void *arg){
|
||||||
luaL_unref(smart_L, LUA_REGISTRYINDEX, wifi_smart_succeed);
|
luaL_unref(smart_L, LUA_REGISTRYINDEX, wifi_smart_succeed);
|
||||||
wifi_smart_succeed = LUA_NOREF;
|
wifi_smart_succeed = LUA_NOREF;
|
||||||
}
|
}
|
||||||
smartconfig_stop();
|
|
||||||
|
|
||||||
#endif // defined( NODE_SMART_OLDSTYLE )
|
#endif // defined( NODE_SMART_OLDSTYLE )
|
||||||
}
|
}
|
||||||
|
@ -195,7 +200,8 @@ static int wifi_start_smart( lua_State* L )
|
||||||
if ( smart_type > 1 )
|
if ( smart_type > 1 )
|
||||||
return luaL_error( L, "wrong arg range" );
|
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 )
|
#endif // defined( NODE_SMART_OLDSTYLE )
|
||||||
|
|
||||||
|
@ -333,7 +339,7 @@ static int wifi_setmac( lua_State* L, uint8_t mode )
|
||||||
if(len!=17)
|
if(len!=17)
|
||||||
return luaL_error( L, "wrong arg type" );
|
return luaL_error( L, "wrong arg type" );
|
||||||
|
|
||||||
os_str2macaddr(mac, macaddr);
|
ets_str2macaddr(mac, macaddr);
|
||||||
lua_pushboolean(L,wifi_set_macaddr(mode, (uint8 *)mac));
|
lua_pushboolean(L,wifi_set_macaddr(mode, (uint8 *)mac));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -591,7 +597,7 @@ static int wifi_station_config( lua_State* L )
|
||||||
if (ml!=17)
|
if (ml!=17)
|
||||||
return luaL_error( L, "MAC:FF:FF:FF:FF:FF:FF" );
|
return luaL_error( L, "MAC:FF:FF:FF:FF:FF:FF" );
|
||||||
c_memset(sta_conf.bssid, 0, 6);
|
c_memset(sta_conf.bssid, 0, 6);
|
||||||
os_str2macaddr(sta_conf.bssid, macaddr);
|
ets_str2macaddr(sta_conf.bssid, macaddr);
|
||||||
sta_conf.bssid_set = 1;
|
sta_conf.bssid_set = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -743,7 +749,7 @@ static int wifi_station_listap( lua_State* L )
|
||||||
if(len!=17)
|
if(len!=17)
|
||||||
return luaL_error( L, "bssid: FF:FF:FF:FF:FF:FF" );
|
return luaL_error( L, "bssid: FF:FF:FF:FF:FF:FF" );
|
||||||
c_memset(bssid, 0, 6);
|
c_memset(bssid, 0, 6);
|
||||||
os_str2macaddr(bssid, macaddr);
|
ets_str2macaddr(bssid, macaddr);
|
||||||
scan_cfg.bssid=bssid;
|
scan_cfg.bssid=bssid;
|
||||||
NODE_DBG(MACSTR, MAC2STR(scan_cfg.bssid));
|
NODE_DBG(MACSTR, MAC2STR(scan_cfg.bssid));
|
||||||
NODE_DBG("\n");
|
NODE_DBG("\n");
|
||||||
|
@ -1229,7 +1235,7 @@ static int wifi_ap_dhcp_config( lua_State* L )
|
||||||
if (ip == 0)
|
if (ip == 0)
|
||||||
return luaL_error( L, "wrong arg type" );
|
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(IPSTR, IP2STR(&lease.start_ip));
|
||||||
NODE_DBG("\n");
|
NODE_DBG("\n");
|
||||||
|
|
||||||
|
@ -1335,9 +1341,9 @@ const LUA_REG_TYPE wifi_map[] =
|
||||||
{ LSTRKEY( "SOFTAP" ), LNUMVAL( SOFTAP_MODE ) },
|
{ LSTRKEY( "SOFTAP" ), LNUMVAL( SOFTAP_MODE ) },
|
||||||
{ LSTRKEY( "STATIONAP" ), LNUMVAL( STATIONAP_MODE ) },
|
{ LSTRKEY( "STATIONAP" ), LNUMVAL( STATIONAP_MODE ) },
|
||||||
|
|
||||||
{ LSTRKEY( "PHYMODE_B" ), LNUMVAL( PHY_MODE_B ) },
|
{ LSTRKEY( "PHYMODE_B" ), LNUMVAL( PHY_MODE_11B ) },
|
||||||
{ LSTRKEY( "PHYMODE_G" ), LNUMVAL( PHY_MODE_G ) },
|
{ LSTRKEY( "PHYMODE_G" ), LNUMVAL( PHY_MODE_11G ) },
|
||||||
{ LSTRKEY( "PHYMODE_N" ), LNUMVAL( PHY_MODE_N ) },
|
{ LSTRKEY( "PHYMODE_N" ), LNUMVAL( PHY_MODE_11N ) },
|
||||||
|
|
||||||
{ LSTRKEY( "NONE_SLEEP" ), LNUMVAL( NONE_SLEEP_T ) },
|
{ LSTRKEY( "NONE_SLEEP" ), LNUMVAL( NONE_SLEEP_T ) },
|
||||||
{ LSTRKEY( "LIGHT_SLEEP" ), LNUMVAL( LIGHT_SLEEP_T ) },
|
{ LSTRKEY( "LIGHT_SLEEP" ), LNUMVAL( LIGHT_SLEEP_T ) },
|
||||||
|
|
Loading…
Reference in New Issue