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
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//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;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case IR_MSG_REQUEST:
|
case IR_MSG_REQUEST:
|
||||||
if (bufBitPos >= ((msgBytes + addrBytes + addrBytes + crcBytes) * (8 + 3)) - syncBits) {
|
if (i_dataBuffer >= ((msgBytes + addrBytes + addrBytes + crcBytes) * bitPerByte)) {
|
||||||
const uint8_t dataSize = msgBytes + addrBytes + addrBytes;
|
const uint8_t dataSize = msgBytes + addrBytes + addrBytes;
|
||||||
isRawAvaliable = true;
|
isRawAvaliable = true;
|
||||||
isMsgAvaliable = (crcCheck(dataSize));
|
isMsgAvaliable = (crcCheck(dataSize));
|
||||||
if (isMsgAvaliable && checkAddr(3, 4)) {
|
if (isMsgAvaliable && checkAddr(3, 4)) {
|
||||||
gotRequest._isAvaliable = true;
|
gotRequest._isAvaliable = true;
|
||||||
gotRequest._set(dataBuffer, msgBytes + addrBytes + addrBytes + crcBytes, crcValue, errorCounter, riseSyncTime);
|
gotRequest._set(dataBuffer, msgBytes + addrBytes + addrBytes + crcBytes, crcValue, errorCounter, riseSyncTime);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
case IR_MSG_DATA_ACCEPT:
|
case IR_MSG_DATA_ACCEPT:
|
||||||
case IR_MSG_DATA_NOACCEPT:
|
case IR_MSG_DATA_NOACCEPT:
|
||||||
if (bufBitPos >= ((bitPerByte + syncBits) * ((rawBuffer[0] & IR_MASK_MSG_INFO) + crcBytes)) - syncBits) {
|
if (i_dataBuffer >= ((dataBuffer[0] & IR_MASK_MSG_INFO) + crcBytes) * bitPerByte) {
|
||||||
const uint8_t dataSize = (rawBuffer[0] & IR_MASK_MSG_INFO);
|
// Serial.println("OK");
|
||||||
isRawAvaliable = true;
|
const uint8_t dataSize = (dataBuffer[0] & IR_MASK_MSG_INFO);
|
||||||
isMsgAvaliable = crcCheck(dataSize);
|
isRawAvaliable = true;
|
||||||
if (isMsgAvaliable && checkAddr(3, 4)) {
|
isMsgAvaliable = crcCheck(dataSize);
|
||||||
gotData._isAvaliable = true;
|
if (isMsgAvaliable && checkAddr(3, 4)) {
|
||||||
gotData._set(dataBuffer, (dataSize)+crcBytes, crcValue, errorCounter, riseSyncTime);
|
gotData._isAvaliable = true;
|
||||||
} else {
|
gotData._set(dataBuffer, (dataSize)+crcBytes, crcValue, errorCounter, riseSyncTime);
|
||||||
gotRawData._isAvaliable = true;
|
} else {
|
||||||
gotRawData._set(dataBuffer, (dataSize)+crcBytes, crcValue, errorCounter, riseSyncTime);
|
gotRawData._isAvaliable = true;
|
||||||
}
|
gotRawData._set(dataBuffer, (dataSize)+crcBytes, crcValue, errorCounter, riseSyncTime);
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}/**/
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}/**/
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
}
|
}
|
||||||
|
|
||||||
// uint8_t* IR_Decoder::getDataBuffer(bool reset = false) {
|
// 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 IR_Decoder::crcCheck(uint8_t len) {
|
||||||
bool crcOK = false;
|
bool crcOK = false;
|
||||||
// получить буффер, если нет
|
|
||||||
if (!isFilterBufferAvaliable) getDataBuffer();
|
|
||||||
if (dataBuffer == nullptr) {
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
crcValue = 0;
|
crcValue = 0;
|
||||||
crcValue = (crc8(dataBuffer, 0, len, poly1) << 8) & ~((crc_t)0xFF);
|
crcValue = (crc8(dataBuffer, 0, len, poly1) << 8) & ~((crc_t)0xFF);
|
||||||
|
Reference in New Issue
Block a user