Why is it that when i use this code for http request on DFRobot_sim808 , I get 'fetch over' message, that means that no data is being returned?
char strings:
char http_cmd[] = " HTTP/1.0\r\n"
"Host: 5ac80719.ngrok.io\r\n"
"\r\n";
char first[] = "GET /index.php?lat=";
char requestion[100];
functions to join them:
void setup() {
float lat = 32.685362, lon = 48.411512;
char char_coor[10];
mySerial.begin(9600);
Serial.begin(9600);
// Set Http Cmd
strcpy(requestion,first);
// For Convert latitude float to char
dtostrf(lat, 4, 6, char_coor);
strcat(requestion,char_coor);
// For Convert longitude float to char
dtostrf(lon, 4, 6, char_coor);
strcat(requestion,"&long=");
strcat(requestion,char_coor);
strcat(requestion,http_cmd);
.
.
.
and fetching:
sim808.send(requestion, strlen(requestion)-1);
while (true) {
int ret = sim808.recv(buffer, sizeof(buffer)-1);
if (ret <= 0){
Serial.println("fetch over...");
break;
}
/*
The program stops at above
*/
buffer[ret] = '\0';
Serial.print("Recv: ");
Serial.print(ret);
Serial.print(" bytes: ");
Serial.println(buffer);
break;
}
thanks