manuva
Newbie level 5
Hi everyone in this forum.Again I come searching for help.On my first post I got direction on how I can write program to interface gsm modem to read and send sms. Now from different tutorials I learn different things in this forum and I wrote the following program using MikroC pro PIC.
but when I interface with physical hardware by using compim does not perform what I programmed please any one to correct me or give another alternative to this.
I appreciate your comments.................................
Welcome.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 unsigned char i=0,yesgot=0,msg[100]; unsigned int storedloc=0,gotit; unsigned char ph[14]; unsigned char *ph1[]="+255657741768"; unsigned char rx_incoming(); unsigned char rx_incoming() { while(PIR1.RCIF==0); return RCREG; } void main() { trisc.f6=0;trisc.f7=1; trisd=0x00;portd=0x00; trisb.f4=0;trisb.f5=0; portb=0; uart1_init(9600);delay_ms(100); RCSTA.SPEN=1;RCSTA.CREN=1; delay_ms(50); uart1_write_text("ate0"); uart1_write(0x0d); delay_ms(40); uart1_write_text("at+cmgf=1");uart1_write(0x0d); loop1: storedloc=0; while(storedloc==0) { gotit= rx_incoming(); if(gotit=='+') { gotit= rx_incoming(); if(gotit=='C') { gotit=rx_incoming(); if(gotit=='M') { gotit=rx_incoming(); if(gotit=='T') { gotit=rx_incoming(); if(gotit=='I') { gotit=rx_incoming(); if(gotit==':') { gotit=rx_incoming(); while(gotit!=',') gotit=rx_incoming(); storedloc=rx_incoming(); } } } } } } } delay_ms(100); uart1_write_text("at+cmgr="); uart1_write(storedloc); uart1_write(0xd); while(yesgot==0) { gotit=rx_incoming(); if(gotit=='+') { gotit=rx_incoming(); if(gotit=='C') { gotit=rx_incoming(); if(gotit=='M') { gotit=rx_incoming(); if(gotit=='G') { gotit=rx_incoming(); if(gotit=='R') { gotit=rx_incoming(); if(gotit==':') { gotit=rx_incoming(); while(gotit!=','){gotit=rx_incoming();}; if(gotit='"') { for(i=0;i<13;i++){gotit=ph[i]=rx_incoming();} } while(gotit!=0x0a){gotit=rx_incoming();} for(i=0;gotit!=0x0d;i++){gotit=msg[i]=rx_incoming();} uart1_write_text("at+cmgd="); uart1_write(storedloc);uart1_write(0x0D); yesgot=1; } } } } } } } if(strcmp(ph,ph1)==0) { if(msg[0]=='O') { if(msg[1]=='N') { if(msg[2]==32) { portb.f5=1;portb.f4=0; } } } if(msg[0]=='O') { if(msg[1]=='F') { if(msg[2]=='F') { if(msg[3]==32) { portb.f4=1; portb.f5=0; } } } } } else if(strcmp(ph,ph1)!=0) { portd.f7=0;delay_ms(500); uart1_write_text("at+cmgf=1"); uart1_write(0x0D); delay_ms(100); uart1_write("at+cmgs="); delay_ms(100); uart1_write(0x22); delay_ms(100); uart1_write(ph); delay_ms(100); uart1_write(0x22); uart1_write(0x0D); delay_ms(500); uart1_write_text("Your not Authorized."); uart1_write(0x0D);delay_ms(500); uart1_write_text("For help contact :"); uart1_write(0x0D);delay_ms(500); uart1_write_text("+255657741768: J.E.MASSAM."); uart1_write(0x0D);delay_ms(1000); uart1_write(0x1A);delay_ms(500); } yesgot=0;storedloc=0;gotit=0; delay_ms(1000); goto loop1; }
but when I interface with physical hardware by using compim does not perform what I programmed please any one to correct me or give another alternative to this.
I appreciate your comments.................................
Welcome.