[英]Raspberry BLE peripherals alternative to bleno
Until now I have developed several programs to use in my Raspberry Rpi2 and RPi3 as BLE perifpherals using bleno .到目前为止,我已经开发了几个程序,可在我的 Raspberry Rpi2 和 RPi3 中使用bleno作为 BLE外设。 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?
谁能告诉我是否有替代 Bleno 的替代品,在 Python 中,甚至在 C 中更好,为我的 Raspberry 开发 BLE 外设服务的代码?
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.我和你有同样的痛苦——试图为 python 获得一个好的 BLE 外设角色库——所以我继续将 Bleno 移植到 python2/3。 It's still a WIP, but the Echo demo works just fine.
它仍然是一个 WIP,但 Echo 演示工作得很好。
https://github.com/Adam-Langley/pybleno/ https://github.com/Adam-Langley/pybleno/
And it's on pypi as "pybleno"它在 pypi 上被称为“pybleno”
Of course, a big shout out to Sandeep Mistry for the fantastic original node codebase.当然,对于出色的原始节点代码库,要向 Sandeep Mistry 大喊大叫。
Hopefully people find it useful.希望人们发现它有用。
Well you can always use the HCI_CHANNEL_USER feature in Linux to talk to the Bluetooth controller directly (from C for example).好吧,您始终可以使用 Linux 中的 HCI_CHANNEL_USER 功能直接与蓝牙控制器对话(例如,来自 C)。 In fact that's exactly what bleno does.
事实上,这正是 bleno 所做的。 Just follow the HCI protocol in the Bluetooth specification.
只需遵循蓝牙规范中的 HCI 协议即可。
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 .我无法给出 C 的答案,但bluepy似乎是目前与 BLE 外围设备对话的最佳选择(就像 bleno 一样),如果您想使用核心模式,可以使用 Adafruit 的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.警告:我自己只是用 Pi 外围设备弄湿了我的脚,并且还没有任何成功的项目。
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)据我所知,没有用 C 编写的库,但这里有一个有趣的起点: https : //git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/ (特别有趣是: doc/mgmt-api.txt, 用于 LE 的 doc/gatt-api.txt)
There seem to be two interfaces to do Bluetooth stuff: D-Bus and HCI sockets.似乎有两个接口可以做蓝牙的东西:D-Bus 和 HCI 插座。 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).
HCI 套接字是具有特殊 AF_BLUETOOTH 域的实际 C 套接字()( http://man7.org/linux/man-pages/man2/socket.2.html有助于解释这一点)。 And you can use org.bluez.* for higher-level interfacing using D-Bus.
您可以使用 org.bluez.* 使用 D-Bus 进行更高级别的接口。
Getting all of that to work would be probably a nightmare, and all of the other Python libraries probably work fine.让所有这些工作可能是一场噩梦,而所有其他 Python 库可能都可以正常工作。 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.
如果你想要更高的性能,你完全可以用 C 或 Rust 来工作,你只需要套接字和 D-Bus,这听起来真的很难。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.