[ASK] how to make HTTP client using WIPSoft


#1

Hi, i am a new user of Fastrack Supreme 20 and i have some problem in using it. my intention is to get a data from the web site that i made using GPRS connection and send the data to another device via serial port. my application has accessed the gprs network and i could send the ICMP packet (ping function) to google.com, yahoo.com, my website and another public web. But there is some problem when i tried to access the data that i want. what i wrote in my application was like this

case WIP_CEV_WRITE:															//Triggered when the writing process to the  
		adl_atSendResponse (ADL_AT_UNS,"\r\ninside the WIP_CEV_WRITE\r\n");		//channel is completed
		Write = wip_write(Channel, "GET /index.php HTTP/1.1\r\n",26);												//Saving the data into the Write buffer
		wm_itoa (Write,writeBuffer);											//Convert the return value of the writing process into ascii
		adl_atSendResponse (ADL_AT_UNS,writeBuffer);							//Send the return value into Hyper Terminal
		adl_atSendResponse (ADL_AT_UNS,"\r\n");							
		break;

But the result that i get from writing this request is BAD REQUEST ERROR (400) page. FYI i made my web using a free public web hosting. so i could only accessed port 80. what should i do then to make my application could access the web site? i thank you for your time and helpful advices.

best regards,
Hade


#2

It looks like your application is already reaching your WEB site!
It is able to send a request to your server and read the replay.

The problem is probably in the request “/index.php” which seems correct (unless the index.php does not exist in your server root directory), try
your.public.ip.address/index.php from a normal browser.

The only other thing I can think of is a wrong target IP address configured in the Fastrack, then you will be requesting the file to someone else.


#3

Hiya,

A couple of things.

  1. Have you looked at the HTTP sample in the WIP samples directory? The sample there works OK.
  2. The string length count in

is wrong. I count 25 characters, not 26. wip_write binary copies (not string copies) the number of bytes specified into the TX buffer - so you don’t have to account for the trailing ‘\0’ at the end of the string. You have copied an extra character into the buffer, which is probably appearing to the Web Server as the start of a header field. This is confusing the web server, which returns the 400 error.
Also, you need to have a blank line between the end of headers to signify that the header block is complete - so you should add another \r\n to the end of your write string.

Really, have a look at the provided sample. Also, there a number of threads alread here on the forum about writing HTTP clients.

ciao, Dave


#4

Do you mind showing me the example code? because in my WIP samples the code is not sending any HTTP get request.
but thank you for the fast reply! i really appreciate it.

Best regards
Okky Kusuma


#5

Hiya,

Are you using M2MStudio as your development environment?

If so, follow the steps below to create a project based on the HTTP GET sample.

  1. Open M2M Studio
  2. Create a new Open AT project (File->New->OpenAT Project)
  3. In the first dialog box Give your project a name (i.e. HTTP Test), and sort out where the files are going to be stored (default is OK). Click Next
  4. In the next dialog box (Select Configurations), make sure that (at least) the [Target]_ARM_ELF_GCC_xxx options are selected. Click Next
  5. In the next dialog box (Binary Project Creation), select the appropriate Open AT OS Package. In the Sample dropdown at the bottom of the dialog box, click the down arrow icon and scroll down until you see the http_get [WIP Open AT Plug-in Package (5.10.0.2020)] option. Click once on this option. Click Next
  6. In the next dialog box (Plugin Selection), ensure that at least the WIP Open AT Plug-in Package is selected. Click Finish to create your project.

You will now have a new project based on the HTTP GET sample provided by Wavecom. Hack away to your heart’s content.

ciao, Dave


#6

hi dave, i am sorry to say that i am using visual C for my IDE. therefore i cannot follow the steps that you gave me. but thanx for the info anyway. the point is are you sure that my application has succesfully reached into the web page. but some how the HTTP request that i made is wrong, so the result that occured was error 400? am i right so far? if that’s the problem then the solution is that i should look for how to make the right HTTP get request, aren’t i?

Best regards,
Okky Kusuma


#7

Hiya,

OK, then you need to look under the folder where you installed OpenAT.

Look for the folder Plug-ins\WIP\5.10.2020\WIP\samples\http_get under the Open AT install folder.

Hope this helps.

ciao, Dave


#8

btw now i’m having another problem, when i changed the data from the web, the data that the wavecom received is not changing immediately. seems like there is some buffer inside the wavecom that needs time to be changed with the new data from the website?


#9

It might not be in the wavecom - it might be getting “cached” elsewhere in the network…


#10

I’m not sure but did you reload page before getting data from it?


#11

emm… what do u mean reload the page? because the program i make is only to get the webpage using Fastrack periodically. i made the poll timing to 5 minutes. so the program is only akses the internet through GPRS, make a socket connection to the destination port 80, and send the Get request and receive the response. but the problem occured in the last step which is the response part. i always receive more then 1 webpage data before the application goes through the WIP_CEV_PEER_CLOSE event. And the data is often still the previous data that haven’t been modified. After a period of time then the data changed into the new data that i had modified. There seems to be some delay in processing the data. any suggestion?

Best Regards,
Hade


#12

Ok. So you get the full web page every time you need new data.
So I think that this delay depends on web server on your hosting and it cannot be helped to reduce this delay.

But I believe that there is a way to get information as fast as it is generated on the server. If you put your data in the database on the hosting side and write a server-side script (on php or perl or ASP) to get the data from database on some client action (click the button or just call the script with some parameters) - you could give to the client the freshest data possible. And also you can try to block cashing for your web pages on hosting side - I guess it is possible.


#13

Note that cacheing may also happen in the GPRS network - and you have no control over that!


#14

Hiya,

Especially if your ISP is using a Proxy Server or Proxy Cache between the GPRS network and the internet.

You can attempt to defeat the proxy server if you use a different URL for each request (as the request will not match anything in the Cache).

Try something like this:

mydomain.com/myhtml.php?id=

i.e. a HTTP GET request

I suggest that you make the be the current time in milliseconds so it is unique…

Let us know how you get on.

ciao, Dave


#15

Hi Dave, i´ve been working with 663 firmware, now i´m working with R74 and M2M Studio. I opened a new project loading the http get sample exactly as you specified, but as soon as i build it i get 2 warnings; did you experienced that? or i have a broken plug-in version? or i just have to download this sample on my modem no matter of the warnings? Thank you!


#16

Normally one would expect code - especially example code - to build “cleanly” (ie, no warnings).
Unfortunately, Sierra Wireless do not seem to follow this practice: https://forum.sierrawireless.com/t/opus-i-samples-do-not-build-cleanly-if-at-all/4304/1 :angry:

However, dealing with compiler messages is a standard part of the ‘C’ development process (nothing magic or special about Open-AT here) - so you should just deal with them as normal!

Probably just shoddy QA by Sierra Wireless. :angry:

Nobody can tell you whether those warnings are serious or benign if you don’t actually say what warnings, precisely, they were! And at what point(s) in the code they occurred.