Ben's notes

Linux, Unix, network, radio...

User Tools

Site Tools


serial_console_over_bluetooth

This is an old revision of the document!


~~TOC~~

Serial console over Bluetooth

Notes

  • The rfcomm process has higher CPU usage when connected.
  • The rfcomm utility is deprecated since Bluez 5.44. No alternative found yet, maybe look into PAN.

Configure

Server

  • Stop ModemManager from interefering:
    systemctl stop ModemManager
    systemctl disable MomdemManager
  • Modify /etc/bluetooth/main.conf:
    [Policy]
    AutoEnable=true
  • Start and enable bluetooth service:
    systemctl enable bluetooth
    systemctl start bluetooth
  • Create systemd service /etc/systemd/system/rfcomm.service
    [Unit]
    Description=RFCOMM service
    After=bluetooth.service
    Requires=bluetooth.service
    
    [Service]
    ExecStart=/usr/bin/rfcomm watch hci0 1 setsid /sbin/agetty --8bits --noclear -L rfcomm0 115200 linux
    
    [Install]
    WantedBy=multi-user.target
  • Enable and start the rfcomm service:
    systemctl enable rfcomm
    systemctl start rfcomm

Client

  • Stop ModemManager from interefering:
    systemctl stop ModemManager
    systemctl disable MomdemManager
  • Add user to dialout group.

Pairing and connecting

  • On the server side:
    bluetoothctl
      discoverable on
      pairable on
  • On the client side:
    bluetoothctl
      scan on
      -wait to discover server-
      scan off
      pair <mac>
  • On the server:
    bluetoothctl
      discoverable off
      pairable off
  • Connect to the serial console over bluetooth:
    # There should be a rfcomm0 device
    crw-rw----. 1 root dialout 216, 0 11 jun 08:14 /dev/rfcomm0
    
    # If device is nonexistent, create one
    sudo rfcomm connect /dev/rfcomm0 <BT server-MAC-address> 1 &
    Connected /dev/rfcomm0 to <MAC> on channel 1
    Press CTRL-C for hangup
    
    # Connect to the serial console:
    screen /dev/rfcomm0 115200

Troubleshooting

  • After resizing your terminal, run: resize.
  • Check bluetooth is not disabled:
    rfkill list
serial_console_over_bluetooth.1497194435.txt.gz · Last modified: 2017/06/11 15:20 by admin