News:

;) This forum is the property of Proton software developers

Main Menu

sms read

Started by acel, Mar 18, 2022, 08:45 PM

Previous topic - Next topic

acel

 +CMT: "+1234567890",,"2022/03/18 22:01:00+12"
 TEST MESSAGE

If Cmd_Buffer[0]="+" And Cmd_Buffer[1]="C" And Cmd_Buffer[2]="M" And Cmd_Buffer[3]="T" And Cmd_Buffer[4]=":" Then
   TEL_Buffer = Mid$(Cmd_Buffer,10,11)
        Hour_Buffer = Mid$(Cmd_Buffer,36,5)

How can I get the content of the message from the incoming sms?

trastikata

Quote from: acel on Mar 18, 2022, 08:45 PMHow can I get the content of the message from the incoming sms?

Hello,

could you please elaborate a little bit on what you are actually asking:
- How to parse the message?
- How to extract a command?
- How to receive the text message from the module?
- How to request the message?
etc ...

It's just not clear what do you need help with.

shantanu@india

#2
Done SMS parsing by PIC's long back... times have changed now with loads of free data.
Anyway... Tel_buff is starting at the 8th position isn't it... your Mid$ mentions 10th position??
Hopefully you are eliminating all non-displayable characters and white spaces before parsing.. e. g CR, LF, space etc. etc.... I used to do that to get a tight compact string.
Try to find the last "... the message lies after that.
The best way is find the length of the string after eliminating all white spaces.... Construct a for loop to iterate through the string to detect all the " characters... Note the position of the " characters... Your test message can be extracted by a Mid$ command starting from the character after the last " upto the end of the string
Regards
Shantanu

dnaci

#3
@acel I share sms reading sample code block with quectel m92. You can edit for using gsm module. I assume serial communication between MCU and module.

Main:
PORTB.0=1 'Test led
p10:
HSerOut ["ATX",13,10] 'Reset module
HSerIn 1000,p10,[Wait("OK")]

tm:
HSerOut ["AT+CMGF=1",13,10] 'It opens to text mode
HSerIn 1000,tm,[Wait("OK")]

m:
HSerOut["AT+CPMS=",34,"SM",34,13,10] 'Memory checking
HSerIn 1000,m,[Wait("OK")]
mlist:
HSerOut["AT+CMGL=",34,"ALL",34,13,10] 'SMS content listing
'HSerIn 5000,mlist,[Wait("REC UNREAD"),skip 5,Str GSMNO\12,skip 34,Str MESAJ\9] 'IPHONE 34
HSerIn 5000,mlist,[Wait("REC UNREAD"),skip 5,Str GSMNO\12,skip 30,Str MESAJ\9] 'ANDROID 30
HSerOut [26]
For SAY=0 To 11
  GSMNO[SAY]=GSMNO[SAY]-48
Next
For SAY=0 To 8
  MESAJ[SAY]=MESAJ[SAY]-48
Next
Cls
Print At 1,1,"SMS GSM NO:" 'SMS sender gsm number
Print At 2,1,#GSMNO[0],#GSMNO[1],#GSMNO[2],#GSMNO[3],#GSMNO[4],#GSMNO[5],#GSMNO[6],#GSMNO[7],
             #GSMNO[8],#GSMNO[9],#GSMNO[10]  'GSM number
DelayMS 2000 
Cls
PORTB.0=0 'Test led
'SMS content is placed between MESAJ[0] and MESAJ[8]. You can increase the number of message variables.

'Delete sms
SMSDLT:
Cls
Print At 1,1,"DELETE ALL SMS"       
HSerOut ["AT+CMGD=1,4",13,10]
HSerIn 2000, SMSDLT, [Wait("OK")]'
DelayMS 1000
Cls

GoTo main


Detailed information about SMS:
http://subnets.ru/saved/sms_pdu_format.html