#include "bloodpressuresetdialog.h"
#include "resolutionadaptive.h"
#include <QGridLayout>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QDebug>
#include <QLoggingCategory>
const QBluetoothUuid targetServiceUuid = QBluetoothUuid(QStringLiteral("0000fff0-0000-1000-8000-00805f9b34fb"));// 目标服务UUID
const QBluetoothUuid targetCharUuid = QBluetoothUuid(QStringLiteral("0000fff4-0000-1000-8000-00805f9b34fb"));// 目标特征UUID
BloodPressureSetDialog::BloodPressureSetDialog(QWidget *parent)
: QDialog(parent),
bleController(nullptr),
currentService(nullptr)
{
//启用所有以 qt.bluetooth 为前缀的日志输出
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
// 窗口设置
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
setMinimumSize(ResolutionAdaptive::size(600, 600));
setWindowTitle(tr("血压计配置"));
// 主布局
auto *mainLayout = new QGridLayout(this);
// 血压计型号选择分组
BloodPressureGroupBox = new QGroupBox(tr("血压计型号选择"), this);
BloodPressureButtonGroup = new QButtonGroup(this);
BloodPressure_YXBLE_Radio = new QRadioButton(tr("USB型"), this);
BloodPressure_WXBLE_Radio = new QRadioButton(tr("无线蓝牙型"), this);
BloodPressure_YXBLE_Radio->setChecked(true);
BloodPressureButtonGroup->addButton(BloodPressure_YXBLE_Radio, 0);
BloodPressureButtonGroup->addButton(BloodPressure_WXBLE_Radio, 1);
auto *radioLayout = new QHBoxLayout(BloodPressureGroupBox);
radioLayout->addWidget(BloodPressure_YXBLE_Radio);
radioLayout->addWidget(BloodPressure_WXBLE_Radio);
mainLayout->addWidget(BloodPressureGroupBox, 0, 0, 1, 2);
// 栈式窗口
stack = new QStackedWidget(this);
auto *YXBLEWidget = new QWidget(stack); // USB页面(空实现)
WXBLEWidget = new QWidget(stack); // 蓝牙页面
stack->addWidget(YXBLEWidget);
stack->addWidget(WXBLEWidget);
mainLayout->addWidget(stack, 1, 0, 1, 2);
// 保存按钮
SaveBtn = new QPushButton(tr("保存配置"), this);
mainLayout->addWidget(SaveBtn, 2, 0, 1, 2, Qt::AlignCenter);
// 初始化
initBluetoothWidget();
// 信号连接
connect(BloodPressureButtonGroup, QOverload<QAbstractButton *, bool>::of(&QButtonGroup::buttonToggled),this, &BloodPressureSetDialog::onRadioButtonToggled);
connect(SaveBtn, &QPushButton::clicked, this, &BloodPressureSetDialog::onSaveClicked);
}
BloodPressureSetDialog::~BloodPressureSetDialog()
{
// 资源清理
if (currentService) {
delete currentService;
}
if (bleController) {
bleController->disconnectFromDevice();
delete bleController;
}
delete discoveryAgent;
}
//蓝牙界面初始
void BloodPressureSetDialog::initBluetoothWidget()
{
// 蓝牙页面布局
auto *mainLayout = new QVBoxLayout(WXBLEWidget);
// 搜索按钮
searchButton = new QPushButton(tr("搜索蓝牙设备"), this);
mainLayout->addWidget(searchButton);
// 设备列表
deviceListWidget = new QListWidget(this);
deviceListWidget->setStyleSheet("QListWidget::item { height: 50px; }");
mainLayout->addWidget(deviceListWidget);
// 状态标签
statusLabel = new QLabel(tr("请点击搜索按钮查找设备"), this);
mainLayout->addWidget(statusLabel);
// 设备发现代理
discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
discoveryAgent->setLowEnergyDiscoveryTimeout(5000); // 5秒超时
// 连接蓝牙信号
connect(searchButton, &QPushButton::clicked, this, &BloodPressureSetDialog::onSearchClicked);
//当蓝牙搜索代理(discoveryAgent)在扫描过程中发现任何符合低功耗蓝牙(BLE)规范的设备时触发
connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered,this, &BloodPressureSetDialog::onDeviceDiscovered);
//当蓝牙搜索达到预设超时时间完成搜索
connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::finished,this, &BloodPressureSetDialog::onDiscoveryFinished);
//当搜索过程中出现异常(如蓝牙硬件未启用、信号干扰导致通信失败等)时触发
connect(discoveryAgent, QOverload<QBluetoothDeviceDiscoveryAgent::Error>::of(&QBluetoothDeviceDiscoveryAgent::error),this, &BloodPressureSetDialog::onDiscoveryError);
}
//选项界面切换
void BloodPressureSetDialog::onRadioButtonToggled(QAbstractButton *button, bool checked)
{
if (checked)
{
if (button == BloodPressure_YXBLE_Radio) {
stack->setCurrentIndex(0); // 显示USB页面
} else if (button == BloodPressure_WXBLE_Radio) {
stack->setCurrentIndex(1); // 显示蓝牙页面
}
}
}
//开始搜索按钮点击
void BloodPressureSetDialog::onSearchClicked()
{
//清空设备列表
deviceListWidget->clear();
statusLabel->setText(tr("正在搜索蓝牙设备..."));
//搜索按钮失能
searchButton->setEnabled(false);
qDebug()<<"正在搜索蓝牙设备...";
// 开始搜索低功耗蓝牙设备
discoveryAgent->start(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod);
}
//当蓝牙搜索代理(discoveryAgent)在扫描过程中发现任何符合低功耗蓝牙(BLE)规范的设备时触发
void BloodPressureSetDialog::onDeviceDiscovered(const QBluetoothDeviceInfo &device)
{
// 只处理BLE设备
if (!(device.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration))
{
return;
}
QString deviceName = device.name();
if (deviceName.isEmpty())
{
deviceName = tr("未知设备");
}
// 创建列表项
auto *item = new QListWidgetItem(deviceListWidget);
auto *itemWidget = new QWidget(deviceListWidget);
auto *itemLayout = new QHBoxLayout(itemWidget);
itemLayout->setContentsMargins(5, 5, 5, 5);
// 设备信息标签
auto *deviceLabel = new QLabel(deviceName, itemWidget);
// 连接按钮
auto *connectBtn = new QPushButton(tr("连接"), itemWidget);
connectBtn->setMinimumWidth(80);
connect(connectBtn, &QPushButton::clicked,this, [this, device](){ onConnectDevice(device); });
itemLayout->addWidget(deviceLabel);
itemLayout->addStretch();
itemLayout->addWidget(connectBtn);
deviceListWidget->setItemWidget(item, itemWidget);
}
//蓝牙搜索完成
void BloodPressureSetDialog::onDiscoveryFinished()
{
statusLabel->setText(tr("搜索完成,找到 %1 个设备").arg(deviceListWidget->count()));
searchButton->setEnabled(true);
qDebug()<<tr("搜索完成,找到 %1 个设备").arg(deviceListWidget->count());
}
//搜索过程出现异常
void BloodPressureSetDialog::onDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error error)
{
QString errorText;
switch (error)
{
case QBluetoothDeviceDiscoveryAgent::PoweredOffError:
errorText = tr("蓝牙未开启,请先开启蓝牙");
break;
case QBluetoothDeviceDiscoveryAgent::InputOutputError:
errorText = tr("蓝牙通信错误");
break;
default:
errorText = tr("搜索错误: %1").arg(discoveryAgent->errorString());
}
statusLabel->setText(errorText);
searchButton->setEnabled(true);
}
//保存配置
void BloodPressureSetDialog::onSaveClicked()
{
if (BloodPressure_WXBLE_Radio->isChecked() && !currentConnectedDevice.address().isNull()) {
QString info = QString("已保存蓝牙配置: %1 (%2)")
.arg(currentConnectedDevice.name())
.arg(currentConnectedDevice.address().toString());
statusLabel->setText(info);
qDebug() << info;
} else if (BloodPressure_YXBLE_Radio->isChecked()) {
statusLabel->setText(tr("已保存USB配置"));
qDebug() << "保存USB配置";
}
}
//连接按钮按下
void BloodPressureSetDialog::onConnectDevice(const QBluetoothDeviceInfo &device)
{
statusLabel->setText(tr("正在连接 %1...").arg(device.name()));
// 如果已有连接,先断开
if (bleController)
{
qDebug()<<"已有连接,bleController执行断开";
bleController->disconnectFromDevice();
delete bleController;
bleController = nullptr;
}
if (currentService)
{
qDebug()<<"已有服务,currentService执行断开";
delete currentService;
currentService = nullptr;
}
// 保存当前连接的设备信息
currentConnectedDevice = device;
// 创建BLE控制器
bleController = QLowEnergyController::createCentral(device, this);
if (!bleController)
{
statusLabel->setText(tr("创建控制器失败"));
return;
}
qDebug()<<QString("创建%1控制器成功").arg(currentConnectedDevice.name());
//当 BLE 控制器成功与蓝牙设备建立连接时触发
connect(bleController, &QLowEnergyController::connected,this, &BloodPressureSetDialog::onControllerConnected);
//当 BLE 控制器与蓝牙设备的连接断开时触发
connect(bleController, &QLowEnergyController::disconnected,this, &BloodPressureSetDialog::onControllerDisconnected);
//当 BLE 控制器在连接或通信过程中发生错误时触发
connect(bleController, QOverload<QLowEnergyController::Error>::of(&QLowEnergyController::error),this, &BloodPressureSetDialog::onControllerError);
//当 BLE 控制器成功发现蓝牙设备提供的一个服务时触发
connect(bleController, &QLowEnergyController::serviceDiscovered,this, &BloodPressureSetDialog::onServiceDiscovered);
//当 BLE 控制器完成对蓝牙设备所有服务的搜索后触发
connect(bleController, &QLowEnergyController::discoveryFinished,this, &BloodPressureSetDialog::onServiceDiscoveryFinished);
// 开始连接
bleController->connectToDevice();
}
//当 BLE 控制器成功与蓝牙设备建立连接时触发
void BloodPressureSetDialog::onControllerConnected()
{
statusLabel->setText(tr("连接成功,正在搜索服务..."));
//qDebug()<<"bleController当前状态:"<<bleController->state();
QTimer::singleShot(300, this, [this]()
{
bleController->discoverServices();
});
}
//当 BLE 控制器与蓝牙设备的连接断开时触发
void BloodPressureSetDialog::onControllerDisconnected()
{
qDebug() << "设备已断开连接,服务可能失效";
statusLabel->setText(tr("设备已断开连接"));
currentConnectedDevice = QBluetoothDeviceInfo();
if (currentService)
{
delete currentService;
currentService = nullptr;
}
}
//当 BLE 控制器在连接或通信过程中发生错误
void BloodPressureSetDialog::onControllerError(QLowEnergyController::Error error)
{
statusLabel->setText(tr("连接错误: %1").arg(bleController->errorString()));
}
//当 BLE 控制器成功发现蓝牙设备提供的一个服务时触发
void BloodPressureSetDialog::onServiceDiscovered(const QBluetoothUuid &newServiceUUid)
{
//qDebug()<<"当前的服务UUid:"<<newServiceUUid;
m_ServiceUuidList.append(newServiceUUid);
}
//当 BLE 控制器完成对蓝牙设备所有服务的搜索后触发
void BloodPressureSetDialog::onServiceDiscoveryFinished()
{
// 先创建一个字符串来存储所有服务UUID
QString allServices;
for (const auto &uuid : m_ServiceUuidList)
{
allServices += uuid.toString() + "\n";
}
qDebug() << QString("BLE控制器完成对蓝牙设备所有服务的搜索,共发现 %1 个服务:").arg(m_ServiceUuidList.count());
qDebug().noquote() << allServices;
bool hasTargetService = m_ServiceUuidList.contains(targetServiceUuid);
if (hasTargetService)
{
statusLabel->setText(tr("发现目标服务,设备可用"));
qDebug() << "找到目标服务 UUID: " << targetServiceUuid.toString();
//开始连接目标服务
currentService = bleController->createServiceObject(targetServiceUuid);
if(currentService)
{
//当服务状态发生变化时触发
connect(currentService, &QLowEnergyService::stateChanged,this, &BloodPressureSetDialog::onServiceStateChanged);
//当服务操作错误时
connect(currentService, QOverload<QLowEnergyService::ServiceError>::of(&QLowEnergyService::error),this, &BloodPressureSetDialog::onServiceError);
// 连接特征读取完成信号
connect(currentService, &QLowEnergyService::characteristicRead,this,&BloodPressureSetDialog::onCharacteristicRead);
qDebug() << "开始发现服务详情:currentService->discoverDetails()";
currentService->discoverDetails();
}
} else {
statusLabel->setText(tr("未发现目标服务,设备可能不兼容"));
qDebug() << "未找到目标服务 UUID: " << targetServiceUuid.toString();
}
// 清空服务列表,避免下次搜索干扰
m_ServiceUuidList.clear();
}
//当前服务状态变化
void BloodPressureSetDialog::onServiceStateChanged(QLowEnergyService::ServiceState newState)
{
if(currentService)
{
switch(newState)
{
case QLowEnergyService::InvalidService://表示服务处于无效状态。通常在服务未正确初始化、连接失败,或已被销毁时出现,此时无法对服务进行任何有效操作(如发现特征、读写数据等)。
{
qDebug()<<"InvalidService状态";
statusLabel->setText(tr("服务处于无效状态"));
}
break;
case QLowEnergyService::DiscoveryRequired://表示服务已被识别(已知其起始和结束句柄),但尚未进行详细信息的发现。此时需要调用 discoverDetails() 方法触发服务详情(如特征、描述符等)的发现过程,否则无法访问服务的具体功能。
{
qDebug()<<"DiscoveryRequired状态";
}
break;
case QLowEnergyService::DiscoveringServices://表示服务正在进行详情发现(discoverDetails() 已被调用且正在执行)。在此状态下,系统正在与 BLE 设备通信,获取服务包含的特征、特征属性、描述符等信息,此时应避免对服务进行其他操作,等待发现完成。
{
qDebug()<<"DiscoveringServices状态";
}
break;
case QLowEnergyService::ServiceDiscovered://表示服务的详情已完全发现并同步完成。此时可以正常访问服务的特征(如读取、写入特征值,设置通知等),是服务可用的主要状态。
{
qDebug()<<"ServiceDiscovered状态";
const QLowEnergyCharacteristic targetChar = currentService->characteristic(targetCharUuid);
// 打印特征属性(调试用)
qDebug() << "特征属性:" << targetChar.properties();
if (targetChar.properties() & QLowEnergyCharacteristic::Read)
{
currentService->readCharacteristic(targetChar);
}
statusLabel->setText(tr("服务就绪,正在准备数据交互..."));
// 查找目标特征(targetCharUuid)
const QList<QLowEnergyCharacteristic> chars = currentService->characteristics();
bool foundTargetChar = false;
for (const auto &ch : chars)
{
if (ch.uuid() == targetCharUuid)
{
foundTargetChar = true;
qDebug()<<"查找目标特征targetCharUuid:"<<ch.uuid();
break;
}
}
if (!foundTargetChar)
{
qDebug() << "未找到目标特征 UUID: " << targetCharUuid.toString();
statusLabel->setText(tr("未找到目标特征,无法通信"));
// 若未找到特征,主动断开连接(避免设备超时)
if (bleController)
{
bleController->disconnectFromDevice();
}
}
}
break;
case QLowEnergyService::LocalService://表示该服务是本地设备(当前应用所在设备)创建的本地服务,而非远程 BLE 设备提供的服务。本地服务通常用于将当前设备作为 BLE 服务器,向其他设备提供数据或功能。
{
qDebug()<<"LocalService状态";
}
break;
default:
qDebug()<<"未知状态";
break;
}
}
}
//服务操作错误
void BloodPressureSetDialog::onServiceError(QLowEnergyService::ServiceError error)
{
//qDebug() << "服务错误导致状态失效:" << error;
switch(error)
{
case QLowEnergyService::NoError://无错误
break;
case QLowEnergyService::OperationError://通用操作错误
qDebug()<<"OperationError";
break;
case QLowEnergyService::CharacteristicWriteError://特征值写入错误
qDebug()<<"CharacteristicWriteError";
break;
case QLowEnergyService::DescriptorWriteError://描述符写入错误
qDebug()<<"DescriptorWriteError";
break;
case QLowEnergyService::UnknownError://未知错误
qDebug()<<"UnknownError";
break;
case QLowEnergyService::CharacteristicReadError://特征值读取错误
qDebug()<<"CharacteristicReadError";
break;
case QLowEnergyService::DescriptorReadError://描述符读取错误
qDebug()<<"DescriptorReadError";
break;
break;
}
}
//特征读取
void BloodPressureSetDialog::onCharacteristicRead(const QLowEnergyCharacteristic &info, const QByteArray &value)
{
QString ch = info.uuid().toString() + " - Characteristic read:" + QString(value);
qDebug()<<ch;
statusLabel->setText(ch);
}
正在搜索蓝牙设备...
qt.bluetooth.winrt: Worker started
qt.bluetooth.winrt: onBluetoothLEDeviceFound: No device given
qt.bluetooth.winrt: BTLE scan completed
qt.bluetooth.winrt: Discovered BTLE device: "248235452300580" "AL_WBP" Num UUIDs 1 RSSI: -40 Num manufacturer data 0
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: onBluetoothLEDeviceFound: No device given
qt.bluetooth.winrt: Discovered BTLE device: "75375243283758" "Bluetooth 44:8d:aa:99:cd:2e" Num UUIDs 0 RSSI: -74 Num manufacturer data 0
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: Discovered BTLE device: "181149789377595" "LKM1S1-D8D43B" Num UUIDs 0 RSSI: -50 Num manufacturer data 0
qt.bluetooth.winrt: onBluetoothLEDeviceFound: No device given
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: onBluetoothLEDeviceFound: No device given
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: Discovered BTLE device: "263711541014828" "Q_BASH_EFD820B9B12C" Num UUIDs 1 RSSI: -74 Num manufacturer data 0
qt.bluetooth.winrt: Discovered BTLE device: "229505267960818" "hellobike" Num UUIDs 0 RSSI: -78 Num manufacturer data 0
qt.bluetooth.winrt: Discovered BTLE device: "230009226015792" "Bluetooth d1:31:32:36:34:30" Num UUIDs 1 RSSI: -80 Num manufacturer data 0
qt.bluetooth.winrt: onBluetoothLEDeviceFound: No device given
qt.bluetooth.winrt: Discovered BTLE device: "263711541014828" "Q_BASH_EFD820B9B12C" Num UUIDs 2 RSSI: -74 Num manufacturer data 1
qt.bluetooth.winrt: Updating device "Q_BASH_EFD820B9B12C" "EF:D8:20:B9:B1:2C"
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: onBluetoothLEDeviceFound: No device given
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: Discovered BTLE device: "95264454933381" "Bluetooth 56:a4:7b:fe:fb:85" Num UUIDs 0 RSSI: -58 Num manufacturer data 1
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: Discovered BTLE device: "106178345988574" "Bluetooth 60:91:92:98:71:de" Num UUIDs 0 RSSI: -68 Num manufacturer data 0
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: Updating data for device "Bluetooth d1:31:32:36:34:30" "D1:31:32:36:34:30"
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: Updating data for device "Q_BASH_EFD820B9B12C" "EF:D8:20:B9:B1:2C"
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
qt.bluetooth.winrt: Updating data for device "AL_WBP" "E1:C4:D1:F4:7D:24"
"搜索完成,找到 8 个设备"
qt.bluetooth.winrt: Using new low energy controller
"创建AL_WBP控制器成功"
qt.bluetooth.winrt: QLowEnergyControllerPrivateWinRTNew::connectToDevice
qt.bluetooth.winrt: QLowEnergyControllerPrivateWinRTNew::registerForStatusChanges
qt.bluetooth.winrt: Service discovery initiated
qt.bluetooth.winrt.service.thread: QLowEnergyControllerPrivateWinRTNew::onServiceDiscoveryFinished Changing service pointer from thread QThread(0x22b19ac8500)
qt.bluetooth.winrt.service.thread: QLowEnergyControllerPrivateWinRTNew::onServiceDiscoveryFinished Changing service pointer from thread QThread(0x22b19ac8500)
qt.bluetooth.winrt.service.thread: QLowEnergyControllerPrivateWinRTNew::onServiceDiscoveryFinished Changing service pointer from thread QThread(0x22b19ac8500)
qt.bluetooth.winrt.service.thread: QLowEnergyControllerPrivateWinRTNew::onServiceDiscoveryFinished Changing service pointer from thread QThread(0x22b19ac8500)
qt.bluetooth.winrt.service.thread: QLowEnergyControllerPrivateWinRTNew::onServiceDiscoveryFinished Changing service pointer from thread QThread(0x22b19ac8500)
qt.bluetooth.winrt.service.thread: QLowEnergyControllerPrivateWinRTNew::onServiceDiscoveryFinished Changing service pointer from thread QThread(0x22b19ac8500)
qt.bluetooth.winrt.service.thread: QLowEnergyControllerPrivateWinRTNew::onServiceDiscoveryFinished Changing service pointer from thread QThread(0x22b19ac8500)
"BLE控制器完成对蓝牙设备所有服务的搜索,共发现 7 个服务:"
{00001800-0000-1000-8000-00805f9b34fb}
{00001801-0000-1000-8000-00805f9b34fb}
{00001810-0000-1000-8000-00805f9b34fb}
{0000fff0-0000-1000-8000-00805f9b34fb}
{8e400001-f315-4f60-9fb8-838830daea50}
{00001805-0000-1000-8000-00805f9b34fb}
{0000180a-0000-1000-8000-00805f9b34fb}
找到目标服务 UUID: "{0000fff0-0000-1000-8000-00805f9b34fb}"
开始发现服务详情:currentService->discoverDetails()
DiscoveringServices状态
qt.bluetooth.winrt: QLowEnergyControllerPrivateWinRTNew::discoverServiceDetails "{0000fff0-0000-1000-8000-00805f9b34fb}"
qt.bluetooth.winrt.service.thread: QLowEnergyControllerPrivateWinRTNew::discoverServiceDetails Changing service pointer from thread QThread(0x22b19ac8500)
qt.bluetooth.winrt: QWinRTLowEnergyServiceHandlerNew::QWinRTLowEnergyServiceHandlerNew
qt.bluetooth.winrt: QWinRTLowEnergyServiceHandlerNew::obtainCharList
ServiceDiscovered状态
特征属性: QFlags(0x2|0x8|0x10)
qt.bluetooth.winrt: QLowEnergyControllerPrivateWinRTNew::readCharacteristic QSharedPointer(QLowEnergyServicePrivate(0x22b1f513590)) 16
qt.bluetooth.winrt.service.thread: QLowEnergyControllerPrivateWinRTNew::readCharacteristic Changing service pointer from thread QThread(0x22b19ac8500)
qt.bluetooth.winrt: Could not obtain native service for Uuid "{0000fff0-0000-1000-8000-00805f9b34fb}"
qt.bluetooth.winrt: Could not obtain native characteristic "{0000fff4-0000-1000-8000-00805f9b34fb}" from service "{0000fff0-0000-1000-8000-00805f9b34fb}"
CharacteristicReadError
查找目标特征targetCharUuid: "{0000fff4-0000-1000-8000-00805f9b34fb}"
InvalidService状态
qt.bluetooth.winrt: Unregistering 0 value change tokens
qt.bluetooth.winrt: QLowEnergyControllerPrivateWinRTNew::unregisterFromStatusChanges
设备已断开连接,服务可能失效
qt.bluetooth.winrt: QLowEnergyControllerPrivateWinRTNew::unregisterFromStatusChanges
qt.bluetooth.winrt: Unregistering 0 value change tokens