简体   繁体   English

树莓 BLE 外设替代 bleno

[英]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.

相关问题 如何读取传入的 BLE 数据? [树莓派] - How can I read incoming BLE data? [Raspberry Pi] 如果在脚本或 python 上使用,蓝牙 BLE Gatttool 不能重复执行,但如果手动使用它可以正常工作。 (树莓派 4) - Bluetooth BLE Gatttool not working on repeat executions if used on script or python, but it works fine if used manually. (Raspberry Pi 4) 为什么我无法在带有 BPM 传感器的 Raspberry Pi 中获得 BLE 指示响应? - Why I can't get the BLE indication response in Raspberry Pi with a BPM Sensor? 我无法列出 Raspberry Pi 附近的 BLE 设备(python、btmgmt) - I cannot list up the BLE devices in the neighbourhood of my Raspberry Pi (python, btmgmt) 我通过蓝牙向 arduino nano ble 33 发送了一个值,并接收到了树莓派的值。 如何将此值转换为数字? - I sent a value to the arduino nano ble 33 via bluetooth and received the value to the raspberry pi. How do I convert this value to a number? 覆盆子上的Zbar? - Zbar on raspberry? 覆盆子与Python - Raspberry With Python Python-连接BLE设备 - Python - Connect a BLE device PiZero W 连接到两个外设(GPIO 和 USB):如何同时连续读取两者? - PiZero W connected to two peripherals (GPIO and USB): how to continuously read from both at same time? 如果/ else替代 - If/else alternative
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM