GSM USB Modem on RPI using usb_modeswitch

https://www.thefanclub.co.za/how-to/how-setup-usb-3g-modem-raspberry-pi-using-usbmodeswitch-and-wvdial

sudo apt-get update
sudo apt-get install ppp usb-modeswitch wvdial

$ lsusb
Bus 001 Device 009: ID 05c6:1000 Qualcomm, Inc. Mass Storage Device

idVendor=05c6, idProduct=1000

Next switch usb device until next reboot:

/tmp $ sudo usb_modeswitch -W -v 05c6 -p 1000 -K
[sudo] password for :
Take all parameters from the command line

* usb_modeswitch: handle USB devices with multiple modes
* Version 2.2.0 (C) Josua Dietze 2014
* Based on libusb1/libusbx

! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor= 0x05c6
DefaultProduct= 0x1000

StandardEject=1
NeedResponse=0

Look for default devices ...
found USB ID 05c6:1000
vendor ID matched
product ID matched
found USB ID 0658:0200
found USB ID 0424:ec00
found USB ID 0424:9514
found USB ID 1d6b:0002
Found devices in default mode (1)
Access device 009 on bus 001
Current configuration number is 1
Use interface number 0
Use endpoints 0x01 (out) and 0x81 (in)

USB description data (for identification)
-------------------------
Manufacturer: Qualcomm, Incorporated
Product: Qualcomm CDMA Technologies MSM
Serial No.: 351602000025260
-------------------------
Sending standard EJECT sequence
Looking for active driver ...
OK, driver detached
Set up interface 0
Use endpoint 0x01 for message sending ...
Trying to send message 1 to endpoint 0x01 ...
OK, message successfully sent
Read the response to message 1 (CSW) ...
Response successfully read (13 bytes).
Trying to send message 2 to endpoint 0x01 ...
OK, message successfully sent
Read the response to message 2 (CSW) ...
Response reading failed (error -1)
Device is gone, skip any further commands
-> Run lsusb to note any changes. Bye!

/tmp $ lsusb
Bus 001 Device 010: ID 05c6:6000 Qualcomm, Inc. Siemens SG75
Bus 001 Device 007: ID 0658:0200 Sigma Designs, Inc.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

/tmp $ lsusb -v -d 05c6:6000

Bus 001 Device 010: ID 05c6:6000 Qualcomm, Inc. Siemens SG75
Couldn't open device, some information will be missing
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x05c6 Qualcomm, Inc.
idProduct 0x6000 Siemens SG75

http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=3&t=2670
http://cateee.net/lkddb/web-lkddb/USB_SERIAL_ZTE.html
http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=3&t=2565
http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=3&t=2565

usb_modeswitch -v 05c6 -p 1000-V 05c6 -P 6000 -M 55534243123456780000000000000011060000000000000000000000000000

dmesg:
[ 11.902783] usb 1-1.5: Product: Qualcomm CDMA Technologies MSM
[ 11.902793] usb 1-1.5: Manufacturer: Qualcomm, Incorporated
[ 11.902803] usb 1-1.5: SerialNumber: 351602000025260
[ 11.905794] usb-storage 1-1.5:1.0: USB Mass Storage device detected
[ 11.906923] scsi host0: usb-storage 1-1.5:1.0
[ 22.390696] random: crng init done
[ 40.917405] usb 1-1.5: USB disconnect, device number 8
[ 41.210686] usb 1-1.5: new high-speed USB device number 9 using dwc_otg
[ 41.343387] usb 1-1.5: New USB device found, idVendor=05c6, idProduct=6000
[ 41.343411] usb 1-1.5: New USB device strings: Mfr=3, Product=2, SerialNumber=4
[ 41.343423] usb 1-1.5: Product: Qualcomm CDMA Technologies MSM
[ 41.343434] usb 1-1.5: Manufacturer: Qualcomm, Incorporated
[ 41.343444] usb 1-1.5: SerialNumber: 351602000025260
[ 41.349624] usb-storage 1-1.5:1.4: USB Mass Storage device detected
[ 41.352063] scsi host0: usb-storage 1-1.5:1.4
[ 41.386810] usbcore: registered new interface driver usbserial
[ 41.386968] usbcore: registered new interface driver usbserial_generic
[ 41.387091] usbserial: USB Serial support registered for generic
[ 41.407558] usbcore: registered new interface driver option
[ 41.407726] usbserial: USB Serial support registered for GSM modem (1-port)
[ 41.408638] option 1-1.5:1.0: GSM modem (1-port) converter detected
[ 41.434694] usb 1-1.5: GSM modem (1-port) converter now attached to ttyUSB0
[ 41.441886] option 1-1.5:1.1: GSM modem (1-port) converter detected
[ 41.449887] usb 1-1.5: GSM modem (1-port) converter now attached to ttyUSB1
[ 41.450324] option 1-1.5:1.2: GSM modem (1-port) converter detected
[ 41.452242] usb 1-1.5: GSM modem (1-port) converter now attached to ttyUSB2
[ 41.452665] option 1-1.5:1.3: GSM modem (1-port) converter detected
[ 41.453470] usb 1-1.5: GSM modem (1-port) converter now attached to ttyUSB3
[ 42.412601] scsi 0:0:0:0: Direct-Access WCDMA MMC Storage 2.31 PQ: 0 ANSI: 2
[ 42.428977] sd 0:0:0:0: Attached scsi generic sg0 type 0
[ 42.429125] sd 0:0:0:0: [sda] Attached SCSI removable disk

Bug in usb_modeswitch
Follow
https://bugs.launchpad.net/raspbian/+bug/1593669
to have systemd startup correctly do switch modem

Setup a file containing the default vendor and product id. In the contents of this file you have to set the target vendor and product id one has obtained by manually switching the mode of the device.
I selected the MessageContent which occurs the most for simular devices…

$ ls /etc/usb_modeswitch.d/
05c6:1000

$ cat /etc/usb_modeswitch.d/05c6\:1000
DefaultVendor= 0x05c6
DefaultProduct=0x1000

TargetVendor= 0x05c6
TargetProduct= 0x6000

MessageContent="5553424312345678000000000000061b000000020000000000000000000000"

StandardEject=1

$ ls -l /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 0 Jun 10 21:55 /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 1 Jun 10 21:55 /dev/ttyUSB1
crw-rw---- 1 root dialout 188, 2 Jun 10 21:55 /dev/ttyUSB2
crw-rw---- 1 root dialout 188, 3 Jun 10 21:55 /dev/ttyUSB3

$ sudo wvdialconf
Editing `/etc/wvdial.conf'.

Scanning your serial ports for a modem.

ttyUSB0: ATQ0 V1 E1 -- OK
ttyUSB0: ATQ0 V1 E1 Z -- OK
ttyUSB0: ATQ0 V1 E1 S0=0 -- OK
ttyUSB0: ATQ0 V1 E1 S0=0 &C1 -- OK
ttyUSB0: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK
ttyUSB0: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyUSB0: Modem Identifier: ATI -- Manufacturer: QUALCOMM INCORPORATED
ttyUSB0: Speed 9600: AT -- OK
ttyUSB0: Max speed is 9600; that should be safe.
ttyUSB0: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyUSB1: ATQ0 V1 E1 -- OK
ttyUSB1: ATQ0 V1 E1 Z -- OK
ttyUSB1: ATQ0 V1 E1 S0=0 -- OK
ttyUSB1: ATQ0 V1 E1 S0=0 &C1 -- OK
ttyUSB1: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK
ttyUSB1: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyUSB1: Modem Identifier: ATI -- Manufacturer: QUALCOMM INCORPORATED
ttyUSB1: Speed 9600: AT -- OK
ttyUSB1: Max speed is 9600; that should be safe.
ttyUSB1: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyUSB2: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyUSB2: ATQ0 V1 E1 -- failed with 9600 baud, next try: 9600 baud
ttyUSB2: ATQ0 V1 E1 -- and failed too at 115200, giving up.
ttyUSB3: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyUSB3: ATQ0 V1 E1 -- failed with 9600 baud, next try: 9600 baud
ttyUSB3: ATQ0 V1 E1 -- and failed too at 115200, giving up.

Found a modem on /dev/ttyUSB0.
Modem configuration written to /etc/wvdial.conf.
ttyUSB0: Speed 9600; init “ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0”
ttyUSB1: Speed 9600; init “ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0”

To be able to access the modem, one has to add the user to the dialout group:

$ sudo apt-get install cu
$ sudo adduser myuser dialout
$ sudo adduser root dialout
$ groups
$ awk -F':' '/dialout/{print $4}' /etc/group

To take effect one first has to reboot ;-(
$ sudo reboot

$ cu -l /dev/ttyUSB0
And if you cannot see what you type:
$ cu -h -l /dev/ttyUSB1

https://hristoborisov.com/index.php/projects/turning-the-raspberry-pi-into-a-sms-center-using-python/

Leave a comment