question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

multiple processes

See original GitHub issue

Hi, when running multiple processes, noble seems to see activity from the other process, and neither process works well. I’m using the noble-device wrapper… Hardware: Rpi3 Raspberian with bluez 5.48 (the upgrade to 5.48 from 5.43 resolved a number of other multi-device issues).

Examples: a single process can detect and talk to 2 devices (eq3 valves). I’m using a ‘connect, read, disconnect, wait 40s, repeat’ scheme. If I start a second of the same process, the first process died with: (this is the first time i’ve seen it die!)

connecting 00:1a:22:09:2c:9a
/home/pi/.node-red/node_modules/noble/lib/hci-socket/gatt.js:618
  var characteristic = this._characteristics[serviceUuid][characteristicUuid];
                                                      ^

TypeError: Cannot read property 'd0e8434dcd290996af416c90f4e0eb2a' of undefined
    at Gatt.notify (/home/pi/.node-red/node_modules/noble/lib/hci-socket/gatt.js:618:58)
    at NobleBindings.notify (/home/pi/.node-red/node_modules/noble/lib/hci-socket/bindings.js:398:10)
    at Noble.notify (/home/pi/.node-red/node_modules/noble/lib/noble.js:353:19)
    at Characteristic.notify (/home/pi/.node-red/node_modules/noble/lib/characteristic.js:106:15)
    at EQ3BLE.NobleDevice.notifyCharacteristic (/home/pi/.node-red/node_modules/noble-device/lib/noble-device.js:134:18)
    at NobleDevice.connectAndSetup.call (/home/pi/.node-red/node_modules/node-red-contrib-eq3-bluetooth/lib/eq3device.js:69:12)
    at EQ3BLE.<anonymous> (/home/pi/.node-red/node_modules/noble-device/lib/noble-device.js:83:7)
    at EQ3BLE.<anonymous> (/home/pi/.node-red/node_modules/noble-device/lib/noble-device.js:71:5)
    at Peripheral.<anonymous> (/home/pi/.node-red/node_modules/noble/lib/peripheral.js:101:13)
    at Service.<anonymous> (/home/pi/.node-red/node_modules/noble/lib/service.js:53:7)

and the second process worked correctly.

If I re-run the first process, it sees the device(s), but reports:

connecting 00:1a:22:09:2c:db
connectThenSetup err :Error: Command Disallowed (0xc)

and the second process can no longer connect to devices (connect does not succeed within 10s, and I cancel it with disconnect). If I then stop the first process again, the second process resumes normal operations.

I also see:

noble: unknown peripheral 001a22092cdb connected!

and other ‘cross application’ messages (I assume it hears everything happening on the bluetooth);

Q: is it meant to be able to work from multiple processes? Should I/will it help to stop noble completely in my 40s between polls, and randomise the polling, and just deal with times it does not work?

I notice there is also an interaction between noble and hcitool (e.g. when I connect to a device in noble, hciscan drops out. Is this normal? - or is my bluez stack still no good?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
artharecommented, Jun 29, 2020

I spent a bunch of time working on getting this working, and have gotten surprisingly close.

What I did: -Started from ws-slave, which runs a websocket-based server for other processes to talk to. -Made it recognize each incoming websocket as a unique “context” with its own unique set of connections and requests. -Reorganized a bunch of the listeners to take into account this “context” concept.

How does it do? -Actually works very well, except for scanning for new devices concurrently with doing other bluetooth operations. Anytime a scan-for-new-devices is going on, it completely hoses all other BLE operations. If you could make your multiple processes coordinate their scanning sequence so they all scan, find their devices, and only then proceed to do their bluetooth stuff, then this would work.

Other tip: -Doing my BLE work in ws-slave separate from my main process really helped my pace of development because it made it easy to debug noble-only problems. It also meant that my master process can destroy and restart the ws-slave process at will in case it messes up.

You can take a look at https://github.com/arthare/noble

0reactions
artharecommented, Jun 11, 2020

I have a raspi 4 running bluez 5.50, and still get this issue. I was hoping to be able to run a bunch of simple processes to talk to a bunch of different BLE devices, but as soon as I go from spawning 1 at a time to spawning 2 at a time, they start throwing all kinds of weird errors I haven’t seen before.

Read more comments on GitHub >

github_iconTop Results From Across the Web

multiprocessing — Process-based parallelism — Python 3.11 ...
multiprocessing is a package that supports spawning processes using an API similar to the threading module. The multiprocessing package offers both local and ......
Read more >
Multiple processes
Let's first understand the situation from a multiple process, one-thread-per-process outlook. In this case, we'd have three processes, literally an input ...
Read more >
Multiprocessing in Python - Running Multiple Processes in ...
Multiprocessing is a built-in package in python that enables the system to run multiple processes simultaneously.
Read more >
Why so many multiple processes in Windows 10?
Hi, I noticed in the task manager that several processes occure more than one time, and some processes occure multiple times, ...
Read more >
Creating Multiple Processes in Python - YouTube
In todays world with the availability of multiple cores, it's highly likely that we end up creating multithreaded applications more often ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found