-
Notifications
You must be signed in to change notification settings - Fork 308
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
Experiments with Bluetooth (exploration prior to documentation) #64
Comments
I solved the problem described under "More work". This is the Dockerfile I used:
Build process:
Notes:
|
Revised Magic IncantationMore research has led me to conclude that "host mode" is not required. The Docker documentation says:
In my testing, I can see nearby Bluetooth MACs via a "Generic BLE in" node irrespective of whether "host" mode is engaged or not. Permissions
docker-compose.yml
The change from the default is to add the last six lines. Dockerfile
Build
Test
If all goes well, the "Scan Result" popup menu will populate and you will be able to open that popup menu and see all your Bluetooth MACs. |
Following on from issue SensorsIot#64, this adds support for Bluetooth in Node-Red: 1. Adds two volume mappings to the template `service.yml`: ``` - /var/run/docker.sock:/var/run/docker.sock - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket ``` 2. Adds device mappings to the template `service.yml`: ``` devices: - "/dev/ttyAMA0:/dev/ttyAMA0" - "/dev/vcio:/dev/vcio" - "/dev/gpiomem:/dev/gpiomem" ``` 3. Changes `build.sh` to: * unconditionally satisfy the `eudev-dev` dependency for `node-red-contrib-generic-ble` by inserting these lines in the generated `Dockerfile`: ``` USER root RUN apk update RUN apk upgrade RUN apk add --no-cache eudev-dev ``` * Add `node-red-contrib-generic-ble` to the list of optional nodes. 4. Changes `menu.sh` to: * define a `user_in_group` function to facilitate checking whether the current user is a member of a particular group. * extends the initial checking performed by the menu to ensure that the current user is a member of both `docker` and `bluetooth` groups. > On the first run of the menu after this patch is applied, most users will likely encounter a reboot prompt enforcing membership of the `bluetooth` group.
Prepared pull request #70 |
Following on from issue SensorsIot#64, this adds support for Bluetooth in Node-Red: 1. Adds two volume mappings to the template `service.yml`: ``` - /var/run/docker.sock:/var/run/docker.sock - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket ``` 2. Adds device mappings to the template `service.yml`: ``` devices: - "/dev/ttyAMA0:/dev/ttyAMA0" - "/dev/vcio:/dev/vcio" - "/dev/gpiomem:/dev/gpiomem" ``` 3. Changes `build.sh` to: * unconditionally satisfy the `eudev-dev` dependency for `node-red-contrib-generic-ble` by inserting these lines in the generated `Dockerfile`: ``` USER root RUN apk update RUN apk upgrade RUN apk add --no-cache eudev-dev ``` * Add `node-red-contrib-generic-ble` to the list of optional nodes. 4. Changes `menu.sh` to: * define a `user_in_group` function to facilitate checking whether the current user is a member of a particular group. * extends the initial checking performed by the menu to ensure that the current user is a member of both `docker` and `bluetooth` groups. > On the first run of the menu after this patch is applied, most users will likely encounter a reboot prompt enforcing membership of the `bluetooth` group.
IOTstack – Experiments with Bluetooth
This issue documents my approach to getting
node-red-contrib-generic-ble
working under IOTstack. I'm hoping that people with a lot more experience than me will spot any flaws in my approach.I don't have a use-case for Bluetooth so I can't go any further than I've documented here. It would be very helpful to get confirmation that the result is fit for purpose and that useful communications can be achieved between Node-Red and Bluetooth devices.
If there's enough interest, I will volunteer to turn this into a documentation page for the IOTstack project. If someone else wants to tackle the documentation using this issue as a starting point, please go right ahead.
Installation
Give the current user access to the Bluetooth hardware
Update to the latest and greatest of everything
Make sure Raspbian (ahem, "Raspberry Pi OS") is up-to-date:
Make sure IOTstack is up-to-date:
Make sure container images are up-to-date:
Demonstrate that nodered is in non-host mode (the default)
In the following, 192.168.132.1 is my local router.
Two hops = non-host mode.
Edit the nodered configuration
Edit ~/IOTstack/docker-compose.yml and add these lines:
The final result should be:
Apply the changes:
Confirm that nodered is in host mode
One hop = host mode.
Confirm that Node-Red (the service) is reachable
You can either open a browser and point it to port 1880 on your Raspberry Pi's IP address or domain name, or you can do it from the command line:
As long as you get the "200 OK" you should be fine.
Install node-red-contrib-generic-ble
Open a shell into the nodered container:
Confirm that BLE is not already installed:
BLE has a dependency that the package does not take care of:
Install BLE:
The compile chucks out a lot of notes and warnings but succeeds.
Confirm that BLE has been installed:
Exit the container shell:
Restart nodered. This picks up the new BLE node:
Check for errors:
The output I get is:
No errors!
Testing
Discussion
First attempt at getting BLE working (failure):
Starting docker-compose.yml configuration:
I forced a complete rebuild of
iotstack_nodered
. The nodes installed at build time were the defaults plus SQLite.I edited docker-compose.yml, to add:
Then restarted nodered and checked that it was in host mode.
At HilscherAutomation I came across the requirement for:
There were more lines in the HilscherAutomation list but the above three were the only ones that mapped to anything on my RPi4. They seemed like a good idea but I do not know whether they are required.
My first attempt at compiling BLE failed because of a missing dependency. I worked out how to install
eudev-dev
, after which BLE compiled.Restarting the nodered container to activate BLE produced an error about
/var/run/docker.sock
so I added a mapping:That cured the
docker.sock
problem but nodered would still not come up. The new error was:I tried to solve that by adding another mapping:
but nodered kept restarting with the same error.
I checked a few more things (eg possible permission conflicts) but that's where I gave up.
Second attempt at getting BLE working (success):
Starting docker-compose.yml configuration:
I forced a complete rebuild of
iotstack_nodered
. The nodes installed at build time were the defaults plus SQLite.I edited docker-compose.yml, to add:
Then restarted nodered and checked that it was in host mode.
I installed the
eudev-dev
dependency and compiled BLE.I restart the nodered container.
And it just worked.
My guess (and it is no more than a guess) is that some or all of the
volumes
and/ordevices
additions to docker-compose.yml needed to be in place before BLE was compiled.More work
I tried to see if I could add
node-red-contrib-generic-ble
to the menu but that, of course, came with theeudev-dev
pre-requisite. I tried adding:as the second line of the Dockerfile but
docker-compose
hated it.I will leave it to others to solve this problem.
Just be aware that, in the meantime, a rebuild of nodered will require a manual install of BLE.
The text was updated successfully, but these errors were encountered: