gpt4 book ai didi

linux - 如何使用 bluez 库在蓝牙中测试 sco 数据包

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:08:48 26 4
gpt4 key购买 nike

问题: 监控主从蓝牙之间的 sco 数据包。

问题描述。 我有小型内部蓝牙设备(在 Linux fedora OS 中开发)并配置为从设备。

我对以下内容感兴趣:

  • Master连接到我们的内置设备并建立sco链接。
    我将如何验证链接已建立?
  • Master 向slave 发送sco 数据包,slave 发回(loopback)
    相同的数据包主控。完全不知道该怎么做?

  • 到目前为止我做了什么:

    好吧,我已经将我们的内置设备配置为从属设备,并通过蓝牙成功连接到 Windows 笔记本电脑。

    我在我的内部 BT 设备中启用了耳机配置文件,我可以在 Windows 上看到耳机图标。

    在 Linux 端通过 c++ 代码我修改了/etc/asound.conf 以包含连接设备的 mac-address(在我的情况下是 windows 笔记本电脑)。
    示例如下所示
    pcm.btheadset {
    type plug
    slave {
    pcm {
    type bluetooth
    device DC:A9:71:8D:2D:C6
    profile "auto"
    }
    }

    然后通过命令在我的内部 BT 上播放声音
    aplay -D btheadset " path of audio_file"

    我可以在我的 Windows 笔记本电脑上成功听到声音。

    到现在为止还挺好。
    现在当我做 hciconfig -a
    acl packets have increase but sco remain at 0

    RX bytes:1041 acl:456 sco:0 events:36 errors:0
    TX bytes:1347 acl:567 sco:0 commands:34 errors:0
  • 这能证明音频工作但不是通过 sco 吗?
  • 我发现我没有btsco驱动或hcid.conf文件。做
    你认为这可能是个问题?
  • 如果我的音频是通过 sco 工作的,谁能给我一个例子
    如何通过 hcidump 进行测试?
  • 如何将它循环回master?

  • 笔记:
    我在播放音乐时做了 hcidump 并保存了文件。我将保存文件转储到 Wireshark 并使用“bthci_sco”过滤数据包,但没有发现任何数据包。那么想知道音乐是如何运作的呢?

    最佳答案

    经过几天与 Ubuntu 频繁崩溃的斗争,它终于奏效了。

    以下是我尝试过的步骤。请作为引用,因为我很可能忘记写一些步骤

    ..................................................... ..................................................................
    问题概述:尝试将Linux OS连接到BT耳机并建立sco链接以播放音乐

    UBuntu 配置:
    内核版本: 3.0.0-32-通用
    Ubuntu 版本 ->11.10

    测试设备: JABRA EASY GO 耳机..
    ..................................................... ......................
    1) 安装以上版本的 Ubuntu 。这个 Ubuntu 版本不受支持,但由于我的内部设备使用几乎相同的内核版本,所以我坚持使用这个版本。

    2) 配置 apt-get 源列表。由于安装的版本不支持,apt-get 将无法工作。要使其工作,请修改 /etc/apt/sources.list .
    示例->

    sudo sed -i -e 's/archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list

    sudo apt-get update && sudo apt-get dist-upgrade

    3)我建议安装突触以及安装包和缺少的库。

    4) 安装以下软件包 -->
         bluez-hcidump 
    bluez-utils
    libbluetooth1
    libbluetooth1-dev
    install automake-1.7 and autoconfig
    cvs

    5) 谷歌下载 btsco 的源代码或替代

    使用以下命令
    cvs -d:pserver:anonymous@bluetooth-alsa.cvs.sourceforge.net:/cvsroot/bluetooth-alsa login
    cvs -d:pserver:anonymous@bluetooth-alsa.cvs.sourceforge.net:/cvsroot/bluetooth-alsa co btsco

    6) 现在正在编译和安装

    i) 进入 btsco 目录

    ii) ./bootstrap
    问题:
    如果错误/警告:在库安装 libbsdl1.2-dev 中找不到宏“AM_PATH_SDL”

    一旦 bootsrap 通过执行配置
    ii) ./配置
    问题 :
  • 如果蓝牙/蓝牙 .h 缺失 -> 安装 libbluetooth-dev
  • 软件包要求 dbus-1>=0.36 不符合 & dbus-glib 未找到 --> 安装 libdbus-glib-1-dev

  • iii) 制作

    问题:
    ./libtool: line 841: X--tag=CXX: command not found 和更多类似这样的错误

    要解决该错误:下载 libtool-1.5.24 tar 球。提取它并执行 configure and make .
    现在再次在 btsco 上进行配置并将 libtool 可执行文件从 libtool 目录复制到 btsco。

    iv) 进行安装
    v) 使 mainatiner-clean
    O/p : btsco 构建成功,您可以在/usr/local/bin 中找到它。

    7) 构建内核模块

    i) cd/usr/src/btsco/kernel

    ii) 制作

    问题:我假设你会得到大量的错误列表。打开 btsco.cand 一步一步处理每个错误

    1 错误声音/driver.h not found bla bla -> 在 btsco.c 文件中注释
    2 条评论 #include 因为现在已经过时了
    3) 添加
     #include< linux/smp.h>
    #include< linux/muxtex.h>

    4) DEFINE_MUTEX(os_mutex);

    5) snd_assert 已过时,因此将 uit 替换为 if 语句示例
    if( bt_sco->playback == NULL) 
    {

    }

    6)用从网络复制的低于9的函数替换kill_proc(再次过时) .. tahnks 给那个人)
    链接: http://www.linuxquestions.org/questions/linux-kernel-70/is-there-any-kill_proc-replacement-for-proprietary-linux-kernel-drivers-4175460017/
    int my_kill_proc(pid_t pid, int sig) {
    int error = -ESRCH; /* default return value */
    struct task_struct* p;
    struct task_struct* t = NULL;
    struct pid* pspid;
    rcu_read_lock();
    p = &init_task; /* start at init */
    do {
    if (p->pid == pid) { /* does the pid (not tgid) match? */
    t = p;
    break;
    }
    p = next_task(p); /* "this isn't the task you're looking for" */
    } while (p != &init_task); /* stop when we get back to init */
    if (t != NULL) {
    pspid = t->pids[PIDTYPE_PID].pid;
    if (pspid != NULL) error = kill_pid(pspid,sig,1);
    }
    rcu_read_unlock();
    return error;
    }

    然后应该是 kill_proc 而不是
    my_kill_proc( bt_sco->thread_pid, SIGINT )  

    6) 替换 %d to %lu对于错误 long int

    7) replace lock_kernal to mutex_lock( &os_mutex)解锁相同

    希望在那之后make会成功

    8) 进行安装
    9)depmod -e
    10 0 清洁

    11) modprobe snd_bt_sco

    ...................................................

    现在运行 btsco

    a) hciconfig hci0 语音 0X0060

    b) hcitool 扫描

    获取 JABRA 的 mac_addre4ss

    c)/usr/local/bin/btsco -r -v mac_addrees

    如果出现错误?:控制打开 (hw:1) 则 jabra 不支持 sco 或未加载内核模块

    d) 在另一个终端上做 -> sudo hcidump -i hci0 sco监控 sco 数据包

    e) 一旦 jabr 连接建立
    运行 aplay -D plughw:Headset /home/my_home_dir/my_sample_fiile.wav

    关于linux - 如何使用 bluez 库在蓝牙中测试 sco 数据包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26137056/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com