void JSONAPI::_headerStart (const char *method) {
  // If an old connection is active, close.
  if (wifly.isConnected()) {
    wifly.close();
  }

  if (!wifly.open(this->host, 80)) {
    Serial.println(F("Failed to connect to host."));
  }
  
  wifly.print(method);
  wifly.print(" ");
  // wifly.print("http://");
  // wifly.print(this->host);
}
Exemplo n.º 2
0
void loop() {
  int available;

  if (wifly.isConnected() == false) {
    Serial.println("Connecting");

    if (wifly.open("192.168.1.100", 4001)) {
      Serial.println("Connected");
    } else {
      Serial.println("Failed to open");
    }
  } else {
    available = wifly.available();

    if (available < 0) {
      Serial.println("Disconnected");
    } else if (available > 0) {
      Serial.write(wifly.read());
    }
  }
}