fix cgiWifi

pull/69/head
Thorsten von Eicken 9 years ago
parent 9c11776869
commit 8867c8e9b6
  1. 10
      esp-link/cgiwifi.c

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

Loading…
Cancel
Save