I have a problem (that has clearly been posted here before)
I am trying to hit a webserver, where I send a number value to a simple uri (it's not properly formed REST)
This code works:
if (client.connect(server, 8888)) {
Serial.print("connected to ");
Serial.println(client.remoteIP());
// Make a HTTP request:
client.println("GET /classicui/CMD?Echo_Kitchen_TTS=62 HTTP/1.1");
client.println("Host: www.myuri.com");
client.println("Connection: close");
client.println();
} else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
This code doesn't
if (client.connect(server, 8888)) {
Serial.print("connected to ");
Serial.println(client.remoteIP());
// Make a HTTP request:
int t1 = 62;
client.println("GET /classicui/CMD?Echo_Kitchen_TTS=" + t1 + " HTTP/1.1");
client.println("Host: www.myuri.com");
client.println("Connection: close");
client.println();
} else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
A few posts suggest sprintf, but others say this is 'using a hammer to squash a mosquito'
So 2 questions,
-
- What is the actual correct way to handle this concatenation (I get that the + is an addition, not a concatenator in C - so, I understand why it is wrong)
-
- If sprintf is deemed too 'heavyweight', what is the soft touch solution?