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
d9b3db06
Commit
d9b3db06
authored
Mar 18, 2017
by
Frank Exoo
Committed by
Arnim Läuger
Mar 18, 2017
Browse files
Show IP address after enduser_setup (#1867)
parent
2f00c1d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/modules/enduser_setup.c
View file @
d9b3db06
...
@@ -144,6 +144,7 @@ static void enduser_setup_ap_stop(void);
...
@@ -144,6 +144,7 @@ static void enduser_setup_ap_stop(void);
static
void
enduser_setup_check_station
(
void
*
p
);
static
void
enduser_setup_check_station
(
void
*
p
);
static
void
enduser_setup_debug
(
int
line
,
const
char
*
str
);
static
void
enduser_setup_debug
(
int
line
,
const
char
*
str
);
static
char
ipaddr
[
16
];
#if ENDUSER_SETUP_DEBUG_ENABLE
#if ENDUSER_SETUP_DEBUG_ENABLE
#define ENDUSER_SETUP_DEBUG(str) enduser_setup_debug(__LINE__, str)
#define ENDUSER_SETUP_DEBUG(str) enduser_setup_debug(__LINE__, str)
...
@@ -285,6 +286,8 @@ static void enduser_setup_check_station(void *p)
...
@@ -285,6 +286,8 @@ static void enduser_setup_check_station(void *p)
return
;
return
;
}
}
c_sprintf
(
ipaddr
,
"%d.%d.%d.%d"
,
IP2STR
(
&
ip
.
ip
.
addr
));
state
->
success
=
1
;
state
->
success
=
1
;
state
->
lastStationStatus
=
5
;
/* We have an IP Address, so the status is 5 (as of SDK 1.5.1) */
state
->
lastStationStatus
=
5
;
/* We have an IP Address, so the status is 5 (as of SDK 1.5.1) */
state
->
connecting
=
0
;
state
->
connecting
=
0
;
...
@@ -874,7 +877,23 @@ static void enduser_setup_serve_status_as_json (struct tcp_pcb *http_client)
...
@@ -874,7 +877,23 @@ static void enduser_setup_serve_status_as_json (struct tcp_pcb *http_client)
uint8_t
curr_status
=
state
->
lastStationStatus
>
0
?
state
->
lastStationStatus
:
wifi_station_get_connect_status
();
uint8_t
curr_status
=
state
->
lastStationStatus
>
0
?
state
->
lastStationStatus
:
wifi_station_get_connect_status
();
char
json_payload
[
64
];
char
json_payload
[
64
];
c_sprintf
(
json_payload
,
"{
\"
deviceid
\"
:
\"
%06X
\"
,
\"
status
\"
:%d}"
,
system_get_chip_id
(),
curr_status
);
struct
ip_info
ip_info
;
if
(
curr_status
==
5
)
{
wifi_get_ip_info
(
STATION_IF
,
&
ip_info
);
/* If IP address not yet available, get now */
if
(
strlen
(
ipaddr
)
==
0
)
{
c_sprintf
(
ipaddr
,
"%d.%d.%d.%d"
,
IP2STR
(
&
ip_info
.
ip
.
addr
));
}
c_sprintf
(
json_payload
,
"{
\"
deviceid
\"
:
\"
%s
\"
,
\"
status
\"
:%d}"
,
ipaddr
,
curr_status
);
}
else
{
c_sprintf
(
json_payload
,
"{
\"
deviceid
\"
:
\"
%06X
\"
,
\"
status
\"
:%d}"
,
system_get_chip_id
(),
curr_status
);
}
const
char
fmt
[]
=
const
char
fmt
[]
=
"HTTP/1.1 200 OK
\r\n
"
"HTTP/1.1 200 OK
\r\n
"
...
@@ -1684,6 +1703,8 @@ static int enduser_setup_start(lua_State *L)
...
@@ -1684,6 +1703,8 @@ static int enduser_setup_start(lua_State *L)
/* Note: The debug callback is set in enduser_setup_init. It's normal to not see this debug message on first invocation. */
/* Note: The debug callback is set in enduser_setup_init. It's normal to not see this debug message on first invocation. */
ENDUSER_SETUP_DEBUG
(
"enduser_setup_start"
);
ENDUSER_SETUP_DEBUG
(
"enduser_setup_start"
);
ipaddr
[
0
]
=
'\0'
;
if
(
!
do_station_cfg_handle
)
if
(
!
do_station_cfg_handle
)
{
{
do_station_cfg_handle
=
task_get_id
(
do_station_cfg
);
do_station_cfg_handle
=
task_get_id
(
do_station_cfg
);
...
...
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