Skip to content

Commit

Permalink
Enable custom address and radio channel
Browse files Browse the repository at this point in the history
  • Loading branch information
matejkarasek committed Oct 4, 2023
1 parent 3433dd2 commit 7e671b9
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 33 deletions.
56 changes: 31 additions & 25 deletions Multiprotocol/CFlie_nrf24l01.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Multiprotocol/Multi_Protos.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Multiprotocol/Multiprotocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ enum FX
};
enum CFLIE
{
CFLIE_AUTO = 0,
CFLIE_DEFAULT = 0,
CFLIE_2Mbps = 1,
CFLIE_1Mbps = 2,
CFLIE_250kbps = 3,
Expand Down
12 changes: 6 additions & 6 deletions Multiprotocol/_Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7e671b9

Please sign in to comment.