From 7e671b98dcdde244f81ddc9d795985caaa6a22e5 Mon Sep 17 00:00:00 2001 From: Matej Karasek Date: Wed, 4 Oct 2023 13:11:12 +0200 Subject: [PATCH] Enable custom address and radio channel --- Multiprotocol/CFlie_nrf24l01.ino | 56 ++++++++++++++++++-------------- Multiprotocol/Multi_Protos.ino | 2 +- Multiprotocol/Multiprotocol.h | 2 +- Multiprotocol/_Config.h | 12 +++---- 4 files changed, 39 insertions(+), 33 deletions(-) diff --git a/Multiprotocol/CFlie_nrf24l01.ino b/Multiprotocol/CFlie_nrf24l01.ino index 40f7ab1ae..c13b0d682 100644 --- a/Multiprotocol/CFlie_nrf24l01.ino +++ b/Multiprotocol/CFlie_nrf24l01.ino @@ -233,25 +233,25 @@ static void send_search_packet() NRF24L01_WriteReg(NRF24L01_07_STATUS, (BV(NRF24L01_07_TX_DS) | BV(NRF24L01_07_MAX_RT))); NRF24L01_FlushTx(); - if (sub_protocol == CFLIE_AUTO) - { - if (rf_ch_num++ > 125) - { - rf_ch_num = 0; - switch(data_rate) - { - case NRF24L01_BR_250K: - data_rate = NRF24L01_BR_1M; - break; - case NRF24L01_BR_1M: - data_rate = NRF24L01_BR_2M; - break; - case NRF24L01_BR_2M: - data_rate = NRF24L01_BR_250K; - break; - } - } - } + // if (sub_protocol == CFLIE_AUTO) + // { + // if (rf_ch_num++ > 125) + // { + // rf_ch_num = 0; + // switch(data_rate) + // { + // case NRF24L01_BR_250K: + // data_rate = NRF24L01_BR_1M; + // break; + // case NRF24L01_BR_1M: + // data_rate = NRF24L01_BR_2M; + // break; + // case NRF24L01_BR_2M: + // data_rate = NRF24L01_BR_250K; + // break; + // } + // } + // } set_rate_channel(data_rate, rf_ch_num); NRF24L01_WritePayload(buf, sizeof(buf)); @@ -789,25 +789,31 @@ static uint8_t CFLIE_initialize_rx_tx_addr() rx_tx_addr[0] = rx_tx_addr[1] = rx_tx_addr[2] = - rx_tx_addr[3] = - rx_tx_addr[4] = 0xE7; // CFlie uses fixed address - + rx_tx_addr[3] = 0xE7; + + unsigned x10 = (RX_num / 10U) % 10; + unsigned x1 = RX_num - x10*10; + switch (sub_protocol) { case CFLIE_2Mbps: data_rate = NRF24L01_BR_2M; - rf_ch_num = option; + rf_ch_num = option; // "RF channel" in the transmitter <0, 125> + rx_tx_addr[4] = x10*16 + x1; // "Receiver" in the transmitter <0, 63> break; case CFLIE_1Mbps: data_rate = NRF24L01_BR_1M; - rf_ch_num = option; + rf_ch_num = option; // "RF channel" in the transmitter <0, 125> + rx_tx_addr[4] = x10*16 + x1; // "Receiver" in the transmitter <0, 63> break; case CFLIE_250kbps: data_rate = NRF24L01_BR_250K; - rf_ch_num = option; + rf_ch_num = option; // "RF channel" in the transmitter <0, 125> + rx_tx_addr[4] = x10*16 + x1; // "Receiver" in the transmitter <0, 63> break; default: data_rate = NRF24L01_BR_2M; rf_ch_num = 80; + rx_tx_addr[4] = 0xE7; // CFlie uses fixed address } return CFLIE_INIT_SEARCH; diff --git a/Multiprotocol/Multi_Protos.ino b/Multiprotocol/Multi_Protos.ino index fc23ae991..3ab3cc54d 100644 --- a/Multiprotocol/Multi_Protos.ino +++ b/Multiprotocol/Multi_Protos.ino @@ -174,7 +174,7 @@ const char STR_SUBTYPE_MOULKG[] = "\x06""Analog""Digit\0"; const char STR_SUBTYPE_KF606[] = "\x06""KF606\0""MIG320""ZCZ50\0"; const char STR_SUBTYPE_E129[] = "\x04""E129""C186"; const char STR_SUBTYPE_FX[] = "\x04""816\0""620\0""9630"; -const char STR_SUBTYPE_CFLIE[] = "\x07""Auto\0 ""2Mbps\0 ""1Mbps\0 ""250kbps"; +const char STR_SUBTYPE_CFLIE[] = "\x07""Default\0 ""2Mbps\0 ""1Mbps\0 ""250kbps"; #define NO_SUBTYPE nullptr #ifdef SEND_CPPM diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index 920d7926c..b20dada94 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -465,7 +465,7 @@ enum FX }; enum CFLIE { - CFLIE_AUTO = 0, + CFLIE_DEFAULT = 0, CFLIE_2Mbps = 1, CFLIE_1Mbps = 2, CFLIE_250kbps = 3, diff --git a/Multiprotocol/_Config.h b/Multiprotocol/_Config.h index 98181c044..296ed3471 100644 --- a/Multiprotocol/_Config.h +++ b/Multiprotocol/_Config.h @@ -230,9 +230,9 @@ #define ESKY150_NRF24L01_INO #define FQ777_NRF24L01_INO #define FX_NRF24L01_INO -#define FY326_NRF24L01_INO -#define GW008_NRF24L01_INO -#define HISKY_NRF24L01_INO +//#define FY326_NRF24L01_INO +//#define GW008_NRF24L01_INO +//#define HISKY_NRF24L01_INO #define HONTAI_NRF24L01_INO #define H8_3D_NRF24L01_INO #define JJRC345_NRF24L01_INO @@ -576,10 +576,10 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= { CABELL_SET_FAIL_SAFE CABELL_UNBIND PROTO_CFLIE - CFLIE_AUTO - CFLIE_2Mbps + CFLIE_DEFAULT + CFLIE_2Mbps CFLIE_1Mbps - CFLIE_250kbps + CFLIE_250kbps PROTO_CG023 CG023 YD829