Arduino + Wifly RN-XV + Processing

Hi,

You have misplaced some of the code in your sketch, check the following code. Have not tested if it runs properly but I least it compiles :slight_smile:

#include "WiFly.h"
#include "Credentials.h"

Server server(80);

void setup() {
  // start the WiFly connection:
  WiFly.begin();
  
  if (!WiFly.join(ssid, passphrase)) {
    while (1) {
      // Hang on failure.
    }
  }

  Serial.begin(9600);
  Serial.print("IP: ");
  Serial.println(WiFly.ip());
  
  server.begin();

  // give the WiFly shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");
  
  //------rest shall be implemented inside loop()
  
  // if you get a connection, report back via serial:
  //if (client.connect(server, 1234)) {
  //  
  //  Serial.println("connected");
  //} 
  //else {
  //  // if you didn't get a connection to the server:
  //  Serial.println("connection failed");
  //}
}

void loop() {
  Client client = server.available();
  
  //If client has been instantiated
  if (client) {
    //check for client connection
    while (client.connected()) {
      //if client has connected
      if (client.available()) {
        //The following code will simply send characters for Terminal input to the server - use it as a test
        while (Serial.available() > 0) {
          char inChar = Serial.read();
            if (client.connected()) {
              client.print(inChar); 
            }
        }
      }
    }
  }
  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    // do nothing:
    while(true);
  }
}