mirror of
https://github.com/Serial-Studio/Serial-Studio.git
synced 2025-01-31 17:42:55 +08:00
fix data write to characteristic
This commit is contained in:
parent
598a9ef463
commit
2fbc6f5871
@ -160,25 +160,14 @@ bool IO::Drivers::BluetoothLE::configurationOk() const
|
|||||||
*/
|
*/
|
||||||
quint64 IO::Drivers::BluetoothLE::write(const QByteArray &data)
|
quint64 IO::Drivers::BluetoothLE::write(const QByteArray &data)
|
||||||
{
|
{
|
||||||
if (m_service && m_selectedCharacteristic >= 0 && m_selectedDescriptor >= 0)
|
if (m_service && m_selectedCharacteristic >= 0 )
|
||||||
{
|
{
|
||||||
const auto &characteristic = m_characteristics.at(m_selectedCharacteristic);
|
const auto &characteristic = m_characteristics.at(m_selectedCharacteristic);
|
||||||
if (characteristic.isValid())
|
if (characteristic.isValid())
|
||||||
{
|
{
|
||||||
const auto &descr = m_descriptors.at(m_selectedDescriptor);
|
m_service->writeCharacteristic(characteristic, data, QLowEnergyService::WriteWithResponse);
|
||||||
if (descr.isValid())
|
|
||||||
{
|
|
||||||
m_service->writeDescriptor(descr, data);
|
|
||||||
return data.length();
|
return data.length();
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qWarning() << "Failed to write data to BLE device: invalid descriptor";
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qWarning()
|
qWarning()
|
||||||
@ -188,7 +177,7 @@ quint64 IO::Drivers::BluetoothLE::write(const QByteArray &data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
qWarning() << "Failed to write data to BLE device: ensure that a "
|
qWarning() << "Failed to write data to BLE device: ensure that a "
|
||||||
"characteristic and a descriptor are selected";
|
"characteristic is selected";
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user