Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth: Failed to connect #57

Open
yochananmarqos opened this issue Apr 2, 2020 · 5 comments
Open

Bluetooth: Failed to connect #57

yochananmarqos opened this issue Apr 2, 2020 · 5 comments

Comments

@yochananmarqos
Copy link

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)

@rootkiwi
Copy link
Owner

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.

@yochananmarqos
Copy link
Author

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

@rootkiwi
Copy link
Owner

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?

@yochananmarqos
Copy link
Author

yochananmarqos commented Jul 12, 2020

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.

@rootkiwi
Copy link
Owner

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: pybluez/pybluez#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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants