Take the 2-minute tour ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

I'm using this simple code

#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>

YunServer server;

void setup() {
  Serial.begin(9600);
  Bridge.begin();
  server.listenOnLocalhost();
  server.begin();
}

void loop() {
  YunClient client = server.accept();
  if (client) {
    Serial.println("client");
    process(client);
    client.stop();
   } else {
     Serial.println("no client");
   }
   delay(50); 
}

void process(YunClient client) {
  String command = client.readStringUntil('/');
  Serial.println(command);
  if (command == "turnLeft") {
    Serial.println("Gira a sinistra");
  }
  if (command == "turnRight") {
    Serial.println("Gira a destra");
  }
  if (command == "goTo") {
    String value = client.readStringUntil('/goTo/');
    Serial.println(value);
  }
}

but it seems to have problem with bridge (or server, or client, i cannot understand) because it only write "no client" on the serial.

I can not understand what is wrong.

Thanks a lot!

share|improve this question

1 Answer 1

Probably too late to answer your question. Your problem is on line

if (client) 

Change it to

if(client.connected())

which actually returns true when client is connected.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.