Envoi SMS avec c

hb008
Messages postés
3
Date d'inscription
mercredi 4 novembre 2009
Statut
Membre
Dernière intervention
7 mars 2012
- 24 févr. 2010 à 19:22
BOUABIDIALI
Messages postés
2
Date d'inscription
dimanche 6 mai 2012
Statut
Membre
Dernière intervention
22 mai 2012
- 22 mai 2012 à 13:01
[b]je veu faire un projet sur l' Envoi SMS lors d'un alarme en utilisant module gsm programmeé en C par une pic 16f877A
je serai tres reconnaissant pour tout personne qui peut m'aider
Merci/b

2 réponses

BOUABIDIALI
Messages postés
2
Date d'inscription
dimanche 6 mai 2012
Statut
Membre
Dernière intervention
22 mai 2012

22 mai 2012 à 12:41
comment envoyer un sms en utilusant les commande AT avec le logiciel PIC COMPALIER
0
BOUABIDIALI
Messages postés
2
Date d'inscription
dimanche 6 mai 2012
Statut
Membre
Dernière intervention
22 mai 2012

22 mai 2012 à 13:01
mon sujet de pfe est un systeme de surveillance par gsm,j'ai fait la sumilation de mon code sur un montage isis composé:un afficheur lcd,un hyperterminal ,une clavier 12 touches,un pic 18f4620,6 switchers et 3 leds:j'aime bien aider pour otimoser mieux mon
code suivante;

#include "D:\telesurv\test9.h"
//#include "D:\PROJ222\AAAAA.h"
#define use_portb_kbd TRUE
#include <string.h>
#include <kbd.c>
#define use_portb_lcd TRUE
#include <lcd.c>
#int_RTCC
void RTCC_isr(void)
{

}
int VrfCdUs (char *);void menu300();
void initialisation();
void coderronne();void test();
int testetat( );void Afficheetat(int );
void tapecode();void affpourcode (int x);
void menu1(); void menu4();void menu2();
void menu3();void menu5();void menu6();void menu31();
void menu541();void menu531();void menu532();
void menu0();void affichemenu(long );
void menu61();void menu62();void menu99();
void menu63();void menu64();void menu520();void menu530();void menu20();
void menu65(); void menu21();int1 verifpass();
void entercode();int1 verifcode(long );
void modif(int nbtch,long adresse,long nex,long ret);
//char message[20]="";

char codesystem[8];
char cd[8];
char pass[9];
char gs[8];
//char cmaster[9];//////////////////////
char codetaped[9];
char capteur=0,capteur_ancien=255;
int1 actsys=False,sirene=false,codeblok=false,defaut=false,activemenu=true;
int codeselect,repcode=0,nbrusr;
long menuAff=0,ancien_menuAff=18,retour;
int attente=2;
int y,x,b=0;
int RT;// RT=Relay Time
int ST;// ST=Siren Time
int ENT;//EXT=Delay Time
int EXT;//Ext=Exit Time
void main()
{
printf("debut du programme");
initialisation();

while (activemenu)
{
//printf("menue %d ancien",menuaff);
if (ancien_menuAff!=menuAff)
{

ancien_menuAff=menuAff;
affichemenu(menuaff);
}
}
while(1)
{
//printf("xxxxx");
if (actsys)
{
capteur_ancien=capteur;
capteur=testetat();
if (capteur!=capteur_ancien)
test();
}
test();
tapecode();
}
}

void initialisation()
{
int i;
port_b_pullups(true);

kbd_init();

lcd_init();
EXT=(read_eeprom(14)-48)*10+read_eeprom(15)-48;
ENT=(read_eeprom(12)-48)*10+read_eeprom(13)-48;
ST=(read_eeprom(10)-48)*10+read_eeprom(11)-48;
RT=(read_eeprom(8)-48)*10+read_eeprom(9)-48;

}

int VrfCdUs (char *usercode)
{
int comp;
comp=strcmp(usercode,codesystem);
printf("\n -%s- -%s-",usercode,codesystem);
repcode++;
if (comp==0)
{
comp=1;
repcode=0;codeblok=false;actsys=!actsys;
lcd_putc("\fCode valide:");
repcode=0;sirene=false;
if (actsys)
lcd_putc("\nAlarm ON");
else
lcd_putc("\nAlarm OFF");
}
else
comp=0;
return (comp);
}
int testetat()
{
char *message;
int1 P,F,B1,B2,Z1,Z2;
int1 Err;
int y=0;
P=input(pin_D0);F=input(pin_D1);
B1=input(pin_D2);B2=input(pin_D3);
Z1=input(pin_D4);Z2=input(pin_D5);
if (P)
y=y+1;
if (F)
y=y+2;
if (B1)
y=y+4;
if (B2)
y=y+8;
if (Z1)
y=y+16;
if (Z2)
y=y+32;
if(y>0)
{
defaut=true;
//sirene=true;
}
else
{
sirene=false;defaut=false;
}
return (y);
}

void menu0()
{
int x;
char t=0;
lcd_putc("\f");
if (actsys)
lcd_putc("ALARME ON");
else
lcd_putc("ALARME OFF");
lcd_putc("\n1:ALARME 2:\SETUP");
while ((t!='1') && (t!='2'))
t=kbd_getc();
switch (t)
{
case '1':{menuAff =1;break;}
case '2':{menuAff =20;break;}
}
t=0;
}

void menu1()
{
char t=0;
lcd_putc("\f");
lcd_putc("1:ALARME on/off \n2:\STATUS");
while ((t!='1') && (t!='2') && (t!='#'))
t=kbd_getc();
switch (t)
{
case '1':menuAff=2;break;
case '2':menuAff=3;break;
case '#':menuAff=0;break;
t=0;
}
}

void menu4()
{
char t=0;
menuAff =4;
lcd_putc("\f");
lcd_putc("1:SETUP USER\n2:SETUP SYSTEM");
while ((t!='1') && (t!='2')&& (t!='#'))
t=kbd_getc();
switch (t)
{
case '1':menuAff =5;break;
case '2':menuAff =6;break;
case '#':menuAff =0;break;
}
t=0;
}


void menu2()
{char cd[8],t;
int i;
lcd_putc("\fALARME ON/OFF");
lcd_putc("\nUser code:");
//menu530();
tapecode();/////////////////////////////////////////////////////////////////////
//entercode();
//!for(i=0;i<8;i++)
//!cd[i]=read_eeprom(38+i);
//!lcd_putc(cd[i]);
//!while(t==0)
//!t=kbd_getc();
//!while((t!='*')&&(t!='#'))
//!switch(t)
//!{case '*':delay_ms(500);for(i=0;i<8;i++)
//!if(cd[i]==codetaped[i])
//!lcd_putc("\f code valide");break;

}





void menu3()
{
char t=0;
capteur=testetat();capteur_ancien=capteur;
lcd_putc("\f");
if (actsys)
lcd_putc("Alarm ON ");
else
lcd_putc("Alarm OFF ");
lcd_putc("# to exit\n");
afficheetat(capteur);
test();

while (t!='#')
{
t=kbd_getc();
capteur=testetat();
if (capteur_ancien!=capteur)
{
capteur_ancien=capteur;
lcd_putc("\f");
if (actsys)
lcd_putc("Alarm ON ");
else
lcd_putc("Alarm OFF ");
afficheetat(capteur);
lcd_putc("# to exit");
}
}
menuAff =1;
}

void menu5()
{
char t=0;
menuAff =5;
lcd_putc("\f");
lcd_putc("1:MASTER CODE\n2:USER CODE/GSM");
while ((t!='1') && (t!='2')&& (t!='#'))
t=kbd_getc();

switch (t)
{
case '1':menuAff =51;break;
case '2':menuAff =520;break;
case '#':menuAff =0;break;
}
t=0;
}

void menu51()
{
menuAff=51;
lcd_putc("\f MASTER CODE:\n ");
modif(8,0,5,51);
if (menuaff==5)
{ delay_ms(500);lcd_putc("\fSAVE MATER CODE");}
}

void menu520()
{
char t=0;
menuAff =520;
lcd_putc("\f");
lcd_putc("1:USER CODE\n2:USER GSM");
while ((t!='1') && (t!='2')&& (t!='#'))
t=kbd_getc();

switch (t)
{
case '1':menuAff =531;break;
case '2':menuAff =52;break;
case '#':menuAff =5;break;
}
t=0;
}

void menu52()
{
int nu=-1;
char t=0;
int1 r=false;
menuAff=52;
lcd_putc("\f GSM NUMBER:");
while (!r)
{
while (t==0)
t=kbd_getc();
if (((t=='*')&&(nu!=-1))||(t=='#'))
r=true;
else
if (t!='*')
{nu=t-48;
if ((nu==1)||(nu==2)||(nu==3)||(nu==4)||(nu==5))
{lcd_gotoxy(14,1);lcd_putc(t);t=0;r=false;}
else
{t=0;}}
}
switch (t)
{
case '*':nbrusr=nu;menuAff=541;break;
case '#':{menuAff =99;retour=52;break;}
}
}

void menu541()
{
char t=0,i,dep;
menuAff=541;
dep=8+(nbrusr)*8;
lcd_putc("\fGSM(");lcd_putc(nbrusr+48);lcd_putc("):");
for (i=0;i<8;i++)
{//lcd_putc(read_eeprom(i+dep));
gs[i]=read_eeprom(i+dep);////////////////////////////////////////////////////
lcd_putc(gs[i]);
}
lcd_putc("\n*MDF 2_DEL #EXIT");
t=0;
while ((t!='2')&&(t!='*')&&(t!='#')&&(t!='1'))
t=kbd_getc();
printf("\rtouche =%c",t);
switch(t)
{
case '1':for(i=0;i<8;i++)
lcd_putc(gs[i]);break;
case '*':menuaff=54;break;
case '#':menuaff=520;break;
case '2':{for (i=0;i<8;i++)
{write_eeprom(i+dep,'?');delay_ms(100);};menuaff=64;retour=541;t=0;break;}
}
t=0;break;
}

void menu54()
{
char t=0,i,dep;
menuAff=54;
dep=8+(nbrusr)*8;
lcd_putc("\fGSM(");lcd_putc(nbrusr+48);lcd_putc("):");
for (i=0;i<8;i++)
lcd_putc(read_eeprom(i+dep));
lcd_putc("\nNew GSM:");
modif(8,dep,541,54);
if (menuaff==5)
{ delay_ms(500);lcd_putc("\fUser GSM Saved");delay_ms(500);}
}
void menu531()
{
{
int nu=-1;
char t=0;
int1 r=false;
menuAff=531;
lcd_putc("\f USER NUMBER:");
while (!r)
{
while (t==0)
t=kbd_getc();
if (((t=='*')&&(nu!=-1))||(t=='#'))
r=true;
else
if (t!='*')
{nu=t-48;
if ((nu==1)||(nu==2)||(nu==3)||(nu==4)||(nu==5)||(nu==6)||(nu==7)||(nu==8)||(nu==9)||(nu==0))
{lcd_gotoxy(14,1);lcd_putc(t);t=0;r=false;}
else
{t=0;}}
}
switch (t)
{
case '*':nbrusr=nu;menuAff=530;break;
case '#':{menuAff =99;retour=531;break;}
}
}

}

void menu530()
{
char t=0,i,dep;
menuAff=530;
dep=56+(nbrusr)*8;
lcd_putc("\fcode(");lcd_putc(nbrusr+48);lcd_putc("):");
for (i=0;i<8;i++)
{cd[i]=read_eeprom(i+dep);
lcd_putc(cd[i]);
}//lcd_putc(read_eeprom(i+dep));
lcd_putc("\n*MDF 2_DEL #EXIT");
t=0;
while ((t!='2')&&(t!='*')&&(t!='#'))
t=kbd_getc();
switch(t)
{
case '*':menuaff=532;delay_ms(500);retour=532;break;
case '#':menuaff=520;delay_ms(500);retour=520;break;
case '2':{for (i=0;i<8;i++)
{write_eeprom(i+dep,'?');delay_ms(100);};menuaff=530;break;}
}
}

void menu532()
{
char t=0,i,dep;
menuAff=532;
dep=56+(nbrusr)*8;
lcd_putc("\fCODE(");lcd_putc(nbrusr+48);lcd_putc("):");
for (i=0;i<8;i++)
lcd_putc(read_eeprom(i+dep));
lcd_putc("\nNew CODE:");
modif(8,dep,530,532);
if (menuaff==5)
{ delay_ms(500);lcd_putc("\fUser CODE Saved");delay_ms(500);}
}

void menu53()
{
char t=0,i,dep;
menuAff=53;
dep=56+(nbrusr)*8;
lcd_putc("\fCD US(");lcd_putc(nbrusr+48);lcd_putc(')');
for (i=0;i<8;i++)
lcd_putc(read_eeprom(i+dep));
lcd_putc("\nNew Cde:");
modif(8,dep,54,53);
if (menuaff==54)
{ delay_ms(500);lcd_putc("\fUser Code Saved");delay_ms(500);}
}

void menu6()
{
char c=0;
menuAff=6;
printf(lcd_putc,"\fLast RT:%c%c\nNew RT:",read_eeprom(8),read_eeprom(9));
modif(2,8,61,6);
if (menuaff==61)
{ delay_ms(500);lcd_putc("\fSAVE RELAY TIME");delay_ms(500);RT=(read_eeprom(8)-48)*10+read_eeprom(9)-48;}
}

void menu61()
{
menuAff=61;
printf(lcd_putc,"\fSIREN TIME:%c%c\nSIREN TIME:",read_eeprom(10),read_eeprom(11));
modif(2,10,62,61);
if (menuaff==62)
{ delay_ms(500);lcd_putc("\fSave SIREN TIME");delay_ms(500);ST=(read_eeprom(10)-48)*10+read_eeprom(11)-48;}
}

void menu62()
{
menuAff=62;
printf(lcd_putc,"\fDELAY ENT IME:%c%c\nDELAY ENT TME:",read_eeprom(12),read_eeprom(13));
modif(2,12,63,62);
if (menuaff==63)
{ delay_ms(500);lcd_putc("\fSave ENTRY DELAY TIME");delay_ms(500);ENT=(read_eeprom(12)-48)*10+read_eeprom(13)-48;}
}

void menu63()
{
menuAff=63;
printf(lcd_putc,"\fDELAY EXT TME:%c%c\nDELAY EXT TME:",read_eeprom(14),read_eeprom(15));
modif(2,14,4,63);
if (menuaff==4)
{ delay_ms(500);lcd_putc("\fSYSTEM READY TO USE");delay_ms(500);EXT=(read_eeprom(14)-48)*10+read_eeprom(15)-48;}
}

void menu64()
{
delay_ms(100);
menuAff =retour;
}

void menu99()
{
menuAff=99;
delay_ms(500);lcd_putc("\fRepeat Last opertaion");delay_ms(500);
menuAff=retour;

}

void affichemenu(long x)
{
printf("\rmenue affiché (%lu)",x);
switch (x)
{
case 0:menu0();break;
case 1:menu1();break;
case 2:menu2();break;
case 21:menu21();break;
case 3:menu3();break;
case 4:menu4();break;
case 5:menu5();break;
case 6:menu6();break;
case 61:menu61();break;
case 99:menu99();break;
case 62:menu62();break;
case 63:menu63();break;
case 64:menu64();break;
case 51:menu51();break;
case 520:menu520();break;
case 52:menu52();break;
case 53:menu53();break;
case 54:menu54();break;
case 541:menu541();break;
case 530:menu530();break;
case 531:menu531();break;
case 532:menu532();break;
case 20:menu20();break;
//case 300:menu300();break;
}
}

void Afficheetat(int y)
{
char *message;
int1 P,F,B1,B2,Z1,Z2,v;
char Po[3]="p ",Fe[3]="F ",Bo1[4]="B1 ",Bo2[4]="B2 ",Zo1[4]="Z1 ",Zo2[4]="Z2 ";
int1 Err;
P=input(pin_D0);F=input(pin_D1);
B1=input(pin_D2);B2=input(pin_D3);
Z1=input(pin_D4);Z2=input(pin_D5);
v=B1*F*B2*Z1*Z2;
if (P)
{
lcd_putc("Po ");
}
if (F)
{
lcd_putc("Fe ");
}
if (B1)
{
lcd_putc("Bo1 ");
}
if (B2)
{
lcd_putc("Bo2 \n");
}
if (Z1)
{
lcd_putc("Zo1 ");
}
if (Z2)
{
lcd_putc("Zo2 ");
}
if (y==0)
lcd_putc("No error");
else if(v==0)
output_high(pin_a1);
}

void coderronne()
{
if (repcode<3)
{
affpourcode (repcode);
//printf("\n Recode=%d \n",repcode);
}
else
{
lcd_putc("\fUndifined User:");
output_high(PIN_A1);
codeblok=true;printf("\n Recode=%d \n",repcode);
}
}

void test()
{
int y=0;
if (codeblok)
sirene=true;

if (actsys)
{
y++;
delay_ms(attente*1000);
if (defaut)
sirene=true;
}
if (sirene)
y=y+2;
if (defaut)
y=y+4;
output_a(y);
}

void tapecode()
{
char c=0;int i=0,n=0;
int1 cdtap=false,exitmenu=false;
affpourcode (repcode);
while (!exitmenu)
{while(n<8)
{while (c==0)
c=kbd_getc();
if ((c!='*') && (c!='#'))
{
lcd_putc('*');printf("%c",c);
for(i=0;i<8;i++)/////////////////////////////////////////
codetaped[i]=c;n++;
codetaped[i]='\0';c=0;
}
}
if (c=='#')
{
printf("\n Repcode=%d \n",repcode);
if (cdtap||(i==0))
{
exitmenu=true;menuaff=1;
}
else
{
affpourcode (repcode);i=0;c=0;
}
}
if (c=='*')
{
printf("#%s# ---> #%s# ",codesystem,codetaped);i=0;
codeselect=VrfCdUs (codetaped);
printf(" comparaison =%d",codeselect);cdtap=true;c=0;
if (codeselect==1)
{
capteur=testetat();
delay_ms(2000);
exitmenu=true;menuaff=3;
}
else
coderronne();
}
}
}

void affpourcode (int x)
{
lcd_putc("\fAlaram ");
if (actsys)
lcd_putc("ON");
else
lcd_putc("OFF");
lcd_putc("(");lcd_putc(repcode+49);lcd_putc("):\n");
//lcd_putc("Press # to exit\n");
lcd_putc("User Code:");
}

void modif(int nbtch,long adresse,long nex,long ret)
{
char num[9],t;
int nbrtch=0,i=0;

while (nbrtch<nbtch)
{
while ((t==0)||(t=='*')||(t=='#'))
t=kbd_getc();
num[nbrtch]=t;
nbrtch++;
lcd_putc(t);
t=0;
}
t=0;
while ((t!='*')&&(t!='#'))
t=kbd_getc();
//printf("\rmodif %d %d %c\r",nbtch,adresse, t);
switch (t)
{

case '*':{menuAff =nex;for (i=0;i<nbtch;i++)
{write_eeprom(adresse+i,num[i]);delay_ms(100);};break;}
case '#':{menuAff =99;retour=ret;break;}
}
}

void menu21()
{
int1 u;
menuaff=21;
lcd_putc("\fEnter MSTR Code:");
entercode();
u=verifcode(0);
printf("\r res==%d menu=%lu==>code[0]=%d",u,menuaff,codetaped[0]);
if (codetaped[0]!='?')
break;
if (codetaped[0]!='\0')
if (u)
{menuaff=4;lcd_putc("\faccess autorized");delay_ms(500);break;}
else
{menuaff=0;lcd_putc("\faccess denied");delay_ms(500);break;}
else
{retour=21;menuaff=99;break;}
}

void entercode()
{
char t=0;
int nbrtch=0,i=0;
lcd_gotoxy(1,2);lcd_putc(" ");lcd_gotoxy(5,2);
while (nbrtch<8)
{
while ((t==0)||(t=='*'))
t=kbd_getc();
codetaped[nbrtch]=t;
nbrtch++;
if (t=='#')
{ codetaped[0]='?';nbrtch=8;t='?';}
else
{lcd_putc('*');t=0;}
}
while ((t!='*')&&(t!='#')&&(t!='?'))
t=kbd_getc();
//printf("\rmodif %d %d %c\r",nbtch,adresse, t);
switch (t)
{
case '*':{codetaped[8]='\0';break;}
case '#':{codetaped[0]='\0';menuaff=21;break;}
case '?':{codetaped[0]='?';menuaff=0;break;}
}
}

int1 verifcode(long adresse)
{
long i=0;int1 j=true;
for (i=0;i<8;i++)
j=j&&(codetaped[i]==read_eeprom(adresse+i));
return (j);
}
void menu20()
{int val;
val=read_eeprom(0);
if(val==0)
{delay_ms(500);
menuaff=4;}
else
//delay_ms(500);
menuaff=21;
}
int msge()
{

//printf("(at+cmgs="gs[i]");
}
0