2024年11月24日星期日 下午9:46:31

树莓派通过Linux中蓝牙协议栈Bluz连接蓝牙音箱接入Home Assistnant

2 年 前
#3690 引用
There are some applications and games that still don’t work with Bluetooth speakers because they directly access the sound system, notably SonicPi.

If your speaker is still silent, make sure the volume is turned up, go back to
Terminal and start bluetoothctl.

https://www.okdo.com/project/set-up-a-bluetooth-speaker-with-a-raspberry-pi/

At the end of 2020, BlueALSA (the Bluetooth Audio ALSA Backend aka bluez-alsa) was ejected and replaced with PulseAudio in the desktop version of Raspberry Pi OS (see the 2020-12-02 release notes). I feared then that there would be problems with the solutions I described as recently as November 4, 2021, to connect Bluetooth® sound devices to the Raspberry Pi running the Lite version of the OS. I
0
2 年 前
#3691 引用
etooth standard specifies three audio profiles

    A2DP (Advanced Audio Distribution Profile) - high-quality audio playback, appropriate for e.g. listening to music.
    HSP (HeadSet Profile) - phone-quality audio playback and recording, appropriate for phone calls.
    HFP (Hands-Free Profile) - same as HSP, but with additional functionality for managing phone calls.

0
2 年 前
#3692 引用
connect 9A:07:65:B4:21:EC Failed to connect: org.bluez.Error.Failed


[bluetooth]# connect 9A:07:65:B4:21:EC
Attempting to connect to 9A:07:65:B4:21:EC
Failed to connect: org.bluez.Error.Failed

0
2 年 前
#3721 引用

BlueZ 5.44体系结构



蓝牙技术的系统结构分为三大部分:底层硬件模块、中间协议层和应用层。

(1)底层硬件模块包括:无线跳频( RF)、基带( BB)和链路管理(LM)

  蓝牙的SIG规定了四种与硬件连接的物理总线方式USB、RS232、 UART和PC卡

(2)BlueZCore层包括各种Profile:

GAP:设备连接

SDAP:查询相关信息

SPP:虚拟串口连接

GOEP:数据传输

(3)中间协议层:

HCI接口:设备扫描、配对

L2CAP协议:蓝牙适配

(4)应用层包括BlueZ各种工具集:

hciconfig:配置蓝牙设备,用于打印设备信息和配置设备

hcitool:配置蓝牙连接,执行比如扫描等命令

gatttool:一种直接使用参数对蓝牙设备进行控制,二就是使用-I参数进入interactive模式对蓝牙设备进行控制

sdptool:搜索并管理设备服务
0
2 年 前
#3722 引用
This project is a rebirth of a direct integration between BlueZ and ALSA. Since BlueZ >= 5, the build-in integration has been removed in favor of 3rd party audio applications. From now on, BlueZ acts as a middleware between an audio application, which implements Bluetooth audio profile, and a Bluetooth audio device.

The current status quo is, that in order to stream audio from/to a Bluetooth device, one has to install PulseAudio, or use BlueZ < 5. However, BlueZ version 4 is considered to be deprecated, so the only reasonable way to achieve this goal is to install PulseAudio.

With this application (later named as BlueALSA), one can achieve the same goal as with PulseAudio, but with less dependencies and more bare-metal-like. BlueALSA registers all known Bluetooth audio profiles in BlueZ, so in theory every Bluetooth device (with audio capabilities) can be connected. In order to access the audio stream, one has to connect to the ALSA PCM device called bluealsa. Please note that this PCM device is based on the ALSA software PCM I/O plugin - it will not be available in the ALSA Kernel proc interface.
0
2 年 前
#3723 引用
PulseAudio is a sound server system for POSIX OSes, meaning that it is a proxy for your sound applications. It is an integral part of all relevant modern Linux distributions and is used in various mobile devices, by multiple vendors. It performs advanced operations on sound data as it passes between your application and hardware
0
2 年 前
#3728 引用
蓝牙设备的主从模式

https://www.docin.com/touch_new/preview_new.do?id=2169470817#:~:text=%E4%BB%8A%E5%A4%A9%E5%B0%B1%E9%9A%8F%E7%9D%80%E4%BA%91%E9%87%8C%E7%89%A9%E9%87%8C%E4%B8%80%E8%B5%B7%E6%9D%A5%E7%9C%8B%E7%9C%8B%E8%93%9D%E7%89%99%E4%B8%B2%E5%8F%A3%E6%A8%A1%E5%9D%97%E4%B8%BB%E6%A8%A1%E5%BC%8F%E5%92%8C%20%E4%BB%8E%E6%A8%A1%E5%BC%8F%E6%9C%89%E4%BB%80%E4%B9%88%E5%8C%BA%E5%88%AB%E3%80%82%20BLE%20%E8%93%9D%E7%89%99%E7%9A%84%E8%A7%92%E8%89%B2%E6%9C%89%E4%BB%A5%E4%B8%8B%E5%87%A0%E7%A7%8D%EF%BC%9A%E5%B9%BF%E6%92%AD%E8%80%85%EF%BC%88Advertise%EF%BC%89%E3%80%81%E6%89%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E4%B8%80%E4%B8%AA%E4%BB%8E%E8%AE%BE%E5%A4%87%E8%BF%9B%E8%A1%8C%E8%BF%9E%E6%8E%A5%E3%80%82
0
2 年 前
#3729 引用

1 摘要
这篇文章的主要目的是告诉大家应该如何使用bluez进行开发,由于bluez的文档实在太少了,入门门槛实在太高了,很多人无从下手,准备写一个专题记录一下自己学习bluez的过程,分享一下bluez的学习方法,让大家少走一些弯路。我用的平台是君正x2000,蓝牙库使用的是bluez5.54,bluez库是通过buildroot编译出来的。通过BLUEZ我主要开发了一个BLE的串口服务端demo。这个程序我已经上传到了

https://download.csdn.net/download/huohongpeng/16681815?spm=1001.2014.3001.5501

有需要的可以自行下载。

2 开发bluez需要哪些知识?
开发bluez与其他常见的c库有本质的区别。以前我们需要什么功能都是移植一个c库,然后调用c库里面的api。而bluez却完全不是这样,bluez编译之后确实也会有一个libbluetooth,但是一般情况下,我们不会直接使用这个库进行开发。也不是像网上很老的教程用socket进行开发。那用什么呢?需要用DBUS进行开发。所以想要开发bulez,那么DBUS编程是绕不开的,必须要学习。

现在我们使用的bluez一般说的都是bluez5,bluez5与之前的bluez版本有很大区别,具体可以参考http://www.bluez.org/release-of-bluez-5-0/ 里面有比较简单的说明。简单的说bluez5所有的API都是通过DBUS来间接调用,而不是直接使用c接口来调用。
0
2 年 前
#3730 引用
Let’s start first with some important information:

Raspbian uses BlueZ as Bluetooth stack.
BlueZ deals with pure Bluetooth tasks (pairing/connection/…)
So, BlueZ needs additional SW components for audio management
First Linux audio manager that comes to mind is ALSA
But, BlueZ (>= v5.0) doesn’t support ALSA anymore
Instead, BlueZ is now using PulseAudio (>= 5.0)
And, PulseAudio still uses ALSA

http://youness.net/raspberry-pi/bluetooth-headset-raspberry-pi
0
2 年 前
#3731 引用
PulseAudio (5.0) supported only A2DP profile
Later, it added also a native support of HSP profile (>=v6.0)
And for HFP, you have to use another module: oFono
Again…

http://youness.net/raspberry-pi/bluetooth-headset-raspberry-pi

see:https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/
0