Friday, September 8, 2017

Cellular Modem on the Pi

Our first attempt at adding WAN connectivity to the Pi failed because we didn't have a proper antenna connection, and we were on site so there was no Radio Shack (ha!) to run to. With the Novatel in pieces after half-assed attempts to solder hair-like antenna leads to gnat-sized antenna ports failed, it was time to order a new modem.


With a Verizon wireless plan in place and service activated, a used USB551L USB modem was located for cheap. This is another Novatel device and rumor was that it works in Linux.

The device was first tested on Windows 10, where it worked once the appropriate Verizon Access Manager was installed to get the right driver and switch the modem over to "interface" mode instead of NDIS mode.

Next it was plugged into the Pi (running Raspbian Stretch Light). lsusb showed that the device was detected:
pi@cabinpi:~ $ lsusb

Bus 001 Device 005: ID 0461:4d51 Primax Electronics, Ltd 0Y357C PMX-MMOCZUL (B) [Dell Laser Mouse]
Bus 001 Device 006: ID 413c:2010 Dell Computer Corp. Keyboard
Bus 001 Device 004: ID 413c:1003 Dell Computer Corp. Keyboard Hub
Bus 001 Device 007: ID 1410:b001 Novatel Wireless Ovation MC551
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. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Groovy. Running dmesg shows the following modem related info:
[    6.329015] usb 1-1.2: New USB device found, idVendor=1410, idProduct=b001
[    6.329026] usb 1-1.2: New USB device strings: Mfr=4, Product=3, SerialNumber=5
[    6.329034] usb 1-1.2: Product: Novatel Wireless 4G
[    6.329042] usb 1-1.2: Manufacturer: Novatel Wireless, Inc.
[    6.329049] usb 1-1.2: SerialNumber: 990000949401861
[    6.432994] usbcore: registered new interface driver usbserial
[    6.433106] usbcore: registered new interface driver usbserial_generic
[    6.433208] usbserial: USB Serial support registered for generic
[    6.456396] usbcore: registered new interface driver option
[    6.456502] usbserial: USB Serial support registered for GSM modem (1-port)
[    6.457455] option 1-1.2:1.0: GSM modem (1-port) converter detected
[    6.458010] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB0
[    6.458362] option 1-1.2:1.1: GSM modem (1-port) converter detected
[    6.459560] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB1
[    6.459892] option 1-1.2:1.2: GSM modem (1-port) converter detected
[    6.460856] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB2
[    6.461159] option 1-1.2:1.4: GSM modem (1-port) converter detected
[    6.464184] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB3


Which is weird, but apparently all the modems use serial ports to handle signaling to the cellular network. And this is where it went to hell. Although the interface (wwan0) showed up, it didn't have an IP address. Google searches result in the knowledge that you have to actually "dial" Verizon for the connection to be established. Thus a horrible rabbit whole of ppp and wvdial was entered, resulting in high school flash backs to ATDT commands to dial up the local BBS and lots of "NO CARRIER" messages.

Okay, this is getting stupid. It shouldn't be this hard. One marginally helpful post demonstrated that in Ubuntu you just run the add connection wizard and bam! you're done. So, I downloaded and installed Ubuntu Mate on the Pi, which gives you more or less a full fledged version of Ubuntu. I clicked on the add connection wizard, and guess what? It just worked. So what vile wizardry allowed this? Apparently the network-manager package. So, back to a our Raspbian Stretch image.

First, install Network Manager:
sudo apt-get install network-manager
Next, add the connection:
sudo nmcli connection edit type gsm con-name "verizon"

This takes you into the nmcli editor, which seems kind of silly to me. I just saved the connection, then nano'd the resulting config file to look like this:
sudo nano /etc/NetworkManager/system-connections/verizon


[connection]
id=verizon
uuid=d8e54212-4eed-44e7-a99b-d284e61d7b94
type=gsm
autoconnect=true
permissions=

[gsm]
apn=vzwinternet
number=*99#
password-flags=1

[ipv4]
dns-search=
method=auto

[ipv6]
addr-gen-mode=stable-privacy
dns-search=
ip6-privacy=0
method=auto

Reboot for good measure, and you end up with:
pi@cabinpi:~ $ sudo nmcli dev
DEVICE           TYPE      STATE        CONNECTION
cdc-wdm0         gsm       connected    verizon

Running ifconfig shows your new double-NAT'd IP address. (A problem for another day.)

Ship it!

1 comment:

  1. The author's unique perspective and in-depth knowledge were evident throughout the post, making it a worthwhile read. Crypto Currency Exchange

    ReplyDelete