├── README.md ├── chatscripts └── twilio └── peers └── twilio /README.md: -------------------------------------------------------------------------------- 1 | # Programmable Wireless Raspberry Pi ppp scripts 2 | Programmable Wireless is a set of developer-first tools to deploy and manage fleets of wireless devices, powering connectivity for the Internet of Things and enabling highly customized Communications use cases. 3 | 4 | This repository includes a group of ppp scripts to connect a Raspberry Pi to the Internet using a USB cellular modem. You can learn more about Programmable Wireless from the [Programmable Wireless Documentation](https://www.twilio.com/docs/api/wireless) and how to connect a USB modem to a Raspberry Pi by following this [guide](https://www.twilio.com/docs/api/wireless/iot-guides/connect-using-raspberry-pi-and-cellular-usb-modem). 5 | ## Requirements 6 | You will need to download and install software packages on your Raspberry Pi before you can use your unlocked cellular USB modem. Follow along with this repository's accompanying [guide](https://www.twilio.com/docs/api/wireless/iot-guides/connect-using-raspberry-pi-and-cellular-usb-modem) if you need additional help. The easiest option is to get a [Raspberry Pi WiFi dongle](https://www.amazon.com/Official-Raspberry-Pi-WiFi-dongle/dp/B014HTNO52/ref=sr_1_1?ie=UTF8&qid=1500054954&sr=8-1&keywords=Raspberry+Pi+Official+WiFi+Adapter) if your device does not have built in wifi. 7 | ## Step 1. Install packages on Raspberry Pi 8 | Type the following in a terminal: 9 | ``` 10 | sudo apt-get update 11 | sudo apt-get install ppp usb-modeswitch 12 | ``` 13 | ## Step 2. Determine current mode of your USB modem 14 | Follow along with this repository's accompanying [guide](https://www.twilio.com/docs/api/wireless/iot-guides/connect-using-raspberry-pi-and-cellular-usb-modem) to determine if your USB modem is in the correct mode. 15 | ## Step 3. Install ppp scripts 16 | Type the following in a terminal: 17 | ``` 18 | wget https://github.com/twilio/wireless-ppp-scripts/archive/master.zip 19 | unzip master.zip 20 | cd wireless-ppp-scripts 21 | sudo cp chatscripts/twilio /etc/chatscripts 22 | sudo cp peers/twilio /etc/ppp/peers 23 | ``` 24 | Thats it for the scripts. You can remove master.zip and wireless-ppp-scripts by typing the following in a terminal: 25 | ``` 26 | rm -rf master.zip 27 | rm -rf wireless-ppp-scripts 28 | ``` 29 | ## Step 4. Shut down wifi if up 30 | Type the following in a terminal: 31 | ``` 32 | sudo ifconfig wlan0 down 33 | ``` 34 | ## Step 5. Connect to the cellular network 35 | Type the following in a terminal: 36 | ``` 37 | sudo pon twilio 38 | ``` 39 | ## Step 4. Confirm 40 | Your USB modem should now be connected to the Internet! Try going to a web page or ping Twilio. Type the following in a terminal to ping www.twilio.com: 41 | ``` 42 | ping -c 3 www.twilio.com 43 | ``` 44 | ## You’re connected! 45 | You inserted a Twilio SIM card into your cellular USB modem and configured ppp to run at boot. Take a look at the other interesting things you can do with a Raspberry Pi such as [sending machine-to-machine Commands](https://www.twilio.com/docs/api/wireless/sending-machine-machine-commands) or creating a cellular connected [security camera](https://www.twilio.com/wireless/blueprints). 46 | -------------------------------------------------------------------------------- /chatscripts/twilio: -------------------------------------------------------------------------------- 1 | # Tested on Huawei Module's 2 | # See http://consumer.huawei.com/solutions/m2m-solutions/en/products/support/application-guides/detail/mu509-65-en.htm?id=82047 3 | 4 | # Exit executition if module receives any of the following strings: 5 | ABORT 'BUSY' 6 | ABORT 'NO CARRIER' 7 | ABORT 'NO DIALTONE' 8 | ABORT 'NO DIAL TONE' 9 | ABORT 'NO ANSWER' 10 | ABORT 'DELAYED' 11 | TIMEOUT 10 12 | REPORT CONNECT 13 | 14 | # Module will send the string AT regardless of the string it receives 15 | "" AT 16 | 17 | # Instructs the modem to disconnect from the line, terminating any call in progress. All of the functions of the command shall be completed before the modem returns a result code. 18 | OK ATH 19 | 20 | # Instructs the modem to set all parameters to the factory defaults. 21 | OK ATZ 22 | 23 | # Result codes are sent to the Data Terminal Equipment (DTE). 24 | OK ATQ0 25 | 26 | # Define PDP context 27 | OK AT+CGDCONT=1,"IP","wireless.twilio.com" 28 | 29 | # ATDT = Attention Dial Tone 30 | OK ATDT*99***1# 31 | 32 | # Don't send any more strings when it receives the string CONNECT. Module considers the data links as having been set up. 33 | CONNECT '' -------------------------------------------------------------------------------- /peers/twilio: -------------------------------------------------------------------------------- 1 | # The options script can specify the device used for the PPP dial-up connection, string transmission speed, hardware acceleration, overflow, and more 2 | 3 | connect "/usr/sbin/chat -v -f /etc/chatscripts/twilio" 4 | 5 | # Where is modem connect? 6 | # Device needs to be in modem mode 7 | # Locate gsm modem with "dmesg | grep gsm" 8 | /dev/ttyUSB0 9 | 10 | # Specify the baud rate (bit/s) used in the PPP dial-up connection. For 11 | # Huawei modules, it is recommended that you set this parameter to 115200 12 | 115200 13 | 14 | # Disables the default behaviour when no local IP address is specified, which is to determine (if possible) the local IP address from the hostname. With this option, the peer will have to supply the local IP address during IPCP negotiation (unless it specified explicitly on the command line or in an options file). 15 | noipdefault 16 | 17 | # Ask the peer for up to 2 DNS server addresses. The addresses supplied by the peer (if any) are passed to the /etc/ppp/ip-up script in the environment variables DNS1 and DNS2, and the environment variable USEPEERDNS will be set to 1. In addition, pppd will create an /etc/ppp/resolv.conf file containing one or two nameserver lines with the address(es) supplied by the peer. 18 | 19 | usepeerdns 20 | 21 | # Add a default route to the system routing tables, using the peer as the gateway, when IPCP negotiation is successfully completed. This entry is removed when the PPP connection is broken. This option is privileged if the nodefaultroute option has been specified. 22 | 23 | defaultroute 24 | 25 | # Do not exit after a connection is terminated; instead try to reopen the connection. The maxfail option still has an effect on persistent connections. 26 | persist 27 | 28 | # Do not require the peer to authenticate itself. This option is privileged. 29 | noauth 30 | --------------------------------------------------------------------------------