Code:'--------------------------------------------------------------------- ' provjeri sms inbox '--------------------------------------------------------------------- main: p: HSerout ["ATZ",13,10] ' pocni komunikaciju,resetuj modem! HSERIN 4000,p,[WAIT("OK")] tm: HSerout ["AT+CMGF=1",13,10] 'postavi text mod HSERIN 2000,tm,[WAIT("OK")] m: HSEROUT["AT+CPMS=",34,"SM",34,13,10] 'ciljana memory lokacija HSERIN 2000,m,[WAIT("OK")] ws: gosub sc1 'odi provjeri temperaturu HSEROUT["AT+CMGL",13,10] 'filter za query LCDOUT $FE,1,"cekaj sms!" HSERIN 5000,ws,[WAIT("REC UNREAD"),skip 3,str telbr\12,skip 12,str TIME\6,skip 8,STR PORUKA\3\13]'trazi unread lcdout $FE,1,telbr[6],telbr[7],telbr[8],telbr[9],telbr[10],telbr[11] pause 3000 tbr[6]="8" tbr[7]="3" tbr[8]="1" tbr[9]="0" tbr[10]="x"'your phone number last two digits, oli zadnje dvije cifre vaseg broja tbr[11]="y" broj=1 for x=6 to 11 if TELBR[x]<>tbr[x] then broj=0 next x lcdout $FE,$c0,tbr[6],tbr[7],tbr[8],tbr[9],tbr[10],tbr[11] pause 2000 IF broj=0 then gosub s4 grijanje[1]="U" 'turn on heating grijanje[2]="G" istaporuka2=1 FOR K=0 to 1 if poruka[K+1]<>grijanje[K+1] then istaporuka2=0 next K if istaporuka2=1 then gosub s1 'ako se sve poklapa idi na slanje poruka 'ukljucene poreosaca grijanj[1]="I" 'turn off heating grijanj[2]="G" IstaPoruka1=1 FOR L=0 to 1 if poruka[L+1]<>grijanj[L+1] then IstaPoruka1=0 'ako se slova iz naredbe ne poklapaju next L 'istaporuk1=0 if IstaPoruka1=1 then gosub s2 'ako se sve poklapa idi na slanje poruka 'iskljucenje poreosaca tmp[1]="T" 'ask for temperature in object tmp[2]="P" IstaPoruka3=1 FOR J=0 to 1 if poruka[J+1]<>tmp[J+1] then IstaPoruka3=0 'ako se slova iz naredbe ne poklapaju next j 'istaporuk1=0 if IstaPoruka3=1 then gosub s3 'ako se sve poklapa idi na slanje poruka 'temperatura u objektu ' ------------------------------------------------------------ ' brisanje poruke iz memeorije ' ------------------------------------------------------------ mm: HSEROUT["AT+CPMS=",34,"SM",34,13,10] 'ciljana memory lokacija HSERIN 2000,mm,[WAIT("OK")] d: HSEROUT["AT+CMGD=1",13,10] 'brisi poruku iz mem loc SM sa indexom 1 HSERIN 2000,d,[WAIT("OK")] LCDOUT $FE,1,"sms izbrisan!" pause 1500 GOTO ws 'subrutines '--------------------------------------------------------------- ' 'subrutine za on/off-i potrosca i obavjest korisnika o poduzetoj akciji 'i provjeru pristigle poruke '--------------------------------------------------------------- s2: if IstaPoruka1=1 then low portd.0 LCDOUT $FE,1,"isklj grijanje!" HSerout ["AT",13,10] Pause 1000 HSerout ["AT+CMGF=1",13,10] 'Postavi Text Mode Pause 1000 HSerout ["AT+CMGS=",34,"+387618310xx",34,",129",13,10] pause 500 HSerout [str poruka\3,str time\6,10,13] s21: HSerout [26] hserin 6000,s21,[WAIT("OK")] return s1: if istaporuka2=1 then high portd.0 LCDOUT $FE,1,"uklj grijanje!" HSerout ["AT",13,10] Pause 1000 HSerout ["AT+CMGF=1",13,10] 'Postavi Text Mode Pause 1000 HSerout ["AT+CMGS=",34,"+387618310xx",34,",129",13,10] pause 500 HSerout [str poruka\3,str time\6,13,10] s11: HSerout [26] hserin 6000,s11,[WAIT("OK")] return '-------------------------------------------------------------- 'temperatura sa ds1820 '-------------------------------------------------------------- sc1: OWOut ow, 1, [$CC, $44] ' pocni temp konverziju wc: OWIn ow, 4, [cr] ' provjeri da'l se jos konvertuje If cr = 0 Then wc OWOut ow, 1, [$CC, $BE] ' ocitaj temp OWIn ow, 0, [temp.LOWBYTE, temp.HIGHBYTE, Skip 4, cr, cpc] ' izracunaj temp u C na 2 decimale temp = (((temp >> 1) * 100) - 25) + (((cpc - cr) * 100) / cpc) Lcdout $fe, 1,"Trenutna temp:"' prikazi temp lcdout $FE,$c0,128,DEC (temp / 100), ".", DEC2 temp, " C"'"izaberite temp " if temp >= posttemp then gosub s3 ' ako je uslov ispunjen salji upozorenje pause 2000 ' goto sc1 return '----------------------------------------------------------------- 'prekoracenje temperature salji sms s3 pozorenja i pogresan korisnik s4 '----------------------------------------------------------------- s3: LCDOUT $FE,1, "Salji temp!" HSerout ["AT",13,10] Pause 1000 HSerout ["AT+CMGF=1",13,10] 'Postavi Text Mode Pause 1000 HSerout ["AT+CMGS=",34,"+387618310xx",34,",129",13,10] pause 500 HSerout ["Temp:",dec (temp/100),10,13] s31: HSerout [26] hserin 6000,s31,[WAIT("OK")] 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")] goto mm End
Bookmarks