Skip to main content
deleted 23 characters in body; edited title
Source Link
dda
  • 1.6k
  • 1
  • 12
  • 18

Arduino + Sim808SIM808: How to get only the jsonJSON object response without the header?

I have been successfully getgetting the response from my web server. The problem is I get the whole package with header and content/body:

Recv: 325 bytes: HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-Powered-By-Plesk: PleskWin
Date: Wed, 02 Aug 2017 03:26:37 GMT
Connection: close
Content-Length: 18

1501644397698.2585

I want to only assign this 1501644397698.2585 to my double variable. How can I do this? I want to only assign this 1501644397698.2585 to my double variable. How can I do this?

This is the code which sendsends and printprints the response:

Serial.println("waiting to fetch...");
sim808.send(http_cmd, sizeof(http_cmd)-1);
while (true) {
    int ret = sim808.recv(buffer, sizeof(buffer)-1);
    if (ret <= 0) {
        Serial.println("fetch over...");
        break;
    }
    buffer[ret] = '\0';
    Serial.print("Recv: ");
    Serial.print(ret);
    Serial.print(" bytes: ");
    Serial.println(buffer);
    break;
}

Arduino + Sim808: How to get only the json object response without the header

I have been successfully get the response from my web server. The problem is I get the whole package with header and content/body:

Recv: 325 bytes: HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-Powered-By-Plesk: PleskWin
Date: Wed, 02 Aug 2017 03:26:37 GMT
Connection: close
Content-Length: 18

1501644397698.2585

I want to only assign this 1501644397698.2585 to my double variable. How can I do this?

This is the code which send and print the response:

Serial.println("waiting to fetch...");
sim808.send(http_cmd, sizeof(http_cmd)-1);
while (true) {
    int ret = sim808.recv(buffer, sizeof(buffer)-1);
    if (ret <= 0){
        Serial.println("fetch over...");
        break;
    }
    buffer[ret] = '\0';
    Serial.print("Recv: ");
    Serial.print(ret);
    Serial.print(" bytes: ");
    Serial.println(buffer);
    break;
}

Arduino + SIM808: How to get only the JSON object response without the header?

I have been successfully getting the response from my web server. The problem is I get the whole package with header and content/body:

Recv: 325 bytes: HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-Powered-By-Plesk: PleskWin
Date: Wed, 02 Aug 2017 03:26:37 GMT
Connection: close
Content-Length: 18

1501644397698.2585

I want to only assign this 1501644397698.2585 to my double variable. How can I do this?

This is the code which sends and prints the response:

Serial.println("waiting to fetch...");
sim808.send(http_cmd, sizeof(http_cmd)-1);
while (true) {
  int ret = sim808.recv(buffer, sizeof(buffer)-1);
  if (ret <= 0) {
    Serial.println("fetch over...");
    break;
  }
  buffer[ret] = '\0';
  Serial.print("Recv: ");
  Serial.print(ret);
  Serial.print(" bytes: ");
  Serial.println(buffer);
  break;
}
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Source Link

Arduino + Sim808: How to get only the json object response without the header

I have been successfully get the response from my web server. The problem is I get the whole package with header and content/body:

Recv: 325 bytes: HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-Powered-By-Plesk: PleskWin
Date: Wed, 02 Aug 2017 03:26:37 GMT
Connection: close
Content-Length: 18

1501644397698.2585

I want to only assign this 1501644397698.2585 to my double variable. How can I do this?

This is the code which send and print the response:

Serial.println("waiting to fetch...");
sim808.send(http_cmd, sizeof(http_cmd)-1);
while (true) {
    int ret = sim808.recv(buffer, sizeof(buffer)-1);
    if (ret <= 0){
        Serial.println("fetch over...");
        break;
    }
    buffer[ret] = '\0';
    Serial.print("Recv: ");
    Serial.print(ret);
    Serial.print(" bytes: ");
    Serial.println(buffer);
    break;
}