SMS Server Tools 3
This site is hosted by Kekekasvi.com
 Menu
Basic information:
Additional information:
Support:
Get SMS Server Tools 3:
Additional Options

 Sponsored links

 Search
Custom Search

 Visitor locations
 
 SMS Server Tools 3 Community
Welcome, Guest. Please login or register. Sun May 19, 2024 21:44
SMSTools3 Community » Help and support Bottom

[fixed in 3.1.7] incoming messages seen in the log, but are ignored

  This topic is locked

Page:  1

Author Post
Member
Registered:
Feb 2010
Location: China
Operating system name and version: CentOS 5.3
Version of smsd: 3.0.10
Smsd installed from: EPEL package repository
Name and model of a modem / phone: Motorola A1200r (Ming)
Interface: USB

Hi folks,
First, thanks to Stefan, Keke and everyone who contributed to SMSTools. It is really nifty.

I'm setting it up so my server can send alerts when something breaks. I just discovered the tool last night, and had it up and running in just a couple of hours. I've already reached this goal, but I noticed a problem along the way.

SMSTools will ignore incoming SMS. The msg is received on the phone. The smsd log file shows the message is there, but nothing is ever created in the incoming directory.

I'm hoping someone can make a suggestion for what to look for to debug this issue.

My setup.
/etc/smsd.conf


/var/log/smsd/smsd.log
(extract)


new msg is received







SELinux is enabled, but nothing is showing up in the audit logs. Setting selinux to permissive does not change anything.

P.S. I use INIT of at+cpms="SM" because I don't want smsd sorting through 4096 empty mail slots in the phone's memory.

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Thank's for your brief report.

As the answer from the modem seems to follow GSM 07.05 specification, I see no other reason than that the answer does not contain <CR> characters. There are <LF> characters, as the log has linefeeds shown. However, there should be both <CR> and <LF> as the definition says.

If my guess is correct, we have to change the code. I assume that the firmware of a modem cannot be altered.

Hopefully you can compile smsd from sources...

Download the latest version, 3.1.6 or 3.1.7beta and extract it into the /usr/local/src directory.

Go to the /usr/local/src/smstools3/src.

Edit smsd.c using some of your favourite editor.

Find "Trying to get stored message".

You will see the following piece of a code. Insert those lines which are colored to the place shown.

 writelogfile(LOG_INFO, 0, "Trying to get stored message %i",sim);
 sprintf(command,"AT+CMGR=%i\r",sim);
 // 3.1beta3: Some modems answer OK in case of empty memory space (added "|(OK)")
 if (put_command(command, answer, sizeof(answer), 1, "(\\+CMGR:.*OK)|(ERROR)|(OK)") == -2)
   return -2;

 if (!strchr(answer, '\r'))
 {
   char *p;

   while ((p = strchr(answer, '\n')))
     *p = '\r';
 }


 if (strstr(answer,",,0\r")) // No SMS,  because Modem answered with +CMGR: 0,,0
   return -1;
 if (strstr(answer,"ERROR")) // No SMS,  because Modem answered with ERROR
   return -1;

Save, make and test. Let me know about the results. I do not yet publish a new version, because this issue was not verified.

Member
Registered:
Feb 2010
Location: China
Topic owner
Hi keke,

No joy with 3.1.6. smstools aborts with or without the patch. I'll try 3.1.7Beta.

FYI: Here is what I got with 3.1.6....



Member
Registered:
Feb 2010
Location: China
Topic owner
3.1.7Beta is equally unhappy. (no patch)



Member
Registered:
Feb 2010
Location: China
Topic owner
Unfortunately, plugging the patch into 3.0.10 doesn't fix anything either.

Also, I inserted a printf into the patch and ran smsd -t , and the output is never seen.

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Problem with a PIN is caused by the quotation marks which are received from a modem. This can be fixed in the modeminit.c:

   writelogfile(LOG_INFO,modemname,"Checking if modem needs PIN");
   put_command(modem,modemname,send_delay,"AT+CPIN?\r",answer,sizeof(answer),50, cpin_expect);

   while ((p = strchr(answer, '"')))
     strcpy(p, p + 1);

   if (strstr(answer,"+CPIN: SIM PIN") && !strstr(answer, "PIN2"))

However, better not to use a PIN while other issues are still unresolved...


I do not understand why your system does not accept incoming messages :(. It seems that there is nothing wrong in the answer from a modem, and the answer and PDU should be handled correctly by the smsd code.

Hopefully you can do one more test:

Stop the smsd if it's running.
Remove the smsd.log file.
Send an SMS to your device (while smsd is not running).
Start the smsd, use the original version 3.0.10.
When you can see from the log that a message was tried to handle, stop the smsd.
Now, do not alter smsd.log with any editor.
Create a dump of it: hexdump -C < /var/log/smsd.log
Show this dump here. It may be long, but I can make it shorted, if necessary, after I have seen what character there is actually in the log.

Member
Registered:
Feb 2010
Location: China
Topic owner
The removal of the double quotes fixed the modem init problem in 3.1.6. (I don't use a PIN anyway.)

This is from 3.0.10.


Just before the extra code you provided to convert 0x0a to 0x0d, I added a



It shows there is a CR+LF at the end of each part. That might explain why the extra code didn't seem to do anything. But, it is also different from what is normally output to the log file, and that puzzles me.

Member
Registered:
Feb 2010
Location: China
Topic owner
CR+LF would obviously throw off the END2=BEGIN1+1 logic in the code after that.

Member
Registered:
Feb 2010
Location: China
Topic owner
Ah yes, that's it. I made this change in 3.1.0, and msgs start appearing in the incoming dir.

  begin1=strstr(answer,"+CMGR:");
if (begin1==0)
return -1;
end1=strstr(begin1,"\r");
if (end1==0)
return -1;

if ( strstr(begin1,"\r\n") ) {
begin2=end1+2;
} else {
begin2=end1+1;
}


end2=strstr(begin2+1,"\r");
if (end2==0)
return -1; 


Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Thanks for the information and the extra logging code. It shows that there is double line-ending used by the modem.

Your fix works, but I will include this kind of a fix in the next version:


   writelogfile(LOG_INFO, 0, "Trying to get stored message %i", sim);
   sprintf(command, "AT+CMGR=%i\r", sim);
   // 3.1beta3: Some modems answer OK in case of empty memory space (added "|(OK)")
   if (put_command(command, answer, sizeof(answer), 1, "(\\+CMGR:.*OK)|(ERROR)|(OK)") == -2)
     return -2;

   while ((begin1 = strchr(answer, '\n')))
     *begin1 = '\r';

   while ((begin1 = strstr(answer, "\r\r")))
     strcpy(begin1, begin1 +1);

   if (strstr(answer, ",,0\r"))    // No SMS,  because Modem answered with +CMGR: 0,,0
     return -1;
   if (strstr(answer, "ERROR"))    // No SMS,  because Modem answered with ERROR
     return -1;


  This topic is locked

Page:  1

SMSTools3 Community » Help and support Top

 
Time in this board is UTC.  

Privacy Policy   SMS Server Tools 3 Copyright © Keijo Kasvi.