* @brief Writes data to the Bluetooth LE device. */
| 570 | * @brief Writes data to the Bluetooth LE device. |
| 571 | */ |
| 572 | qint64 IO::Drivers::BluetoothLE::write(const QByteArray& data) |
| 573 | { |
| 574 | if (m_service && m_selectedCharacteristic >= 0 |
| 575 | && m_selectedCharacteristic < m_characteristics.count()) { |
| 576 | const auto& characteristic = m_characteristics.at(m_selectedCharacteristic); |
| 577 | if (characteristic.isValid()) { |
| 578 | m_service->writeCharacteristic(characteristic, data, QLowEnergyService::WriteWithResponse); |
| 579 | return data.length(); |
| 580 | } |
| 581 | |
| 582 | else { |
| 583 | qWarning() << "Failed to write to BLE device: invalid characteristic"; |
| 584 | return 0; |
| 585 | } |
| 586 | } |
| 587 | |
| 588 | qWarning() << "Failed to write data to BLE device: ensure that a characteristic is selected"; |
| 589 | return 0; |
| 590 | } |
| 591 | |
| 592 | /** |
| 593 | * @brief Writes to a UUID-resolved characteristic for split read/write devices. |
nothing calls this directly
no test coverage detected