diff --git a/IR_Encoder.cpp b/IR_Encoder.cpp index d2a9582..f8ab807 100644 --- a/IR_Encoder.cpp +++ b/IR_Encoder.cpp @@ -139,6 +139,7 @@ void IR_Encoder::sendDataFULL(uint16_t addrFrom, uint16_t addrTo, uint8_t *data, { if (len > bytePerPack) { + Serial.println("IR Pack to big"); return; } constexpr uint8_t dataStart = msgBytes + addrBytes + addrBytes; @@ -168,6 +169,19 @@ void IR_Encoder::sendDataFULL(uint16_t addrFrom, uint16_t addrTo, uint8_t *data, sendBuffer[packSize - crcBytes] = crc8(sendBuffer, 0, packSize - crcBytes, poly1) & 0xFF; sendBuffer[packSize - crcBytes + 1] = crc8(sendBuffer, 0, packSize - crcBytes + 1, poly2) & 0xFF; + //* вывод итогового буфера + // Serial.print("IR SEND [len="); + // Serial.print(packSize); + // Serial.print("] : "); + // for (uint8_t i = 0; i < packSize; i++) + // { + // if (sendBuffer[i] < 0x10) + // Serial.print('0'); + // Serial.print(sendBuffer[i], HEX); + // Serial.print(' '); + // } + // Serial.println(); + // if (decPair != nullptr) { // decPair->isWaitingAccept = ((msgType >> 5) & IR_MASK_MSG_TYPE == IR_MSG_DATA_ACCEPT); // if (decPair->isWaitingAccept) { @@ -179,6 +193,7 @@ void IR_Encoder::sendDataFULL(uint16_t addrFrom, uint16_t addrTo, uint8_t *data, rawSend(sendBuffer, packSize); } + void IR_Encoder::sendAccept(uint16_t addrTo, uint8_t customByte) { constexpr uint8_t packsize = msgBytes + addrBytes + 1U + crcBytes; diff --git a/IR_config.h b/IR_config.h index 80893e4..4149f4a 100644 --- a/IR_config.h +++ b/IR_config.h @@ -52,7 +52,7 @@ msg type:                                         // | 01234567 |                                         //  ----------                                         // | xxx..... | = тип сообщения -                                        // | ...xxxxx | = длина (максимум 31 бита) +                                        // | ...xxxxx | = длина (максимум 31 бита) - не больше 24 байт на тело пакета                                         //  ---------- */ #define IR_MSG_BACK 0U // | 000...... | = Задний сигнал машинки #define IR_MSG_ACCEPT 1U // | 001..... | = подтверждение @@ -116,7 +116,7 @@ msg type: typedef uint16_t crc_t; // #define BRUTEFORCE_CHECK // Перепроверяет пакет на 1 битные ошибки //TODO: зависает -#define bytePerPack 16 // колличество байтов в пакете +#define bytePerPack (31) // колличество байтов в пакете #ifndef freeFrec #define freeFrec false #endif