asmok
Posts: 13
Joined: Thu Feb 23, 2012 11:01 am

RasPi66 SMS Collector - Raspbian, Nokia CS-17, SMS Tools 3

Mon Mar 04, 2013 4:14 pm

I'm going next month to the Spain - St. James Way. I'm going to keep a SMS Diary about journey.

I got Raspberry Pi, Raspbian, Nokia CS-17 and SMS Tools 3 (v. 3.1.15). I use EXIM4 for sending emails.

Read documents and community forum for SMS Tools 3:

http://smstools3.kekekasvi.com/index.php?p=configure
http://smstools3.kekekasvi.com/index.php?p=run
http://smstools3.kekekasvi.com/board.php

I did use this document for EXIM4, works well.

http://library.linode.com/email/exim/se ... -6-squeeze

Why this way? Why not latest and greatest smart phone on the road? This way it is so much more fun ;)

Here is RasPi with Nokia CS-17:

Image

SMS Diary - http://www.arkki.info/ (in finnish only, sorry for that)
SMS Diary - https://twitter.com/AsmoStJamesWay (in finnish only, sorry for that)
SMS Diary - https://www.facebook.com/asmo.koskinen (in finnish only, sorry for that)

I send SMS to RasPi66, RasPi66 sends it to Gmail. Postie from Wordpress fetches email as a blog update and WP to Twitter updates Twitter. And finally Twitter updates Facebook status.

SMS in Wordpress:
Image

Link in Twitter:
Image

Link in Facebook:
Image

http://wordpress.org/extend/plugins/postie/
http://wordpress.org/extend/plugins/wp-to-twitter/

RasPi66 sends to me a SMS about it's uptime every day at noon.

Good friend of mine, Mikael, improved my original bash scripts (he is professional, me - just another hobbyist). Thank you, Mikael!
-----

Here is my working setup, comments are welcome :D

1. Raspberry Pi, Raspbian, SMS Tools 3 and Nokia CS-17 work together.

Code: Select all

[   99.324483] usb 1-1.2: new high-speed USB device number 5 using dwc_otg
[   99.426069] usb 1-1.2: New USB device found, idVendor=0421, idProduct=0623
[   99.426100] usb 1-1.2: New USB device strings: Mfr=2, Product=1, SerialNumber=3
[   99.426117] usb 1-1.2: Product: Nokia Datacard
[   99.426131] usb 1-1.2: Manufacturer: Nokia
[   99.426145] usb 1-1.2: SerialNumber: 1DE419ABDA600E71611474367488B1DCFFA70132
[   99.945175] cdc_acm 1-1.2:1.1: ttyACM0: USB ACM device
[  100.051434] cdc_acm 1-1.2:1.3: ttyACM1: USB ACM device
2. My configuration files for SMS Tools 3.

a. /etc/smsd.conf

Code: Select all

devices = GSM
outgoing = /var/spool/sms/outgoing
sent = /var/spool/sms/sent
checked = /var/spool/sms/checked
incoming = /var/spool/sms/incoming
failed = /var/spool/sms/failed
logfile = /var/log/smstools/smsd.log
infofile = /var/run/smstools/smsd.working
pidfile = /var/run/smstools/smsd.pid
stats = /var/log/smstools/smsd_stats
loglevel = 5
receive_before_send = yes
autosplit = 0
decode_unicode_text = yes
filename_preview = 6
date_filename = 1
datetime_format = %Y-%m-%d-%H-%M
incoming_utf8 = yes
language_file = /usr/local/etc/language-UTF-8.fi
eventhandler = /usr/local/bin/clean_up_and_mailx

[GSM]
init = AT+CPMS="ME","ME","ME"
check_memory_method = 5
device = /dev/ttyACM0
incoming = yes
outgoing = yes
cs_convert = yes
report = no
signal_quality_ber_ignore = yes
report_device_details = yes
b. /usr/local/bin/clean_up_and_mailx

Code: Select all

#!/bin/bash
 
# To whom
TO=(username here)@gmail.com
 
# Directory for SMS messages
INCOMING=/var/spool/sms/incoming
 
# Directory for messages
EMAIL=/var/spool/sms/email
 
# Directory for emailed messages
EMAILED=/var/spool/sms/emailed
 
# Add subject to the email
SUBJECT="$(date '+%a %d/%m/%Y %H:%M')"
 
# Exit with error
die() {
  [[ -n $1 ]] && echo $1
  exit 1
}
 
# Remove lines and send cleaned up SMS to Gmail/Postie/Wordpress
process_message() {
  message="${1}"
  echo "PROCESSING $message"
  sed '1,12d' "${message}" | /usr/bin/mailx -s "$SUBJECT" $TO
  mv ${message} $EMAILED || die
  return 0
}
 
### MAIN ###
 
# Make sure the directories exist
for dir in $INCOMING $EMAIL $EMAILED; do
  if [ ! -e ${dir} ]; then
    mkdir -p ${dir} || die
  fi
done
 
# For eventhandler
if [ "$1" = "RECEIVED" ]; then
  for incoming_sms in ${INCOMING}/*; do
    case $incoming_sms in
 
      # Check for "Laudes", "Sextam" and "Vesper"
      *Laudes* | *Sextam* | *Vesper* )
        process_message $incoming_sms
        ;;
 
      # Remove anything else
      *)
        if [ -e $incoming_sms ]; then
          rm -f $incoming_sms || die
          echo "$incoming_sms is trashed"
        fi
        ;;
 
    esac
  done
fi
 
exit 0

# EOF
c. /usr/local/bin/uptime_sms

Code: Select all

#!/bin/bash
 
TO=35845xxxxxxxx
OUTGOING=/var/spool/sms/outgoing
 
# Exit with error
die() {
  [[ -n $1 ]] && echo $1
  exit 1
}
 
### MAIN ###
 
# Make sure the outgoing directory exists
if [ ! -e ${OUTGOING} ]; then
  mkdir -p ${OUTGOING} || die
fi
 
# Construct uptime SMS message
(
  echo -e "To: $TO\n"
  /usr/bin/uptime
) > ${OUTGOING}/UPTIME-SMS || die
 
exit 0
d. uptime_sms is in crontab. There is also a line for Postie.

Code: Select all

root@RasPi66:~# crontab -l
0 12 * * * /usr/local/bin/uptime_sms
*/5 * * * * /usr/bin/curl -O /dev/null http://www.arkki.info/wp-content/plugins/postie/get_mail.php >/dev/null 2>&1
e. root@RasPi66:/var/spool/sms/emailed# cat 2013-03-15.GSM.iK0tQw-Laudes

Code: Select all

root@RasPi66:/var/spool/sms/emailed# cat 2013-03-15.GSM.iK0tQw-Laudes
Lähettäjä: 35845xxxxxxx
Osoitetyyppi: 91 international, ISDN/telephone
Viestikeskus: 358508771035
Lähetetty: 15.03.2013 11:31:45
Vastaanotettu: 15.03.2013 11:31:53
Otsikko: GSM
Modeemi: GSM
Liittymätunniste: 244915810098636
Raportti: ei
Merkistö: UTF-8
Pituus: 175

Laudes TESTI Tässä viestissä on enemmän kuin 140 merkiää... Osaako SMS Tools 3 käsitellä moniosaisia viestejä? Katsotaan, kun lähetän tämän viestin. Nämä merkit ovat osassa 2.
3. Read these log files.

a. tail -f /var/log/smsd.log

Code: Select all

2013-03-15 11:31:53,5, GSM: SMS received (part 1/2), From: 35845xxxxxxx
2013-03-15 11:31:53,5, GSM: SMS received (part 2/2), From: 35845xxxxxxx
2013-03-15 11:31:54,3, GSM: Exec: eventhandler said something:
2013-03-15 11:31:54,3, GSM: ! PROCESSING /var/spool/sms/incoming/2013-03-15.GSM.iK0tQw-Laudes
2013-03-15 11:35:31,5, GSM: SMS received, From: 35845xxxxxxx
2013-03-15 11:35:31,3, GSM: Exec: eventhandler said something:
2013-03-15 11:35:31,3, GSM: ! /var/spool/sms/incoming/2013-03-15.GSM.26Rutg-Tama_v is trashed

b. tail -f /var/log/exim4/mainlog

Code: Select all

2013-03-15 11:31:59 1UGQzS-0003LA-5z => (username_here)@gmail.com R=dnslookup T=remote_smtp H=gmail-smtp-in.l.google.com [173.194.71.26] X=TLS1.2:RSA_ARCFOUR_SHA1:128 DN="C=US,ST=California,L=Mountain View,O=Google Inc,CN=mx.google.com"
2013-03-15 11:31:59 1UGQzS-0003LA-5z Completed
-----
Best Regards Asmo Koskinen.
Last edited by asmok on Fri Mar 15, 2013 9:54 am, edited 14 times in total.

asmok
Posts: 13
Joined: Thu Feb 23, 2012 11:01 am

Re: RasPi66 SMS Collector - Raspbian, Nokia CS-17 and smstoo

Wed Mar 13, 2013 9:22 am

I update post above when I find something to add or change.

Best Regards Asmo Koskinen.

jmprince80
Posts: 4
Joined: Thu Sep 19, 2013 12:44 am

Re: RasPi66 SMS Collector - Raspbian, Nokia CS-17, SMS Tools

Sat Sep 21, 2013 4:48 pm

Hey, I use a similar setup for http://streetunity.org/sms/ - sms server tools 3 is probably the most stable and flexible way to send SMS on the Pi.

It also seems to play nicely with Asterisk + chan_dongle installed.

I'm looking to partner with Pi owners in other countries to form international 2-way SMS gateway, currently we offer service to UK numbers, but if more people got on board then this could be the start of something very useful :) All thats needed is an unlimited SMS plan, a dongle, and an internet connected Pi.. couldn't be cheaper :)

User avatar
DaveDriesen
Posts: 113
Joined: Sun Mar 31, 2013 8:28 pm
Location: Top of the food chain
Contact: Website

Re: RasPi66 SMS Collector - Raspbian, Nokia CS-17, SMS Tools

Thu Sep 26, 2013 12:50 pm

jmprince80 wrote:I'm looking to partner with Pi owners in other countries to form international 2-way SMS gateway, currently we offer service to UK numbers, but if more people got on board then this could be the start of something very useful :) All thats needed is an unlimited SMS plan, a dongle, and an internet connected Pi.. couldn't be cheaper :)
Hmm.. I did the exact same thing back in 2005 or so.. Meaning, I own a company that has a node-based network of SMS gateways placed in datacenters around the globe and hooked up to regional SMSC's, that does exactly this.

Well to be more precise (and that is the reason of this post) the network has the capability to do exactly this, but users were never interested enough to use the feature, so nowadays this particular aspect of the service lays in waste. Turns out companies don't really mind what they pay for their texts. Not enough to make them appreciate your service, even if it's free. They'd just as soon send a text from the UK straight to Malaysia, than route it over the network. Luckily a non-issue my company because we make money either way, but still it was sad to see such a good idea end up in oblivion because nobody cares.

To add to that, beware that the mainstream way of sending an sms (i.e. through mobile networks) is quite slow and only allows for a couple dozen texts to be sent per minute. If and when your service becomes successful, this won't be enough and to increase throughput you will need to connect to regional SMSC's directly through TCP/IP using API's provided by most mobile providers. That will allow you to send thousands of SMS messages per minute (we can send 10000 texts per minute on an average provider). But! That kind of thing is never in scope of "unlimited SMS" plans, is stupidly expensive (think multiple K/month PER CARRIER) and the variations in these API's will make your head explode.

Also consider that leveraging unlimited SMS plans this way is likely to be a violation of terms of service. Read up well so that you're prepared for awkward questions.

On the other hand, it certainly is a very interesting topic and makes for fun projects, you will meet some of the most passionate, helpful and wise techies, geeks and total pros who live and breathe mobile/telecom and rarely have an occasion to share their vast knowledge. That alone is enough to make this worthwhile.

Dave Driesen
Linux dev and oldskool elite

psyluck
Posts: 1
Joined: Thu Oct 17, 2013 2:50 pm

Re: RasPi66 SMS Collector - Raspbian, Nokia CS-17, SMS Tools

Thu Oct 17, 2013 2:57 pm

Hi Dave,

we are extremely interested in partnering with you, we also have our system ready for sending out massive sms, we tried the unlimited international plans but your right, it never worked the way we expect it to work. kindly send me a contact no. or an email so we could contact you for a possible partnership. i believe we share the same cause and purpose. you may reach me at bluepackets@gmail.com, i shall await for your favorable reply...i'll try to call you as soon as i got your number, thanks and have a nice day.

Psyluck

Return to “Networking and servers”