Persistent PPP connection and hologram network connect on startup


#1

I have some general questions about the SDK for which I couldn’t really find an answer in the docs. I am using the Nova and SDK to have a Lora gateway via 3G. Now our gateway is quite remote and I would like the PPP interface to be reconnecting if it loses connection. Is this already the case when it drops? Or how would I go about to do this?

Furthermore, are there any standard ways in the CLI tool to have ‘hologram network connect’ run at boot of my raspberry, or should i setup a init scripts?

Cheers


Connect to Hologram Cellular on RaspPi3B startup
#2

I would utilize Cron to have to modem connect at startup, as that is what I do. Make sure to include sudo in the command, or it typically won’t run properly.

As to making sure it stays connected, I have an hourly Cron job run a shell script that disconnects the modem, waits 5 sec, and reconnects using the Hologram CLI commands


#3

Thanks, that was some good insight, I completely forgot about trusty cron. I decided to spice it up a bit and not disconnect if not needed, the less downtime the better in my opinion. I am not a big expert on shell scripts, but maybe you could check if this would be solid

#!/bin/bash

host="google.com"

# PPP DEVICE
device=$((ifconfig ppp0) 2>&1)

# PING TWICE AND STORE RESULTS IN VAR
ping=$((ping -c2 $host) 2>&1)

# IF FAILED PING OR NO PPP DEVICE
if [[ $device != *"RUNNING"* ]] || [[ $ping = *"100% packet loss"* ]] || [[ $ping = *"unknown host"* ]]; then
  echo "Connecting PPP"
  hologram network disconnect
  sleep 5
  hologram network connect
  echo "Connected PPP"
else
  echo "Already connected to PPP"
fi

#4

I’m even less knowlaganle than you are for shell drivers, lol. But looks good to me!


#5

I like the script! here a few comments:

  1. If you want to run this script through Cron, you will need to add the full path to bash and to hologram on the lines involving hologram, since Cron doesn’t have access to your $PATH environment variable. Took me a while to figure that out.

  2. Maybe we could add a loop between “Connecting PPP” and “Connected PPP” to let hologram retry the connection in case hologram network connect times out. This way you can let the script run say every 30 minutes to save bandwidth, but make sure it connects as quickly as possible once it knows it is offline.

Cheers!