PDA

View Full Version : writing master number in eeprom for sms controler simple example



xxxxxx
- 21st May 2009, 00:58
here is a simple example, not so optimized :D, how to set up a master number for sms controller...hope someone find this usefull!!!


'
'pic defines
'------------------------------------------------------------------------
@ DEVICE pic16F887, WDT_OFF ' Watchdog Timer
@ DEVICE pic16F887, PWRT_ON ' Power-On Timer
@ DEVICE pic16F887, MCLR_ON ' Master Clear Options (Internal)
@ DEVICE pic16F887, BOD_ON ' Brown-Out Detect
@ DEVICE pic16F887, LVP_OFF ' Low-Voltage Programming
@ DEVICE pic16F887, CPD_OFF ' Data Memory Code Protect
@ DEVICE pic16F887, PROTECT_OFF ' Program Code Protection
'
'
'------------------------------------------------------------------------

eeprom 128,["MP"]
.
.
.
'
'wait for sms
'-------------------------------------------------------------------------
HSERIN 5000,ws,[WAIT("REC UNREAD"),skip 3,str telbr\12,skip 12,str TIME\6,skip 8,STR PORUKA\3\13]'trazi, cekaj unread
pause 3000

FOR h=128 TO 129'read out command from eeprom
READ h,tbr[H]
NEXT h

flag=1
FOR h=0 to 1
if poruka[h+1]<>tbr[h+128] then flag=0 'check the command message
next h

if flag=1 then gosub s6 'go and write last 4 numbers in eeprom


'
' CHECK THE USER FOR EVERU SMS COMMAND
'-------------------------------------------------------------------


FOR y=48 TO 51
READ y,telbrmp[y]
NEXT y
lcdout $FE,1,"x","x",telbrmp[48],telbrmp[49],telbrmp[50],telbrmp[51]
pause 1000


broj=1
for x=8 to 11
if TELBR[x]<>TELBRmp[x+40] then broj=0
next x
lcdout $FE,$c0,"x","x",TELBR[8],TELBR[9],TELBR[10],TELBR[11]
pause 2000

IF broj=0 then gosub s4 ' if the numebers dont fit send sms no right's

s6:
FOR x=8 TO 11
WRITE x+40,telbr[x]'upisi master broj u eeprom
NEXT x
lcdout $FE,1,"YOUR MASTER NMB"
LCDOUT $FE,$C0,"+38761XX",TELBR[8],TELBR[9],TELBR[10],TELBR[11]
PAUSE 2000
lcdout $fe,1
return

s4:
LCDOUT $FE,1,"nemate prava!"
HSerout ["AT",13,10]
Pause 1000
HSerout ["AT+CMGF=1",13,10] 'Postavi Text Mode
Pause 1000
HSerout ["AT+CMGS=",34,str telbr\12,34,",129",13,10]
pause 500
HSerout ["nemate prava",str time\6,13,10]
s12:
HSerout [26]
hserin 6000,s12,[WAIT("OK")]