# Quectel EC25 LTE Modem

This is **not** a simple configuration and requires a lot of potentially dangerous changes to your system. The Quectel EC25 modems need a package from the ```testing``` Debian apt tree which is not available on ```stable``` or ```stretch```. Having multiple trees setup at the same time on Debian can quickly de-stabilize your Lollipop can cause strange problems.

Only perform these steps and operations if you *must* have a Quectel EC25 and cannot find a modem that's supported by default by Debian ```stretch``` or Debian ```stable```.

# Inspiration / Further Reading

- [http://www.embeddedpi.com/documentation/3g-4g-modems/quecetel-modem-gps-setup](http://www.embeddedpi.com/documentation/3g-4g-modems/quecetel-modem-gps-setup)
- [http://www.embeddedpi.com/documentation/3g-4g-modems/mypi-industrial-raspberry-pi-3g-4g-modem-howto](http://www.embeddedpi.com/documentation/3g-4g-modems/mypi-industrial-raspberry-pi-3g-4g-modem-howto)
- [http://www.embeddedpi.com/documentation/3g-4g-modems/quecetel-modem-gps-setup](http://www.embeddedpi.com/documentation/3g-4g-modems/quecetel-modem-gps-setup)
- [https://git.lollipopcloud.solutions/lollipop-cloud/docs/src/branch/master/hardware/gps.md](https://git.lollipopcloud.solutions/lollipop-cloud/docs/src/branch/master/hardware/gps.md)
- [https://www.cnx-software.com/2018/02/11/how-to-use-3g-and-gps-on-raspberry-pi-with-thaieasyelec-3g-hat-expansion-board/](https://www.cnx-software.com/2018/02/11/how-to-use-3g-and-gps-on-raspberry-pi-with-thaieasyelec-3g-hat-expansion-board/)
- [https://blog.enchose.com/raspberry-pi-runs-ppp-dial-up-quectel-ec25-lte-modem/](https://blog.enchose.com/raspberry-pi-runs-ppp-dial-up-quectel-ec25-lte-modem/)
- [https://www.quectel.com/support/faq.htm](https://www.quectel.com/support/faq.htm)
- [https://osmocom.org/projects/quectel-modems/wiki/EC25](https://osmocom.org/projects/quectel-modems/wiki/EC25)
- [https://truetechembedded.blogspot.com/2018/03/quectel-ec25ec20-software-porting-guide.html](https://truetechembedded.blogspot.com/2018/03/quectel-ec25ec20-software-porting-guide.html)
- [https://www.quectel.com/UploadImage/Downlad/Quectel_WCDMA&LTE_Linux_USB_Driver_User_Guide_V1.8.pdf](https://www.quectel.com/UploadImage/Downlad/Quectel_WCDMA&LTE_Linux_USB_Driver_User_Guide_V1.8.pdf)
- [https://sixfab.com/updated-tutorial-3-make-a-ppp-internet-connection-with-3g-4glte-shields-on-raspberry-pi/](https://sixfab.com/updated-tutorial-3-make-a-ppp-internet-connection-with-3g-4glte-shields-on-raspberry-pi/)
- [https://sixfab.com/product/quectel-ec25-mini-pcle-4glte-module/](https://sixfab.com/product/quectel-ec25-mini-pcle-4glte-module/)
- [https://sixfab.com/gps-tracker-with-3g-4glte-shield/](https://sixfab.com/gps-tracker-with-3g-4glte-shield/)
- [https://tools.ietf.org/html/draft-ietf-behave-nat64-discovery-heuristic-17](https://tools.ietf.org/html/draft-ietf-behave-nat64-discovery-heuristic-17)

# Setup Apt Repos

See the ```advanced/debian_multi_repo.md``` documentation and setup the ```testing``` apt tree at a minimum. 

Once complete, continue. *The Quectel EC25 will **NOT** work without this step being complete.*

# Setup LTE/3G/etc Support

``` bash

apt-get update
apt-get install -t testing libqmi-utils
systemctl reboot

```

# Setup NetworkManager/ModemManager

After rebooting in the previous step the modem should work 100% with our standard NetworkManager and ModemManager docs. Head over to them for your appropriate distribution for final setup of the modem internet connection.

# Setup GPS (Optional)

Prior to setting up GPS make sure you have an antenna connected to the EC25. We've had reasonable success with this one: https://www.mouser.com/ProductDetail/673-GPSMOD1333

## GPS Tools (Per lollipop cloud docs)

``` bash

apt-get install picocom gpsd gpsd-clients python-gps gpsbabel

```

## Setup / Testing GPS on Quectel

``` bash

tmux new -s gps testing
picocom /dev/ttyUSB2 -b 115200
    AT+QGPS=1 # Turns on GNSS module
    AT+QGPSEND # Turns off GNSS module
    AT+QGPSCFG="autogps",1 # Enable GPS whenever module comes online

picocom /dev/ttyUSB1 -b 9600

systemctl stop gpsd.socket
gpsd -n -N -D 3 -S 2948 /dev/ttyUSB1
gpsmon 127.0.0.1:2948 # more reliable with quectel gps for some reason (may need to work WITH cgps)
cgps 127.0.0.1:2948 # the "usual" way we like to monitor gps status

```

## Setup gpsd defaults for the EC25

``` bash

/etc/default/gpsd # Add /dev/ttyUSB1 to device
                  # Add -n -D 3 to options (for debugging)

```

# NAT64 + DNS64

If you find yourself on a pure ipv6 network with NAT64/DNS64 deployed, you'll need the following breadcrumbs and information to get things online.

This section is a Work In Progress and not 100% working. Help Welcome.

## Figure out NAT64 endpoints via RFC7050

This may or may not be deployed on your carrier's network. Start here for decyphering NAT64 prefixes.

``` bash

host ipv4only.arpa
ipv4only.arpa has address 192.0.0.170
ipv4only.arpa has address 192.0.0.171
ipv4only.arpa has IPv6 address 2607:7700:0:26::c000:aa
ipv4only.arpa has IPv6 address 2607:7700:0:26::c000:ab
ping 2607:7700:0:26::8.8.8.8

```

## Figure out NAT64 endpoints w/o RFC7050

See the ```rfc7050.py``` script and ajust it lightly to look for an ipv4 only DNS record so the prefix can be found programatically by the rest of the script.

## Turn on DNS64 in Unbound

You'll need an additional include line in the config *above* the existing one for ```/etc/unbound/dns64.conf```.

``` bash

cat > /etc/unbound/dns64.conf <<EOF
module-config: "dns64 validator iterator"
dns64-prefix: 2607:7700:0:26::/96
EOF
systemctl restart unbound

```

## Turn off DNS64 in Unbound

This is how you'd turn off DNS64 when back on ipv4 in some capacity.

``` bash

cat > /etc/unbound/dns64.conf <<EOF
#module-config: "dns64 validator iterator"
#dns64-prefix:
EOF
systemctl restart unbound

```

## Dig into the clat setup

See ```clat.md``` for additional details on how to setup routing for the NAT64 edge. This is not working 100% and you've been warned some iptables and similarly difficult tech tinkering is required.
