[issue #84] Fix and unit test added
This commit is contained in:
@@ -646,6 +646,7 @@ void MqttClient::processMessage(MqttMessage* mesg)
|
||||
if (mqtt_connected() or tcp_client == nullptr)
|
||||
{
|
||||
uint8_t qos = mesg->flags();
|
||||
qos = (qos / 2) & 3;
|
||||
payload = header;
|
||||
mesg->getString(payload, len);
|
||||
Topic published(payload, len);
|
||||
@@ -654,8 +655,19 @@ void MqttClient::processMessage(MqttMessage* mesg)
|
||||
Console << "Received Publish (" << published.str().c_str() << ") size=" << (int)len << endl;
|
||||
#endif
|
||||
// << '(' << string(payload, len).c_str() << ')' << " msglen=" << mesg->length() << endl;
|
||||
if (qos) payload+=2; // ignore packet identifier if any
|
||||
const char* ID; // remove PublishID() to avoid misuse
|
||||
if (qos) {
|
||||
ID = payload;
|
||||
payload+=2; // ignore packet identifier if any
|
||||
}
|
||||
len=mesg->end()-payload;
|
||||
if (qos == 1)
|
||||
{
|
||||
MqttMessage msg(MqttMessage::Type::PubAck);
|
||||
msg.add(ID[0]); // MessageID high
|
||||
msg.add(ID[1]); // MessageID low
|
||||
msg.sendTo(this);
|
||||
}
|
||||
// TODO reset DUP
|
||||
// TODO reset RETAIN
|
||||
|
||||
|
||||
Reference in New Issue
Block a user