SmsText

Hi.

I need to read an compare the text from the incomming sms.
The incomming SMS looks like this:

Based on the text of this message i have to compare the string and make some action. Simply put, incomming sms is used as control command.
Anyone done this ?

Surely, this is just basic ‘C’ string handling?
Nothing specific to Wavecom or Open-AT?

But take a look at the Wavecom “String processing function set” in the Basic Development Guide - they may be able to help you in parsing the string…

If you control the definition of the text format you can, of course, make your life easier by specifically designing it to be easy to decode… 8)

Im not sure if i understand you right, but i was thinking to process this text as normal string. In the basic development guide i found AT Strings Service, but im not sure if this would be of help for me.

User can send sms with wrong text and i have to make some compare before i send reply. From my point of view i can compare this string thru normal c function and pass this data to sms that is used for reply. Could this be done on this way ?

That’s the ADL User Guide - not the Basic interface!

I doubt it - like it says, this is to process Standard repsonse strings - you are not looking at the standard response; you are looking at the content of the SMS.

As previously noted, the term “Basic” can be a bit misleading here :frowning:

See: wavecom.com/modules/movie/sc … ight=basic

Yes - and you can simplify that comparison by defining the format in a way that’s easy to compare.
Using fixed-width fields is one way to do it.

However, if the commands are to be entered manually by people, you may prefer to make the format such that they’re easier to enter - and put some extra effort into parsing them.

As ever, it’s a tradeoff - and you need to consider the requirements of your application (including your customers!) to determine the best course…

You got that right :confused:

I done this, but i im not sure how to process this incomming text. This incoming text is used as command and after i make compare i send ( as reply ) some early defined message from array on messages.

So maybe the right question would be, how to take the text from the incomming smsText , so i can compare it to my defined words.

The text is supplied as a parameter to your message handler - you just use it!

Read the description of the ADL SMS Service in the ADL User Guide!

Hi!!

While using SMS API, whenever SMS comes, it goes to the SMS DATA HANDLER. The SMS handler conists of 3 parameters:

SmsTel: Consists of Telephone Number from where the message came
SmsTimeOrLength: The date and Time
SmsText: The text which is sent.

In that SMS Data Handler, try this code

bool Sms_Handler( ascii * SmsTel, ascii * SmsTimeOrLength, ascii * SmsText )
{
	ascii buffer[20]= "Text";  // Text to be compared
	if(wm_strcmp( buffer,SmsText ) == 0)
	{
	       TRACE (( 3, " Text is Correct " ));
	}
	else
	{
		TRACE (( 3, " Text is not Correct " ));
       	}
	return TRUE;
}

I think, this might solve your problem,

With Regards,
SUNIL RAO

Thank your for the code. ! That did solve the problem.

I write some stringCompare function and the program was compiled with no errors, but it didn’t work as it should.The only thing that i did not use was the wm_strcmp function.I was using the stdio.h and normal string copy functions. :cry: On the other side, the wm_strcmp comes from strcmp ?.

I need to use the delimiter " , " becuse the sms can have multiple commands.So i guess i can not use something like ascii *s = strtok(SmsText, ", ");

If i use

then i get warning:

and the code is start to act weird after 2 sms’s.

What would you do for first and second question ?

Thanx!

Hi!

FYI, It is sufficient, if you just declare adl_global.h file, this takes care of all the header files. no need of adding stdio.h …etc…

wm_strcmp and strcmp both means the same, in wm_remote.h we have
the statement
#define wm_strcmp strcmp
for more information, you can see in the file.

Can you be more precise, what information you want regarding second question?

With Regards,
SUNIL RAO.M

Hi Sunil

If you have multple commands separated with comma and if the commands are in such format : comm=1, comm=2
how would you separate them, so you can read then both or together ?

Im not sure if this is the problem becuse i can not send more then 2 sms’s but, why do i get this warning?

Hi embeddedOne !

this is how to use strtok :

char string[] = "comm=1,comm=2";
char *token;

token = strtok(string,",");
while (token != NULL)
{
   TRACE((1, "The token is: "));
   TRACE((1,  token));
   token = strtok(NULL,",");
}

result for this code is :

if you use a 2 dimensional char array for “token”, you will be able to handle all substrings at the same time…

Hi !

I have no idea regarding this, but whenever we have a responses like
+CMTI: x,y then we can use this command

wm_strGetParameterString ( dst, src, Position )

see the basic development guide.pdf for further reference.

I have doubt, whenver i send an SMS, i want the delivery report after the message is sent, do you know how to get this ( with AT commands) .

With Regards,
SUNIL RAO

It needs a sequence of commands - this is what I use

AT+CSMS=0
AT+CNMI=2,1,3,1,1
AT+CSMP=49

Look them up, and adjust to your requirements 8)

Note that these settings are not saved by AT&W - you need AT+CSAS.

The result I see is something like this:

(In real life, I do see the full phone number)

Still not sure precisely what those timestamps mean, though. :frowning:
wavecom.com/modules/movie/sc … =timestamp

@ colin-tfe
I think that strtok should solve the problem but i can’t make it work.
When i get +CMTI:comm1,comm2 from the sms and when i want to compare it to defined string,nothing happens.
Program is compiled without errors :confused: . Maybe dumb idea but… type casting ?

@SunilRao
wm_strGetParameterString ( dst, src, Position )
I’v read the basic docu. and there are examples that i can use.

so, wm_strGetParameterString ( dst, smsText, Position ) should give me the “comm1,comm2” result.
How do you then make the compare between defined string and incomming one (smsText)?.

Hi !!

Anweil

Thank you for information provided

With Regards,
SUNIL RAO.M

Hi !

what is the result of the strtok ?? Show your code and the substrings you have after strtok.