08-06-2018, 22:05
If we want to use a concatenated String variable (let's assume: "WD-"+X) as Hostname, than we can use these two assignments:
if (wifi.createTCP(mux_id, "WD-"+String(variableX), 80, 0)) {
String s_VariableX = String(variableX);
char *prefix = "GET / HTTP/1.1\r\nHost: WD-";
char *postfix =" host:80\r\nConnection: close\r\n\r\n";
String url = prefix +s_VariableX+ postfix;
const char *get_json = url.c_str(); //this whole thing can be done once as init also... --> then I think we can save microcontroller cycles!
I hope this helps you a bit for convincing to switch to hostnames
if (wifi.createTCP(mux_id, "WD-"+String(variableX), 80, 0)) {
String s_VariableX = String(variableX);
char *prefix = "GET / HTTP/1.1\r\nHost: WD-";
char *postfix =" host:80\r\nConnection: close\r\n\r\n";
String url = prefix +s_VariableX+ postfix;
const char *get_json = url.c_str(); //this whole thing can be done once as init also... --> then I think we can save microcontroller cycles!
I hope this helps you a bit for convincing to switch to hostnames

