9 years, 10 months ago.

To Wei Zou

Hi Sir,

My name is Dorothy.

I have tried out the main.cpp that you wrote and I could successfully compile. Thank God.

But I have one problem:

My problem is I could not get the whole string of HTTP output page. Instead of that the output was repeated:

I edited your main.cpp and it is shown below:

  1. include "mbed.h"
  1. include "GPRSInterface.h"
  1. include "HTTPClient.h"
  1. define TEST_HTTP_GET 1
  1. define PIN_TX P0_0
  1. define PIN_RX P0_1

GPRSInterface gprs(PIN_TX,PIN_RX,9600,"shppd",NULL,NULL);

HTTPClient http;

char str[512];

int main()

{

gprs.init();

while(false == gprs.connect()) {

printf("gprs connect error\n");

wait(2);

}

successful DHCP

printf("IP Address is %s\n", gprs.getIPAddress());

int ret;

HTTPText inText(str, 512);

HTTPText outText(str);

  1. if TEST_HTTP_GET

GET data

printf("\nTrying to fetch page...\n");

ret = http.get("http://www.mytransport.sg/busarrival/12101.json?_=1402902181703", str, 512);

if (!ret) {

printf("Page fetched successfully - read %d characters\n", strlen(str));

printf("Result: %s\n", str);

} else {

printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());

}

  1. endif

gprs.disconnect();

return 0;

}

I was trying to get this output:

{"time":"16062014 150206","count":7,"bstop":"12101","info":

[{"wc2":"1","wc1":"1","bl2":"","bl1":"","arr2":"17","arr1":"5","bsvc":"52"},

{"wc2":"1","wc1":"1","bl2":"2","bl1":"1","arr2":"7","arr1":"3","bsvc":"61"},

{"wc2":"0","wc1":"0","bl2":"","bl1":"","arr2":"20","arr1":"9","bsvc":"74"},

{"wc2":"0","wc1":"0","bl2":"1","bl1":"1","arr2":"28","arr1":"11","bsvc":"75"},

{"wc2":"1","wc1":"1","bl2":"","bl1":"","arr2":"18","arr1":"5","bsvc":"151"},

{"wc2":"1","wc1":"0","bl2":"","bl1":"","arr2":"13","arr1":"6","bsvc":"154"},

{"wc2":"0","wc1":"0","bl2":"1","bl1":"1","arr2":"18","arr1":"9","bsvc":"184"}]}

But I could not produce the whole output but the output was repeated:

I got like this:

{"time":"16062014 150206","count":7,"bstop":"12101","info":

[{"wc2":"1","wc1":"1","bl2":"","bl1":"","arr2":"17","arr1":"5","bsvc

{"time":"16062014 150206","count":7,"bstop":"12101","info":

[{"wc2":"1","wc1":"1","bl2":"","bl1":"","arr2":"17","arr1":"5","bsvc

It was repeated:

May I kindly ask you that what would be the problems?

Thank you so much.

I am looking forward to hearing from you:D

Regards

Dorothy

Question relating to:

this is a demo code for HTTPClient_GPRS library

I would like to encourage you to use proper headline, don't use "To username". Use more generic headline about the actual problem. It can be answered by other users who are familiar with the topic.

Use "<<code>> <</code>>" for code highlighting !

Thanks for understanding.

Regards,
0xc0170

posted by Martin Kojtal 16 Jun 2014

Oh sir,

Thanks for your good advices.

posted by Dorothy Luai 16 Jun 2014
Be the first to answer this question.