|
|
View previous topic :: View next topic |
Author |
Message |
saeed
Joined: 07 Mar 2017 Posts: 10
|
sending sms in pdu format |
Posted: Tue Apr 04, 2017 10:46 am |
|
|
Hi
I try to send sms in pdu format and i can do it in hyperterminal. I try to send character 'S' (ascii code 53).
But when i do it via mcu, there is no result.
In addition, there is no problem in other AT commands (via MCU) and i can see the results.
MCU: PIC18F452
CCS: V5.049
Here is my code:
Code: |
#include <18f452.h>
#use delay(clock = 12000000)
#use rs232(baud=19200,xmit=PIN_C6,RCV=PIN_C7,parity=N,bits=8,ERRORS)
#include <lcd.c>
#fuses hs,nowdt
#define use_portd_lcd true
#DEFINE SIZE_BUFFER 32
char ctrlz = 26;
char Receive_String[SIZE_BUFFER];
int counter_read = 0x00;
#int_rda
void rda_isr(){
Receive_String[counter_read]=getc();
counter_read = (counter_read + 1) % SIZE_BUFFER;
}
void main(){
lcd_init();
set_tris_c(0b10000000);
enable_interrupts(int_rda);
enable_interrupts(global);
printf("ATE0\r");
delay_ms(10);
printf("AT+CMGF=0\r");
delay_ms(10);
printf("AT+CMGS=14\r");
delay_ms(10);
printf("079189XXXXXXXXXX01000C9189XXXXXXXXXX00000153");
delay_ms(10);
printf("%c",ctrlz);
}
|
Thanks in advance. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19498
|
|
Posted: Tue Apr 04, 2017 2:42 pm |
|
|
First, you are leaving out the short message service centre number, so we can't tell if this is right. Remember this is sent in decimal semi octets, coded as a continuous binary stream, so getting this right can be a pain....
What happens if you put your full message into one of the online decoders?.
<http://www.twit88.com/home/utility/sms-pdu-encode-decode>
If I put zeros in for the missing phone numbers, your message does not decode (gives a length of zero). Seems also very strange that the SMSC number has the same first couple of digits as your destination number...
Putting in Vodaphone's SMSC number and a zero for the receiver number, gives:
079144775810065011000A9200000000000000AA0153 |
|
|
saeed
Joined: 07 Mar 2017 Posts: 10
|
|
Posted: Tue Apr 04, 2017 4:48 pm |
|
|
Ttelmah wrote: | First, you are leaving out the short message service centre number, so we can't tell if this is right. Remember this is sent in decimal semi octets, coded as a continuous binary stream, so getting this right can be a pain....
What happens if you put your full message into one of the online decoders?.
<http://www.twit88.com/home/utility/sms-pdu-encode-decode>
If I put zeros in for the missing phone numbers, your message does not decode (gives a length of zero). Seems also very strange that the SMSC number has the same first couple of digits as your destination number...
Putting in Vodaphone's SMSC number and a zero for the receiver number, gives:
079144775810065011000A9200000000000000AA0153 |
Thank you Ttelmah for your answer
My SMSC number is +989350001400 and my number is +989171080000
so my code will be
Code: |
printf("079189390500410001000C9189191780000000000153");
|
I use the link below to decode messages.
http://smstools3.kekekasvi.com/topic.php?id=288
here is the result:
Code: |
SMS SUBMIT (send)
Receipt requested: no
SMSC: 989350001400
Receipient: 989171080000
TOA: 91 international, Numbering Plan: unknown
Validity: Not Present
TP-PID: 00
TP-DCS: 00
TP-DCS-desc: Uncompressed Text, No class
Alphabet: Default (7bit)
S
Length: 1
|
The strange thing is that i can send message with hyperterminal with these codes but it doesn't work on mcu. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19498
|
|
Posted: Wed Apr 05, 2017 12:51 am |
|
|
If I put your numbers into the encoder I pointed to I get a 15 length, not a 14.
So:
Code: |
AT+CMGW=15
079189390500410011000C918919178000000000AA0153
|
As you say this correctly decodes, but needs one more byte in the length.
However, I'd suspect you are trying to send things before the modem has responded. You really do need to have a 'wait_ok' routine, and wait for it to accept the commands.
The standard advice is to wait at least 20mSec after the reply from a command (remember that if you are using standard UART buffering, there are still two characters to send when the code returns from a printf), and the reply may take up to 100mSec (for standard commands) after this. Some commands can take longer.
I think you are just sending too fast. By hand from Hyperterminal, you will be seeing the replies, and at the fastest be sending quite a significant fraction of a second after each... |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|