MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / write

Method write

app/src/IO/Drivers/BluetoothLE.cpp:572–590  ·  view source on GitHub ↗

* @brief Writes data to the Bluetooth LE device. */

Source from the content-addressed store, hash-verified

570 * @brief Writes data to the Bluetooth LE device.
571 */
572qint64 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.

Callers

nothing calls this directly

Calls 4

lengthMethod · 0.80
countMethod · 0.45
isValidMethod · 0.45
writeCharacteristicMethod · 0.45

Tested by

no test coverage detected