Probing
Probing your modem
Finding your modem's serial device
Now you need to find out your modem's device node. That'll normally be printed in /var/log/kern.log when you plug the modem in, or will appear in dmesg during boot. Common device nodes are /dev/ttyUSB0 and /dev/ttyACM0.
If it doesn't seem to be detected at all and it's a USB device (almost all, even internal modems, are) then try using lsusb to find its vendor and product codes and load the usbserial module manually. (You can probe a bluetooth modem too with a bit more work - see the end of the document for setup). For example, if lsusb shows:
Bus 002 Device 002: ID 413c:8138 Dell Computer Corp. Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard EAP-SIM Port
the vendor ID is 413c and the device ID is 8138, so I can load the driver with:
sudo modprobe usbserial vendor=0x413c product=0x8138
after which I can access the modem as /dev/ttyUSB0 .
Probe script for modem capabilities
Save the following text to a file named 'probe.txt' on your GNOME desktop. This script will be used to probe your modem for its capabilities and a few other details.
REPORT +GCAP: REPORT +COPS: REPORT +CREG: TIMEOUT 2 '' # Change the PIN below to your SIM unlock PIN if you have one. # If you don't, just leave it at 0000. ATZ+CPIN="0000" OK-ATZ-OK AT+GCAP +GCAP: AT+COPS? +COPS: AT+CREG? +CREG:
Probing the modem
Once you know the device node for your modem, execute the following shell command, replacing MODEMDEVICE with the path to the device node:
chat -s -f ~/Desktop/probe.txt </dev/MODEMDEVICE >/dev/MODEMDEVICE
For example, the following shows me probing my my built-in HSDPA modem on /dev/ttyUSB0 then my USB mobile phone on /dev/ttyACM0:
craig$ chat -s -f ~/Desktop/probe.txt >/dev/ttyACM0 </dev/ttyACM0 chat: Sep 03 10:40:47 +GCAP: +CGSM,+DS,+W chat: Sep 03 10:40:47 +COPS: 0,2,"50501",2 chat: Sep 03 10:40:47 +CREG: 0,1 craig$ chat -s -f ~/Desktop/probe.txt >/dev/ttyUSB0 </dev/ttyUSB0 chat: Sep 03 10:40:51 +GCAP: +CGSM,+DS,+ES chat: Sep 03 10:40:52 +COPS: 0,0,"Telstra Mobile",2 chat: Sep 03 10:40:52 +CREG: 0,1
The part of the output you want to include on this wiki page is the bit after +GCAP:, eg +CGSM,+DS,+ES. It'd be helpful if you could post the COPS output, too, eg 0,0,"Telstra Mobile",2.
Getting more hardware details
Lots of GSM/CDMA modems are rebranded. Everything in a Dell machine, for example. You can get hardware details from these modems using gsmctl from the gsm-utils package in universe:
craig$ # My Dell 5520 internal HSDPA modem craig$ gsmctl -d /dev/ttyUSB0 ME <ME0> Manufacturer: Novatel Wireless Incorporated <ME1> Model: Expedite EU870D MiniCard <ME2> Revision: 10.9.0102.0-00 [2007-07-03 13:50:21] <ME3> Serial Number: 351380115216121 craig$ craig$ # My N95-3 craig$ gsmctl -d /dev/ttyACM0 ME <ME0> Manufacturer: Nokia <ME1> Model: Nokia N95 <ME2> Revision: V 06wk41v57.1 24-04-08 RM-160 (c) Nokia <ME3> Serial Number: 318911111771193
Note: The serial numbers in the above have been replaced with dummies.
If you file a bug with an issue about phone support, consider attaching the output of gsmctl -d /dev/MODEMDEVICE ALL to the bug report (in addition to the output of lshal and the other information requested by the NM team). It might prove handy.
Probing bluetooth modems
A bluetooth modem generally works as a virtual serial device over an rfcomm channel. You can probe these much the same way as shown above, but first you need to set up the channel.
To start with, make sure the tools you'll need are installed:
sudo aptitude install bluez-utils ppp
Turn bluetooth on in your phone and set it to be visible to all (discoverable). If it's a dedicated modem not a phone, you might need to press the "connect" or "discover" button instead. It'll also help if you pair your phone/modem and laptop then set the pairing to trusted on the phone/modem so that you're not prompted to approve connections all the time.
Now find its bluetooth MAC address using hcitool scan:
craig$ hcitool scan
Scanning ...
00:1D:E9:F5:55:AF Craig's N95You can now set your phone/modem back to invisible (not discoverable) mode if you prefer to. We'll be talking to it directly from now on, so bluetooth must be on but does not need to be discoverable.
Use sdptool to discover the rfcomm port for DUN (dial-up networking) communication:
craig$ sdptool search --bdaddr 00:1D:E9:F5:55:AF DUN
Searching for DUN on 00:1D:E9:F5:55:AF ...
Service Name: Dial-Up Networking
Service RecHandle: 0x1001f
Service Class ID List:
"Dialup Networking" (0x1103)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 4
Language Base Attr List:
code_ISO639: 0x454e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Dialup Networking" (0x1103)
Version: 0x0100The RFCOMM channel we need is 4, as shown on the line below RFCOMM in the output above. Note that this often varies; some phones change RFCOMM DUN channels when rebooted, for example.
We now know enough to set up an RFCOMM binding we can use to talk to the modem. Specify your device's bluetooth MAC address and its RFCOMM channel (the last argument to rfcomm) in place of mine when you run the command below:
craig$ sudo rfcomm bind /dev/rfcomm0 00:1D:E9:F5:55:AF 4 craig$
It will generate no output, but running rfcomm again without arguments should show a binding.
craig$ rfcomm rfcomm0: 00:1D:E9:F5:55:AF channel 4 clean
You can now use /dev/rfcomm0 as the serial device node to talk to the modem when probing it using the instructions above. The phone and/or gnome-bluetooth on your laptop might prompt you for a passkey to set up a pairing if you haven't used the two devices together before. Additionally, the phone/modem may prompt you to accept the bluetooth connection from the laptop, so make sure you're ready to accept if prompted. Setting up a trusted pairing will eliminate that prompt.
This setup procedure will also let you use ppp over the rfcomm channel to connect to the Internet through your phone. Use a ppp and chat setup, or use a tool like wvdial just as you would a USB or serial GSM modem once you've created the binding. Here's a little shell script I use to re-bind the phone before connecting:
# replace the following with the MAC address of your phone. Note that
# your phone does NOT need to be discoverable for this to work.
BT=00:1D:E9:F5:55:AF
if test "$(id -u)" -ne 0 ; then
exec sudo $0
fi
CHAN=$(sdptool search --bdaddr $BT DUN | awk '/Channel/ { print $2}')
rfcomm release 2
rfcomm bind 2 "$BT" "$CHAN"
rfcommThis full procedure has been tested on a Nokia N95 and an LG U990.
Notes
The gsmctl program from the gsm-utils should be able to probe most modems, but appears to have issues parsing provider information returned by many devices. As I wasn't able to get it to reliably probe my modems I've provided a chat script to do the job instead. However, it and libgsm appear to be an ideal way to talk to modems, and should probably be considered for use by NetworkManager when doing things like:
- Determining battery level and charging state for a bluetooth or USB phone/modem
(I'm thinking in terms of a NetworkManager popup: "WARNING: The modem you are using for your network connection is almost out of battery power")
- Determining network connection quality - Getting operator details - Getting make/model information - Discovering operators within range for roaming etc - Testing PIN locking status
Also, some handy commands for GSM hardware control and probing can be found here and here.