           //DEBUG_SERIAL.println("CWLAP char at");
           //DEBUG_SERIAL.println(i);
         }
+      }
+    }
+  }
+}
+
+void callbackIP(char* line, void* context) {
+  NParams* p = (NParams*)context;
+  int o = 0;
+  int max = 0;
+  char* dst = NULL;
+  if (memcmp_P(line, PSTR("+CWSAP_CUR:\""), 12)==0) {
+    o = 12;
+    max = MAX_APNAME;
+    dst = p->APNAME;
+  } else if (memcmp_P(line, PSTR("+CWJAP_CUR:\""), 12)==0) {
+    o = 12;
+    max = MAX_APNAME;
+    dst = p->JAPNAME;
+  } else if (memcmp_P(line, PSTR("+CIFSR:APIP,\""), 13)==0) {
+    o = 13;
+    max = 3*4+3+1;
+    dst = p->APIP;
+  } else if (memcmp_P(line, PSTR("+CIFSR:STAIP,\""), 14)==0) {
+    o = 14;
+    max = 3*4+3+1;
+    dst = p->STAIP;
+  }
+  if (dst != NULL) {
+    for (int i = o; i-o < max; i++) {
+      if (line[i] == '"') {
+        break;
+      } else {
+        dst[i-o]=line[i];
+        dst[i-o+1]=0;
       }
     }
   }

    //netsend(n, buff);
  } else if (req[n] == 2) {
    char wifilist[CWLAP_MAX_LEN] = "";
    commandWaitCallback_P(PSTR("AT+CWLAP\r\n"), 10000, 1000, &callbackCWLAP, (void*)wifilist);
    while(waitData(100)) {
      readLine();
    }
    netsend_P(n, STATUS_200);
    netsend_P(n, headers_A);
    netsend_P(n, headers_B);
    netsend_P(n, HTML_PART_A);
    netsend_P(n, PSTR("Arduino httpd"));
    netsend_P(n, HTML_PART_B);
    netsend_P(n, PSTR("<label>WiFi networks:</label>\r\n<ul>"));
    char* token = strtok(wifilist, "\t");
    while (token != NULL) {
      buff[0] = 0;

      netsend(n, buff);
      token = strtok(NULL, "\t");
    }

    netsend_P(n, PSTR("</ul><form method='GET' action='wifisave'><label>Connect to network:</label>"));
    netsend_P(n, PSTR("<input type='text' placeholder='network' name='n'/>"));
    netsend_P(n, PSTR("<input type='text' placeholder='password' name='p'/>"));
    netsend_P(n, PSTR("<input type='submit' value='Connect/Disconnect'/></form>"));
