Yun - Parsing incoming URL for string


i did google search , forum, found more on char , integers. sorry if missed answer - so, follow links if commonly answered question.

i stripped bridge example needed. but, reason when send following urls yun caught "error" lines , printed client.  i'm sure it's incredibly simple eluding me:

code: [select]
#include <bridge.h>
#include <yunserver.h>
#include <yunclient.h>

yunserver server;

void setup() {
  serial.begin(9600);
  pinmode(13,output);
  digitalwrite(13, low);
  bridge.begin();
  server.listenonlocalhost();
  server.begin();
}

void loop() {
  yunclient client = server.accept();

  if (client) {
    process(client);
    client.stop();
  }

  delay(50);
}

void process(yunclient client) {
  string command = client.readstringuntil('/');

  if (command == "open") {
    digitalwrite(13,1);
   
  }
  if (command == "close") {
    digitalwrite(13,0);
  }
 
  if (client.read() != '/') {
    client.println(f("error"));
    client.println(command); // debug
    return;
  }
}


when send:
code: [select]
http://192.168.32.57/arduino/open

led 13 not turn on , on browser:

 
code: [select]

error
open


a matter of fact, whatever send after "...arduino/" caught error , printed. example/bridge code works expected.

any guidance helpful , welcome. want use add wireless trigger functioning project/sketch.

thank you!
 

code: [select]
  string command = client.readstringuntil('/');
why assume / left in buffer?

have looked @ code , determined is?



Arduino Forum > Products > Arduino Yún (Moderator: fabioc84) > Yun - Parsing incoming URL for string


arduino

Comments