Raspberry BLE peripherals alternative to bleno

4.8k Views Asked by At

Until now I have developed several programs to use in my Raspberry Rpi2 and RPi3 as BLE perifpherals using bleno. Can anyone tell me if there is something alternative to Bleno, in Python or even better in C, to develop a code for a BLE peripherals service for my Raspberry?

4

There are 4 best solutions below

0
On

I've had this same pain as you - trying to get a good BLE Peripheral role library for python - so I went ahead and ported Bleno to python2/3. It's still a WIP, but the Echo demo works just fine.

https://github.com/Adam-Langley/pybleno/

And it's on pypi as "pybleno"

Of course, a big shout out to Sandeep Mistry for the fantastic original node codebase.

Hopefully people find it useful.

1
On

Well you can always use the HCI_CHANNEL_USER feature in Linux to talk to the Bluetooth controller directly (from C for example). In fact that's exactly what bleno does. Just follow the HCI protocol in the Bluetooth specification.

1
On

I can't give you answers for C, but bluepy seems to be the best in breed for speaking to BLE peripherals (as bleno does) right now, and if you want to use core mode, there's Adafruit's BlueFruit LE.

Caveat: I'm only getting my feet wet with Pi peripherals myself and don't have any successful projects with either of these yet.

0
On

There isn't a library written in C as far as I know, but here's an interesting place to start: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/ (especially interesting are: doc/mgmt-api.txt, doc/gatt-api.txt for LE things)

There seem to be two interfaces to do Bluetooth stuff: D-Bus and HCI sockets. HCI sockets are actual C socket()s with the special AF_BLUETOOTH domain (http://man7.org/linux/man-pages/man2/socket.2.html is kind of helpful for explaining this). And you can use org.bluez.* for higher-level interfacing using D-Bus.

Getting all of that to work would be probably a nightmare, and all of the other Python libraries probably work fine. If you want higher performance, you could totally get something to work in C or Rust, and all you should need is sockets and D-Bus, it just sounds really really hard.