talkiepi

package module
v0.0.0-...-2105f0c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2023 License: MPL-2.0 Imports: 14 Imported by: 0

README

RotaryDialphone (talkiepi)

talkiepi is a headless capable Mumble client written in Go, written for walkie talkie style use on the Pi using GPIO pins connected to an old rotary phone for pickup, dial and ring functionality. It is a fork of [dchote which again is a fork of barnard.

Hardware prerequisites

See Hardware doc for steps on how to hook up the hardware.

Installing prerequisites

  1. Install Raspberry Pi OS Light, e.g. via Raspberry Pi Imager
  2. In /boot partition on SD card add line enable_uart=1 in config.txt
  3. Login to uart console with baudrate 11520 (connect Gnd and both Uart Pins via USB2Serial Adapter). Login is pi pw raspberry
  4. Run raspi-config go to network settings and setup wifi connection that is available in the house, make sure to enable a supported network (for me only 2.4GHz worked) to test this run the following command to find the SSID of all supported networks
iw wlan0 scan | grep ESSID

Alternatively, you can create a valid wpa_supplicant.conf file and place it in the boot partition. It will automatically be copied to the proper location under /etc/wpa_supplicant and removed from the boot volume after the next boot. An valid example file content would be

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=CH

network={
        ssid="TestWIFI"
        psk="password"
}
  1. Run sudo apt-get update
  2. Install gpiozero
sudo apt install python3-gpiozero
  1. Setup tailscale vpn, this is only required when multiple devices are located in different networks
  • Sign up connect the mumble server as well as some service computer to handle the authentications for the next step
  • Install tailscale on the raspi device, the last step requires accessing the generated url with a browser to authenticate the device
sudo apt-get update --allow-releaseinfo-change
curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up
  1. Blacklist audio output and enable usb audio as card 0 sudo nano /etc/modprobe.d/alsa-base.conf
options snd-usb-audio index=0
blacklist snd_bcm2835

check .asoundrc for best default

if missing libasound2-plugins

  1. disable hdmi to save some power /usr/bin/tvservice -o place in /etc/rc.local

  2. Setup a mumble server with the above credentials and make sure to open up channel 0-9. Make sure to write the ip address or hostname (including potential tailscale postfix if using a vpn setup)

Installing talkiepi

Install the following command to install the talkipie fork of this repo.

wget https://raw.githubusercontent.com/ramonaerne/talkiepi/master/debian/talkiepi-update.sh
sudo sh talkiepi-update.sh

which does install the latest debian package automatically.

Next adapt the hostname via raspi-config if multiple boards are used in the same network and make sure to ensure unique entries for `/etc/mumble_env.sh with the following default content

# replace with your server and credentials and place in /boot/mumble_env.sh
SERVER=...
PASSWORD=...
USERNAME=zero01
CHANNEL=1

make sure to select a unique channel (1-9) and username for all devices on the same server and provide server ip:port as well as the login password.

The default install guide from dchote is here.

GPIO

J8:                        Connect to the phone circuit:
   3V3  (1) (2)  5V        
 GPIO2  (3) (4)  5V    
 GPIO3  (5) (6)  GND   
 GPIO4  (7) (8)  GPIO14
   GND  (9) (10) GPIO15
GPIO17 (11) (12) GPIO18    -> ringSleep#
GPIO27 (13) (14) GND       -> GND to ring circuit
GPIO22 (15) (16) GPIO23    -> (for overlay pcb workaround connect to GPIO12)
   3V3 (17) (18) GPIO24    -> ringEnable
GPIO10 (19) (20) GND       -> GND to all button circuits below
 GPIO9 (21) (22) GPIO25    -> dialpin
GPIO11 (23) (24) GPIO8     -> pickup
   GND (25) (26) GPIO7     -> dialStartStop
 GPIO0 (27) (28) GPIO1 
 GPIO5 (29) (30) GND   
 GPIO6 (31) (32) GPIO12    -> ringPwm (connect to GPIO23 as workaround)
GPIO13 (33) (34) GND   
GPIO19 (35) (36) GPIO16
GPIO26 (37) (38) GPIO20
   GND (39) (40) GPIO21

You can edit your pin assignments in talkiepi.go

const (
        RingSleepPin    uint = 18
        RingEnablePin   uint = 24
        RingPwmChannel  int  = 0  // gpio12 or gpio18
	...
)

and gpio.go

var dialPin = pinDef{25, gpio.ActiveLow, gpio.EdgeRising, 0, []Event{EVENT_NOP, EVENT_DIAL_INC}}
var pickupPin = pinDef{8, gpio.ActiveLow, gpio.EdgeBoth, 0, []Event{EVENT_PICKUP_STOP, EVENT_PICKUP_START}}
var dialStartPin = pinDef{7, gpio.ActiveLow, gpio.EdgeBoth, 0, []Event{EVENT_DIAL_STOP, EVENT_DIAL_START}}

Building talkiepi from source

Run make build-from-go and have a look at the makefile for more info.

Releasing a new debian package
  1. Check out latest talkiepi repo, possibly this has been done via go command instead of git clone so look up how to do that :)
  2. Bump the version by adding a git tag in the form vX.Y and push it to origin
git tag -a vX.Y
git push origin vX.Y
  1. Run VERSION=X.Y make deb-pkg from mumble user on a checked out repository (possibly checked out with go instead of git clone)
  2. Copy generated talkiepi_armhf.deb to a computer with github login
  3. Create a new release on github, selecting the new tag and adding the copied file into the window. Make sure it is named talkiepi_armhf.deb and contains no version information, otherwise the autoupdate script will not work.

Pi Zero Fixes

I have compiled libopenal without ARM NEON support so that it works on the Pi Zero. The packages can be found in the workarounds. directory of this repo, install the libopenal1 package over your existing libopenal install.

Helpful commands

sudo journalctl -fu talkiepi

License

MPL 2.0

Author

Documentation

Index

Constants

View Source
const (
	RingSleepPin    uint = 18
	RingEnablePin   uint = 24
	RingPwmChannel  int  = 0 // gpio12 or gpio18
	RingMessageCode      = "ring-on-your-phone-already"
	RingFreqNs           = 50000000 // 20Hz
	RingDurationSec      = 5
)

Raspberry Pi GPIO pin assignments (CPU pin definitions)

View Source
const (
	EVENT_NOP = iota
	EVENT_PICKUP_START
	EVENT_PICKUP_STOP
	EVENT_DIAL_START
	EVENT_DIAL_STOP
	EVENT_RING_RECEIVE
	EVENT_DIAL_INC
)
View Source
const (
	STATE_IDLE = iota
	STATE_CALL
	STATE_DIAL
	STATE_RING
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event int

func (Event) String

func (e Event) String() string

type State

type State int

func (State) String

func (s State) String() string

type Talkiepi

type Talkiepi struct {
	Config *gumble.Config
	Client *gumble.Client

	Address   string
	TLSConfig tls.Config

	ConnectAttempts uint

	Stream *gumbleopenal.Stream

	ChannelName    string
	IsConnected    bool
	IsTransmitting bool

	GPIOEnabled bool
	Button      gpio.Pin
	ButtonState uint

	EventQueue   chan Event
	CurrentState State
	DialCounter  int

	RingEnable    gpio.Pin
	RingSleepN    gpio.Pin
	RingPwm       *sysfs.PWMPin
	IsRingingChan chan struct{}

	AssignedNumber int
	NotReally      bool
}

func (*Talkiepi) ChangeChannel

func (b *Talkiepi) ChangeChannel(ChannelName string)

func (*Talkiepi) CleanUp

func (b *Talkiepi) CleanUp()

func (*Talkiepi) Connect

func (b *Talkiepi) Connect()

func (*Talkiepi) HandleEvents

func (b *Talkiepi) HandleEvents()

func (*Talkiepi) HandleState

func (b *Talkiepi) HandleState()

function allowed to block until state changes is called asynchronously from event queue handler

func (*Talkiepi) Init

func (b *Talkiepi) Init()

func (*Talkiepi) OnACL

func (b *Talkiepi) OnACL(e *gumble.ACLEvent)

func (*Talkiepi) OnBanList

func (b *Talkiepi) OnBanList(e *gumble.BanListEvent)

func (*Talkiepi) OnChannelChange

func (b *Talkiepi) OnChannelChange(e *gumble.ChannelChangeEvent)

func (*Talkiepi) OnConnect

func (b *Talkiepi) OnConnect(e *gumble.ConnectEvent)

func (*Talkiepi) OnContextActionChange

func (b *Talkiepi) OnContextActionChange(e *gumble.ContextActionChangeEvent)

func (*Talkiepi) OnDisconnect

func (b *Talkiepi) OnDisconnect(e *gumble.DisconnectEvent)

func (*Talkiepi) OnPermissionDenied

func (b *Talkiepi) OnPermissionDenied(e *gumble.PermissionDeniedEvent)

func (*Talkiepi) OnServerConfig

func (b *Talkiepi) OnServerConfig(e *gumble.ServerConfigEvent)

func (*Talkiepi) OnTextMessage

func (b *Talkiepi) OnTextMessage(e *gumble.TextMessageEvent)

func (*Talkiepi) OnUserChange

func (b *Talkiepi) OnUserChange(e *gumble.UserChangeEvent)

func (*Talkiepi) OnUserList

func (b *Talkiepi) OnUserList(e *gumble.UserListEvent)

func (*Talkiepi) OpenStream

func (b *Talkiepi) OpenStream()

func (*Talkiepi) ParticipantLEDUpdate

func (b *Talkiepi) ParticipantLEDUpdate()

func (*Talkiepi) ReConnect

func (b *Talkiepi) ReConnect()

func (*Talkiepi) ResetStream

func (b *Talkiepi) ResetStream()

func (*Talkiepi) SendMessage

func (b *Talkiepi) SendMessage(message string)

func (*Talkiepi) Transition

func (b *Talkiepi) Transition(e Event) State

func (*Talkiepi) TransmitStart

func (b *Talkiepi) TransmitStart()

func (*Talkiepi) TransmitStop

func (b *Talkiepi) TransmitStop()

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL