Skip to content

Commit

Permalink
Merge pull request #923 from deXol/develop
Browse files Browse the repository at this point in the history
[BLE] Resend last message if the response only contains 0xFF data
  • Loading branch information
limpkin authored Oct 5, 2021
2 parents fb00b9c + eaab433 commit af8cd3f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/MPDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,15 @@ void MPDevice::newDataRead(const QByteArray &data)
bool isFirstBlePacket = isBLE() && bleImpl->isFirstPacket(data);
if (isBLE())
{
auto isFFCondition = [](char c) { return c == static_cast<char>(0xFF);};
if (std::all_of(data.begin(), data.end(), isFFCondition))
{
qCritical() << "Only 0xFF received as response, resend last message.";
// Flip message bit and resend the last message
bleImpl->flipMessageBit(commandQueue.head().data);
sendDataDequeue();
return;
}
isDebugStartMsg = isFirstBlePacket && pMesProt->getCommand(data) == MPCmd::DEBUG;
}
else
Expand Down

0 comments on commit af8cd3f

Please sign in to comment.