 }
 
 /*
+ * build hostname from MAC address 
+ */
+String gethostname(bool cache) {
+  static String mac = "";
+  if (mac.length() && cache) {
+     return mac;
+  }
+  String pattern = "STAMAC,\"";
+  String answer = wifi.getLocalIP().c_str();
+  int starti = answer.indexOf(pattern) + pattern.length();
+  mac = answer.substring(starti, answer.length() -1);  
+  int stopi = mac.indexOf("\"");
+  mac = String("wino-") + mac.substring(0,stopi);
+  mac.replace(":", "");
+  return mac;
+}
+/*
  * lg_heartbeat - send a json message with some data to lg server
  */
 

    SerialUSB.println("tcp connection failed");
  }

  String payload = "{ \"host\": \"wino\" }"; 
  String request = "POST /api/collections/heartbeat?user_key=" + String(LG_API_KEY) + " HTTP/1.1\r\n"
    + "Host: " + LG_HOST + "\r\n"
    + "User-Agent: arduino-wino/1.0 \r\n"

  if(wifi.kick()) {
    SerialUSB.print("ESP8266 turned on \r\n");
  } else {
    SerialUSB.print("ESP8266 still offline\r\n");
    errcnt++; 
  }

  SerialUSB.print("FW version: ");
