Come faccio a ...

Io ho provato ad unirli ma una volta mi legge uno modificando in loop alcune cose mi legge solo l'altro
Come faccio ad unire questo programma

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

// Listen to the default port 5555, the Yún webserver
// will forward there all the HTTP requests you send
YunServer server;

void setup() {
  // Bridge startup
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
  Bridge.begin();
  digitalWrite(13, HIGH);

  // Listen for incoming connection only from localhost
  // (no one from the external network could connect)
  server.listenOnLocalhost();
  server.begin();
}

void loop() {
  // Get clients coming from server
  YunClient client = server.accept();

  // There is a new client?
  if (client) {
    // Process request
    process(client);

    // Close connection and free resources.
    client.stop();
  }

  delay(50); // Poll every 50ms
}

void process(YunClient client) {
  // read the command
  String command = client.readStringUntil('/');

  // is "digital" command?
  if (command == "digital") {
    digitalCommand(client);
  }

  // is "analog" command?
  if (command == "analog") {
    analogCommand(client);
  }

  // is "mode" command?
  if (command == "mode") {
    modeCommand(client);
  }
}

void digitalCommand(YunClient client) {
  int pin, value;

  // Read pin number
  pin = client.parseInt();

  // If the next character is a '/' it means we have an URL
  // with a value like: "/digital/13/1"
  if (client.read() == '/') {
    value = client.parseInt();
    digitalWrite(pin, value);
  }
  else {
    value = digitalRead(pin);
  }

  // Send feedback to client
  client.print(F("Pin D"));
  client.print(pin);
  client.print(F(" set to "));
  client.println(value);

  // Update datastore key with the current pin value
  String key = "D";
  key += pin;
  Bridge.put(key, String(value));
}

void analogCommand(YunClient client) {
  int pin, value;

  // Read pin number
  pin = client.parseInt();

  // If the next character is a '/' it means we have an URL
  // with a value like: "/analog/5/120"
  if (client.read() == '/') {
    // Read value and execute command
    value = client.parseInt();
    analogWrite(pin, value);

    // Send feedback to client
    client.print(F("Pin D"));
    client.print(pin);
    client.print(F(" set to analog "));
    client.println(value);

    // Update datastore key with the current pin value
    String key = "D";
    key += pin;
    Bridge.put(key, String(value));
  }
  else {
    // Read analog pin
    value = analogRead(pin);

    // Send feedback to client
    client.print(F("Pin A"));
    client.print(pin);
    client.print(F(" reads analog "));
    client.println(value);

    // Update datastore key with the current pin value
    String key = "A";
    key += pin;
    Bridge.put(key, String(value));
  }
}

void modeCommand(YunClient client) {
  int pin;

  // Read pin number
  pin = client.parseInt();

  // If the next character is not a '/' we have a malformed URL
  if (client.read() != '/') {
    client.println(F("error"));
    return;
  }

  String mode = client.readStringUntil('\r');

  if (mode == "input") {
    pinMode(pin, INPUT);
    // Send feedback to client
    client.print(F("Pin D"));
    client.print(pin);
    client.print(F(" configured as INPUT!"));
    return;
  }

  if (mode == "output") {
    pinMode(pin, OUTPUT);
    // Send feedback to client
    client.print(F("Pin D"));
    client.print(pin);
    client.print(F(" configured as OUTPUT!"));
    return;
  }

  client.print(F("error: invalid mode "));
  client.print(mode);
}

con questo in modo che funzionano contemporaneamente?

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

#define DHTPIN 2
#define DHTTYPE DHT11 

YunServer server;
DHT dht(DHTPIN, DHTTYPE);
int h, t;

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

void loop() {
  h = dht.readHumidity();
  t = dht.readTemperature();

  YunClient client = server.accept();
  if (client) {
    process(client);
    client.stop();
  }
  
  delay(50);
}

void process(YunClient client) {
  
  String command = client.readStringUntil('\r');

  if (command == "termo") {
    temp(client);
  }

  if (command == "idro") {
    idro(client);
  }
}

void temp(YunClient client) {
  if (isnan(t)) {
    client.print(F("Error"));
  } else {
    client.print(t);
  }
}

void idro(YunClient client) {
    if (isnan(t)) {
      client.print(F("Error"));
    } else {
      client.print(h);
    }
}

Il problema penso che sia questo peró non so come rusolverlo:
La lettura dei comandi per la temperatura porta questa stringa
String command = client.readStringUntil('\r');
Invece quella xeo comandi per il bridge porta questa
String command = client.readStringUntil('/');
Forse il probllema è anche nel client perchè se creo due processi e due client uno funziona bene r l altro no bisogna cliccare tipo 3 4 volte per far partire il comando.

dove sbaglio?
IL comando (http://192.168.1.54/arduino/digital/13/1) funziona solo se clicco tre volte e poi il led si accende , invece il comando(http://192.168.1.54/arduino/termo) della temperatura funziona bene

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

#define DHTPIN 2
#define DHTTYPE DHT11 

YunServer server;
DHT dht(DHTPIN, DHTTYPE);
int h, t;

// Listen to the default port 5555, the Yún webserver
// will forward there all the HTTP requests you send
YunServer server2;

void setup() {
  // Bridge startup
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
  Bridge.begin();
  digitalWrite(13, HIGH);

  // Listen for incoming connection only from localhost
  // (no one from the external network could connect)
  server.listenOnLocalhost();
  server.begin();
}
void loop() {
  h = dht.readHumidity();
  t = dht.readTemperature();

  YunClient client2 = server2.accept();
  if (client2) {
    process2(client2);
    client2.stop();
  }
  
  delay(50);

 
  
  YunClient client = server.accept();

  if (client) {
    // Process request
    process(client);

    // Close connection and free resources.
    client.stop();
  }

  delay(50); // Poll every 50ms
}
void process2(YunClient client2) {
  
  String command2 = client2.readStringUntil('\r');

  if (command2 == "termo") {
    temp(client2);
  }

  if (command2 == "idro") {
    idro(client2);
  }
}

void temp(YunClient client2) {
  if (isnan(t)) {
    client2.print(F("Error"));
  } else {
    client2.print(t);
  }
}

void idro(YunClient client2) {
    if (isnan(t)) {
      client2.print(F("Error"));
    } else {
      client2.print(h);
    }
}
void process(YunClient client) {
  // read the command
  String command = client.readStringUntil('/');

  // is "digital" command?
  if (command == "digital") {
    digitalCommand(client);
  }

  // is "analog" command?
  if (command == "analog") {
    analogCommand(client);
  }

  // is "mode" command?
  if (command == "mode") {
    modeCommand(client);
  }
}

void digitalCommand(YunClient client) {
  int pin, value;

  // Read pin number
  pin = client.parseInt();

  // If the next character is a '/' it means we have an URL
  // with a value like: "/digital/13/1"
  if (client.read() == '/') {
    value = client.parseInt();
    digitalWrite(pin, value);
  }
  else {
    value = digitalRead(pin);
  }

  // Send feedback to client
  client.print(F("Pin D"));
  client.print(pin);
  client.print(F(" set to "));
  client.println(value);

  // Update datastore key with the current pin value
  String key = "D";
  key += pin;
  Bridge.put(key, String(value));
}

void analogCommand(YunClient client) {
  int pin, value;

  // Read pin number
  pin = client.parseInt();

  // If the next character is a '/' it means we have an URL
  // with a value like: "/analog/5/120"
  if (client.read() == '/') {
    // Read value and execute command
    value = client.parseInt();
    analogWrite(pin, value);

    // Send feedback to client
    client.print(F("Pin D"));
    client.print(pin);
    client.print(F(" set to analog "));
    client.println(value);

    // Update datastore key with the current pin value
    String key = "D";
    key += pin;
    Bridge.put(key, String(value));
  }
  else {
    // Read analog pin
    value = analogRead(pin);

    // Send feedback to client
    client.print(F("Pin A"));
    client.print(pin);
    client.print(F(" reads analog "));
    client.println(value);

    // Update datastore key with the current pin value
    String key = "A";
    key += pin;
    Bridge.put(key, String(value));
  }
}

void modeCommand(YunClient client) {
  int pin;

  // Read pin number
  pin = client.parseInt();

  // If the next character is not a '/' we have a malformed URL
  if (client.read() != '/') {
    client.println(F("error"));
    return;
  }

  String mode = client.readStringUntil('\r');

  if (mode == "input") {
    pinMode(pin, INPUT);
    // Send feedback to client
    client.print(F("Pin D"));
    client.print(pin);
    client.print(F(" configured as INPUT!"));
    return;
  }

  if (mode == "output") {
    pinMode(pin, OUTPUT);
    // Send feedback to client
    client.print(F("Pin D"));
    client.print(pin);
    client.print(F(" configured as OUTPUT!"));
    return;
  }

  client.print(F("error: invalid mode "));
  client.print(mode);
}