amila133
Member level 4
I was able to dial the phone using PIC. My phone only support for PDU format.
I studied about PDU format and I sent SMS using Hyperterminal in PC through serial port.
But when I applied same methodology in PIC it doesn't work.
I need some code example to do it.If you have please send me. This is my code.
Thank You very much
I studied about PDU format and I sent SMS using Hyperterminal in PC through serial port.
But when I applied same methodology in PIC it doesn't work.
I need some code example to do it.If you have please send me. This is my code.
Code:
int i=0;
int j=0;
void main(){
const unsigned char para[3]="AT";
const unsigned char pdumode[10]="AT+CMGF=0"; //select pdu mode (o is given ; 1 is given for text mode)
const unsigned char dial[17] ="ATD0716530115;\n\r";
const unsigned char tpdu_length[11]="AT+CMGS=16"; //length of the message
const unsigned char message1[47]="069149170000F311000B914917560311F50000AA02C822"; //message
unsigned short receive;
//toPDU("It is easy to send sms messages", send);
Usart_Init(9600);
TRISB=0;
PORTB=0;
while(1) {
for(i=0;i<3; i++){
Usart_Write(para[i]); //type at
Delay_ms(200);
}
Usart_Write(0x0D);
if(Usart_Data_Ready()){
PORTB=1;
Delay_ms(4000);
PORTB=0; //set pdumode
for(i=0;i<10;i++) {
//if(command1[i]=='\0') break;
Usart_Write(pdumode[i]);
Delay_ms(200);
}
Usart_Write(0x0D);
if(Usart_Data_Ready()){
PORTB=1;
Delay_ms(4000);
PORTB=0;
for(i=0;i<11;i++) {
//if(command1[i]=='\0') break;
Usart_Write(tpdu_length[i]); //length of the message
Delay_ms(200);
}
Usart_Write(0x0D); //enter
if(Usart_Data_Ready()){
PORTB=1;
Delay_ms(4000);
PORTB=0;
for(i=0;i<47;i++){ //send message
//if(command1[i]=='\0') break;
Usart_Write(message1[i]);
Delay_ms(200);
}
PORTB=1;
Delay_ms(500);
PORTB=0;
Usart_Write(26); //ctrl+z
PORTB=1;
Delay_ms(7000);
PORTB=0;
if(Usart_Data_Ready()){
for(i=0;i<17;i++){ //dial really starting
if(dial[i]=='\0') break;
Usart_Write(dial[i]);
Delay_ms(200);
}
PORTB=1;
Delay_ms(1000);
PORTB=0;
}
}
}
}
}
}
Thank You very much