📢 Webサイト閉鎖と移転のお知らせ
このWebサイトは2026年9月に閉鎖いたします。
新しい記事は移転先で追加しております。(旧サイトでは記事を追加しておりません)
| 627行目: | 627行目: | ||
// タイムアウトタイマの初期化 | // タイムアウトタイマの初期化 | ||
discoveryTimeout = std::make_unique<QTimer>(this); | discoveryTimeout = std::make_unique<QTimer>(this); | ||
discoveryTimeout | discoveryTimeout.setInterval(10000); // 10秒のタイムアウト | ||
discoveryTimeout | discoveryTimeout.setSingleShot(true); | ||
connect(discoveryTimeout.get(), &QTimer::timeout, this, &BLEServiceDiscovery::onDiscoveryTimeout); | connect(discoveryTimeout.get(), &QTimer::timeout, this, &BLEServiceDiscovery::onDiscoveryTimeout); | ||
| 645行目: | 645行目: | ||
// 接続開始 | // 接続開始 | ||
controller | controller.connectToDevice(); | ||
discoveryTimeout | discoveryTimeout.start(); | ||
} | } | ||
catch (const std::exception &e) { | catch (const std::exception &e) { | ||
| 660行目: | 660行目: | ||
try { | try { | ||
if (controller) { | if (controller) { | ||
controller | controller.disconnectFromDevice(); | ||
discoveryTimeout | discoveryTimeout.stop(); | ||
} | } | ||
} | } | ||
| 682行目: | 682行目: | ||
{ | { | ||
qDebug() << "デバイスに接続"; | qDebug() << "デバイスに接続"; | ||
discoveryTimeout | discoveryTimeout.stop(); | ||
// サービス探索の開始 | // サービス探索の開始 | ||
controller | controller.discoverServices(); | ||
} | } | ||
| 692行目: | 692行目: | ||
{ | { | ||
qDebug() << "デバイスから切断"; | qDebug() << "デバイスから切断"; | ||
discoveryTimeout | discoveryTimeout.stop(); | ||
} | } | ||
| 701行目: | 701行目: | ||
// サービスオブジェクトの作成 | // サービスオブジェクトの作成 | ||
QLowEnergyService* service = controller | QLowEnergyService* service = controller.createServiceObject(uuid, this); | ||
if (service) { | if (service) { | ||
connectServiceSignals(service); | connectServiceSignals(service); | ||
| 712行目: | 712行目: | ||
{ | { | ||
qDebug() << "サービス探索が完了"; | qDebug() << "サービス探索が完了"; | ||
discoveryTimeout | discoveryTimeout.stop(); | ||
emit discoveryComplete(); | emit discoveryComplete(); | ||
} | } | ||