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