View previous topic :: View next topic |
Author |
Message |
mutthunaveen
Joined: 08 Apr 2009 Posts: 100 Location: Chennai, India
|
SIM900 HTTP post anyone succeeded?? |
Posted: Sun Jun 19, 2016 10:24 pm |
|
|
Dear Forum
I've done a lot of googling and still failed to get a working example for
SIM900 HTTP post request.
Here is my code after internet connection successful.
Code: |
AT+HTTPPARA="CID",1
AT+HTTPPARA="URL","http://blawebsite.comli.com/log_tempt.php"
AT+HTTPDATA=7,10000 --> the module requests with "DOWNLOAD"
-------this is where i pass the variables
var_a=26
------ after passing i give control+z command
AT+HTTPACTION=1
response = +HTTPACTION:1,200,0
AT+HTTPTERMeverything is working positive, the problem is i have to see in my sql db value as 26, but the db is updated with "0"
|
I've tried from Internet Explorer -> "http://blawebsite.comli.com/log_tempt.php?var_a=26"
the above link is absolutely working and i see in sql db value as 26.
Can someone help me with a working example for a POST command using SIM900 ?
Thank you |
|
|
guy
Joined: 21 Oct 2005 Posts: 297
|
|
Posted: Mon Jun 20, 2016 5:13 am |
|
|
I haven't worked with SIM900. I don't know if it's any help but ctrl-Z is ASCII 26. |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Mon Jun 20, 2016 6:49 am |
|
|
Hi, I'm not familiar with that module but i am familiar with 2G connections.
First off, does your modem support http? Does it have a native stack? There should be an app note if it does
There is alot you are either not doing or not showing.
You need to set up you modem properly for "internet use".
Stuff like setting you APN based on your Cell Carrier...enable GPRS connections, set up ports, .... its about 10 steps.
The datasheet for your module should have the AT commands required.... figuring out the right sequence might take some trials.
What is your goal?
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Mon Jun 20, 2016 7:00 am |
|
|
I don't use it either but when I googled...SIM900 HTTP post request.. I got 28,000+ hits and some say 'solved', so I'd be looking there...
While the code won't be in CCS C...it should be easy to convert.
Jay |
|
|
mutthunaveen
Joined: 08 Apr 2009 Posts: 100 Location: Chennai, India
|
|
Posted: Mon Jun 20, 2016 7:32 am |
|
|
dears
hmm yes. There are 10 steps to follow, and yes i have them all in my code which i did not write them all here.
I was able to get information from internet with HTTP GET request... it works very well.
and of course my modem supports internet protocols.
and when I'm trying to POST to internet (my request is provoking the page in internet but the variable data is not posting there. So in webpage the value is reading as "0" each time).
and from google there are so many answers where few of them are posted as [solved] but if i read in detail no one succeeded. They are all fake posts (arduino) and they used GET request for posting data. (actually that solves the purpose but that is not correct way).
Product application notes are not so solid (the are no practical examples).
So, if someone have succeeded plz do help me.
thank you. |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Mon Jun 20, 2016 10:47 am |
|
|
... my best guess is that you are trying to log data via some sort of REST or the likes API.
We cant help you if you dont show your work.
you need to set up a connection to the "cloud server" then you need to send the GET/POST request with a specific number of bytes you are sending, socket configurations, other steps... there are a lot of steps, and we are not seeing you do any of them.
your browser does all this automatically... your PIC needs to handle these things one by one and YOU have to code it.
Ive had "Clouds" that require UTF-8 encoding...others dont...what does your system require? are you using your own server? what are you using? PHANT? some REST API? Adafruit.IO? ...
there is alot of information missing and we cant really help you based on what you have presented.
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
mutthunaveen
Joined: 08 Apr 2009 Posts: 100 Location: Chennai, India
|
|
Posted: Mon Jun 20, 2016 10:11 pm |
|
|
in another 12 hrs i will post most of the content.. |
|
|
mutthunaveen
Joined: 08 Apr 2009 Posts: 100 Location: Chennai, India
|
|
Posted: Tue Jun 21, 2016 9:31 am |
|
|
Dear
the website im using is
Code: |
http://blawebsite.comli.com/log_tempt.php
|
the php will be waiting for a POST request. when i send variable "var_a=20" by calling the website address, the PHP page will GET the variable value "var_a" and stores the same in SQL database.
untill here i hope you understand
Code: |
http://blawebsite.comli.com/log_tempt.php?var_a=15
|
when i enter the above line in IE or firefox or even from my mobile phone the value is getting stored perfectly in SQL (so it works)
coming to my SIM900 module and with my PIC micro controller or with PC terminal
if i call the website with the following web address
Code: |
http://blawebsite.comli.com/log_tempt.php?var_a=15
|
again The value is getting stored perfectly in SQL (so it works here too from my terminal or from my PIC controller)
here comes the core part, i use the following code to connect to internet and process my http addresses
Code: |
AT+CGATT?
+CGATT: 1
OK
AT+SAPBR=3,1,"CONTYPE","GPRS"
OK
AT+SAPBR=3,1,"APN","airtelgprs.com"
OK
AT+SAPBR=1,1
OK
AT+HTTPPARA="CID",1
OK
AT+HTTPPARA="URL","http://blawebsite.comli.com/log_tempt.php"
OK
AT+HTTPDATA=7,10000
OK
DOWNLOAD
var_a=20
OK
AT+HTTPACTION=1
response = +HTTPACTION:1,200,0
AT+HTTPTERM
|
with the above everything works but my SQL is saving value as "0"
after "DOWNLOAD" and after entering variable, im sending control+z for testing. Any iteration with without any way it did save the variable value im feeding.
and if i use the following
Code: |
AT+HTTPPARA="URL","http://blawebsite.comli.com/log_tempt.php?var_a=10"
OK
AT+HTTPDATA=7,10000
OK
DOWNLOAD
0
OK
AT+HTTPACTION=1
response = +HTTPACTION:1,200,0
AT+HTTPTERM
|
the above code fantastically works...
but this is not absolutely a good way of posting data to a http server.
i hope this is sufficient to understand my request |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Tue Jun 21, 2016 9:55 am |
|
|
re:
with the above everything works but my SQL is saving value as "0"
OK, You need to show us your real code ! I can think of several reasons why it isn't working but without seeing your code I'm not about to say 'this is why' or 'this is wrong'.
Jay |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Tue Jun 21, 2016 2:47 pm |
|
|
Quote: | but this is not absolutely a good way of posting data to a http server. |
Why not?
This is the way websites like "Thingspeak" or even higher end clouds like "Pubnub" do it.
What do you think your PC browser is doing?
your browser requests the page with the variable as part of the URI, just the way you say "its not a good way".
Quote: | the above code fantastically works... |
So your problem is what? you have a working solution it seems.
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
mutthunaveen
Joined: 08 Apr 2009 Posts: 100 Location: Chennai, India
|
|
Posted: Tue Jun 21, 2016 10:44 pm |
|
|
Hi Gabriel
Code: |
AT+HTTPPARA="URL","http://blawebsite.comli.com/log_tempt.php?var_a=10"
OK
AT+HTTPDATA=7,10000
OK
DOWNLOAD
0
OK
AT+HTTPACTION=1
response = +HTTPACTION:1,200,0
AT+HTTPTERM
|
yes this works, the solution i ve is not procedural. even SIM900 AN says to load data after DOWNLOAD
anyhow. i will go with the above practice finally. because in internet i dont find anyone loading the http post variables after "download"....
If someone succeed with POST request after DOWNLOAD. plz do share in this post..
thank you for your time dears |
|
|
mutthunaveen
Joined: 08 Apr 2009 Posts: 100 Location: Chennai, India
|
|
Posted: Tue Jun 21, 2016 10:48 pm |
|
|
temtronic wrote: | re:
with the above everything works but my SQL is saving value as "0"
OK, You need to show us your real code ! I can think of several reasons why it isn't working but without seeing your code I'm not about to say 'this is why' or 'this is wrong'.
Jay |
issue is not with SQL or PHP. it is with what SIM900 transfers.
With the same setup SIM900 and internet and with different approach of request processing the code works.
Anyhow i will go with second method post posting for the moment. |
|
|
|