Files
2026-07-25 18:41:15 +05:00
..
2026-07-25 18:41:15 +05:00
2026-07-25 18:41:15 +05:00
2026-07-25 18:41:15 +05:00

CallPipe Relay (Raspberry Pi)

The Pi pairs to the phone as a Bluetooth HFP hands-free unit. During a call the phone routes call audio to it over SCO; bluez-alsa exposes that as ALSA PCMs. callpipe-relay.py is a dumb audio pipe: Bluetooth SCO (via arecord/aplay) ⇄ the phone's audio TCP server over WiFi. Call control lives on the phone.

See ../docs/relay-setup.md for the one-time Bluetooth stack setup.

Install

# on the Pi (root):
apt-get install -y bluez bluez-firmware bluez-alsa-utils alsa-utils python3 python-is-python3
install -D callpipe-relay.py /opt/callpipe/callpipe-relay.py
install -D callpipe-relay.service /etc/systemd/system/callpipe-relay.service
# set the phone IP:
systemctl edit callpipe-relay        # or edit Environment=CALLPIPE_PHONE=... in the unit
systemctl enable --now callpipe-relay

Config (env)

var default meaning
CALLPIPE_PHONE 10.0.1.239 phone (hub) IP
CALLPIPE_PORT 9010 phone audio TCP port
CALLPIPE_BT auto HFP device MAC (auto-detected from bluez-alsa)

Wire protocol (TCP, both directions)

[4B big-endian len N][1B type][payload] where N = 1 + len(payload)

  • A (0x41): PCM S16LE mono 16 kHz, 20 ms (640 B) frames
  • C (0x43): control JSON — phone sends {"cmd":"start"|"stop"}; relay sends {"event":"hello|started|stopped|error", ...}

Manual test

CALLPIPE_PHONE=<dev-ip> python /opt/callpipe/callpipe-relay.py
# with tools/phone_stub.py running on <dev-ip>, place a call routed to BT