简体   繁体   English

如何使用 Bluez L2CAP 发送更多字节?

[英]How can I send more bytes using Bluez L2CAP?

I have the following code that connects to another machine using BlueZ and sends packets:我有以下代码使用 BlueZ 连接到另一台机器并发送数据包:

struct sockaddr_l2 addr = { 0 };
    int s, status;
    char dest[18] = "DC:FB:48:6B:BF:0B";

    int socket1;

    int32_t value = 0;

    // allocate a socket
    socket1 = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);


    // set the connection parameters (who to connect to)
    addr.l2_family = AF_BLUETOOTH;
    addr.l2_psm = htobs(0x1001);

    str2ba( dest, &addr.l2_bdaddr );
    status = connect(socket1, (struct sockaddr *)&addr, sizeof(addr));
    while( status != 0)
    {
        status = connect(socket1, (struct sockaddr *)&addr, sizeof(addr));
        std::cout << "Waiting for DC:FB:48:6B:BF:0B" << std::endl;
        sleep(2);
    }

    while (true)
    {
        double data[512] = {0.0};
        memset(data, 0, 512);
        status = write(socket1, data, 512);
     }

As you can see, I just send 512 bytes and other machine reads them just fine.如您所见,我只发送了 512 个字节,其他机器读取它们就好了。 However, when I try to increase to 1000 bytes, other machine can no longer accept any bytes and just does nothing.但是,当我尝试增加到 1000 字节时,其他机器不再接受任何字节并且什么也不做。

How can I send more bytes in this case?在这种情况下如何发送更多字节? I am using Linux CentOS 8.我正在使用 Linux CentOS 8。

By default the maximum transmission rate of L2CAP is 672 bytes.默认情况下,L2CAP 的最大传输速率为 672 字节。 I would recommend you to try setting the maximum transmission unit to your required value.我建议您尝试将最大传输单位设置为所需的值。

Have a look at "4.3.1 Maximum Transmission Unit" here .此处查看“4.3.1 最大传输单元”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 L2CAP IOS + Linux (Bluez) - L2CAP IOS + Linux (Bluez) 我如何在bluez中获得蓝牙rssi和链接质量值? - how can i get bluetooth rssi and link quality value in bluez? 在哪里可以找到 BlueZ 的一些文档? - Where can I find some documentation for BlueZ? 使用Bluez / Linux,我可以运行守护程序来广播BLE ibeacons并同时使用RFCOMM进行连接吗? - Using Bluez/Linux, can I run a daemon broadcasting BLE ibeacons and be connectable using RFCOMM simultaneously? 如何使用bluez在Linux上通过蓝牙4.0 LE连接到FitBit Zip? - How can I connect to the FitBit Zip over Bluetooth 4.0 LE on Linux with bluez? 如何从返回字节数组的dbus bluez api中提取任何有用的信息 - how I can extract any useful information from the dbus bluez api that returns a byte array 如何使用管道将&#39;ls-l&#39;的输出发送到cp命令? - how to send output of 'ls-l' to cp command using pipes? 如何使用BlueZ5库作为普通用户(没有sudo)执行PyBluez示例? - How do I execute PyBluez samples using BlueZ5 library as normal user (without sudo)? 如何在 Ubuntu 20.04 上使用 BlueZ 5 和 5.4 内核发送打包的广告数据包 - How to send a packed advertising packet with BlueZ 5 and the 5.4 kernel on Ubuntu 20.04 使用蓝牙加密狗时是否需要Bluez - Do i need Bluez when using a bluetooth dongle
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM