mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2025-05-04 07:10:16 +00:00
fix Accept
This commit is contained in:
parent
37f49e0d82
commit
686f2a7ffe
@ -68,7 +68,7 @@ void IR_Encoder::sendData(uint16_t addrTo, uint8_t* data, uint8_t len, bool need
|
|||||||
rawSend(sendBuffer, packSize);
|
rawSend(sendBuffer, packSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IR_Encoder::sendACK(uint16_t addrTo, uint8_t addInfo, bool forAll = false) {
|
void IR_Encoder::sendAccept(uint16_t addrTo, uint8_t addInfo, bool forAll = false) {
|
||||||
memset(sendBuffer, 0x00, dataByteSizeMax);
|
memset(sendBuffer, 0x00, dataByteSizeMax);
|
||||||
sendBuffer[0] = IR_MSG_ACCEPT << 5;
|
sendBuffer[0] = IR_MSG_ACCEPT << 5;
|
||||||
sendBuffer[0] |= addInfo & IR_MASK_MSG_INFO;
|
sendBuffer[0] |= addInfo & IR_MASK_MSG_INFO;
|
||||||
@ -106,22 +106,22 @@ void IR_Encoder::sendRequest(uint16_t addrTo, uint8_t addInfo) {
|
|||||||
rawSend(sendBuffer, msgBytes + addrBytes + addrBytes + crcBytes);
|
rawSend(sendBuffer, msgBytes + addrBytes + addrBytes + crcBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IR_Encoder::sendBack(uint8_t* data = nullptr, uint8_t len = 0){
|
void IR_Encoder::sendBack(uint8_t* data = nullptr, uint8_t len = 0) {
|
||||||
_sendBack(false, 0, data, len);
|
_sendBack(false, 0, data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IR_Encoder::sendBackTo(uint16_t addrTo, uint8_t* data = nullptr, uint8_t len = 0){
|
void IR_Encoder::sendBackTo(uint16_t addrTo, uint8_t* data = nullptr, uint8_t len = 0) {
|
||||||
_sendBack(true, addrTo, data, len);
|
_sendBack(true, addrTo, data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IR_Encoder::_sendBack(bool isAdressed ,uint16_t addrTo,uint8_t* data, uint8_t len){
|
void IR_Encoder::_sendBack(bool isAdressed, uint16_t addrTo, uint8_t* data, uint8_t len) {
|
||||||
if (len > bytePerPack) { return; }
|
if (len > bytePerPack) { return; }
|
||||||
memset(sendBuffer, 0x00, dataByteSizeMax);
|
memset(sendBuffer, 0x00, dataByteSizeMax);
|
||||||
constexpr uint8_t dataStart = msgBytes + addrBytes;
|
uint8_t dataStart = msgBytes + addrBytes + (isAdressed ? addrBytes : 0);
|
||||||
|
|
||||||
uint8_t packSize = msgBytes + addrBytes + len + crcBytes;
|
uint8_t packSize = msgBytes + addrBytes + (isAdressed ? addrBytes : 0) + min(1, len) + crcBytes;
|
||||||
uint8_t msgType =
|
uint8_t msgType =
|
||||||
(IR_MSG_BACK << 5) | (isAdressed << 4U) | ((packSize - crcBytes) & (IR_MASK_MSG_INFO>>1));
|
(IR_MSG_BACK << 5) | (isAdressed << 4U) | ((packSize - crcBytes) & (IR_MASK_MSG_INFO >> 1));
|
||||||
|
|
||||||
// формирование массива
|
// формирование массива
|
||||||
// msg_type
|
// msg_type
|
||||||
|
@ -45,7 +45,7 @@ public:
|
|||||||
void IR_Encoder::setBlindDecoders(IR_Decoder* decoders [], uint8_t count);
|
void IR_Encoder::setBlindDecoders(IR_Decoder* decoders [], uint8_t count);
|
||||||
void rawSend(uint8_t* ptr, uint8_t len);
|
void rawSend(uint8_t* ptr, uint8_t len);
|
||||||
void sendData(uint16_t addrTo, uint8_t* data, uint8_t len, bool needAccept = false);
|
void sendData(uint16_t addrTo, uint8_t* data, uint8_t len, bool needAccept = false);
|
||||||
void sendACK(uint16_t addrTo, uint8_t addInfo = 0, bool forAll = false);
|
void sendAccept(uint16_t addrTo, uint8_t addInfo = 0, bool forAll = false);
|
||||||
void sendRequest(uint16_t addrTo, uint8_t addInfo = 0);
|
void sendRequest(uint16_t addrTo, uint8_t addInfo = 0);
|
||||||
void sendBack(uint8_t* data = nullptr, uint8_t len = 0);
|
void sendBack(uint8_t* data = nullptr, uint8_t len = 0);
|
||||||
void sendBackTo(uint16_t addrTo, uint8_t* data = nullptr, uint8_t len = 0);
|
void sendBackTo(uint16_t addrTo, uint8_t* data = nullptr, uint8_t len = 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user