add Accept logic

This commit is contained in:
2024-02-27 11:38:23 +03:00
parent 4d92acf15b
commit 9643237465
4 changed files with 29 additions and 16 deletions

View File

@ -72,17 +72,17 @@ void IR_Encoder::sendData(uint16_t addrTo, uint8_t* data, uint8_t len, bool need
rawSend(sendBuffer, packSize);
}
void IR_Encoder::sendAccept(uint16_t addrTo, uint8_t addInfo) {
void IR_Encoder::sendAccept(uint16_t addrTo) {
memset(sendBuffer, 0x00, dataByteSizeMax);
sendBuffer[0] = IR_MSG_ACCEPT << 5;
sendBuffer[0] |= addInfo & IR_MASK_MSG_INFO;
sendBuffer[0] |= msgBytes + addrBytes + crcBytes & IR_MASK_MSG_INFO; // размер пакета
// addr_self
sendBuffer[1] = id >> 8 & 0xFF;
sendBuffer[2] = id & 0xFF;
Serial.print("\nRAW Accept to ");
Serial.println(addrTo);
// Serial.print("\nRAW Accept to ");
// Serial.println(addrTo);
// data crc
@ -92,10 +92,10 @@ void IR_Encoder::sendAccept(uint16_t addrTo, uint8_t addInfo) {
rawSend(sendBuffer, msgBytes + addrBytes + crcBytes);
}
void IR_Encoder::sendRequest(uint16_t addrTo, uint8_t addInfo) {
void IR_Encoder::sendRequest(uint16_t addrTo) {
memset(sendBuffer, 0x00, dataByteSizeMax);
sendBuffer[0] = IR_MSG_REQUEST << 5;
sendBuffer[0] |= addInfo & IR_MASK_MSG_INFO;
sendBuffer[0] |= msgBytes + addrBytes + addrBytes + crcBytes & IR_MASK_MSG_INFO;
// addr_self
sendBuffer[1] = id >> 8 & 0xFF;
@ -127,7 +127,7 @@ void IR_Encoder::_sendBack(bool isAdressed, uint16_t addrTo, uint8_t* data, uint
uint8_t packSize = msgBytes + addrBytes + (isAdressed ? addrBytes : 0) + min(1, len) + crcBytes;
uint8_t msgType =
((isAdressed ? IR_MSG_BACK_TO : IR_MSG_BACK)<<5) | ((packSize) & (IR_MASK_MSG_INFO >> 1));
((isAdressed ? IR_MSG_BACK_TO : IR_MSG_BACK) << 5) | ((packSize) & (IR_MASK_MSG_INFO >> 1));
// формирование массива
// msg_type