【问题标题】:how to test sco packets in bluetooth using bluez library如何使用 bluez 库在蓝牙中测试 sco 数据包
【发布时间】:2014-11-26 00:56:33
【问题描述】:

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

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

我对以下事情感兴趣:

  1. Master 连接到我们的内置设备并建立 sco 链接。 如何验证链接已建立?

  2. Master 发送 sco 数据包给 slave,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
  1. 这是否能证明音频工作正常但不是通过 sco?
  2. 我发现我没有 btsco 驱动程序或 hcid.conf 文件。做 您认为这可能是个问题吗?
  3. 如果我的音频是通过 sco 工作的,谁能给我一个例子 如何通过 hcidump 进行测试?
  4. 如何将它循环回master?

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

【问题讨论】:

    标签: linux audio bluetooth bluez


    【解决方案1】:

    经过几天与 Ubuntu 频繁崩溃的斗争,终于成功了。

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

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

    UBuntu 配置:
    内核版本: 3.0.0-32-generic
    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) 我建议安装 synaptic 以及安装包和缺少的库。

    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) ./配置 问题:

    1. 如果蓝牙/蓝牙 .h 丢失 -> 安装 libbluetooth-dev
    2. 软件包要求 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.can,逐步处理每个错误

    1 错误声音/driver.h 未找到 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 替换为 error long int

    7) replace lock_kernal to mutex_lock( &amp;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

    【讨论】:

      猜你喜欢
      • 2015-02-02
      • 2021-07-09
      • 2012-07-06
      • 1970-01-01
      • 2017-03-29
      • 1970-01-01
      • 2014-08-30
      • 1970-01-01
      • 2021-12-10
      相关资源
      最近更新 更多