For anyone interested, here is how I got past this issue. My goal was to use the Nova modem in Raspberian Stretch to access Amazon IoT web services, preferably from a tier-1 carrier like AT&T or Verizon. My application code is written in Python 3.5, but I’m not a Linux expert, and I have never dealt with AT modems, so be warned that there may well be better ways to do this!
First, here are some sites that helped:
I had an AT&T SIM, and after searching online I found the APN for AT&T is ‘nxtgenphone’.
With the modem plugged in, executing ‘ifconfig’ shows an interface at wwan0, but it is set to an unroutable IP:
Using ‘ls /dev/tty*’ to list the tty devices shows:
In my case there are 2 USB interfaces associated with the modem, ttyUSB0 and ttyUSB1 with ttyUSB1 as the active modem port.
If I open a Screen to that interface, I can run a few diagnostics on the modem. I found the Hologram diagnostic-test listed at the links above to be pretty useful.
Check that the port is working by typing ‘at’:
Now check the current APN setting:
On a new modem this will display ‘hologram’ as the APN and in my case it needed to be changed to ‘nxtgenphone’.
Verify that the APN has changed by querying again:
Now, reset the modem:
At this point the blue and red lights should both be on and solid, assuming you are inside the network coverage area.
This might take a few seconds to reply. When it does, you should see your chosen network in the list, similar to below:
+cops: (1,"AT&T","AT&T","310410",8),(3,"313 100","313 100","313100",8),(1,"310 260","310 260","310260",9),(0,1,2,3,4),(0,1,2)
Now we need to save the APN in non-volatile memory. To do that type:
The modem will switch off for a short period and then back on. Now you can unplug the modem and plug it back in and it will always come back up on the new APN.
Now we need to setup PPPD. Clone the scripts from the Hologram Git repo and copy them into correct folders under /etc/ as shown here:
git clone https://github.com/hologram-io/hologram-tools.git
sudo cp ppp/chatscripts/* /etc/chatscripts/
sudo cp ppp/peers/* /etc/ppp/peers/
In my case I’m using the ‘nova-m’ scripts, and since I really wanted eth0 interface to be primary and the cell modem to be secondary, I edited /etc/ppp/peers/nova-m and commented out the section setting the interface to defaultroute:
Use this connection as the default route.
I left /etc/chatscripts/nova-m untouched.
At this point, if I execute ‘ifconfig’ I see the wwan0 interface, shown here:
When I execute ‘sudo pon nova-m’, and then re-execute ‘ifconfig’, I see a new ppp0 interface:
In my case the ppp0 interface is connecting to the AT&T gateway at 10.64.64.64. If I ping a site using the interface, I can see that it works:
So, I know the interface works, but if I turn off eth0 and try to connect my Python app to Amazon AWS, it fails. I guess this is because my default gateway is on the 192 address, so traffic from my app always tries to go through 192.
If I inspect the routing table using ‘route -n’, I see this:
I can add a new route entry, and by setting the Metric value to a number just a bit higher than the eth0 metric, my ppp0 interface will take a lower priority. This allows the traffic to go out eth0 if eth0 is up, and ppp0 if it is down. Here is how I add the route:
sudo route add default gw 10.64.64.64 metric 203 ppp0
I’m weak on networking, so some sysadmin might point out a better way to set this up, but this accomplishes my goal, and now my python app can communicate with AWS via the cell network.
Adding the route in this manner does not live between resets, so it needs to be added each time the Pi powers up. In my case, that’s okay because I really don’t want the cell modem turned on unless my app is on. I can control this when my app initializes by sending the appropriate commands via Python’s ‘subprocess’ API.