This commit is contained in:
2025-08-22 15:33:19 +03:00
parent bc9563fbb5
commit dec8467280
2 changed files with 17 additions and 2 deletions

View File

@ -139,6 +139,7 @@ void IR_Encoder::sendDataFULL(uint16_t addrFrom, uint16_t addrTo, uint8_t *data,
{ {
if (len > bytePerPack) if (len > bytePerPack)
{ {
Serial.println("IR Pack to big");
return; return;
} }
constexpr uint8_t dataStart = msgBytes + addrBytes + addrBytes; 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] = crc8(sendBuffer, 0, packSize - crcBytes, poly1) & 0xFF;
sendBuffer[packSize - crcBytes + 1] = crc8(sendBuffer, 0, packSize - crcBytes + 1, poly2) & 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) { // if (decPair != nullptr) {
// decPair->isWaitingAccept = ((msgType >> 5) & IR_MASK_MSG_TYPE == IR_MSG_DATA_ACCEPT); // decPair->isWaitingAccept = ((msgType >> 5) & IR_MASK_MSG_TYPE == IR_MSG_DATA_ACCEPT);
// if (decPair->isWaitingAccept) { // if (decPair->isWaitingAccept) {
@ -179,6 +193,7 @@ void IR_Encoder::sendDataFULL(uint16_t addrFrom, uint16_t addrTo, uint8_t *data,
rawSend(sendBuffer, packSize); rawSend(sendBuffer, packSize);
} }
void IR_Encoder::sendAccept(uint16_t addrTo, uint8_t customByte) void IR_Encoder::sendAccept(uint16_t addrTo, uint8_t customByte)
{ {
constexpr uint8_t packsize = msgBytes + addrBytes + 1U + crcBytes; constexpr uint8_t packsize = msgBytes + addrBytes + 1U + crcBytes;

View File

@ -52,7 +52,7 @@ msg type:
                                        // | 01234567 |                                         // | 01234567 |
                                        //  ----------                                         //  ----------
                                        // | xxx..... | = тип сообщения                                         // | xxx..... | = тип сообщения
                                        // | ...xxxxx | = длина (максимум 31 бита)                                         // | ...xxxxx | = длина (максимум 31 бита) - не больше 24 байт на тело пакета
                                        //  ---------- */                                         //  ---------- */
#define IR_MSG_BACK 0U // | 000...... | = Задний сигнал машинки #define IR_MSG_BACK 0U // | 000...... | = Задний сигнал машинки
#define IR_MSG_ACCEPT 1U // | 001..... | = подтверждение #define IR_MSG_ACCEPT 1U // | 001..... | = подтверждение
@ -116,7 +116,7 @@ msg type:
typedef uint16_t crc_t; typedef uint16_t crc_t;
// #define BRUTEFORCE_CHECK // Перепроверяет пакет на 1 битные ошибки //TODO: зависает // #define BRUTEFORCE_CHECK // Перепроверяет пакет на 1 битные ошибки //TODO: зависает
#define bytePerPack 16 // колличество байтов в пакете #define bytePerPack (31) // колличество байтов в пакете
#ifndef freeFrec #ifndef freeFrec
#define freeFrec false #define freeFrec false
#endif #endif