   net_client.stop();
 }
 
-bool get_host_v2(const char *appkey, char *url) {
-  uint8_t buf[BUFSIZE] = {0};
-
-  String data("{\"a\":\"");
-  data += String(appkey);
-  data += String("\",\"n\":\"1\",\"v\":\"v1.0\",\"o\":\"1\"}");
-  uint16_t len = data.length();
+bool get_host_v2() {
+  uint8_t buf[BUFSIZE];
+  uint16_t len;
+
+  len = snprintf((char *)buf + 3, BUFSIZE - 3, "{\"a\":\"%s\",\"n\":\"1\",\"v\":\"v1.0\",\"o\":\"1\"}", g_appkey);
 
   buf[0] = 1;
   buf[1] = (uint8_t)((len >> 8) & 0xff);
   buf[2] = (uint8_t)(len & 0xff);
 
-  memcpy(buf + 3, data.c_str(), len);
   len += 3;
 
   buf[len] = 0;

  return false;
}

bool setup_with_appkey_and_devid(const char *appkey, const char *devid) {
  uint8_t buf[BUFSIZE];

  if (appkey == NULL) return false;

  String data("{\"a\": \"");
  data += String(appkey);

  if (devid == NULL) {
    data += String("\", \"p\":4}");
  } else {
    data += String("\", \"p\":4, \"d\": \"");
    data += String(devid);
    data += String("\"}");
  }
  uint16_t len = data.length();

  buf[0] = 1;
  buf[1] = (uint8_t)((len >> 8) & 0xff);
  buf[2] = (uint8_t)(len & 0xff);

  memcpy(buf + 3, data.c_str(), len);
  len += 3;

  buf[len] = 0;

      StaticJsonBuffer<JSON_BUFSIZE> jsonBuffer;
      JsonObject& root = jsonBuffer.parseObject(p);
      if (root.success()) {
        strcpy(g_url, root["c"]);
        return true;
      }
    }
