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. Tue Apr 16, 2024 15:00
SMSTools3 Community » Help and support Bottom

Running cmdfile outside of scheduled regular_run_interval

Login and Post Reply

Page:  1

Author Post
Member
Registered:
Feb 2018
Location: Czech Republic
Operating system name and version: Raspberry pi, Arch Linux ARM
Version of smsd: 3.1.21
Smsd installed from: package obtained from AUR
Name and model of a modem / phone: Huawei E3531
Interface: USB

Hello, Ladies & Gentlemen,
This is my first post so please be gentle. ;)

Short version: Is there a way to tell smsd to run a cmdfile with some AT commands outside of the regular_run schedule?

Longer version:
I would like to eventually reach the following functionality with my setup:

- smsd will regularly check credit balance on the SIM (got this working already)
- SMS/email should be sent (just once) if balance is below certain threshold (work in progress, don't need help so far)
- If an SMS with a specific text is received, manually check balance again, then send a response SMS with the balance

The last line is where I have issues. I know that I can detect the incoming command SMS with an eventhandler, I know that I can create a cmdfile, and I know the AT/USSD commands I need, but I do not know how to tell smd to run it now.

Is such functionality achievable in the current version?

I tried manually creating a cmdfile, but smsd just ignores it. (expected, but I wanted to try it anyway, just in case)
I already searched the forums for keyword "USSD", but all discussions I checked pointed towards simply using regular_run.


And if I do end up having to use regular_run for this as well, what do you consider to be a "healthy" lower bound for regular_run_interval? E.g. should I expect any issues if I schedule regular_run every 10 seconds? 20? 30?

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
There is no way to run cmdfile outside of the schedule. Also handling of the USSD answer might be problematic, so another solution may be required.

Even when you already have a working solution for balance checking, please view this topic as an example:
Sample config and script for regular_run and balance of prepaid SIM using USSD.

That sample checks the balance periodically, and also after a defined number of messages are sent. This sample could be extended as follows:

A new file definition which is a wildcard:
query_balance_flagfiles="/var/spool/sms/stats/guery.${DEVICENAME}.balance.*"
 
'bash' Syntax Highlight powered by GeSHi


Before $get_balance is last tested, it could be set to 1 if any queries exists:
for f in $query_balance_flagfiles; do
  get_balance=1
  break
done
 
'bash' Syntax Highlight powered by GeSHi


Later when the balance is handled, the script could check if any queries were made, and send the answers:
answer="<suitably formatted answer>"

for FILE in $query_balance_flagfiles; do
  number=$(head -1 $FILE)
  echo "To: $number" > $FILE
  echo "" >> $FILE
  echo "$answer" >> $FILE
  FILE2=$(mktemp "${outgoing}/send_XXXXXX")
  mv $FILE $FILE2
done
 
'bash' Syntax Highlight powered by GeSHi


Finally, in the eventhandler, when the correct keyword is detected, the script should store the number of sender to the random file which is created like:
FILE=$(mktemp "/var/spool/sms/stats/guery.GSM1.balance.XXXXXX")
echo "$FROM" > $FILE
 
'bash' Syntax Highlight powered by GeSHi


To get the answer in reasonable time, regular_run_interval should not be too long. And if more than one queries were made, all will get the same answer.

This was shown just as an example or an idea. It is not tested. It may work, or not. ;)

Login and Post Reply

Page:  1

SMSTools3 Community » Help and support Top

 
Time in this board is UTC.  

Privacy Policy   SMS Server Tools 3 Copyright © Keijo Kasvi.