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
5ca807d7
Commit
5ca807d7
authored
Jun 24, 2015
by
Luna
Browse files
fixed net.dns.getdnsserver() and added wifi.ap.getconfig()
parent
5c84ea1b
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/modules/net.c
View file @
5ca807d7
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
#include "c_types.h"
#include "c_types.h"
#include "mem.h"
#include "mem.h"
#include "espconn.h"
#include "espconn.h"
#include "lwip/dns.h"
#ifdef CLIENT_SSL_ENABLE
#ifdef CLIENT_SSL_ENABLE
unsigned char *default_certificate;
unsigned char *default_certificate;
...
@@ -1445,14 +1446,13 @@ static int net_getdnsserver( lua_State* L )
...
@@ -1445,14 +1446,13 @@ static int net_getdnsserver( lua_State* L )
if (numdns >= DNS_MAX_SERVERS)
if (numdns >= DNS_MAX_SERVERS)
return luaL_error( L, "server index out of range [0-%d]", DNS_MAX_SERVERS - 1);
return luaL_error( L, "server index out of range [0-%d]", DNS_MAX_SERVERS - 1);
ip_addr_t ipaddr;
ip_addr_t ipaddr = dns_getserver(numdns);
dns_getserver(numdns,&ipaddr);
if ( ip_addr_isany(&ipaddr) ) {
if ( ip_addr_isany(&ipaddr) ) {
lua_pushnil( L );
lua_pushnil( L );
} else {
} else {
char temp[20] = {0};
char temp[20] = {0};
c_sprintf(temp, IPSTR, IP2STR( &ipaddr ) );
c_sprintf(temp, IPSTR, IP2STR( &ipaddr
.addr
) );
lua_pushstring( L, temp );
lua_pushstring( L, temp );
}
}
...
...
app/modules/wifi.c
View file @
5ca807d7
...
@@ -815,6 +815,20 @@ static int wifi_ap_getbroadcast( lua_State* L ){
...
@@ -815,6 +815,20 @@ static int wifi_ap_getbroadcast( lua_State* L ){
return
wifi_getbroadcast
(
L
,
SOFTAP_IF
);
return
wifi_getbroadcast
(
L
,
SOFTAP_IF
);
}
}
// Lua: wifi.ap.getconfig()
static
int
wifi_ap_getconfig
(
lua_State
*
L
)
{
struct
softap_config
config
;
wifi_softap_get_config
(
&
config
);
lua_pushstring
(
L
,
config
.
ssid
);
if
(
config
.
authmode
=
AUTH_OPEN
)
lua_pushnil
(
L
);
else
lua_pushstring
(
L
,
config
.
password
);
return
2
;
}
// Lua: wifi.ap.config(table)
// Lua: wifi.ap.config(table)
static
int
wifi_ap_config
(
lua_State
*
L
)
static
int
wifi_ap_config
(
lua_State
*
L
)
{
{
...
@@ -1051,6 +1065,7 @@ static const LUA_REG_TYPE wifi_ap_dhcp_map[] =
...
@@ -1051,6 +1065,7 @@ static const LUA_REG_TYPE wifi_ap_dhcp_map[] =
static
const
LUA_REG_TYPE
wifi_ap_map
[]
=
static
const
LUA_REG_TYPE
wifi_ap_map
[]
=
{
{
{
LSTRKEY
(
"config"
),
LFUNCVAL
(
wifi_ap_config
)
},
{
LSTRKEY
(
"config"
),
LFUNCVAL
(
wifi_ap_config
)
},
{
LSTRKEY
(
"getconfig"
),
LFUNCVAL
(
wifi_ap_getconfig
)
},
{
LSTRKEY
(
"getip"
),
LFUNCVAL
(
wifi_ap_getip
)
},
{
LSTRKEY
(
"getip"
),
LFUNCVAL
(
wifi_ap_getip
)
},
{
LSTRKEY
(
"setip"
),
LFUNCVAL
(
wifi_ap_setip
)
},
{
LSTRKEY
(
"setip"
),
LFUNCVAL
(
wifi_ap_setip
)
},
{
LSTRKEY
(
"getbroadcast"
),
LFUNCVAL
(
wifi_ap_getbroadcast
)
},
{
LSTRKEY
(
"getbroadcast"
),
LFUNCVAL
(
wifi_ap_getbroadcast
)
},
...
...
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