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. Thu Mar 28, 2024 22:56
SMSTools3 Community » Help and support Bottom

A few questions to ask and problems to solve

Login and Post Reply

Page:  1

Author Post
Member
Registered:
Jun 2017
Location: Russian Federation
Operating system name and version: OpenWRT CHAOS CALMER (15.05, r46767)
Version of smsd: 3.1.15
Smsd installed from: package repository
Name and model of a modem / phone: Huawei E3276
Interface: USB

First of all, keke, I think you've created a swiss-army knife for modem handling and would like to thank you for this! A lot! Awesome work!

2 keke and all:
Smstool3 do helping me to solve my task, which is: notifying of incoming SMS messages and making USSD-request one per 24 hours to check a reminder of money on my SIM-car installed in Huawei E3276 modem connected to OpenWRT-driver router.
My main problem is PDU or GSM-7 decoding of cyrillic text.
Thanks to The Author, smstools3 do able to convert USSD messages by it's own means. According to teh documentation we've got two main ussd_convert options(2 and 4).
When I'm using ussd_convert = 2, I cannot convert a result of this internal conversion by all power of iconv.
When I'm using ussd_convert = 4, I'm successfully getting all digits in USSD message, but cannot decode text either.
However, I'm successfully convert all cyrillic SMS from USC-2 to UTF-8 by iconv(see eventhandler below)
I've tried a lot of combinations doing the same with smstool-decoded text, but failed at it.
My last solution is to use ussd_convert = 4, then just to throw out all characters except first five, which contains only digits of my remaining balance.
But this solution is kinda wierd and temporary, so the question is:

what coding must I use as a source when passing smstool-decoded text to iconv?
or what algorithm must I use to get from PDU message to readable UTF-8?

please help!

Here's my smsd.conf:
devices = GSM1
outgoing = /var/spool/sms/outgoing
checked = /var/spool/sms/checked
incoming = /var/spool/sms/incoming
logfile = /var/log/smsd.log
loglevel = 5
infofile = /var/run/smstools/smsd.working
pidfile = /var/run/smstools/smsd.pid
outgoing = /var/spool/sms/outgoing
checked = /var/spool/sms/checked
failed = /var/spool/sms/failed
incoming = /var/spool/sms/incoming
sent = /var/spool/sms/sent
#stats = /var/log/smsd_stats
receive_before_send = no
autosplit = 3
keep_filename = no
#decode_unicode_text = yes
#incoming_utf8 = yes

[GSM1]
device = /dev/ttyUSB1
incoming = yes
baudrate = 9600
loglevel_lac_ci = 8
check_memory_method = 4
init = ATZ
#init2 = AT+CMSS="ME","ME","ME"
#init2 = AT+CNMI=1,1,0,2
regular_run_cmd = AT+CUSD=1,"AA184C3602",15;
regular_run_interval = 43200
ussd_convert = 4
eventhandler = /etc/smsd/smsdeh.sh
eventhandler_ussd = /etc/smsd/smsdeh.sh
 
 
'smsdconf' Syntax Highlight powered by GeSHi


And here's my eventhandler:
#!/bin/sh
status="$1"
file="$2"
msgbody="/var/log/sms.log"
if [ -f "$msgbody" ]
then
        rm -f $msgbody
        touch $msgbody
fi

ussdbody="/var/log/ussd.log"
if [ -f "$ussdbody" ]
then
        rm -f $ussdbody
fi

case "$1" in
RECEIVED)

        head -12 $file | grep -e "^From: " -e "^Sent: " -e "^Received: " >> $msgbody
        if grep "Alphabet: UCS2" $file >/dev/null; then
                tail +13 $file | iconv -f UCS-2 -t UTF-8 >> $msgbody
        else
                tail +13 $file >> $msgbody
        fi
        echo >> $msgbody
        mailsend -f --------- -t ---------- -smtp smtp.gmail.com -starttls \
        -cs "utf-8" -user -------- -pass ------- -auth-plain  -sub "SMS was received" -msg-body $msgbody
    ;;
USSD)

        ussd=$(head -5 $file | sed 's/^.*\/\///' | sed 's/ //' | cut -c-5)
        echo ".............. ............: "$ussd" ............" >> $ussdbody
        mailsend -f --------- -t ---------- -smtp smtp.gmail.com -starttls \
        -cs "utf-8" -user -------- -pass ------- -auth-plain  -sub "Balance check results" -msg-body $ussdbody

;;
esac
 
 
'bash' Syntax Highlight powered by GeSHi


Member
Registered:
Jun 2017
Location: Russian Federation
Topic owner
Very important notice!
Here's a sample of a reply, received from my modem:


When I'm using Smstool3 PDU converter http://smstools3.kekekasvi.com/topic.php?id=288 and tick "GSM 7bit packed" I'm getting the same(on my sight) result which I'm able to get with ussd_convert = 2.
When I tick "UCS2" radiobutton - I'm getting exactly what I need!
Ok, - I decided, - I'll use ussd_convert = 2, then I'll pass converted message to iconv -f USC-2 -t UTF-8 - and I was wrong in this suggestion, getting a garbage again.

Dear keke, since you've programmed and have built this converter to your site, you know what exactly it does when I tick UCS-2 button before I press Convert.

Please enlighten me!

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Thank you for choosing this software!

It looks like some operator has changed the answer for USSD, and therefore version 3.1.15 does not handle it properly.

You need to install smsd version 3.1.21. I do not know if it's available in the repository. Likely you need to compile it from sources.

With the version 3.1.21 use the setting ussd_convert = 1.

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
If you cannot upgrade smsd on OpenWRT, you could try the following:

Use ussd_convert = 4, so you can get eventhandler called. Also use regular_run_statfile = /var/log/ussd.stat. This file is created each time when USSD answer is received and it contains only the latest answer. The file exists when eventhandler is called, later it is deleted.

In your eventhandler do the following:
tmp=`cat /var/log/ussd.stat | awk -v FS="(CUSD: 0,\"|\",72)" '{print $2}' | sed 's/../\\\x&/g'`
answer=`echo -n -e "$tmp" | iconv -f UCS-2BE -t UTF-8`
 
'bash' Syntax Highlight powered by GeSHi


If this does not work, please show the /var/log/ussd.stat.

My testing was (on Ubuntu, not on OpenWRT):


Member
Registered:
Jun 2017
Location: Russian Federation
Topic owner
Thanks a lot, keke, it works! And you're a genius!
However, you've probably mistyped when instructed me to use ussd_convert = 4. Your receipt works perfectly, but with ussd_convert = 2.
With this parameter I've replicated your solution with success!
Then I've commented out regular_run_statfile = /var/log/ussd.stat from smsd.conf and changed eventhandler script to the following:
# now we don't need to use any additional files, so file="$2" argument to eventhandler is pretty enough
tmp=$(head -5 $file | awk -v FS="(CUSD: 0,\"|\",72)" '{print $2}' | sed 's/../\\\x&/g')
# or if we like sed as I do ))
tmp=$(head -5 $file | sed 's/^.*+CUSD: 0,"//' | sed 's/",72.*//' | sed 's/../\\\x&/g')
tmp2=$(echo -n -e $tmp | iconv -f UCS-2BE -t UTF-8)
# the rest of USSD message is adevertising garbage so we don't need it to be redirected to our clean and shiny mailbox
ussd=$(echo -n -e $tmp2 | cut -c-9)
echo "Current reminder is: "$ussd >> $ussdbody
mailsend -f --------- -t ---------- -smtp smtp.gmail.com -starttls \
-cs "utf-8" -user -------- -pass ------- -auth-plain  -sub "Balance check results" -msg-body $ussdbody
 
'bash' Syntax Highlight powered by GeSHi


Member
Registered:
Jun 2017
Location: Russian Federation
Topic owner
keke wrote
Thank you for choosing this software!

It looks like some operator has changed the answer for USSD, and therefore version 3.1.15 does not handle it properly.

You need to install smsd version 3.1.21. I do not know if it's available in the repository. Likely you need to compile it from sources.

With the version 3.1.21 use the setting ussd_convert = 1.

Unfortunately, OpenWRT freshest repos does have smstools3 3.1.15 only. And, as you absolutely right, the only way is to build 3.1.21 from source.
Once decided, we have two ways to do this: (1) - straight on our OpenWRT hardware and it's really-really hard if you even have powerful router (2) - cross-compiling, which is easy if you build your firmware right form a source. Fortunately, I've did it before and can do it again in a short time and post here a guide and package itself.
But, I'm lazy, the problem is solved and I, in particular, don't need newer version. However, I can do this for the community here.
What do you think, should I?

Member
Registered:
Jun 2017
Location: Russian Federation
Topic owner
I'm unable to edit my prevoius post so I have to apology!
keke you're not mistyped, we can use as ussd_convert = 4 so ussd_convert = 2.
Moreover, we may not use smstools3 internal conversion at all, because once USSD received, we're dealing with PDU message itself.

Member
Registered:
Jun 2017
Location: Russian Federation
Topic owner
Well, I made a cross-compilation of the pacakge while building a new firmware.
Here's a Makefile:
include $(TOPDIR)/rules.mk

PKG_NAME:=smstools3
PKG_VERSION:=3.1.21
PKG_RELEASE:=1

PKG_BUILD_DIR:= $(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk

define Package/smstools3
        SECTION:=utils
        CATEGORY:=Utilities
        TITLE:=Sms Server Tools 3
        URL:=http://smstools3.kekekasvi.com
        DEPENDS:=+libiconv-full
endef

define Package/smstools3/description
        The SMS Server Tools 3 is a SMS Gateway software which can send and receive
        short messages through GSM modems and mobile phones.
endef

define Build/Prepare
        mkdir -p $(PKG_BUILD_DIR)
        $(CP) ./src/* $(PKG_BUILD_DIR)/
        # comment this out if you don't want to change anything in original smstools3 Makefile
        $(Build/Patch)
endef

define Build/Compile
        $(MAKE) -C $(PKG_BUILD_DIR) \
        CC=$(TARGET_CC) \
        USER_CFLAGS='$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS) -I$(STAGING_DIR)/usr/lib/libiconv-full/include' \
        USER_LDFLAGS='$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS) -L$(STAGING_DIR)/usr/lib/libiconv-full/lib'
endef

define Package/smstools3/install
        $(INSTALL_DIR) $(1)/usr/local/bin
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/smsd $(1)/usr/local/bin/
        $(INSTALL_DATA) ./scripts/sendsms $(1)/usr/local/bin/
        $(INSTALL_DATA) ./scripts/sms2unicode $(1)/usr/local/bin/
        $(INSTALL_DATA) ./scripts/unicode2sms $(1)/usr/local/bin/
#       $(INSTALL_DIR) $(1)/usr/share/smstools3/examples
#       $(INSTALL_DATA) ./examples/* $(1)/usr/share/smstools3/examples/
        $(INSTALL_DIR) $(1)/etc/
        $(INSTALL_DATA) ./examples/smsd.conf.non-root $(1)/etc/smsd.conf
endef

$(eval $(call BuildPackage,smstools3))
 
 
'make' Syntax Highlight powered by GeSHi


A short HOWTO 2 all, whom it may concern:
Download tarball from this site, and extract it as is to openwrt/packages/utils/smstool3
Create Makefile there with the contents above.
Note, that every line cannot begin with a space(s), so substitute any leading spaces to Tab(s) after copy/paste.
Since I've always wanted to use ussd_convert = 1, I added +CFLAGS += -D USE_ICONV to the project's Makefile( which is inside the ./src/)
If you don't want to change any option at Makefile, pls comment out $(Build/Patch) string from openWRT Makefile.
If you didn't do any changes in the project's Makefile, you may substitute Build/Compile section to the following:

define Build/Compile
        $(MAKE) -C $(PKG_BUILD_DIR) \
                CC="$(TARGET_CC)" \
                CFLAGS="$(TARGET_CFLAGS) -Wall" \
                LDFLAGS="$(TARGET_LDFLAGS)"
endef
 
'make' Syntax Highlight powered by GeSHi

2 keke
If you'd transfer your project to github, it can be possible to fully automate the process of compilation/integration of a new version using this(for ex.):
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=http://git.openwrt.org/project/smstools3.git
..... etc.
Of course we may automate the build process with PKG_DATA_FILENAME:=, but in this case we need to manually edit Makefile each time new version is coming out.


« Last edit by blakman on Sun Jun 18, 2017 23:20, 82 months ago. »

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.