Skip to content

Commit

Permalink
Extra debug output.
Browse files Browse the repository at this point in the history
  • Loading branch information
arobenko committed May 28, 2024
1 parent 645289a commit 3124c40
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Mqtt5ClientFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,9 @@ QList<cc_tools_qt::DataInfoPtr> Mqtt5ClientFilter::recvDataImpl(cc_tools_qt::Dat
m_recvDataPtr = std::move(dataPtr);
m_inData.insert(m_inData.end(), m_recvDataPtr->m_data.begin(), m_recvDataPtr->m_data.end());
auto consumed = ::cc_mqtt5_client_process_data(m_client.get(), m_inData.data(), static_cast<unsigned>(m_inData.size()));
if (3 <= getDebugOutputLevel()) {
std::cout << '[' << currTimestamp() << "] (" << debugNameImpl() << "): consumed bytes: " << consumed << "/" << m_inData.size() << std::endl;
}
assert(consumed <= m_inData.size());
m_inData.erase(m_inData.begin(), m_inData.begin() + consumed);
m_recvDataPtr.reset();
Expand Down Expand Up @@ -876,6 +879,10 @@ void Mqtt5ClientFilter::doTick()

void Mqtt5ClientFilter::socketConnected()
{
if (2 <= getDebugOutputLevel()) {
std::cout << '[' << currTimestamp() << "] (" << debugNameImpl() << "): socket connected report" << std::endl;
}

auto basicConfig = CC_Mqtt5ConnectBasicConfig();
::cc_mqtt5_client_connect_init_config_basic(&basicConfig);

Expand Down Expand Up @@ -925,6 +932,10 @@ void Mqtt5ClientFilter::socketConnected()

void Mqtt5ClientFilter::socketDisconnected()
{
if (2 <= getDebugOutputLevel()) {
std::cout << '[' << currTimestamp() << "] (" << debugNameImpl() << "): socket disconnected report" << std::endl;
}

::cc_mqtt5_client_notify_network_disconnected(m_client.get());
}

Expand All @@ -950,6 +961,10 @@ void Mqtt5ClientFilter::registerTopicAliases()

void Mqtt5ClientFilter::sendDataInternal(const unsigned char* buf, unsigned bufLen)
{
if (3 <= getDebugOutputLevel()) {
std::cout << '[' << currTimestamp() << "] (" << debugNameImpl() << "): sending " << bufLen << " bytes" << std::endl;
}

auto dataInfo = cc_tools_qt::makeDataInfoTimed();
dataInfo->m_data.assign(buf, buf + bufLen);
if (!m_sendDataPtr) {
Expand All @@ -971,6 +986,10 @@ void Mqtt5ClientFilter::brokerDisconnectedInternal()

void Mqtt5ClientFilter::messageReceivedInternal(const CC_Mqtt5MessageInfo& info)
{
if (2 <= getDebugOutputLevel()) {
std::cout << '[' << currTimestamp() << "] (" << debugNameImpl() << "): app message received: " << info.m_topic << std::endl;
}

assert(m_recvDataPtr);
auto dataInfo = cc_tools_qt::makeDataInfoTimed();
if (info.m_dataLen > 0U) {
Expand Down Expand Up @@ -1024,6 +1043,10 @@ void Mqtt5ClientFilter::messageReceivedInternal(const CC_Mqtt5MessageInfo& info)

void Mqtt5ClientFilter::nextTickProgramInternal(unsigned ms)
{
if (3 <= getDebugOutputLevel()) {
std::cout << '[' << currTimestamp() << "] (" << debugNameImpl() << "): tick request: " << ms << std::endl;
}

assert(!m_timer.isActive());
m_tickMs = ms;
m_tickMeasureTs = QDateTime::currentMSecsSinceEpoch();
Expand All @@ -1040,6 +1063,10 @@ unsigned Mqtt5ClientFilter::cancelTickProgramInternal()
auto diff = now - m_tickMeasureTs;
assert(diff < std::numeric_limits<unsigned>::max());
m_tickMeasureTs = 0U;

if (3 <= getDebugOutputLevel()) {
std::cout << '[' << currTimestamp() << "] (" << debugNameImpl() << "): cancel tick: " << diff << std::endl;
}
return static_cast<unsigned>(diff);
}

Expand Down

0 comments on commit 3124c40

Please sign in to comment.