Hi guys,
I’m working on upgrading databat to support the new multi-container setup (along with some general updates). Unfortunately, I’ve run into issues with using Bluetooth in the new setup. In short, I’m trying to get bluepy to work, but so far I have been unable to do so.
The old Bluetooth documentation states that “Starting from balenaOS 2.9.3+rev1, bluetooth devices are controlled by the host operating system and available for all user containers. Just install the software tools that you require to talk to the bluetooth devices, and start using it.”
To my knowledge, I have annotated things properly, and the container is running in both network_mode: host
and privileged: true
, which from what I gather is all that should be needed (see [1], [2], and[3]).
When I try to either use blescan
(which is just a wrapper), or call it directly from Python, I get the same issue:
$ blescan
Scanning for devices...
Traceback (most recent call last):
File "/usr/local/bin/blescan", line 10, in <module>
sys.exit(main())
File "/usr/local/lib/python3.7/dist-packages/bluepy/blescan.py", line 122, in main
devices = scanner.scan(arg.timeout)
File "/usr/local/lib/python3.7/dist-packages/bluepy/btle.py", line 854, in scan
self.stop()
File "/usr/local/lib/python3.7/dist-packages/bluepy/btle.py", line 803, in stop
self._mgmtCmd(self._cmd()+"end")
File "/usr/local/lib/python3.7/dist-packages/bluepy/btle.py", line 312, in _mgmtCmd
raise BTLEManagementError("Failed to execute management command '%s'" % (cmd), rsp)
bluepy.btle.BTLEManagementError: Failed to execute management command 'scanend' (code: 11, error: Rejected)
Any pointers would be appreciated.
References
[1] docker-compose.yml:
version: '2'
services:
lab:
build: ./lab
privileged: true
network_mode: host
labels:
io.balena.features.dbus: "1"
io.balena.features.kernel-modules: "1"
io.balena.features.firmware: "1"
[2] Dockerfile:
FROM balenalib/raspberrypi3-python
ENV DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket
ENV UDEV=1
RUN install_packages \
build-essential \
bluez \
python-dbus \
python-dev \
libglib2.0-dev
COPY ./requirements.txt /requirements.txt
RUN pip install -r /requirements.txt --no-cache-dir
CMD sleep 3600
[3] requirements.txt:
bluepy==1.3.0
[4] Relevant (WIP) Sonar Pull Request