From 75f79095ae0892430f464bfb0dc64438ff27de27 Mon Sep 17 00:00:00 2001 From: pascallanger Date: Wed, 29 Jan 2025 09:42:16 +0100 Subject: [PATCH] JIABAILE RX ID in EEPROM Not an autobind protocol anymore. --- Multiprotocol/JIABAILE_nrf24l01.ino | 79 +++++++++++++++++++++-------- Multiprotocol/Multiprotocol.h | 3 +- Protocols_Details.md | 9 +++- 3 files changed, 68 insertions(+), 23 deletions(-) diff --git a/Multiprotocol/JIABAILE_nrf24l01.ino b/Multiprotocol/JIABAILE_nrf24l01.ino index 26c96df..54ba76d 100644 --- a/Multiprotocol/JIABAILE_nrf24l01.ino +++ b/Multiprotocol/JIABAILE_nrf24l01.ino @@ -23,12 +23,13 @@ Multiprotocol is distributed in the hope that it will be useful, #define JIABAILE_RF_NUM_CHANNELS 3 #define JIABAILE_BIND_PACKET_PERIOD 12700 #define JIABAILE_PACKET_PERIOD 2408 -#define JIABAILE_BIND_COUNT 2000 +#define JIABAILE_BIND_COUNT 160 //2 sec #define JIABAILE_WRITE_TIME 1000 enum { JIABAILE_BIND=0, JIABAILE_RX, + JIABAILE_PREP_DATA, JIABAILE_DATA, }; @@ -70,6 +71,15 @@ static void __attribute__((unused)) JIABAILE_send_packet() if(!CH5_SW && Channel_data[CH5] > CHANNEL_MIN_COMMAND) packet[3] |= 0x10; //Mid speed } + else + { + bind_counter--; + if(!bind_counter) + { + BIND_DONE; + phase = JIABAILE_PREP_DATA; + } + } packet[7] = 0x55 + hopping_frequency[hopping_frequency_no]; for(uint8_t i=0;i4?30:8) + sum; - if(sum==4 || sum ==7) - hopping_frequency[0]++; - hopping_frequency[1] = 40 + sum; - if((sum & 0x06) == 0x06) - hopping_frequency[1] += 21; - hopping_frequency[2] = 70 + sum; + //Write the RXID #ifdef DEBUG_SERIAL - debug("RF"); + debug("RXID "); for(uint8_t i=0; i < 3; i++) - debug(" %d", hopping_frequency[i]); + debug(" %02X", packet_in[3+i]); debugln(); #endif + addr=JIABAILE_EEPROM_OFFSET+RX_num*3; + for(uint8_t i=0;i<3;i++) + eeprom_write_byte((EE_ADDR)(addr+i),packet_in[3+i]); //Switch to normal mode BIND_DONE; - phase = JIABAILE_DATA; + phase = JIABAILE_PREP_DATA; } #ifdef DEBUG_SERIAL else @@ -172,7 +177,6 @@ uint16_t JIABAILE_callback() } XN297_SetTxRxMode(TXRX_OFF); JIABAILE_send_packet(); - phase++; return JIABAILE_WRITE_TIME; case JIABAILE_RX: //Wait for the packet transmission to finish @@ -182,6 +186,34 @@ uint16_t JIABAILE_callback() XN297_SetTxRxMode(RX_EN); phase = JIABAILE_BIND; return JIABAILE_BIND_PACKET_PERIOD - JIABAILE_WRITE_TIME; + case JIABAILE_PREP_DATA: + //Read the RXID + addr=JIABAILE_EEPROM_OFFSET+RX_num*3; + for(uint8_t i=0;i<3;i++) + rx_id[i+1] = eeprom_read_byte((EE_ADDR)(addr+i)); + #ifdef DEBUG_SERIAL + debug("RXID "); + for(uint8_t i=0; i < 3; i++) + debug(" %02X", rx_id[i+1]); + #endif + XN297_SetTxRxMode(TXRX_OFF); + XN297_SetTXAddr(rx_id, 5); + //Set the normal frequencies + sum=rx_id[1]&0x07; + hopping_frequency[0] = (sum>4?30:8) + sum; + if(sum==4 || sum ==7) + hopping_frequency[0]++; + hopping_frequency[1] = 40 + sum; + if((sum & 0x06) == 0x06) + hopping_frequency[1] += 21; + hopping_frequency[2] = 70 + sum; + #ifdef DEBUG_SERIAL + debug(" RF"); + for(uint8_t i=0; i < 3; i++) + debug(" %d", hopping_frequency[i]); + debugln(); + #endif + phase++; default: //JIABAILE_DATA #ifdef MULTI_SYNC telemetry_set_input_sync(JIABAILE_PACKET_PERIOD); @@ -194,10 +226,15 @@ uint16_t JIABAILE_callback() void JIABAILE_init() { - BIND_IN_PROGRESS; // Autobind protocol JIABAILE_initialize_txid(); JIABAILE_RF_init(); - phase = JIABAILE_BIND; + if(IS_BIND_IN_PROGRESS) + { + phase = JIABAILE_BIND; + bind_counter = JIABAILE_BIND_COUNT; + } + else + phase = JIABAILE_PREP_DATA; hopping_frequency_no = 0; } diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index 96fc4ec..a5bcd9c 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -856,7 +856,8 @@ enum { #define DSM_CLONE_EEPROM_OFFSET 1074 // (4) TX ID, (1) Initialized, end is 1079 #define TRAXXAS_EEPROM_OFFSET 1079 // RX ID and SOP index, 3 bytes per model id, end is 1079+192=1271 #define XK2_EEPROM_OFFSET 1271 // RX ID checksum, 1 byte per model, end is 1271+64=1335 -//#define CONFIG_EEPROM_OFFSET 1335 // Current configuration of the multimodule +#define JIABAILE_EEPROM_OFFSET 1335 // RX ID, 3 bytes per model, end is 1335+64*3=1527 +//#define CONFIG_EEPROM_OFFSET 1527 // Current configuration of the multimodule /* STM32 Flash Size */ #ifndef DISABLE_FLASH_SIZE_CHECK diff --git a/Protocols_Details.md b/Protocols_Details.md index 3508fe0..29e0291 100644 --- a/Protocols_Details.md +++ b/Protocols_Details.md @@ -701,6 +701,8 @@ A|E|T|R ## Traxxas - *43* +You must assign a different RX number for each receiver/car. Otherwise the new receiver/car ID will overwrite the previous one. + ### Sub_protocol TQ2 - *0* Transmitter TQ, Receivers: 6519, 2218(X), ECM-2.5 @@ -1516,6 +1518,8 @@ Models: WLtoys cars 284131/284161/284010/124016/124017/144010 and Eachine EAT14 ## XK2 - *99* +You must assign a different RX number for each receiver/plane. Otherwise the new receiver/plane ID will overwrite the previous one. + ### Sub_protocol X4 - *0* Transmitter: XK X4-A160, X5S, model: XK A160S, XK A280, XK A300 @@ -1924,7 +1928,10 @@ ARM| ### Sub_protocol FQ777_951 - *3* ## JIABAILE - *102* -Autobind protocol + +Models: JBL-430x + +You must assign a different RX number for each car. Otherwise the new car ID will overwrite the previous one. CH1|CH2|CH3|CH4|CH5|CH6|CH7 ---|---|---|---|---|---|---