 String stream_id;
 String stream_pk;
 char* host ="kitwallace.co.uk";
-
+char* path ="/rt/home.xq?";
 
 // interaction
-//const int startAP = D1;
+const int CONFIG = D7;
 const int LED = D4;
 
 WiFiServer server(80);
 WiFiClient client;
 
 void setup() {
-	delay(1000);
-	Serial.begin(9600);
+
+  Serial.begin(9600);
+    delay(1000);
+  Serial.println();
   Serial.println(String("ap started: ") + ap_started + " WiFi connected: " + wifi_connected); 
 
-  pinMode(D1,INPUT);
-  pinMode(D4,OUTPUT);
-  digitalWrite(D4,HIGH);  // turn it off
+  pinMode(CONFIG,INPUT);
+  pinMode(LED,OUTPUT);
+  digitalWrite(LED,HIGH);  // turn it off
   bool result = SPIFFS.begin();
   boolean loadOK;
   loadOK = getConfiguration();
   if (loadOK) {
-    wifi_connected = connectWiFi();
+     Serial.println("Configuration loaded");
+     wifi_connected = connectWiFi();
   }
   else {
-    wifi_connected = false;
+     Serial.println("No configuration found");
+     wifi_connected = false;
   }
 }
 
 void loop() {
-  if (! ap_started && digitalRead(D1)) {
+  if (! ap_started && (digitalRead(CONFIG) || ! wifi_connected)) {
     startAP();
     startServer();
     ap_started = true;

  return true;
}

void httpGet(char * host,String url) {
   WiFiClient client;
   url.replace(" ", "+");
   int httpPort = 80;
   while (true) {
    if (client.connect(host, httpPort)) break;

/*
 * on bootup attempt to read configuration from SPIFFS and connect
 * 
 * When pin CONFIG (D7) high start accesspoint and interact with user to provide the 
 * required access point  credentials and other parameters
 * save configuration to SPIFFS
 * Connect to the required access point and stop the server
