diff --git a/Multiprotocol/MLINK_cyrf6936.ino b/Multiprotocol/MLINK_cyrf6936.ino index 0279f32..f772fa0 100644 --- a/Multiprotocol/MLINK_cyrf6936.ino +++ b/Multiprotocol/MLINK_cyrf6936.ino @@ -465,18 +465,40 @@ uint16_t ReadMLINK() return 1000; } +static void __attribute__((unused)) MLINK_shuffle_freqs(uint32_t seed, uint8_t *hop) +{ + randomSeed(seed); + + for(uint8_t i=0; i < MLINK_NUM_FREQ/2; i++) + { + uint8_t r = random(0xfefefefe) % (MLINK_NUM_FREQ/2); + uint8_t tmp = hop[r]; + hop[r] = hop[i]; + hop[i] = tmp; + } +} + uint16_t initMLINK() { MLINK_cyrf_config(); //Init ID and RF freqs + for(uint8_t i=0; i < MLINK_NUM_FREQ/2; i++) + { + hopping_frequency[i ] = (i<<1) + 3; + hopping_frequency[i+MLINK_NUM_FREQ/2] = (i<<1) + 3; + } + // part1 memcpy(MLINK_Data_Code ,rx_tx_addr,4); - calc_fh_channels(MLINK_NUM_FREQ/2); - memcpy(&hopping_frequency[MLINK_NUM_FREQ/2],hopping_frequency,MLINK_NUM_FREQ/2); + MLINK_shuffle_freqs(MProtocol_id, hopping_frequency); + + // part2 MProtocol_id ^= 0x6FBE3201; set_rx_tx_addr(MProtocol_id); memcpy(MLINK_Data_Code+4,rx_tx_addr,4); - calc_fh_channels(MLINK_NUM_FREQ/2); + MLINK_shuffle_freqs(MProtocol_id, &hopping_frequency[MLINK_NUM_FREQ/2]); + + // part3 MLINK_CRC_Init = rx_tx_addr[3]; //value sent during bind then used to init the CRC MLINK_Unk_6_2 = 0x3A; //unknown value sent during bind but doesn't seem to matter diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index b4cfa74..5fb6f40 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -19,7 +19,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 3 #define VERSION_REVISION 2 -#define VERSION_PATCH_LEVEL 29 +#define VERSION_PATCH_LEVEL 30 //****************** // Protocols diff --git a/Protocols_Details.md b/Protocols_Details.md index 15d94e9..d43a012 100644 --- a/Protocols_Details.md +++ b/Protocols_Details.md @@ -870,6 +870,8 @@ Extended limits supported Telemetry: the 2 RXs I have are sending different information in different format, I've done something which might work or not so please report +Bind: the RX must be really close to the TX + CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13|CH14|CH15|CH16 ---|---|---|---|---|---|---|---|---|----|----|----|----|----|----|---- CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12||CH13|CH14|CH15|CH16