OpenBSD - Installer smstools3

Timonier, barre à babord, toute !

smstools3 est un logiciel de passerelle SMS (Short Message Service), permettant d’envoyer des notifications sms via un modem GSM (ou téléphone).

Objectifs

Couvrir le processus d’installation du service smsd, et fournir les services suivants

Prérequis

OpenBSD, utilise le pilote umsm, la page de man dédiée fournit une liste exhaustive des périphériques supportés.

Installation

Installer le package:

doas pkg_add smstools3

Gérer le service au démarrage:

doas rcctl enable smsd

Configuration

Généralitées

smsd doit pouvoir accéder au port série. Ajoutons, l’utilisateur _smsd au groupe dialer.

doas usermeod -G dialer _smsd

Une analyse de dmesg, nous fournit les indications sur le périphérique à usiter.

umsm0 detached
umsm0 at uhub1 port 1 configuration 1 interface 0 "HUAWEI_MOBILE HUAWEI_MOBILE" rev 2.10/1.02 addr 2
ucom0 at umsm0
umsm1 at uhub1 port 1 configuration 1 interface 1 "HUAWEI_MOBILE HUAWEI_MOBILE" rev 2.10/1.02 addr 2

Ici le périphérique ucom0 correspond à /dev/cuaU0.

Daemon

/etc/smsd.conf

(...)
devices = GSM1
loglevel = 7
(...)
user = _smsd

pidfile = /var/run/smsds/smsd.pid
infofile = /var/run/smsd/smsd.info

logfile = /var/log/smsd/smsd.log

[GSM1]
device = /dev/cuaU0
incoming = yes
rtscts = no
senddelay = 20
(...)
pin=9999
(...)

Attention: La déclaration du code PIN peut-être nécessaire, si la carte SIM gère un abonnement data. La ligne ne devra pas comporter autre chose que la déclaration: pin=9999

Dans mon cas, le service ne démarrait pas !

Il peut-être rajoutée d’autre modem via la directive [GSMx].

Démarrons le service:

doas rcctl start smsd

Tester le service envoie

le modem, attend de recevoir les informations suivantes:

To: 33612345678

Bonjour, voici le message a envoyer !

Cas 1: binaire sendsms

Travaillant avec des locales anglaises, nous n’utiliserons pas les accents Francais.

$ sendsms  
Destination(s): 33612345678
Text: Bonjour, voici le message a envoyer !
-- 
Text: Bonjour, voici le message a envoyer !
To: 33612345678

Si en amont, vous avez arretté le service, vous trouverez dans /var/spool/sms/outgoing/ un fichier come celui-ci: send_OUgktp

/var/spool/sms/outgoing/send_OUgktp

To: 33612345678

Bonjour, voici le message a envoyer !

Au redemarrage du service, nous constatons dans les logs:

/var/log/smsd/smsd.log

2020-05-15 11:54:47,2, smsd: Smsd v3.1.21 started.
2020-05-15 11:54:47,2, smsd: Running as _smsd:_smsd (590:590).
2020-05-15 11:54:47,7, smsd: Running startup_check (shell): /var/spool/sms/incoming/smsd_script.FvZHG9 /tmp/smsd_data.DFODlw
2020-05-15 11:54:47,7, smsd: Done: startup_check (shell), execution time 0 sec., status: 0 (0)
2020-05-15 11:54:47,4, smsd: File mode creation mask: 022 (0644, rw-r--r--).
2020-05-15 11:54:47,5, smsd: Outgoing file checker has started. PID: 73612.
2020-05-15 11:54:47,7, smsd: All PID's: 73612,18220
2020-05-15 11:54:47,5, GSM1: Modem handler 0 has started. PID: 18220. Will only send messages.
2020-05-15 11:54:47,6, GSM1: Checking if modem is ready
2020-05-15 11:54:48,7, GSM1: -> AT
2020-05-15 11:54:48,5, smsd: SMS To: 33612345678. Moved file /var/spool/sms/outgoing/send_XrgtoZ to /var/spool/sms/checked
2020-05-15 11:54:48,7, GSM1: Command is sent, waiting for the answer. (5)
2020-05-15 11:54:48,7, GSM1: <- OK
2020-05-15 11:54:48,6, GSM1: Pre-initializing modem
2020-05-15 11:54:48,7, GSM1: -> ATE0
2020-05-15 11:54:48,7, GSM1: Command is sent, waiting for the answer. (10)
2020-05-15 11:54:48,7, GSM1: <- OK
2020-05-15 11:54:48,7, GSM1: -> AT+CMEE=1;+CREG=2
2020-05-15 11:54:48,5, smsd: SMS To: 33612345678. Moved file /var/spool/sms/outgoing/send_OUgktp to /var/spool/sms/checked
2020-05-15 11:54:49,7, GSM1: Command is sent, waiting for the answer. (10)
2020-05-15 11:54:49,7, GSM1: <- ^DSFLOWRPT:000001B1,00000000,00000000,0000000000000000,0000000000000000,00000000,00000000 OK
2020-05-15 11:54:49,6, GSM1: Checking if modem needs PIN
2020-05-15 11:54:49,7, GSM1: -> AT+CPIN?
2020-05-15 11:54:49,7, GSM1: Command is sent, waiting for the answer. (10)
2020-05-15 11:54:49,7, GSM1: <- +CPIN: READY OK
2020-05-15 11:54:50,7, GSM1: -> AT+CSQ
2020-05-15 11:54:50,7, GSM1: Command is sent, waiting for the answer. (10)
2020-05-15 11:54:50,7, GSM1: <- +CSQ: 14,99 OK
2020-05-15 11:54:50,6, GSM1: Signal Strength Indicator: (14,99) -85 dBm (Workable), Bit Error Rate: not known or not detectable
2020-05-15 11:54:50,6, GSM1: Checking if Modem is registered to the network
2020-05-15 11:54:50,7, GSM1: -> AT+CREG?
2020-05-15 11:54:50,7, GSM1: Command is sent, waiting for the answer. (10)
2020-05-15 11:54:50,7, GSM1: <- +CREG: 2,1,"183A","0620AB3E" OK
2020-05-15 11:54:50,6, GSM1: Modem is registered to the network
2020-05-15 11:54:50,6, GSM1: Location area code: 183A, Cell ID: AB3E
2020-05-15 11:54:50,7, GSM1: -> AT+CSQ
2020-05-15 11:54:51,7, GSM1: Command is sent, waiting for the answer. (10)
2020-05-15 11:54:51,7, GSM1: <- +CSQ: 14,99 OK
2020-05-15 11:54:51,6, GSM1: Signal Strength Indicator: (14,99) -85 dBm (Workable), Bit Error Rate: not known or not detectable
2020-05-15 11:54:51,6, GSM1: Selecting PDU mode
2020-05-15 11:54:51,7, GSM1: -> AT+CMGF=0
2020-05-15 11:54:51,7, GSM1: Command is sent, waiting for the answer. (5)
2020-05-15 11:54:51,7, GSM1: <- ^DSFLOWRPT:000001B3,00000000,00000000,0000000000000000,0000000000000000,00000000,00000000 OK
2020-05-15 11:54:51,7, GSM1: -> AT+CGSN
2020-05-15 11:54:52,7, GSM1: Command is sent, waiting for the answer. (5)
2020-05-15 11:54:52,7, GSM1: <- 123456789101112 OK
2020-05-15 11:54:52,5, GSM1: IMEI: 123456789101112
2020-05-15 11:54:52,7, GSM1: -> AT+CIMI
2020-05-15 11:54:52,7, GSM1: Command is sent, waiting for the answer. (5)
2020-05-15 11:54:52,7, GSM1: <- 234567891011121 OK
2020-05-15 11:54:52,5, GSM1: IMSI: 234567891011121
2020-05-15 11:54:52,5, GSM1: Waiting for messages to send...
2020-05-15 11:54:52,6, GSM1: I have to send 1 short message for /var/spool/sms/checked/send_OUgktp
2020-05-15 11:54:52,6, GSM1: Sending SMS from  to 33612345678
2020-05-15 11:54:52,6, GSM1: Checking if modem is ready
2020-05-15 11:54:52,7, GSM1: -> AT
2020-05-15 11:54:52,7, GSM1: Command is sent, waiting for the answer. (5)
2020-05-15 11:54:52,7, GSM1: <- OK
2020-05-15 11:54:52,6, GSM1: Pre-initializing modem
2020-05-15 11:54:52,7, GSM1: -> ATE0
2020-05-15 11:54:53,7, GSM1: Command is sent, waiting for the answer. (10)
2020-05-15 11:54:53,7, GSM1: <- OK
2020-05-15 11:54:53,7, GSM1: -> AT+CMEE=1;+CREG=2
2020-05-15 11:54:54,7, GSM1: Command is sent, waiting for the answer. (10)
2020-05-15 11:54:54,7, GSM1: <- ^DSFLOWRPT:000001B5,00000000,00000000,0000000000000000,0000000000000000,00000000,00000000 OK
2020-05-15 11:54:54,6, GSM1: Checking if modem needs PIN
2020-05-15 11:54:54,7, GSM1: -> AT+CPIN?
2020-05-15 11:54:54,7, GSM1: Command is sent, waiting for the answer. (10)
2020-05-15 11:54:54,7, GSM1: <- +CPIN: READY OK
2020-05-15 11:54:54,7, GSM1: -> AT+CSQ
2020-05-15 11:54:54,7, GSM1: Command is sent, waiting for the answer. (10)
2020-05-15 11:54:54,7, GSM1: <- +CSQ: 14,99 OK
2020-05-15 11:54:54,6, GSM1: Signal Strength Indicator: (14,99) -85 dBm (Workable), Bit Error Rate: not known or not detectable
2020-05-15 11:54:54,6, GSM1: Checking if Modem is registered to the network
2020-05-15 11:54:55,7, GSM1: -> AT+CREG?
2020-05-15 11:54:55,7, GSM1: Command is sent, waiting for the answer. (10)
2020-05-15 11:54:55,7, GSM1: <- +CREG: 2,1,"183A","0620AB3E" OK
2020-05-15 11:54:55,6, GSM1: Modem is registered to the network
2020-05-15 11:54:55,6, GSM1: Selecting PDU mode
2020-05-15 11:54:55,3, GSM1: Unexpected input: ^DSFLOWRPT:000001B7,00000000,00000000,0000000000000000,0000000000000000,00000000,00000000
2020-05-15 11:54:55,7, GSM1: -> AT+CMGF=0
2020-05-15 11:54:56,7, GSM1: Command is sent, waiting for the answer. (5)
2020-05-15 11:54:56,7, GSM1: <- OK
2020-05-15 11:54:56,7, GSM1: -> AT+CMGS=47
2020-05-15 11:54:56,7, GSM1: Command is sent, waiting for the answer. (10)
2020-05-15 11:54:56,7, GSM1: <- >
2020-05-15 11:54:56,7, GSM1: -> 0011000B913386747787F30000FF25C2B75BFDAECB5920FB3B3D4E83D86550BB3C9F87CF6550185476DBDFF9B21C1402
2020-05-15 11:55:00,7, GSM1: Command is sent, waiting for the answer. (60)
2020-05-15 11:55:00,7, GSM1: <- ^DSFLOWRPT:000001B9,00000000,00000000,0000000000000000,0000000000000000,00000000,00000000 ^DSFLOWRPT:000001BB,00000000,00000000,0000000000000000,0000000000000000,00000000,00000000 +CMGS: 109 OK
2020-05-15 11:55:00,5, GSM1: SMS sent, Message_id: 109, To: 33612345678, sending time 8 sec.
2020-05-15 11:55:00,6, GSM1: Deleted file /var/spool/sms/checked/send_OUgktp>

Vous devriez avoir recu le message, comme indiqué ci-dessus.

Pour rendre les logs moins verbeux, sans les commandes AT, il faut , par exemple, baisser la valeure loglevel à 5.

Cas 2: Dépôt d’un fichier texte.

Le service est démarré.

créer un fichier monSMS-toSend dans votre répertoire:

echo "To: 3312345678" >> monSMS_toSend
echo "" >> monSMS_toSend
echo "Bonjour, voici mon second message !" >> monSMS_toSend
mv monSMS_toSend /var/spool/sms/outgoing

Le fichier est parti, il est reçu, analysons les logs au level 5:

2020-05-21 12:22:23,5, smsd: SMS To: 33612345678. Moved file /var/spool/sms/outgoing/monSMS_toSend to /var/spool/sms/checked
2020-05-21 12:22:23,3, GSM1: Unexpected input: ^RSSI:16 ^HCSQ:"LTE",40,26,76,14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SSI:15 ^HCSQ:"LTE",38,27,76,20 ^RSSI:14 ^HCSQ:"LTE",37,27,81,22 ^RSSI:14 ^HCSQ:"LTE",37,26,71,20 ^RSSI:14 ^HCSQ:"LTE",37,26,71,20 ^RSSI:14 ^HCSQ:"LTE",37,27,71,22 ^RSSI:14 ^HCSQ:"LTE",37,27,71,20 ^RSSI:14 ^HCSQ:"LTE",37,27,76,20 ^RSSI:14 ^HCSQ:"LTE",37,27,71,20 ^RSSI:14 ^HCSQ:"LTE",37,27,76,22 ^RSSI:14 ^HCSQ:"LTE",37,27,71,20 ^RSSI:14 ^HCSQ:"LTE",37,27,71,20 ^RSSI:14 ^HCSQ:"LTE",37,27,71,20 ^RSSI:15 ^HCSQ:"LTE",38,27,71,20 ^RSSI:15 ^HCSQ:"LTE",38,27,71,20 ^RSSI:16 ^HCSQ:"LTE",40,27,71,14 ^RSSI:14 ^HCSQ:"LTE",37,27,71,20 ^RSSI:15 ^HCSQ:"LTE",39,27,71,16
2020-05-21 12:22:30,5, GSM1: SMS sent, Message_id: 111, To: 33612345678, sending time 7 sec.

Verbosité: 3 lignes de logs.

Documentation