an2linuxserver icon indicating copy to clipboard operation
an2linuxserver copied to clipboard

Bluetooth: Failed to connect

Open yochananmarqos opened this issue 4 years ago • 5 comments

I'm not able to connect to my laptop via Bluetooth. The Android app sees my laptop, but attempting to initiate pairing results in "Failed to connect."

an2linuxserver.service:

[Unit]
Description=AN2Linux
Wants=bluetooth.service
After=bluetooth.service

[Service]
Type=simple
User=yochanan
Group=yochanan
StandardOutput=null
Restart=on-failure
ExecStartPre=/usr/bin/sleep 3
ExecStart=/usr/bin/an2linuxserver
Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
PrivateDevices=true
ProtectHome=read-only
ProtectSystem=strict
ReadWritePaths=/tmp

[Install]
WantedBy=default.target
● an2linuxserver.service - AN2Linux
     Loaded: loaded (/usr/lib/systemd/system/an2linuxserver.service; enabled; vendor pre>
     Active: activating (start-pre) since Thu 2020-04-02 14:29:18 MDT; 2s ago
Cntrl PID: 436584 (sleep)
      Tasks: 1 (limit: 18764)
     Memory: 216.0K
     CGroup: /system.slice/an2linuxserver.service
             └─436584 /usr/bin/sleep 3

Apr 02 14:29:18 inspirognome systemd[1]: Starting AN2Linux...

Manjaro GNOME an2linuxserver-git r32.58648ec

T-Mobile OnePlus 7 Pro Oxygen OS 10.03 Android 10.0 An2Linux 0.12.0(17)

yochananmarqos avatar Apr 02 '20 20:04 yochananmarqos

Haven't tried bluetooth myself in a long time. Just did with my laptop, and both initiating pairing and sending notifications worked. Sorry I can not be of more help, hard for me to find the problem if I can not reproduce the error.

rootkiwi avatar Jul 12 '20 08:07 rootkiwi

What did you do exactly? Your main README and separate READMEs for each service file say different things.

yochananmarqos avatar Jul 12 '20 15:07 yochananmarqos

On phone right now, can try more tomorrow. I did not use a systemd service for my bluetooth test. Just paired phone with laptop with bluetooth. Then ran an2linuxserver.py and tried paring and send test notification.

What do you mean, is the READMEs wrong?

rootkiwi avatar Jul 12 '20 16:07 rootkiwi

You're just running it without the server? I have it installed to /usr/bin/. This is what happens for me:

$ an2linuxserver
2020-07-12 10:36:43.015 root         INFO     Server certificate fingerprint: 22 48 25 4B 4A 07 AE FB 46 8D 6A BC 3A 1C 0C 75 4A 10 CC 2C 30 88 39 B2 3A 96 D3 9B 03 3A 6F 5E (an2linuxserver:826)
2020-07-12 10:36:43.016 root         INFO     (TCP) Waiting for connections on port 46352 (an2linuxserver:850)
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/bluetooth/bluez.py", line 238, in advertise_service
    _bt.sdp_advertise_service (sock._sock, name, service_id, \
_bluetooth.error: (2, 'No such file or directory')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/sbin/an2linuxserver", line 874, in <module>
    bluetooth_server = ThreadingBluetoothServer()
  File "/usr/sbin/an2linuxserver", line 284, in __init__
    advertise_service(self.bluetooth_server_sock, "AN2Linux_bluetooth_server",
  File "/usr/lib/python3.8/site-packages/bluetooth/bluez.py", line 242, in advertise_service
    raise BluetoothError (str (e))
bluetooth.btcommon.BluetoothError: (2, 'No such file or directory')

I mean the main README and each service README is different explaining what to do to get Bluetooth working.

yochananmarqos avatar Jul 12 '20 16:07 yochananmarqos

I have tried both running an2linuxserver.py directly and using a systemd/User service. Best to try without a service first just to get that working.

From reading here: https://github.com/pybluez/pybluez/issues/161

You may need to do these steps from the README: https://github.com/rootkiwi/an2linuxserver/#pybluez-not-working

Edit bluetooth.service in an override file

systemctl edit bluetooth.service

Add the following lines

[Service]
ExecStart=
ExecStart=/usr/lib/bluetooth/bluetoothd -C
ExecStartPost=/bin/chmod 662 /var/run/sdp

then apply changes

systemctl daemon-reload
systemctl restart bluetooth.service

rootkiwi avatar Jul 14 '20 11:07 rootkiwi