Code:
GSM_Subroutine:
HSerout ["AT+CMGL=",34,"ALL",34,13] 'Check if there is new SMS. 34 is for " symbol
Hserin 5000,err,[wait(10,13,10),str command\2]
if command[0]="O" then return 'If response was just OK, then there was no SMS
if command[0]="+" then goto read_sms 'If response started with + sign then there was some sms
err:
return
read_sms:
Lcdout com,line1,"Reading SMS",rep " "\4
for l=0 to 5:command[l]=0:next l 'Clear buffer
GoSub Mobile_Number 'get mobile number from setup, to check correct admin number
HSerout ["AT+CMGL=",34,"ALL",34,13] '"ALL" is for Wavecom module. Read all SMS
' Read Caller ID etc. The timeout value in the HSERIN statement is important.
' it takes some time before the phone replies to the AT+CMGL command
HSerin 5000,ex_sms4,[wait("READ"),skip 4,waitstr command\10,skip 27,STR command\6\13] 'Number is waitstr command\10
LCDOut com,line1,"Read 1 SMS",rep " "\4,com,line2,"Command: ",str command\6
sms_delete:
HSerout ["AT+CMGD=1,4",13] 'Delete all messages
LCDOut com,line1,"Deleting SMS":pause 150
HSerin 15000,ex_sms2,[wait("OK")] 'Wait for OK (null)
LCDOut com,line1,"Deleted SMS ":Pause 1000
GoTo lcd_cls
ex_sms2: 'No new message or timeout error
LCDOut com,line2,"Error",rep " "\11:Pause 1000
GoTo sms_chk
ex_sms3:
LCDOut com,line2,"SMS Check Error":Pause 1000
GoTo sms_delete
ex_sms4: 'Wrong Number!
LCDOut com,line2,"Error phone Nbr":Pause 1000
GoTo sms_delete
I repeat again, study your GSM AT commands before attempting anything.
Bookmarks