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

Outdated docs about Peripheral config #361

Open
vovagorodok opened this issue Feb 23, 2022 · 15 comments
Open

Outdated docs about Peripheral config #361

vovagorodok opened this issue Feb 23, 2022 · 15 comments

Comments

@vovagorodok
Copy link

Should be removed following notes? :
at: Peripheral

You will need to have modified the dbus configuration file to open the permissions for 'ukBaz.bluezero'. This is covered in the System Setup section of the documentation

at: https://github.com/ukBaz/python-bluezero/blob/main/docs/install_bluez.rst#creating-a-bluezero-peripheral

A peripheral application will be registered on the DBus using the bus name of ukBaz.bluezero. An example dbus configuration file is provided and will need to be copied to the correct location:
@ukBaz
Copy link
Owner

ukBaz commented Feb 23, 2022

Yes, well spotted. Looks like they got missed with 7e4bf74

@vovagorodok
Copy link
Author

With new method examples should always runs with sudo unfortunately

@ukBaz
Copy link
Owner

ukBaz commented Feb 23, 2022

No, you should not need to use sudo. As the ukBaz.bluezero name is not being claimed then it can be done without sudo

@vovagorodok
Copy link
Author

In case without sudo I have AccessDenied:

pi@home:~/python-bluezero/examples $ python3 ble_uart.py 
ERROR:dbus.proxies:Introspect error on :1.5:/: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.AccessDenied: Rejected send message, 2 matched rules; type="method_call", sender=":1.19" (uid=1000 pid=618 comm="python3 ble_uart.py ") interface="org.freedesktop.DBus.Introspectable" member="Introspect" error name="(unset)" requested_reply="0" destination=":1.5" (uid=0 pid=424 comm="/usr/lib/bluetooth/bluetoothd ")
Traceback (most recent call last):
  File "ble_uart.py", line 69, in <module>
    main(list(adapter.Adapter.available())[0].address)
  File "/home/pi/.local/lib/python3.7/site-packages/bluezero/adapter.py", line 49, in available
    mng_objs = dbus_tools.get_managed_objects()
  File "/home/pi/.local/lib/python3.7/site-packages/bluezero/dbus_tools.py", line 93, in get_managed_objects
    return manager.GetManagedObjects()
  File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 70, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib/python3/dist-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.AccessDenied: Rejected send message, 2 matched rules; type="method_call", sender=":1.19" (uid=1000 pid=618 comm="python3 ble_uart.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination=":1.5" (uid=0 pid=424 comm="/usr/lib/bluetooth/bluetoothd ")

@ukBaz
Copy link
Owner

ukBaz commented Feb 23, 2022

When you run bluetoothctl do you have to run that with sudo also?

@vovagorodok
Copy link
Author

vovagorodok commented Feb 23, 2022

No, bluetoothctl doesn't require sudo:

pi@home:~ $ bluetoothctl
[bluetooth]#
pi@home:~ $ bluetoothctl -v
bluetoothctl: 5.50

@ukBaz
Copy link
Owner

ukBaz commented Feb 23, 2022

OK, let me run some tests

@ukBaz
Copy link
Owner

ukBaz commented Feb 23, 2022

I've done a fresh install of Bluezero and checked that there is no ukBaz.bluezero is /etc/dbus-1/system.d/.

I think your issue is coming from else were.

(venv) [bash]python-bluezero $ python examples/ble_uart.py 
Advertisement registered
Connected to 58:19:A8:D6:77:DB
raw bytes: [116, 101, 115, 116]
With options: {'device': '/org/bluez/hci0/dev_58_19_A8_D6_77_DB', 'link': 'LE', 'mtu': 517}
Text value: test
Sending
raw bytes: [98, 108, 117, 101]
With options: {'device': '/org/bluez/hci0/dev_58_19_A8_D6_77_DB', 'link': 'LE', 'mtu': 517}
Text value: blue
Sending
^C(venv) [bash]python-bluezero $ ll /etc/dbus-1/system.d/uk*
ls: cannot access '/etc/dbus-1/system.d/uk*': No such file or directory

@vovagorodok
Copy link
Author

vovagorodok commented Feb 23, 2022

pi@home:~ $ uname -a
Linux home 5.10.63-v7+ #1496 SMP Wed Dec 1 15:58:11 GMT 2021 armv7l GNU/Linux

Its clear instalation rpi os without gui. What system do you have?
and just install:

pip3 install bluezero

@ukBaz
Copy link
Owner

ukBaz commented Feb 23, 2022

I've tested it on two systems:

$ uname -a
Linux TestMachine1 5.10.60-v7+ #1449 SMP Wed Aug 25 15:00:01 BST 2021 armv7l GNU/Linux

And

$ uname -a
Linux TestMachine2 5.4.0-100-generic #113-Ubuntu SMP Thu Feb 3 18:43:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Is the OS you are referring to Raspberry Pi OS Lite? There are some known additional setup required with that. More details at: https://raspberrypi.stackexchange.com/a/116843/121848

@vovagorodok
Copy link
Author

Yes RPiOS Lite on RPi Zero 2.
Works, but I don't know exact solution. What I'm done:

sudo apt install pulseaudio-module-bluetooth
sudo reboot
sudo apt remove pulseaudio-module-bluetooth

@ukBaz
Copy link
Owner

ukBaz commented Feb 23, 2022

I think it is adding user pi to group bluetooth that is the key bit.

pi@raspberrypi4b:~ $ sudo usermod -G bluetooth -a pi  

@vovagorodok
Copy link
Author

Yes. I forgot. This one was done by me to

@ukBaz
Copy link
Owner

ukBaz commented Feb 23, 2022

OK. I think this sounds like a general RPi setup rather than an issue with Bluezero. Can I go ahead and close this issue?

@vovagorodok
Copy link
Author

vovagorodok commented Feb 23, 2022

The goal of this issue is removing Outdated text in docs

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