qbluetoothdeviceinfo servicedata()方法提出了奇怪的问题,字节具有0个值
我正在尝试使用qbluetoothdeviceinfo类(QT 6.3)从蓝牙设备中检索服务数据信息,但是当它包含具有0个值的字节时,它将被截断。
例如,我在写为0xff22233000065的蓝牙设备中有服务数据:问题是qbluetoothdeviceinfo的servicedata()方法返回QByTearray,该QbyTearray只有前三个字节FF,22、33,并在找到00时停止。 你们中有人遇到过这样类似的问题吗?
谢谢您提前的
编辑:在这里,我粘贴了我的代码摘录,试图澄清我的问题:
//...
discoveryAgent = new QBluetoothDeviceDiscoveryAgent();
connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered,
this, &BluetoothController::addDevice);
//...
void BluetoothController::addDevice(const QBluetoothDeviceInfo &device)
{
//...
QBluetoothUuid sId = device.serviceIds().front();
//Here is the problem: instead of having sData composed by 6 bytes
//as expected in my test (i.e 0xFF 0x22 0x33 0x00 0x00 0x65),
//sData has size = 3 and has only 0xFF 0x22 0x33
QByteArray sData = device.serviceData(sId);
//...
}
I am trying to retrieve Service Data information from Bluetooth devices using QBluetoothDeviceInfo class (Qt 6.3), but when it contains bytes with 0 values it gets truncated.
For example I have the Service Data in my bluetooth device written as 0xFF2233000065: the problem is that serviceData() method of QBluetoothDeviceInfo returns a QByteArray that has only the first three bytes FF, 22, 33 and stops when it founds 00.
Any of you has encountered such a similar issue?
Thank you in advance
edit: Here I paste excerpts from my code, trying to clarify my issue:
//...
discoveryAgent = new QBluetoothDeviceDiscoveryAgent();
connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered,
this, &BluetoothController::addDevice);
//...
void BluetoothController::addDevice(const QBluetoothDeviceInfo &device)
{
//...
QBluetoothUuid sId = device.serviceIds().front();
//Here is the problem: instead of having sData composed by 6 bytes
//as expected in my test (i.e 0xFF 0x22 0x33 0x00 0x00 0x65),
//sData has size = 3 and has only 0xFF 0x22 0x33
QByteArray sData = device.serviceData(sId);
//...
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论