Issue GSM for send a variable on a web page
JChris
Posts: 58
Hi, I try to send a variable on a web page with the method "GET" but I don't understand why answers of my GSM don't match with answers that I should have.
I use the sim card "SIM5320" and a propeller C3
My code is:
And I get this answer (image is attached)
The last line, I get as answer +CHTTPACT: 237 and I think that I should have : +CHTTPACT: DATA, (number of data).
Then I should have an other line that says that the communication is successful (+CHTTPACT:0)
If anyone has a hint, I would appreciate
I use the sim card "SIM5320" and a propeller C3
My code is:
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 GSM_Rx = 3 GSM_Tx = 4 GSM_Baud = 9600 GPS_power = 5 VAR byte AT_Reponse[150], latitude[11], N_S[2], longitude[12], E_W[2], Date[6], UTCtime[10], altitude[10], vitesse[10], course[10], AmpI[10], AmpQ[10] byte degre_lat[3], degre_minute_lat[3], degre_seconde_lat[7], resultat_latitude[15], degre_lon[3], degre_minute_lon[3], degre_seconde_lon[7], resultat_longitude[15] byte date_jour[5], date_mois[5], date_annee[5], resultat_date[15], jour_local[5], date_local[15] byte char, ptr, ptr1, ptr2 OBJ pst : "Parallax Serial Terminal" GSM : "FullDuplexSerial" Math : "Float32Full" PUB main pst.start(115200) Math.Start GSM.start(GSM_Rx, GSM_Tx, 0, GSM_Baud) waitcnt(clkfreq*2+cnt) ' Start_Module latitude[0] := "d" latitude[1] := "a" latitude[2] := "m" latitude[3] := "i" latitude[4] := "e" latitude[5] := "n" latitude[6] := 0 ptr := 0 repeat gsm.str(string("AT+CGSOCKCONT=1,",34,"IP",34,",",34,"m2minternet",34,13)) Rx pst.Str(String(13)) pst.str(String("La réponse à ta requete est la suivante 8: ",9)) pst.Str(@AT_Reponse) pst.Str(String(13)) waitcnt(clkfreq*2+cnt) gsm.str(string("AT+CSOCKAUTH=1,1,",34,"SFR",34,",",34,"SFR",34,13)) Rx pst.Str(String(13)) pst.str(String("La réponse à ta requete est la suivante 9: ",9)) pst.Str(@AT_Reponse) pst.Str(String(13)) waitcnt(clkfreq*3+cnt) gsm.str(string("AT+CHTTPACT=",34,"www.choupi.com",34,",80",13)) Rx pst.Str(String(13)) pst.str(String("La réponse à ta requete est la suivante 10: ",9)) pst.Str(@AT_Reponse) pst.Str(String(13)) waitcnt(clkfreq*3+cnt) ' gsm.str(string("GET /index.php HTTP/1.1",26)) gsm.str(string("GET /index.php? HTTP/1.1 ")) ' gsm.str(String("HTTP/1.1",13,10)) gsm.str(String("Host: www.choupi.com ",13,26)) ' ' gsm.str(String("www.smart-wine-cellar.com",13,10)) ' gsm.str(String("User-Agent: MY WEB AGENT",13,10)) ' gsm.str(String("Content-Length: 0",13,10,13,10,26)) Rx pst.Str(String(13)) pst.str(String("La réponse à ta requete est la suivante 11: ",9)) pst.Str(@AT_Reponse) pst.Str(String(13)) waitcnt(clkfreq*2+cnt) Rx pst.Str(String(13)) pst.str(String("La réponse à ta requete est la suivante 12: ",9)) pst.Str(@AT_Reponse) pst.Str(String(13)) waitcnt(clkfreq*2+cnt) Rx pst.Str(String(13)) pst.str(String("La réponse à ta requete est la suivante 13: ",9)) pst.Str(@AT_Reponse) pst.Str(String(13)) waitcnt(clkfreq*2+cnt) PUB Rx Rx_GSM Pub Rx_GSM GSM.RxFlush repeat char := GSM.Rx pst.dec(char) while (char <> 10) RxPacketNow_GSM Pri RxPacketNow_GSM | valeur ptr := 0 ptr1 := 0 Repeat char := GSM.Rx pst.dec(char) AT_Reponse[ptr++] := Char while Char <> 13 AT_Reponse[--ptr] := 0
And I get this answer (image is attached)
The last line, I get as answer +CHTTPACT: 237 and I think that I should have : +CHTTPACT: DATA, (number of data).
Then I should have an other line that says that the communication is successful (+CHTTPACT:0)
If anyone has a hint, I would appreciate
Comments
Is the url complete, to me it looks incomplete (missing some text after the ?):
http://www.choupi.com/index.php?
And trying to access it results in a 404 error
When I access the website via a browser, nothing changes even if I put a variable after the "?"
Could it be the comma before the closing quote ( "AT+CGSOCKCONT=1,",34, ) as in the repeat loop below?
check with after the CSOCKAUTH command
Anyway according to the HTTP application note (http://simcom.ee/documents/SIM5320/sim52xx_http_application_note_v0.02.pdf)
you might want to try this (normally there would be no need for the host or content-length, but I'm not sure if the modem needs it)
I little off topic, but it would be interesting if you could post details of your GSM interface module and circuit.
Many thanks.
Firstly, if I take this three sentences :
my code doesn't work fine but I have a good start.
My complete code is the following:
And my answers are attached (the first loop is the image "Answers1" and the second loop is "Answers2")
Two answers are different, I don't understand why
Secondly, I haven't got all steps that give the datasheet because I haven't got "OK" and "+CHTTPACT: DATA, (number of data)":(simcom.ee/documents/SIM5320/sim52xx_http_application_note_v0.02.pdf
Therefore I don't think that it works fine because my URL doesn't change
And it is working as you get a response back on you request, just a bit different as described in the document
+HTTPACT: REQUEST indicates that the request is handled
Followed by the response data
+HTTPACT: 0 indicates the end of the response
Having a repeat loop ending when +HTTP:ACT: 0 is received will get you the complete HTTP response
I am wondering if it is normal that my URL doesn't change when I send a variable with the "GET" method?
What is my variable that I want send on web page is in correct position in the frame?
So you need to change that in order to change it in your URL. I hope that is what you're asking?
The response from the smart-wine-cellar seems to just echo back what you supply, so I'm not sure how useful it is (or it is just used for testing?)
You'll need to parse the response in order to get the result coming back from smart-wine-cellar,which might be a bit difficult as spin is not very good at string handling. There is a string library in the obex, that might make life easier:
http://obex.parallax.com/object/579
I would like to send the variable "latitude" on a web page for record this variable in a database.
Is it possible? And how do I do if it is possible because I try to retrieve the variable for one week but without results.
I already made a php script for retrieve the variable with "GET" method.
I would make the response to the retrieval simpler, no html for instance, just the latitude returned and some indication if it went wrong, like
That way parsing is easier and you could use something like this (not tested at all, and URL used is 'made up')
So I want to send the variable with the propeller C3 by the "GET" method on a web page, which is www.smart-wine-cellar and retrieve this variable sent by the propeller with a PHP script ($latitude=$_GET;) for recording the variable in the database.
I use $_GET in PHP script because I use "GET" method for sending of the variable in spin program
In php the $_GET is an array so to read the latitude you would need this statement in PHP
Make sure you 'clean/check' $latitude before you use/store it to prevent errors (like inserting links or SQL queries in the variable), unless you're 100% sure no one else has access to the website
EDIT: see http://php.net/manual/en/reserved.variables.get.php
I sent a string variable whereas for record my variable into the database, my variable had to be a integer