Index: sources/bluetooth/BLEScanner.cpp =================================================================== diff -u -rbe1b2d8f110b741f3d630df438da07d411110543 -r9efb7cf51c882dc1f374df0b2a8b8c20efafaa4e --- sources/bluetooth/BLEScanner.cpp (.../BLEScanner.cpp) (revision be1b2d8f110b741f3d630df438da07d411110543) +++ sources/bluetooth/BLEScanner.cpp (.../BLEScanner.cpp) (revision 9efb7cf51c882dc1f374df0b2a8b8c20efafaa4e) @@ -15,11 +15,11 @@ macAddress = "EC:21:E5:F4:BC:C9"; // for testing only } -void BLEScanner::initConnections() +void BLEScanner::onInitConnections() { // discovery agent - connect(discoveryAgent, SIGNAL(deviceDiscovered(const QBluetoothDeviceInfo&)), + connect(discoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)), this, SLOT(onDeviceDiscovered(const QBluetoothDeviceInfo&))); connect(discoveryAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)), this, SLOT(onDiscoveryAgentError(QBluetoothDeviceDiscoveryAgent::Error))); @@ -32,14 +32,14 @@ * \details Initializes the class by setting the connections * \return true on first initialization, false if it has already been initialized */ -bool BLEScanner::init() +bool BLEScanner::doInit() { if (_init) return false; _init = true; - initConnections(); + onInitConnections(); LOG_EVENT("UI," + tr("%1 Initialized").arg(metaObject()->className())); @@ -51,10 +51,9 @@ * \brief BLEScanner::quit * Called when the application is exiting. */ -void BLEScanner::quit() +void BLEScanner::onQuit() { - quitThread(); // verified - + onQuitThread(); // verified } @@ -63,7 +62,7 @@ * \details Moves this object to main thread to be handled by QApplicaiton * It will also be destroyed there. */ -void BLEScanner::quitThread() +void BLEScanner::onQuitThread() { if (!_thread ) return; @@ -77,21 +76,21 @@ * Sets the BLE mac address to pair with * \param mac - (QString) The mac address to pair to (e.g. "EC:21:E5:F4:BC:C9") */ -void BLEScanner::setMacAddress(const QString &mac) +void BLEScanner::onSetMacAddress(const QString &mac) { macAddress = mac; } /*! - * \brief BLEScanner::onSelectedDevice + * \brief BLEScanner::doSelectDevice * \param addr - The mac address of the device to connect to */ -void BLEScanner::onSelectedDevice(const QString &addr) +void BLEScanner::doSelectDevice(const QString &addr) { - setMacAddress(addr); + onSetMacAddress(addr); for (const QBluetoothDeviceInfo &deviceInfo : devices) { if (deviceInfo.address().toString() == addr) { - connectToDevice(deviceInfo); + onConnectToDevice(deviceInfo); return; } } @@ -106,7 +105,7 @@ { qDebug() << __FUNCTION__ << deviceInfo.address(); devices.append(deviceInfo); - emit deviceDiscovered(deviceInfo); + emit didDiscoverDevice(deviceInfo); } /*! @@ -117,7 +116,7 @@ void BLEScanner::onDiscoveryAgentError(QBluetoothDeviceDiscoveryAgent::Error error) { qDebug() << __FUNCTION__ << error; - emit scanForDevicesError(error); + emit didReceiveScanForDevicesError(error); } /*! @@ -126,14 +125,14 @@ */ void BLEScanner::onScanFinished() { - emit scanFinished(); + emit didFinishScan(); } /*! * \brief BLEScanner::scanForDevices * Tells the discovery agent to start scanning for devices */ -void BLEScanner::scanForDevices() +void BLEScanner::doScanForDevices() { discoveryAgent->start(); } @@ -184,7 +183,7 @@ * The BLE device must be in the correct mode and it * must support indicate / notify for the blood pressure measurement characteristic (0x2A35). */ -void BLEScanner::requestBPMeasurement() +void BLEScanner::doRequestBPMeasurement() { if (omronBloodPressureService == nullptr) { @@ -219,14 +218,14 @@ * Requests blood pressure measurement data * \param serviceState - the new state of the service */ -void BLEScanner::serviceStateChanged(const QLowEnergyService::ServiceState &serviceState) +void BLEScanner::onServiceStateChanged(const QLowEnergyService::ServiceState &serviceState) { switch (serviceState) { case QLowEnergyService::ServiceDiscovered: { - requestBPMeasurement(); + doRequestBPMeasurement(); break; } case QLowEnergyService::InvalidService: @@ -278,7 +277,7 @@ return; } - parseMeasurement(byteArray); + doParseMeasurement(byteArray); } @@ -287,7 +286,7 @@ * Parses the BP and Pulse Rate measurement data * \param byteArray - the data to be parsed */ -void BLEScanner::parseMeasurement(const QByteArray &byteArray) +void BLEScanner::doParseMeasurement(const QByteArray &byteArray) { bp_measurement_t measurement; @@ -328,7 +327,7 @@ qDebug() << "user_id: " << measurement.user_id; qDebug() << "measurement_status: " << measurement.measurement_status; - emit receivedBPMeasurement(measurement); + emit didReceiveBPMeasurement(measurement); } @@ -338,7 +337,7 @@ * \param desc - the descriptor that was written to * \param byteArray - data confirming a descriptor disconnect or connection */ -void BLEScanner::confirmedDescriptorWrite(const QLowEnergyDescriptor &desc, const QByteArray &byteArray) +void BLEScanner::onConfirmedDescriptorWrite(const QLowEnergyDescriptor &desc, const QByteArray &byteArray) { qDebug() << "Confirmed descriptor write: " << byteArray; if (desc.isValid() && desc == desc && byteArray == QByteArray::fromHex("0000")) { @@ -357,7 +356,7 @@ * \param c - the BLE characteristic that was read * \param byteArray - the data read from the BLE characteristic */ -void BLEScanner::serviceCharacteristicsRead(const QLowEnergyCharacteristic &c,const QByteArray &byteArray) +void BLEScanner::onServiceCharacteristicsRead(const QLowEnergyCharacteristic &c,const QByteArray &byteArray) { qDebug() << __FUNCTION__ << c.name() << " data: " << byteArray; @@ -379,16 +378,16 @@ foreach (QLowEnergyService* service, services) { connect(service, SIGNAL(stateChanged(QLowEnergyService::ServiceState)), - this, SLOT(serviceStateChanged(QLowEnergyService::ServiceState))); + this, SLOT(onServiceStateChanged(QLowEnergyService::ServiceState))); connect(service, SIGNAL(characteristicChanged(QLowEnergyCharacteristic, QByteArray)), this, SLOT(onCharacteristicChanged(QLowEnergyCharacteristic,QByteArray))); connect(service, SIGNAL(characteristicRead(QLowEnergyCharacteristic,QByteArray)), - this, SLOT(serviceCharacteristicsRead(QLowEnergyCharacteristic,QByteArray))); + this, SLOT(onServiceCharacteristicsRead(QLowEnergyCharacteristic,QByteArray))); connect(service, SIGNAL(descriptorWritten(QLowEnergyDescriptor, QByteArray)), - this, SLOT(confirmedDescriptorWrite(QLowEnergyDescriptor, QByteArray))); + this, SLOT(onConfirmedDescriptorWrite(QLowEnergyDescriptor, QByteArray))); } } @@ -401,7 +400,6 @@ void BLEScanner::onControllerError(const QLowEnergyController::Error &error) { qDebug() << __FUNCTION__ << "LE controller error: " << error; - } /*! @@ -414,7 +412,6 @@ qDebug() << __FUNCTION__; lowEnergyController->discoverServices(); - } /*! @@ -424,7 +421,6 @@ void BLEScanner::onDeviceDisconnected() { qDebug() << __FUNCTION__; - } /*! @@ -434,7 +430,7 @@ * Connects to the desired device * \param deviceInfo - The QBluetoothDeviceInfo object to connect to */ -void BLEScanner::connectToDevice(const QBluetoothDeviceInfo& deviceInfo) +void BLEScanner::onConnectToDevice(const QBluetoothDeviceInfo& deviceInfo) { lowEnergyController = QLowEnergyController::createCentral(deviceInfo);