Meu BQ Aquaris E5 (edição Ubuntu) não foi detectado como um modem GSM na edição desktop do Ubuntu 15.10. Por isso, tentei o seguinte script de shell:
vendor=$1
product=$2
cat <<EOF > /etc/usb_modeswitch.d/mobile
DefaultVendor= ${vendor}
DefaultProduct= ${product}
TargetVendor= ${vendor}
TargetProduct= ${product}
# MessageContent="5553424312345678c00000008000069f030000000000000000000000000000"
# MessageContent="55534243f4fa00000000000000000600000000000000000000000000000000"
MessageContent="5553424356fb00000000000000000600000000000000000000000000000000"
EOF
service modemmanager restart
service udev restart
rmmod option
rmmod usb_wwan
rmmod usbserial
usb_modeswitch -I -W -c /etc/usb_modeswitch.d/mobile --type option-zerocd
sleep 2
modprobe usbserial vendor=${vendor} product=${product}
sleep 2
modprobe usb_wwan
sleep 2
modprobe option
sleep 2
vndr='printf "%x" ${vendor}'
prdt='printf "%x" ${product}'
echo "$vndr $prdt" > /sys/bus/usb-serial/drivers/option1/new_id
Executou o script de shell acima da seguinte forma:
detect_usb 0x2a47 0x0c02.
Depois disso, a seguinte mensagem foi exibida em / var / log / syslog:
Nov 9 08:14:32 family-desktop kernel: [ 1038.246463] usbcore: registered new interface driver usbserial
Nov 9 08:14:32 family-desktop kernel: [ 1038.246487] usbcore: registered new interface driver usbserial_generic
Nov 9 08:14:32 family-desktop kernel: [ 1038.246504] usbserial: USB Serial support registered for generic
Nov 9 08:14:32 family-desktop kernel: [ 1038.246525] usbserial_generic 4-1.8:1.1: The "generic" usb-serial driver is only for testing and one-off prototypes.
Nov 9 08:14:32 family-desktop kernel: [ 1038.246528] usbserial_generic 4-1.8:1.1: Tell [email protected] to add your device to a proper driver.
Nov 9 08:14:32 family-desktop kernel: [ 1038.246530] usbserial_generic 4-1.8:1.1: generic converter detected
Nov 9 08:14:32 family-desktop kernel: [ 1038.246648] usb 4-1.8: generic converter now attached to ttyUSB0
Nov 9 08:14:36 family-desktop kernel: [ 1042.266838] usbcore: registered new interface driver option
Nov 9 08:14:36 family-desktop kernel: [ 1042.266865] usbserial: USB Serial support registered for GSM modem (1-port)
A execução do lsusb no meu sistema mostra o seguinte:
Bus 004 Device 004: ID 2a47:0c02
Bus 004 Device 003: ID 0781:5590 SanDisk Corp.
.....
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 004: ID 2188:0ae1
Mas tentar enviar comandos AT para o modem (detectado como / dev / ttyUSB0), falha. O seguinte script de demonstração do python-gsmmodem é usado:
!/usr/bin/env python
"""\
Demo: handle incoming SMS messages by replying to them
Simple demo app that listens for incoming SMS messages, displays the sender's number
and the messages, then replies to the SMS by saying "thank you"
"""
from __future__ import print_function
import logging
import sys
PORT = "/dev/ttyUSB%s" % (sys.argv[1])
BAUDRATE = 9600
PIN = '<my Pin>' # SIM card PIN (if any)
from gsmmodem.modem import GsmModem
def handleSms(sms):
print(u'== SMS message received ==\nFrom: {0}\nTime: {1}\nMessage:\n{2}\n'.format(sms.number, sms.time, sms.text))
print('Replying to SMS...')
sms.reply(u'SMS received: "{0}{1}"'.format(sms.text[:20], '...' if len(sms.text) > 20 else ''))
print('SMS sent.\n')
def main():
print('Initializing modem...')
# Uncomment the following line to see what the modem is doing:
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
modem = GsmModem(PORT, BAUDRATE, smsReceivedCallbackFunc=handleSms)
modem.smsTextMode = False
modem.connect(PIN)
print('Waiting for SMS message...')
try:
modem.rxThread.join(230**31) # Specify a (huge) timeout so that it essentially blocks indefinitely, but still receives CTRL+C interrupt signal
finally:
modem.close();
if __name__ == '__main__':
main()
Ele retorna algo da seguinte forma:
# python sms_handler_demo.py 0
Initializing modem...
INFO: Connecting to modem on port /dev/ttyUSB0 at 9600bps
DEBUG: write: ATZ
Traceback (most recent call last):
File "sms_handler_demo.py", line 41, in <module>
main()
File "sms_handler_demo.py", line 33, in main
modem.connect(PIN)
File "/usr/local/lib/python2.7/dist-packages/gsmmodem/modem.py", line 177, in connect
self.write('ATZ') # reset configuration
File "/usr/local/lib/python2.7/dist-packages/gsmmodem/modem.py", line 413, in write
responseLines = super(GsmModem, self).write(data + writeTerm, waitForResponse=waitForResponse, timeout=timeout, expectedResponseTermSeq=expectedResponseTermSeq)
File "/usr/local/lib/python2.7/dist-packages/gsmmodem/serial_comms.py", line 140, in write
raise TimeoutException()
gsmmodem.exceptions.TimeoutException: None