All,
Its generally never happened that I don't find an answer to my problem, but this time I have, and unfortunately for something as simple as String Concatenation. My programming skills are limited, probably that's the reason why I haven't been able to figure it out yet, hence the shout for help.
So I'm using ESP8266 for integrating some sensors and uploading data to my server. I'm having problems concatenating multiple strings - combination of fixed text and variable. Ofcourse I did do a search and I tried quite a few combinations, but none to any good. Code is as below:
//HTTP procedure begins
char PostStr1[ ] = "=records&data[]=";
char ndate[ ] = "2018-01-22,";
char ntime[ ] = "16:05:18,";
char nvar[ ] = "A,";
char PostString[ ] = "";
String PostString = "table"+ PostStr1 + ndate + ntime + secSince + var1 + var2 + var3 + var4 + var5;
Serial.println(PostString);
Serial.println();
http.begin("http://my.webserver.com/uploadD.php"); //this is the actual php file that is called for upload
http.addHeader("Content-Type", "application/x-www-form-urlencoded"); //This content type is needed for IoT upload API
Serial.print("HTTP Response code = ");
Serial.println(httpCode);
Serial.print("Application Repsonse: ");
http.writeToStream(&Serial);
Serial.println();
http.end();
This is not working. It gives an error saying "conflicting declaration String PostString"
I even tried:
String PostString = ("table") + String PostStr1 + ndate + ntime + secSince + var1 + var2 + var3 + var4 + var5;
Got the same error.
PostString = ("table") + String PostStr1 + ndate + ntime + secSince + var1 + var2 + var3 + var4 + var5;
Got the error "expected primary-expression before 'Poststr1'"
I'm using Arduino 1.8.5 IDE.
Apologies if this might be a stupid silly query which might have been answered already. Rest of my code is ready and I'm not stuck only at this issue. Thanks a ton in advance.
-Deepak