/piphone

Primary LanguageRust

piPhone

Modern day tin can phone built using Orange Pi 3B.

Getting Started

Install Orange Pi OS (Arch) from here to an SD card using balenaEtcher.

Get SSH and WiFi setup. You can use nmcli to connect to WiFi.

nmcli dev wifi connect <wifi_name> password <wifi_passwd>

Give the Pi a static DHCP assignment in your router and setup port forwarding for port 5060 (voip).

Install rust.

sudo pacman -S rustup
rustup default stable

Make sure your user is in audio group.

sudo usermod -aG audio $USER

You should see devices listed with the following command (no sudo).

alsactl info

Finally, run the app using cargo.

cargo run

Usage

GPIO3_C7 (physical pin 12 below) must be high to activate the phone. You can connect this to 3.3V (physical pin 1) with a jumper or add a switch.

 +------+-----+----------+--------+---+   PI3B   +---+--------+----------+-----+------+
 | GPIO | wPi |   Name   |  Mode  | V | Physical | V |  Mode  | Name     | wPi | GPIO |
 +------+-----+----------+--------+---+----++----+---+--------+----------+-----+------+
 |      |     |     3.3V |        |   |  1 || 2  |   |        | 5V       |     |      |
 |  140 |   0 |    SDA.2 |     IN | 1 |  3 || 4  |   |        | 5V       |     |      |
 |  141 |   1 |    SCL.2 |     IN | 1 |  5 || 6  |   |        | GND      |     |      |
 |  147 |   2 |    PWM15 |     IN | 0 |  7 || 8  | 1 | ALT1   | RXD.2    | 3   | 25   |
 |      |     |      GND |        |   |  9 || 10 | 1 | ALT1   | TXD.2    | 4   | 24   |
 |  118 |   5 | GPIO3_C6 |     IN | 0 | 11 || 12 | 1 | IN     | GPIO3_C7 | 6   | 119  |
 |  128 |   7 | GPIO4_A0 |     IN | 0 | 13 || 14 |   |        | GND      |     |      |
 |  130 |   8 |    TXD.7 |     IN | 0 | 15 || 16 | 0 | IN     | RXD.7    | 9   | 131  |
 |      |     |     3.3V |        |   | 17 || 18 | 0 | IN     | GPIO4_A1 | 10  | 129  |
 |  138 |  11 | SPI3_TXD |     IN | 0 | 19 || 20 |   |        | GND      |     |      |
 |  136 |  12 | SPI3_RXD |     IN | 0 | 21 || 22 | 0 | IN     | TXD.9    | 13  | 132  |
 |  139 |  14 | SPI3_CLK |     IN | 0 | 23 || 24 | 0 | IN     | SPI3_CS1 | 15  | 134  |
 |      |     |      GND |        |   | 25 || 26 | 0 | IN     | GPIO4_A7 | 16  | 135  |
 |   32 |  17 |    SDA.3 |     IN | 1 | 27 || 28 | 1 | IN     | SCL.3    | 18  | 33   |
 |  133 |  19 |    RXD.9 |     IN | 0 | 29 || 30 |   |        | GND      |     |      |
 |  124 |  20 | GPIO3_D4 |     IN | 0 | 31 || 32 | 0 | IN     | PWM11    | 21  | 144  |
 |  127 |  22 | GPIO3_D7 |     IN | 0 | 33 || 34 |   |        | GND      |     |      |
 |  120 |  23 | GPIO3_D0 |     IN | 0 | 35 || 36 | 0 | IN     | GPIO3_D5 | 24  | 125  |
 |  123 |  25 | GPIO3_D3 |     IN | 0 | 37 || 38 | 0 | IN     | GPIO3_D2 | 26  | 122  |
 |      |     |      GND |        |   | 39 || 40 | 0 | IN     | GPIO3_D1 | 27  | 121  |
 +------+-----+----------+--------+---+----++----+---+--------+----------+-----+------+
 | GPIO | wPi |   Name   |  Mode  | V | Physical | V |  Mode  | Name     | wPi | GPIO |
 +------+-----+----------+--------+---+   PI3B   +---+--------+----------+-----+------+

Systemd

You can use systemd to automatically start the phone app on boot.

Create a new service file at /etc/systemd/system/piphone.service with the following contents.

[Unit]
Description=Piphone
After=network.target sound.target

[Service]
Type=simple
WorkingDirectory=/home/tanner/dev/piphone
ExecStart=/usr/bin/cargo run --release
Environment="PATH=/home/tanner/.cargo/bin:/usr/bin:/bin"
Restart=always
RestartSec=5

[Install]
WantedBy=default.target

Restart and RestartSec will restart the app if it crashes after 5 seconds.

Next, enable the service.

sudo systemctl enable piphone.service
sudo systemctl restart piphone.service

You can check the status using status.

systemctl status piphone.service