Hi
I would like to send the device Id to a tcp server and cannot seem to stop it splitting it into many packets fore each element of the string. What is the correct way to send this string variable as a single value to the client port please? I am after a way to include the dev_id in my data packet along with the other fields with sprintf . It sends correctly to the serial port.
The following code hopefully explains what I have been struggling with.
Thanks for any help.
indent preformatted text by 4 spaces
TCPClient client;
byte server[] = { 192, 168, 0, 195 };
char id[12];
char id2[100];
char* dev_id;
String String_ID = NULL;
String myIDStr = NULL;
void setup()
{
Serial.begin(9600);
while(!Serial.available()) SPARK_WLAN_Loop();
Serial.println("connecting to host...");
if (client.connect(server, 3053))
{
Serial.println("connected");
String myIDStr = Spark.deviceID();
Serial.println(myIDStr) ; // prints correctly to the serial port
client.print("Dev ,Packet nos ,Data, unit_Id, RSSI, Batt, datetime"); //send one packet to tcp server
client.print(myIDStr) ; //sends 24+ single byte network packets
for (int i = 0 ; i < 24 ; i ++ )
{
String_ID.concat( String(myIDStr[i]) );
}
client.print(String_ID); //sends 24+ single byte network packets
}
}
void loop()
{
}
indent preformatted text by 4 spaces