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

Access to bluetooth device from Node-RED container. #40

Closed
DeuceCode opened this issue Nov 4, 2019 · 4 comments
Closed

Access to bluetooth device from Node-RED container. #40

DeuceCode opened this issue Nov 4, 2019 · 4 comments

Comments

@DeuceCode
Copy link

I'm using a Pi 4, bluetooth is working correctly.
I'm able to use bluetooth dependant nodes from within Node-RED running natively on the Pi, however attempting the same from Node-RED running in the IOTStack container fails and causes the container to restart.

Is it possible to access the bluetooth device from within the container?

@gcgarner
Copy link
Owner

gcgarner commented Nov 4, 2019

At the moment the container doesn't have the permission to access host devices. There should be a way to give it access.

Which node are you using, I'll give it a go and report back

@gcgarner
Copy link
Owner

gcgarner commented Nov 4, 2019

I got into an endless restart initially (deleting the flows.json file stopped the endless restart)

It looks like by setting the network_mode to host it stopped the endless restart issue. I tried the BLE scan and it doesnt return any results, my phone does however see my watch

Could you try editing your docker-compose.yml file and see if it fixes your results:

  nodered:
    container_name: nodered
    build: ./services/nodered/.
    restart: unless-stopped
    user: "0"
    network_mode: "host"

add the line for network mode, the file indentation is important.

after this run docker-compose up -d (if you have a continuous restart issue like i had run sudo rm ~/IOTstack/volumes/nodered/data/flows.json then docker-compose restart nodered )

The host option has another side effect, you can no longer access containers by name, you would now need to use 127.0.0.1 in stead of the name

@DeuceCode
Copy link
Author

I believe I experienced the same endless restart issue you mentioned. I'm fairly new to this kind of thing but, that's what the logs in portainer seemed to be indicating. Deleting the flows did indeed stop this.

I'm looking to use node-red-contrib-xiaomi-ble as the simplest method to poll at the moment one Xiaomi Mijia Bluetooth Temperature Humidity Sensor (hopefully in the future multiple sensors).

Editing the docker-compose.yml file to include network_mode: "host" does allow the scan to complete inside the container, and a temp, humidity, battery response is returned as expected.

Having to access other containers by IP instead of name seems like a fair trade in this case to gain the additionally functionally.

Thank you.

@gcgarner
Copy link
Owner

gcgarner commented Nov 4, 2019

Thanks @DeuceCode I will amend the documentation. I appreciate you testing the modified yml file

@gcgarner gcgarner closed this as completed Nov 4, 2019
Willem-Dekker pushed a commit to robertcsakany/IOTstack that referenced this issue Jun 14, 2020
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