#include "controller.h" Controller::Controller(QObject *parent) : QObject(parent), m_pDiscoveryAgent(new QBluetoothServiceDiscoveryAgent()) { connect(m_pDiscoveryAgent, &QBluetoothServiceDiscoveryAgent::serviceDiscovered, this, &Controller::onServiceDiscovered); connect(m_pDiscoveryAgent, &QBluetoothServiceDiscoveryAgent::finished, this, [&]() { qDebug() << "finished"; }); connect(m_pDiscoveryAgent, &QBluetoothServiceDiscoveryAgent::canceled, this, [&](){ qDebug() << "canceled"; }); } void Controller::startScan() { qDebug() << "calling start"; if(!m_pDiscoveryAgent->isActive()) { m_pDiscoveryAgent->start(); qDebug() << "started"; } } void Controller::stopScan() { qDebug() << "calling stop"; if(m_pDiscoveryAgent->isActive()) m_pDiscoveryAgent->stop(); } void Controller::onServiceDiscovered(const QBluetoothServiceInfo &serviceInfo) { qDebug() << "service discovered" << serviceInfo.serviceName(); }