Show IP address after enduser_setup (#1867)
This commit is contained in:
parent
2f00c1d8d9
commit
d9b3db06f6
|
@ -144,6 +144,7 @@ static void enduser_setup_ap_stop(void);
|
|||
static void enduser_setup_check_station(void *p);
|
||||
static void enduser_setup_debug(int line, const char *str);
|
||||
|
||||
static char ipaddr[16];
|
||||
|
||||
#if ENDUSER_SETUP_DEBUG_ENABLE
|
||||
#define ENDUSER_SETUP_DEBUG(str) enduser_setup_debug(__LINE__, str)
|
||||
|
@ -285,6 +286,8 @@ static void enduser_setup_check_station(void *p)
|
|||
return;
|
||||
}
|
||||
|
||||
c_sprintf (ipaddr, "%d.%d.%d.%d", IP2STR(&ip.ip.addr));
|
||||
|
||||
state->success = 1;
|
||||
state->lastStationStatus = 5; /* We have an IP Address, so the status is 5 (as of SDK 1.5.1) */
|
||||
state->connecting = 0;
|
||||
|
@ -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 ();
|
||||
|
||||
char json_payload[64];
|
||||
|
||||
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[] =
|
||||
"HTTP/1.1 200 OK\r\n"
|
||||
|
@ -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. */
|
||||
ENDUSER_SETUP_DEBUG("enduser_setup_start");
|
||||
|
||||
ipaddr[0] = '\0';
|
||||
|
||||
if (!do_station_cfg_handle)
|
||||
{
|
||||
do_station_cfg_handle = task_get_id(do_station_cfg);
|
||||
|
|
Loading…
Reference in New Issue