mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2025-06-27 20:59:37 +00:00
dataPack changes done
This commit is contained in:
113
IR_Decoder.cpp
113
IR_Decoder.cpp
@ -75,76 +75,57 @@ void IR_Decoder::writeToBuffer(bool bit) {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//const auto testval = bufferBitSizeMax;
|
||||
if ((bufBitPos >= (8 * msgBytes) - syncBits) && !isMsgAvaliable) {
|
||||
switch ((rawBuffer[0] >> 5) & IR_MASK_MSG_TYPE) {
|
||||
case IR_MSG_ACCEPT:
|
||||
if (bufBitPos >= ((msgBytes + addrBytes + crcBytes) * (8 + 3)) - syncBits) {
|
||||
const uint8_t dataSize = msgBytes + addrBytes;
|
||||
isRawAvaliable = true;
|
||||
isMsgAvaliable = crcCheck(dataSize);
|
||||
if (isMsgAvaliable && checkAddr(1, 2)) {
|
||||
gotAccept._set(dataBuffer, msgBytes + addrBytes + crcBytes, crcValue, errorCounter, riseSyncTime);
|
||||
gotAccept._isAvaliable = true;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//const auto testval = bufferBitSizeMax;
|
||||
if ((i_dataBuffer >= (8 * msgBytes)) && !isMsgAvaliable) {
|
||||
switch ((dataBuffer[0] >> 5) & IR_MASK_MSG_TYPE) {
|
||||
case IR_MSG_ACCEPT:
|
||||
if (i_dataBuffer >= ((msgBytes + addrBytes + crcBytes) * bitPerByte)) {
|
||||
const uint8_t dataSize = msgBytes + addrBytes;
|
||||
isRawAvaliable = true;
|
||||
isMsgAvaliable = crcCheck(dataSize);
|
||||
if (isMsgAvaliable && checkAddr(1, 2)) {
|
||||
gotAccept._set(dataBuffer, msgBytes + addrBytes + crcBytes, crcValue, errorCounter, riseSyncTime);
|
||||
gotAccept._isAvaliable = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case IR_MSG_REQUEST:
|
||||
if (bufBitPos >= ((msgBytes + addrBytes + addrBytes + crcBytes) * (8 + 3)) - syncBits) {
|
||||
const uint8_t dataSize = msgBytes + addrBytes + addrBytes;
|
||||
isRawAvaliable = true;
|
||||
isMsgAvaliable = (crcCheck(dataSize));
|
||||
if (isMsgAvaliable && checkAddr(3, 4)) {
|
||||
gotRequest._isAvaliable = true;
|
||||
gotRequest._set(dataBuffer, msgBytes + addrBytes + addrBytes + crcBytes, crcValue, errorCounter, riseSyncTime);
|
||||
}
|
||||
case IR_MSG_REQUEST:
|
||||
if (i_dataBuffer >= ((msgBytes + addrBytes + addrBytes + crcBytes) * bitPerByte)) {
|
||||
const uint8_t dataSize = msgBytes + addrBytes + addrBytes;
|
||||
isRawAvaliable = true;
|
||||
isMsgAvaliable = (crcCheck(dataSize));
|
||||
if (isMsgAvaliable && checkAddr(3, 4)) {
|
||||
gotRequest._isAvaliable = true;
|
||||
gotRequest._set(dataBuffer, msgBytes + addrBytes + addrBytes + crcBytes, crcValue, errorCounter, riseSyncTime);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case IR_MSG_DATA_ACCEPT:
|
||||
case IR_MSG_DATA_NOACCEPT:
|
||||
if (bufBitPos >= ((bitPerByte + syncBits) * ((rawBuffer[0] & IR_MASK_MSG_INFO) + crcBytes)) - syncBits) {
|
||||
const uint8_t dataSize = (rawBuffer[0] & IR_MASK_MSG_INFO);
|
||||
isRawAvaliable = true;
|
||||
isMsgAvaliable = crcCheck(dataSize);
|
||||
if (isMsgAvaliable && checkAddr(3, 4)) {
|
||||
gotData._isAvaliable = true;
|
||||
gotData._set(dataBuffer, (dataSize)+crcBytes, crcValue, errorCounter, riseSyncTime);
|
||||
} else {
|
||||
gotRawData._isAvaliable = true;
|
||||
gotRawData._set(dataBuffer, (dataSize)+crcBytes, crcValue, errorCounter, riseSyncTime);
|
||||
}
|
||||
case IR_MSG_DATA_ACCEPT:
|
||||
case IR_MSG_DATA_NOACCEPT:
|
||||
if (i_dataBuffer >= ((dataBuffer[0] & IR_MASK_MSG_INFO) + crcBytes) * bitPerByte) {
|
||||
// Serial.println("OK");
|
||||
const uint8_t dataSize = (dataBuffer[0] & IR_MASK_MSG_INFO);
|
||||
isRawAvaliable = true;
|
||||
isMsgAvaliable = crcCheck(dataSize);
|
||||
if (isMsgAvaliable && checkAddr(3, 4)) {
|
||||
gotData._isAvaliable = true;
|
||||
gotData._set(dataBuffer, (dataSize)+crcBytes, crcValue, errorCounter, riseSyncTime);
|
||||
} else {
|
||||
gotRawData._isAvaliable = true;
|
||||
gotRawData._set(dataBuffer, (dataSize)+crcBytes, crcValue, errorCounter, riseSyncTime);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}/**/
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}/**/
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
// uint8_t* IR_Decoder::getDataBuffer(bool reset = false) {
|
||||
@ -186,12 +167,6 @@ void IR_Decoder::writeToBuffer(bool bit) {
|
||||
|
||||
bool IR_Decoder::crcCheck(uint8_t len) {
|
||||
bool crcOK = false;
|
||||
// получить буффер, если нет
|
||||
if (!isFilterBufferAvaliable) getDataBuffer();
|
||||
if (dataBuffer == nullptr) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
crcValue = 0;
|
||||
crcValue = (crc8(dataBuffer, 0, len, poly1) << 8) & ~((crc_t)0xFF);
|
||||
|
Reference in New Issue
Block a user