   Serial.print("signal strength (RSSI):");
   Serial.print(rssi);
   Serial.println(" dBm");
+
+  Serial.flush();
 }
 
 void softReset() {

  Serial.println(" bytes free");
  Serial.flush();
  delay(2000);
  conn.stop();  
}

void setupWifi() {
  initWifi();

  Serial.println("\nWifi initialized. Connecting to server.");
  printWifiStatus();

  Serial.println("connected to server");
  Serial.flush();
}

void connectToServer() {
  while(!conn.connect(server, port)) {
      Serial.println("Can't connect to the server.");
      Serial.flush();
      delay(1000);     
    }
}

void initWifi() {
  int status = WL_IDLE_STATUS;

  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    Serial.flush();

    status = WiFi.begin(ssid, password);

    delay(3000);
  }
}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  Serial.begin(9600);
  Serial.println("Starting up.");
  setupWifi();
  pseudopod = new Pseudopod(conn, conn);
}

