Android pour Arduino Uno + Wi-Fi bouclier de la chaîne de communication

Je suis en train de faire une lumière sans fil, dispositif de commande (marche/arrêt/gradation) à l'aide d'un Arduino, une application Android, et un routeur.

Je suis en train de l'Arduino static IP 192.168.1.2 à l'aide du routeur. Je suis l'envoi de chaînes de caractères ("1"off", "2"-diminution de la luminosité, le "3"-augmenter la luminosité, "4") à partir de l'application Android pour l'adresse IP 192.168.1.2. J'ai branché l'Arduino à l'Internet à l'aide de la Arduino Wi-Fi bouclier et configurer le WifiServer en utilisant le code suivant:

char ssid[] = "NAME"; //Your network SSID (name)
char pass[] = "PASS"; //Your network password (use for WPA, or use as key for WEP)

int keyIndex = 0;     //Your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;

WiFiServer server(23);

boolean alreadyConnected = false; //Whether or not the client was connected previously.

void setup() {
    //Start serial port:
    Serial.begin(9600);

    //Attempt to connect to Wi-Fi network:
    while ( status != WL_CONNECTED) {
        Serial.print("Attempting to connect to SSID: ");
        Serial.println(ssid);
        status = WiFi.begin(ssid, pass);
        //Wait 10 seconds for connection:
        delay(10000);
    }
    //Start the server:
    server.begin();
    //You're connected now, so print out the status:
    printWifiStatus();
 }

Le principal problème que j'ai est de savoir comment accepter et d'imprimer les chaînes à partir de l'appareil Android. Le code actuel que j'ai à faire c'est:

    //Listen for incoming clients
    WiFiClient client = server.available();
    if (client) {
        //An HTTP request ends with a blank line
        boolean newLine = true;
        String line = "";

        while (client.connected() && client.available()) {
            char c = client.read();
            Serial.print(c);

            //If you've gotten to the end of the line (received a newline
            //character) and the line is blank, the HTTP request has ended,
            //so you can send a reply.
            if (c == '\n' && newLine) {
                //Send a standard HTTP response header
                //client.println("HTTP/1.1 200 OK");
                //client.println("Content-Type: text/html");
                //client.println();
            }
            if (c == '\n') {
                //You're starting a new line
                newLine = true;
                Serial.println(line);
                line = "";
            }
            else if (c != '\r') {
              //You've gotten a character on the current line
              newLine = false;
              line += c;
            }
        }
        Serial.println(line);

        //Give the web browser time to receive the data
        delay(1);

        //Close the connection:
        //client.stop();
    }
}

Je suis en la fondant le code du blog Android Arduino Commutateur avec un TinyWebDB hack, mais ce code est pour un Ethernet shield. L'application Android a été faite en utilisant le MIT App Inventor, qui est semblable à celui trouvé le post de blog.

TLDR, comment puis-je obtenir les chaînes à l'aide de l'Arduino Wi-Fi gratuite, d'un bouclier?

Le fait de l'Arduino code ne fonctionne pas? Qu'est-ce que le comportement actuel?
maintenant les chaînes qui sont envoyés à l'adresse IP ne sont pas imprimés sur l'écran afin de "char c" n'est pas écrit.
Avez-vous essayé de connecter à votre arduino à partir d'un programme telnet, sans le Android? Ce n'est que faire?

OriginalL'auteur Marwan Alayli | 2013-03-31