#include "DS89C4XX.h"
#include "stdio.h"
void main()
{
char c;
char aa[40];
int i=0;
/**********Serial port initialization**************************/
SCON0 = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */
TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */
TH1 = 252; /* TH1: reload value for 14400 baud @ 22.1184MHz */
TR1 = 1; /* TR1: timer 1 run */
TI_0 = 1; /* TI: set TI to send first char of UART */
/************End of serial port initialization****************/
P1 = 0x0F; //to see if the LEDs blink conencted to P1 port
msdelay(20000);
P1 = 0xF0; //to see if the LEDs blink conencted to P1 port
msdelay(20000);
/*Printing string in LCD before sending command to GPRS module*/
printchar(0,0, "Sending AT command");
/*Sending AT command using serial port*/
printf("AT\n");
/*Waiting for the response*/
scanf("%s", &aa);
/*There is a LCD to show the result. I deleted the LCD codes for simplicity
The LCD was showing outptu when conencted to PC terminal.
But it was not showing the output when conencted to GPRS module.*/
printchar(0,0, aa);
while(1);
}
import MDM
import MOD
ip='IP'
apn = 'internet'
server = '0.0.0.0'
MDM.send('AT+CGDCONT=1,'+ip+','+apn+','+server+'\r',0)
res = MDM.receive(20)
print res
username = 'whatever'
password = 'whatever'
MDM.send('AT#USERID='+username+'\r',0)
res = MDM.receive(20)
print res
MDM.send('AT#PASSW='+password+'\r',0)
res = MDM.receive(20)
print res
MDM.send("AT#GPRS=1\r",0)
res = MDM.receive(80)
print res
MDM.send('AT$GPSACP\r',0)
gps = 'This is GPS data:'+MDM.receive(30)
gps = gps.replace(' ','')
gps = gps.replace('\r','') # This is to remove unwanted characters
gps = gps.replace('\n','') # from the gps output.
gps = gps.replace('OK','')
print gps
web = 'www.e-secretary.net'
MDM.send('AT#SKTD=0,80,'+web+'\r',0)
res = MDM.receive(50)
print res
req1 = 'GET /gps/dgl.php?name='+gps+' HTTP/1.0'
req2 = 'Host: '+web
req3 = 'Connection: keep-alive'
MDM.send(req1,0)
MDM.sendbyte(0x0d,0)
MDM.sendbyte(0x0a,0)
res = MDM.receive(10)
MDM.send(req2,0)
MDM.sendbyte(0x0d,0)
MDM.sendbyte(0x0a,0)
res = MDM.receive(10)
MDM.send(req3,0)
MDM.sendbyte(0x0d,0)
MDM.sendbyte(0x0a,0)
MDM.sendbyte(0x0d,0)
MDM.sendbyte(0x0a,0)
res = MDM.receive(100)
print res
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?