mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-01-26 16:49:11 +03:00
47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
#include "SubAckPacket.hpp"
|
|
|
|
using AsyncMqttClientInternals::SubAckPacket;
|
|
|
|
SubAckPacket::SubAckPacket(ParsingInformation* parsingInformation, OnSubAckInternalCallback callback)
|
|
: _parsingInformation(parsingInformation)
|
|
, _callback(callback)
|
|
, _bytePosition(0)
|
|
, _packetIdMsb(0)
|
|
, _packetId(0) {
|
|
}
|
|
|
|
SubAckPacket::~SubAckPacket() {
|
|
}
|
|
|
|
void SubAckPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) {
|
|
char currentByte = data[(*currentBytePosition)++];
|
|
if (_bytePosition++ == 0) {
|
|
_packetIdMsb = currentByte;
|
|
} else {
|
|
_packetId = currentByte | _packetIdMsb << 8;
|
|
_parsingInformation->bufferState = BufferState::PAYLOAD;
|
|
}
|
|
}
|
|
|
|
void SubAckPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) {
|
|
char status = data[(*currentBytePosition)++];
|
|
|
|
/* switch (status) {
|
|
case 0:
|
|
Serial.println("Success QoS 0");
|
|
break;
|
|
case 1:
|
|
Serial.println("Success QoS 1");
|
|
break;
|
|
case 2:
|
|
Serial.println("Success QoS 2");
|
|
break;
|
|
case 0x80:
|
|
Serial.println("Failure");
|
|
break;
|
|
} */
|
|
|
|
_parsingInformation->bufferState = BufferState::NONE;
|
|
_callback(_packetId, status);
|
|
}
|