yum --enablerepo=rpmforge install usb_modeswitch minicom
packages yum --enablerepo=rpmforge install usb_modeswitch minicom
, then create / edit /etc/usb-modeswitch.conf :DefaultVendor = 0x12d1
DefaultProduct = 0x1446
MessageEndPoint = "0x01"
MessageContent = "55534243000000000000000000000011060000000000000000000000000000"
usb_modeswitch
and see something like the following:Looking for target devices ...
No devices in target mode or class found
Looking for default devices ...
Found default devices (1)
Accessing device 004 on bus 007 ...
Using endpoints 0x01 (out) and 0x81 (in)
Inquiring device details; driver will be detached ...
Looking for active driver ...
OK, driver found ("usb-storage")
OK, driver "usb-storage" detached
SCSI inquiry data (for identification)
-------------------------
Vendor String: HUAWEI
Model String: Mass Storage
Revision String: 2.31
-------------------------
USB description data (for identification)
-------------------------
Manufacturer: HUAWEI Technology
Product: HUAWEI Mobile
Serial No.: not provided
-------------------------
Setting up communication with interface 0 ...
Trying to send the message to endpoint 0x01 ...
OK, message successfully sent
Device is gone, skipping any further commands
-> Run lsusb to note any changes. Bye.
ls /dev | grep ttyUSB
ls /dev | grep ttyUSB
:ttyUSB0
ttyUSB1
ttyUSB2
minicom –s
configure a serial port for work with / dev / ttyUSB0,devices = huaweiE1550
logfile = /var/log/smsd.log
loglevel = 2
[huaweiE1550]
device = /dev/ttyUSB0
baudrate = 115200
rtscts = no
init = at+cpms="sm","sm",""
incoming = yes
incoming = high
service smsd start
and check this miracle: smssend 9128141111 'test message'
(does not understand Cyrillic, needs to be converted to UCS-2BE , I’ll not consider this in this article) and wait for a sms on a mobile phone. If the coveted message did not come, put in the config loglevel = 7 and go for the tambourine. I got everything up the first time.From: 79128141111
From_TOA: 91 international, ISDN/telephone
From_SMSC: 79126313431
Sent: 11-03-02 08:05:46
Received: 11-03-02 08:08:09
Subject: huaweiE1550
IMSI: 2500XXXXXXXXXXX
Report: no
Alphabet: ISO
UDH: false
Test message
#!/bin/sh # SMSCtrl # chkconfig: - 55 45 # description: Sms control, Egor N. Zuskin, 2011, http://www.it2k.ru/projects/smsctrl . /etc/rc.d/init.d/functions DAEMON=smsctrl REFRESH_TIME=15 COMMAND_CHAR="#" INCOMING_DIR=/var/spool/sms/incoming ALLOW_PHONES="79128141111 79128141112" SEND_BACK_REPORT=YES to_log(){ text=$1 export LANG=en_EN log_date=`date "+%b %d %H:%M:%S "` log_host=`hostname -s` echo "$log_date $log_host $DAEMON: $text" >> /var/log/$DAEMON.log } start() { echo -n "Starting $DAEMON: " $0 --daemon && success || failure RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/$DAEMON to_log "Starting ..." return $RETVAL } stop() { # Stop daemon. echo -n "Shutting down $DAEMON: " killproc $0 RETVAL=$? to_log "Stopping ..." echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/$DAEMON } run() { for File in $(ls $INCOMING_DIR); do Allow=0 for Phone in $ALLOW_PHONES; do cat $INCOMING_DIR/$File | grep "From: $Phone" > /dev/null 2>&1 [ $? -eq 0 ] && Allow=1 done; [ $Allow -eq 0 ] && continue cat $INCOMING_DIR/$File | grep "$COMMAND_CHAR" [ $? -ne 0 ] && continue FromPhone=`cat $INCOMING_DIR/$File | grep "From:" | cut -d " " -f2` command=`cat $INCOMING_DIR/$File | grep "$COMMAND_CHAR" | cut -d "$COMMAND_CHAR" -f2` to_log "Incoming command: $command from $FromPhone" out=`$command` if [ "$SEND_BACK_REPORT" = "YES" ]; then smssend $FromPhone "$out" to_log "Send sms to $FromPhone: $out" fi rm -f $INCOMING_DIR/$File to_log "Deleting file $INCOMING_DIR/$File" done } daemon() { exec >/dev/null exec 2>/dev/null ( trap "" TERM while [ true ]; do run sleep $REFRESH_TIME; done; )& } case "$1" in --daemon) daemon ;; run) run ;; start) start ;; stop) stop ;; restart) $0 stop $0 start exit $? ;; status) status $DAEMON echo ;; *) echo "Usage: $DAEMON {start|stop|restart|status|run}" exit 1 esac exit 0
COMMAND_CHAR="#" –
INCOMING_DIR=/var/spool/sms/incoming – -
ALLOW_PHONES="79128141111 79128141112" –
SEND_BACK_REPORT=YES – -
chkconfig --add smsctrl
, service smsctrl start
eventhandler = /root/bin/sms_event.sh
#!/bin/bash COMMAND_CHAR="#" ALLOW_PHONES="79128141111 79128141112" SEND_BACK_REPORT=YES [ "$1" = "RECEIVED" ] || exit 0 to_log(){ text=$1 export LANG=en_EN log_date=`date "+%b %d %H:%M:%S "` log_host=`hostname -s` echo "$log_date $log_host $text" >> /var/log/smsctrl.log } File=$2 Allow=0 for Phone in $ALLOW_PHONES; do cat $File | grep "From: $Phone" > /dev/null 2>&1 [ $? -eq 0 ] && Allow=1 done; [ $Allow -eq 0 ] && exit 0 cat $INCOMING_DIR/$File | grep "$COMMAND_CHAR" [ $? -ne 0 ] && exit 0 FromPhone=`cat $File | grep "From:" | cut -d " " -f2` command=`cat $File | grep "$COMMAND_CHAR" | cut -d "$COMMAND_CHAR" -f2` to_log "Incoming command: $command from $FromPhone" out=`$command` if [ "$SEND_BACK_REPORT" = "YES" ]; then smssend $FromPhone "$out" to_log "Send sms to $FromPhone: $out" fi rm -f $File to_log "Deleting file $File"
#!/bin/bash ls –la /etc | grep $1
#/root/bin/test.sh sms
to the coveted number and look at the tail –f /var/log/smsctrl.log
log, if all is well, we’ll #/root/bin/test.sh sms
in response : smsd.conf
Source: https://habr.com/ru/post/114912/
All Articles