Skip to content

Commit af8cd3f

Browse files
authored
Merge pull request #923 from deXol/develop
[BLE] Resend last message if the response only contains 0xFF data
2 parents fb00b9c + eaab433 commit af8cd3f

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/MPDevice.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,15 @@ void MPDevice::newDataRead(const QByteArray &data)
243243
bool isFirstBlePacket = isBLE() && bleImpl->isFirstPacket(data);
244244
if (isBLE())
245245
{
246+
auto isFFCondition = [](char c) { return c == static_cast<char>(0xFF);};
247+
if (std::all_of(data.begin(), data.end(), isFFCondition))
248+
{
249+
qCritical() << "Only 0xFF received as response, resend last message.";
250+
// Flip message bit and resend the last message
251+
bleImpl->flipMessageBit(commandQueue.head().data);
252+
sendDataDequeue();
253+
return;
254+
}
246255
isDebugStartMsg = isFirstBlePacket && pMesProt->getCommand(data) == MPCmd::DEBUG;
247256
}
248257
else

0 commit comments

Comments
 (0)