|
|
@ -227,18 +227,22 @@ static int ICACHE_FLASH_ATTR cgiWiFiGetScan(HttpdConnData *connData) { |
|
|
|
const int chunk = 1460/64; // ssid is up to 32 chars
|
|
|
|
const int chunk = 1460/64; // ssid is up to 32 chars
|
|
|
|
int len = 0; |
|
|
|
int len = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
os_printf("GET scan: cgiData=%d noAps=%d\n", (int)connData->cgiData, cgiWifiAps.noAps); |
|
|
|
|
|
|
|
|
|
|
|
// handle continuation call, connData->cgiData-1 is the position in the scan results where we
|
|
|
|
// handle continuation call, connData->cgiData-1 is the position in the scan results where we
|
|
|
|
// we need to continue sending from (using -1 'cause 0 means it's the first call)
|
|
|
|
// we need to continue sending from (using -1 'cause 0 means it's the first call)
|
|
|
|
if (connData->cgiData) { |
|
|
|
if (connData->cgiData) { |
|
|
|
int next = (int)connData->cgiData-1; |
|
|
|
int next = (int)connData->cgiData-1; |
|
|
|
int pos = next; |
|
|
|
int pos = next; |
|
|
|
while (pos < cgiWifiAps.noAps && pos < next+chunk) { |
|
|
|
while (pos < cgiWifiAps.noAps && pos < next+chunk) { |
|
|
|
len += os_sprintf(buff+len, "{\"essid\": \"%s\", \"rssi\": %d, \"enc\": \"%d\"},\n", |
|
|
|
len += os_sprintf(buff+len, "{\"essid\": \"%s\", \"rssi\": %d, \"enc\": \"%d\"}%c\n", |
|
|
|
cgiWifiAps.apData[pos]->ssid, cgiWifiAps.apData[pos]->rssi, cgiWifiAps.apData[pos]->enc); |
|
|
|
cgiWifiAps.apData[pos]->ssid, cgiWifiAps.apData[pos]->rssi, cgiWifiAps.apData[pos]->enc, |
|
|
|
|
|
|
|
(pos+1 == cgiWifiAps.noAps) ? ' ' : ','); |
|
|
|
|
|
|
|
pos++; |
|
|
|
} |
|
|
|
} |
|
|
|
// done or more?
|
|
|
|
// done or more?
|
|
|
|
if (pos == cgiWifiAps.noAps) { |
|
|
|
if (pos == cgiWifiAps.noAps) { |
|
|
|
len += os_sprintf(buff+len-1, "]}}\n"); |
|
|
|
len += os_sprintf(buff+len, "]}}\n"); |
|
|
|
httpdSend(connData, buff, len); |
|
|
|
httpdSend(connData, buff, len); |
|
|
|
return HTTPD_CGI_DONE; |
|
|
|
return HTTPD_CGI_DONE; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|