From 8466d49a3a340334645f01f6b1bfb821276d247b Mon Sep 17 00:00:00 2001 From: Dennis Date: Tue, 14 Mar 2017 20:52:16 -0400 Subject: [PATCH] Fixed packet errors when trying to unbind when in bind mode This use case didn't really make any sense, but it should not cause packet errors, so fixed it. --- Multiprotocol/CABELL_nrf224l01.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Multiprotocol/CABELL_nrf224l01.ino b/Multiprotocol/CABELL_nrf224l01.ino index 9e29ae6..a1f4027 100644 --- a/Multiprotocol/CABELL_nrf224l01.ino +++ b/Multiprotocol/CABELL_nrf224l01.ino @@ -106,11 +106,11 @@ static void __attribute__((unused)) CABELL_send_packet(uint8_t bindMode) uint8_t packetSize = sizeof(TxPacket) - ((((channelReduction - (channelReduction%2))/ 2)) * 3); // reduce 3 bytes per 2 channels, but not last channel if it is odd uint8_t maxPayloadValueIndex = sizeof(TxPacket.payloadValue) - (sizeof(TxPacket) - packetSize); - if (sub_protocol == CABELL_UNBIND) { + if ((sub_protocol == CABELL_UNBIND) && !bindMode) { TxPacket.RxMode = CABELL_RxTxPacket_t::RxMode_t::unBind; - TxPacket.option = option & (~CABELL_OPTION_MASK_CHANNEL_REDUCTION); //remove channel reduction if in unBind mode + TxPacket.option = option; } else { - if (sub_protocol == CABELL_SET_FAIL_SAFE) { + if (sub_protocol == CABELL_SET_FAIL_SAFE && !bindMode) { TxPacket.RxMode = CABELL_RxTxPacket_t::RxMode_t::setFailSafe; } else { TxPacket.RxMode = (bindMode) ? CABELL_RxTxPacket_t::RxMode_t::bind : CABELL_RxTxPacket_t::RxMode_t::normal;