This guide explains how to configure Ubuntu 24.04 to act as a Bluetooth Serial Port (SPP) server to receive data from the ABCommander app.
sudo apt update
sudo apt install bluez bluez-tools- Edit the service:
sudo nano /lib/systemd/system/bluetooth.service - Change
ExecStartline to:ExecStart=/usr/libexec/bluetooth/bluetoothd --compat - Reload:
sudo systemctl daemon-reload && sudo systemctl restart bluetooth - Permissions:
sudo chmod 777 /var/run/sdp(repeat after restart).
Ubuntu's ModemManager often "hijacks" serial ports, causing "Address already in use" errors.
sudo systemctl stop ModemManagerCreate a script with these contents for a clean connection:
#!/bin/bash
echo "--- Resetting Bluetooth Stack ---"
sudo pkill -9 rfcomm
sudo rfcomm release all
sudo hciconfig hci0 down
sudo hciconfig hci0 up
sudo sdptool add --channel=4 SP
echo "Waiting for connection on CHANNEL 4..."
sudo rfcomm listen 10 4 # Uses /dev/rfcomm10Follow these steps exactly to ensure a successful connection without "Address already in use" errors:
- Stop ModemManager:
sudo systemctl stop ModemManager - Run the Script: Execute
./ble_listen.shin Terminal A.- It should say:
Waiting for connection on channel 4. - Do NOT start the
catcommand yet.
- It should say:
- Open App: Launch ABCommander on your phone.
- Click Connect: Select your Ubuntu laptop from the list.
- Verify Handshake:
- Look at Terminal A (Ubuntu). It should change to:
Connection from [MAC] to /dev/rfcomm10 - The App status should change to:
Status: Connected to...and the button should say Disconnect.
- Look at Terminal A (Ubuntu). It should change to:
- Read Data: Open Terminal B (New Tab) and run:
sudo cat /dev/rfcomm10
- Action: Press buttons in the app. Commands like
1_ONwill appear in Terminal B.
- Stop Sniffer: In Terminal B, press
Ctrl+Cto stopcat. - Disconnect App: Click Disconnect on the phone.
- Reset Server: In Terminal A, press
Ctrl+Cand runsudo rfcomm release allbefore the next test.
- Address already in use: Run
sudo rfcomm release alland ensure nocatortailprocesses are running on/dev/rfcomm*. - Send failed: Usually means the physical connection is up but the TTY device (
/dev/rfcomm10) failed to initialize. Restart the script.