Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QLowEnergyService:: writeCharacteristic takes a long time, how can it be shortened?

QLowEnergyService:: writeCharacteristic takes a long time, how can it be shortened?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 142 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jerome522
    wrote on last edited by
    #1

    The following is my code that takes about 100ms or more between qDebug1 and qDebug2. Even if I reduce the amount of data sent, the time spent is not significantly reduced. How should I handle this?

    int CommBluebooth::SendDataEx(const QByteArray i_data)
    {
    int maxBytes = 200;
    int frames = (i_data.count() - 1) / maxBytes + 1;
    for (int i = 0; i < frames; i++)
    {
    if (i_data.isNull() || i_data.isEmpty() || !IsConnect())
    {
    return 0;
    }

        int         sendlen = (i + 1 == frames) ? (i_data.count() -  (i * maxBytes)): maxBytes;
        QByteArray  sendData = i_data.mid(i * maxBytes, sendlen);
        if (m_service != nullptr)
        {
            QString str;
            str += QString("<%1> - ").arg(QTime::currentTime().toString("HH:mm:ss.zzz"));
            qDebug()<<"bluetooth strat sending:"  << str;
            m_service->writeCharacteristic(m_writeCharacteristic, sendData, m_blueboothParam->writeMode);
            QString str2;
            str2 += QString("<%1> - ").arg(QTime::currentTime().toString("HH:mm:ss.zzz"));
            qDebug()<<"Bluetooth transmission completed:"  << str2;
        }
    }
    return i_data.size();
    

    }

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved