Bluetooth testing on Raspberry pi

Hi,

I am testing raspberry pi, I have installed node-red V 1.3.3. For Bluetooth testing, I am getting the below error message in debug window.

[
/__bledev/6b582bf82aab err:Error: Missing Peripheral Device
=>Error: Missing Peripheral Device
at Peripheral.a (/home/pi/.node-red/node_modules/node-red-contrib-generic-ble/dist/generic-ble.js:217:31)
at Object.onceWrapper (events.js:420:28)
at Peripheral.emit (events.js:314:20)
at PeripheralRemovableNoble.Noble.onDisconnect (/home/pi/.node-red/node_modules/@abandonware/noble/lib/noble.js:245:16)
at BluezBindings.emit (events.js:314:20)
at ProxyInterface. (/home/pi/.node-red/node_modules/node-red-contrib-generic-ble/dist/noble/lib/bluez/noble/lib/bluez/bindings.js:623:18)
at ProxyInterface.emit (events.js:314:20)
at EventEmitter.$listeners. (/home/pi/.node-red/node_modules/dbus-next/lib/client/proxy-interface.js:108:17)
at EventEmitter.emit (events.js:326:22)
at handleMessage (/home/pi/.node-red/node_modules/dbus-next/lib/bus.js:118:23)
]

Could you please help me to solve this issue

Br,
Devendra

  1. is this the first time you are using this node on any release of NR?
  2. did you do the pre requirements for the 'pi' user as defined in the instructions? (see: node-red-contrib-generic-ble (node) - Node-RED)
  3. What RPI are you using?

You should open an issue on the node's github page: Issues · CANDY-LINE/node-red-contrib-generic-ble · GitHub

Hi,
strong text
Thanks for your response.

  1. is this the first time you are using this node on any release of NR? - Yes, the First time this is the fresh raspberry pi I just installed node-red and Bluetooth node.

  2. did you do the pre requirements for the 'pi' user as defined in the instructions? (see: node-red-contrib-generic-ble (node) - Node-RED) - In permission, I did not understand which permission need to enable/set process owner's permission properly and manually could you please let me know what I need to do. attached permission details screenshot.

  3. What RPI are you using? - Raspberry Pi 3

Br,
Devendra

The default permissions on a Linux device does not allow users to access Bluetooth.

Many people in the past suggested running Node-RED under the "root" user but this is really poor practice for security reasons.

Instead you need to make sure that the user running Node-RED (typically "pi" on a Raspberry Pi) has access to the bluetooth device. Check the permissions on the device by running ls -l /dev

Example /dev output:

crw--w---- 1 root tty       4,   9 Apr 18 14:41 tty9
crw-rw---- 1 root dialout 204,  64 Apr 18 14:42 ttyAMA0
crw------- 1 root root      5,   3 Apr 18 14:41 ttyprintk
crw--w---- 1 root tty       4,  64 Apr 18 14:42 ttyS0
crw------- 1 root root     10, 239 Apr 18 14:41 uhid
crw------- 1 root root     10, 223 Apr 18 14:41 uinput
crw-rw-rw- 1 root root      1,   9 Apr 18 14:41 urandom
drwxr-xr-x 3 root root          60 Apr 18 14:41 v4l
crw-rw---- 1 root video   243,   0 Apr 18 14:41 vchiq
crw-rw---- 1 root video   248,   0 Apr 18 14:41 vcio

Note that many devices are owned by root:root. But in the case above, I changed the ttyAMA0 (USB) device to be owned by root:dialout. Dialout being the traditional Linux user group for devices like USB/Serial, etc (from the old modem days). Then you add the pi user to the dialout group.

I typically don't use Bluetooth on my devices so I can't give you the exact device names.

From the readme I pointed you to:

Installation Note (Linux)

The Node-RED process owner must belong to bluetooth group in order to access BlueZ D-Bus API, otherwise this node doesn't work at all because of bluetoothd permission issue. For example, if you're going to run the process by pi user, run the following command.

sudo usermod -G bluetooth -a pi

Then reboot the OS so that the policy changes take effect.

sudo reboot
3 Likes

@Zenofmud, I did this sudo usermod -G bluetooth -a pi but still facing the same issue.

If I do bluetooth testing through the console It is working only not communicating in node-red.

Have you opened an issue on the GitHub page?

Have you checked that the bluetooth device actually belongs to the bluetooth group?

You will need to logout and then log back in after running the usermod command (but probably easier to just reboot the pi)

@zenofmud - no I have not opened an issue on the GitHub page.

@TotallyInformation - am using Ipad6 as a Bluetooth device. On Ipad, I have Installed the LightBlue application.

Now I can see a change, my raspberry pi got to connect with Ipad for a few seconds and then disconnect. while connecting raspberry pi with Ipad on the Ipad screen showing pair request again and again even click on Pair.

One year before I did same steps with the same raspberry pi & Ipad as bluetooth device, at that time it was working perfectly. but I don't know why this problem come.

Hello,

My raspberry pi got connected with my Ipad & iPhone also.

but not able to read data. my node-red flow attached. is there anything I am missing?
flows (2).json (3.1 KB)

Br,
Devendra

What bluetooth app are you using on the iPad?

I am using the LightBlue app for custom data as Blank selected.

Br,
Devendra

Hmm, wish I could help but I can't seem to get my iPad Pro using lightBlue see my rpi4 at all.

@zenofmud thanks for your time for this testing, could you please give me Bluetooth testing details/document/suggestion. So that I will follow according to your testing.

for lightBlue testing, you need to create one Virtual Devices in this app at the application bottom you will see this, then add (+) one off the peripheral. then only you will see this in your node-red Bluetooth node.

Br,
Devendra

So do you define it as a 'Blank' peripheral? I tried that but it doesn't show in the Pi4 when trying to use bluetooth to discover devices

Yes, I have defined Blank peripheral, first time while searching you will see Mac address then after the first communication is done then it will show as a Blank replacement on Mac address.

That’s the problem, I don’t see the iPad’s Bluetooth MAC address in the pi Bluetooth connection. I do see my Mac mini

you are checking in node-red Bluetooth node?

checking in both node-red ond in the Pi's bluetooth manager. It doesn't look like I'll be much help to you...sorry.