Robin2:
You need to post the exact program that you used.
Here is the code i used, i have add the code from your post in it as well:
#include <SoftwareSerial.h>
char a[100];
char cmd[100];
struct packet{
char packet_type[15];
char sensor_name[10];
char payload[10];
};
struct packet syn;
const byte numChars = 100;
char receivedChars[numChars];
boolean newData = false;
SoftwareSerial esp (8,9);
void setup() {
Serial.begin(9600);
esp.begin(9600);
esp.println("AT+CWJAP=\"SSID\",\"PASSWORD\""); //i had used the actual ones here
delay(5000);
int i=0;
char c[100];
while (esp.available()>0) {
c[i]= esp.read();
Serial.write(c[i]);
delay(10);
i++;
}
esp.println("AT+CIPSTART=\"TCP\",\"192.168.8.100\",5555");
delay(1000);
i=0;
c[100];
while (esp.available()>0) {
c[i]= esp.read();
Serial.write(c[i]);
delay(10);
i++;
}
//Initiallizing the struct declared above
strcpy(syn.packet_type,"syn");
strcpy(syn.sensor_name,"temp");
strcpy(syn.payload,"100.7");
//Storing all the struct variables in one string to send it, i couldnt think of anyother way to do it for now
strcpy(a,syn.packet_type);
strcat(a,syn.sensor_name);
strcat(a,syn.payload);
//len =sizeof(a);
//Serial.print("len="+len);
//strcpy(cmd,"AT+CIPSEND=");
//strcat(cmd,len);
esp.println("AT+CIPSEND=12");
delay(2000);
i=0;
while (esp.available()>0) {
c[i]= esp.read();
Serial.write(c[i]);
delay(10);
i++;
}
esp.println(a);
delay(1000);
i=0;
/*At this point after sending the string a to the server i get a response but the response gets terminated, i have written what happens in the question above */
recvWithStartEndMarkers();
showNewData();
/*while (esp.available()>0) {
c[i]= esp.read();
Serial.write(c[i]);
delay(10);
i++;
}*/
}
void loop() {
//Here i am just sending arbritary data to the server for checking it
esp.println("AT+CIPSEND=3");
delay(1000);
int i=0;
char c[100];
while (esp.available()>0) {
c[i]= esp.read();
Serial.write(c[i]);
delay(10);
i++;
}
esp.println("aab");
delay(1000);
//again here i am supposed to get the serponce from the server but i recieve a truncated response after the +IPD from here
i=0;
while (esp.available()>0) {
c[i]= esp.read();
Serial.write(c[i]);
delay(10);
i++;
}
esp.println("AT+CIPSEND=3");
delay(1000);
i=0;
while (esp.available()>0) {
c[i]= esp.read();
Serial.write(c[i]);
delay(10);
i++;
}
esp.println("bbb");
delay(1000);
i=0;
//while (esp.available()>0) {
//c[i]= esp.read();
//Serial.write(c[i]);
//delay(10);
//i++;
//}
recvWithStartEndMarkers();
showNewData();
}
void recvWithStartEndMarkers() {
static boolean recvInProgress = false;
static byte ndx = 0;
char startMarker = '@';
char endMarker = '!';
char rc;
while (Serial.available() > 0 && newData == false) {
rc = Serial.read();
if (recvInProgress == true) {
if (rc != endMarker) {
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else {
receivedChars[ndx] = '\0'; // terminate the string
recvInProgress = false;
ndx = 0;
newData = true;
}
}
else if (rc == startMarker) {
recvInProgress = true;
}
}
}
void showNewData() {
if (newData == true) {
Serial.print("This just in ... ");
Serial.println(receivedChars);
newData = false;
}
}
Robin2:
Also, it is easier to help if you respond within (say) 24 hrs while your problem is still in my mind....R
I am sorry about that as well i had internet issues that why, i will keep that in mind next time.
Thank you for helping me out