diff --git a/Multiprotocol/Multi_Protos.ino b/Multiprotocol/Multi_Protos.ino index 527059b..1ece75c 100644 --- a/Multiprotocol/Multi_Protos.ino +++ b/Multiprotocol/Multi_Protos.ino @@ -118,6 +118,7 @@ const char STR_UDIRC[] ="UDIRC"; const char STR_JIABAILE[] ="JIABAILE"; const char STR_KAMTOM[] ="KAMTOM"; const char STR_WL91X[] ="WL91x"; +const char STR_WPL[] ="WPL"; const char STR_SUBTYPE_FLYSKY[] = "\x04""Std\0""V9x9""V6x6""V912""CX20"; const char STR_SUBTYPE_HUBSAN[] = "\x04""H107""H301""H501"; @@ -518,7 +519,9 @@ const mm_protocol_definition multi_protocols[] = { #if defined(WL91X_CCNRF_INO) {PROTO_WL91X, STR_WL91X, NO_SUBTYPE, 0, OPTION_NONE, 0, 0, SW_NRF, WL91X_init, WL91X_callback }, #endif - + #if defined(WPL_NRF24L01_INO) + {PROTO_WPL, STR_WPL, NO_SUBTYPE, 0, OPTION_NONE, 0, 0, SW_NRF, WPL_init, WPL_callback }, + #endif #if defined(XERALL_NRF24L01_INO) {PROTO_XERALL, STR_XERALL, NO_SUBTYPE, 0, OPTION_NONE, 0, 0, SW_NRF, XERALL_init, XERALL_callback }, #endif diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index f4f0b37..7095ee0 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -19,7 +19,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 3 #define VERSION_REVISION 4 -#define VERSION_PATCH_LEVEL 50 +#define VERSION_PATCH_LEVEL 51 #define MODE_SERIAL 0 @@ -134,6 +134,7 @@ enum PROTOCOLS PROTO_KAMTOM = 104, // =>NRF24L01 PROTO_SHENQI2 = 105, // =>NRF24L01 PROTO_WL91X = 106, // =>CC2500 & NRF24L01 + PROTO_WPL = 107, // =>NRF24L01 PROTO_NANORF = 126, // =>NRF24L01 PROTO_TEST = 127, // =>CC2500 diff --git a/Multiprotocol/Validate.h b/Multiprotocol/Validate.h index 97ee21d..62f7c11 100644 --- a/Multiprotocol/Validate.h +++ b/Multiprotocol/Validate.h @@ -341,6 +341,7 @@ #undef SYMAX_NRF24L01_INO #undef V2X2_NRF24L01_INO #undef V761_NRF24L01_INO + #undef WPL_NRF24L01_INO #undef XERALL_NRF24L01_INO #undef YD717_NRF24L01_INO #undef YUXIANG_NRF24L01_INO @@ -399,6 +400,7 @@ #undef UDIRC_CCNRF_INO #undef KAMTOM_NRF24L01_INO #undef WL91X_CCNRF_INO + #undef WPL_NRF24L01_INO //Save flash space... #undef CABELL_NRF24L01_INO #undef REDPINE_CC2500_INO diff --git a/Multiprotocol/WPL_nrf24l01.ino b/Multiprotocol/WPL_nrf24l01.ino new file mode 100644 index 0000000..85c5d1c --- /dev/null +++ b/Multiprotocol/WPL_nrf24l01.ino @@ -0,0 +1,143 @@ +/* + This project is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + +Multiprotocol is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Multiprotocol. If not, see . + */ +// Compatible with WPL "Basic" TX models D12, D12KM, D22, D32, D42, D14 + +#if defined(WPL_NRF24L01_INO) + +#include "iface_xn297.h" + +#define FORCE_WPL_ORIGINAL_ID + +#define WPL_PACKET_PERIOD 9875 +#define WPL_RF_NUM_CHANNELS 4 +#define WPL_PAYLOAD_SIZE 16 +#define WPL_BIND_COUNT 303 //3sec + +static void __attribute__((unused)) WPL_send_packet() +{ + XN297_Hopping(hopping_frequency_no + (IS_BIND_IN_PROGRESS?0:4) ); + hopping_frequency_no++; + hopping_frequency_no &= WPL_RF_NUM_CHANNELS-1; // 4 RF channels + + memset(&packet[8],0,7); + packet[0] = 0x94; //?? + packet[1] = 0x16; //?? + packet[2] = 0xCC; //?? + + if(IS_BIND_IN_PROGRESS) + { + memcpy(&packet[3],rx_tx_addr,5); + packet[9] = 0x08; // ?? Not bound + Headlights on + } + else + { + packet[3 ] = convert_channel_s8b(CH1); // Throttle + packet[4 ] = convert_channel_s8b(CH2); // Steering + packet[5 ] = convert_channel_16b_limit(CH3,0x22,0x5E); // Steering trim + packet[6 ] = rx_tx_addr[3]; // 0x32?? + packet[7 ] = convert_channel_s8b(CH4); // Aux + packet[9 ] = 0x80 // ?? Bound + | GET_FLAG(CH5_SW, 0x08) // Headlights 100%=on + | GET_FLAG(CH6_SW, 0x04) // Throttle rate 100%=high + | GET_FLAG(CH7_SW, 0x02); // Steering rate 100%=high + } + + // Send + XN297_SetPower(); + XN297_SetTxRxMode(TX_EN); + XN297_WritePayload(packet, WPL_PAYLOAD_SIZE); +} + +static void __attribute__((unused)) WPL_RF_init() +{ + XN297_Configure(XN297_CRCEN, XN297_SCRAMBLED, XN297_1M); + XN297_SetTXAddr((uint8_t*)"\x69\xA5\x37\x4D\x8B", 5); + XN297_HoppingCalib(WPL_RF_NUM_CHANNELS*2); // Calibrate bind and normal channels +} + +static void __attribute__((unused)) WPL_initialize_txid() +{ + //Bind frequencies + memcpy(hopping_frequency ,"\x17\x25\x46\x36", WPL_RF_NUM_CHANNELS); //23=17, 37=25, 70=46, 54=36 + //Normal frequencies + memcpy(hopping_frequency+4,"\x0C\x2A\x3D\x1D", WPL_RF_NUM_CHANNELS); //12=0C, 42=2A, 61=3D, 29=1D + #ifdef FORCE_WPL_ORIGINAL_ID + memcpy(rx_tx_addr,"\x96\x2A\xA9\x32\xB4",5); + #endif +} + +uint16_t WPL_callback() +{ + #ifdef MULTI_SYNC + telemetry_set_input_sync(WPL_PACKET_PERIOD); + #endif + if(bind_counter) + if(--bind_counter==0) + BIND_DONE; + WPL_send_packet(); + return WPL_PACKET_PERIOD; +} + +void WPL_init() +{ + BIND_IN_PROGRESS; // autobind protocol + WPL_initialize_txid(); + WPL_RF_init(); + hopping_frequency_no = 0; + bind_counter=WPL_BIND_COUNT; +} + +#endif +/* https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/issues/1120 +Bind packet +----------- +XN297 1Mb Scrambled +Bind address: 69 A5 37 4D 8B +RF channels: 23, 37, 70, 54 +Timing: 9875µs +Payload 16 bytes: 94 16 CC 96 2A A9 32 B4 00 08 00 00 00 00 00 33 + +P[0] = 94 ?? +P[1] = 16 ?? +P[2] = CC ?? +P[3..7] = Normal address +P[8] = 00 ?? +P[9] = 08 ?? not bound?, Throttle and Steering rate low, Headlights on +P[10..14] = 00 ?? +P[15] = sum(P[0..14])+66 why 66... + +Normal packet +----------- +XN297 1Mb Scrambled +Normal address: 96 2A A9 32 B4 +RF channels: 12=0C, 42=2A, 61=3D, 29=1D -> no idea where they come from... +Timing: 9875µs +Payload 16 bytes: 94 16 CC 80 80 38 32 80 00 88 00 00 00 00 00 4E +P[0] = 94 ?? +P[1] = 16 ?? +P[2] = CC ?? +P[3] = Throttle, not enough data on dumps... Same coding as Steering? +P[4] = Steering, not enough data on dumps, looks like one side goes from 7F to 00 and the other 80 to FF which would be s8b +P[5] = Steering trim 22..5E, mid gives 40 not 38... Was the trim centered on the other dumps with value 38? +P[6] = 32 ?? Left over from the bind packet TX_ADDR[3]? +P[7] = 80 ?? Additional channel? It moves at the same time as the trim but my guess is that it is an unconnected channel. +P[8] = 00 ?? +P[9] = 80 ?? bound?, Throttle and Steering rate low, Headlights off + |02 -> Steering rate high + |04 -> Throttle rate high + |08 -> Headlights on +P[10..14] = 00 ?? +P[15] = sum(P[0..14])+66 why 66... +*/ \ No newline at end of file diff --git a/Multiprotocol/_Config.h b/Multiprotocol/_Config.h index 31e6fde..9c49fa5 100644 --- a/Multiprotocol/_Config.h +++ b/Multiprotocol/_Config.h @@ -261,6 +261,7 @@ #define SYMAX_NRF24L01_INO #define V2X2_NRF24L01_INO #define V761_NRF24L01_INO +#define WPL_NRF24L01_INO #define XERALL_NRF24L01_INO #define YD717_NRF24L01_INO #define YUXIANG_NRF24L01_INO @@ -876,6 +877,8 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= { W6_6_1 W6_HEL W6_HEL_I + PROTO_WPL + NONE PROTO_XERALL NONE PROTO_XK diff --git a/Protocols_Details.md b/Protocols_Details.md index 5ce686f..7508241 100644 --- a/Protocols_Details.md +++ b/Protocols_Details.md @@ -155,9 +155,10 @@ CFlie|AIR|38|CFlie||||||||NRF24L01| [WFLY](Protocols_Details.md#WFLY---40)||40|WFR0x||||||||CYRF6936| [WFLY2](Protocols_Details.md#WFLY2---79)||79|RF20x||||||||A7105| [WK2x01](Protocols_Details.md#WK2X01---30)||30|WK2801|WK2401|W6_5_1|W6_6_1|W6_HEL|W6_HEL_I|||CYRF6936| -[WL91X](Protocols_Details.md#WL91X---106)||106|||||||||NRF24L011&CC2500|XN297 +[WL91X](Protocols_Details.md#WL91X---106)||106|||||||||NRF24L01&CC2500|XN297 +[WPL](Protocols_Details.md#WPL---107)||107|||||||||NRF24L01|XN297 [XERALL](Protocols_Details.md#XERALL---91)||91|Tank||||||||NRF24L01|XN297 -[XK](Protocols_Details.md#XK---62)||62|X450|X420|Cars||||||NRF24L011&CC2500|XN297 +[XK](Protocols_Details.md#XK---62)||62|X450|X420|Cars||||||NRF24L01&CC2500|XN297 [XK2](Protocols_Details.md#XK2---99)||99|X4|P10|||||||NRF24L01&CC2500|XN297 [YD717](Protocols_Details.md#YD717---8)||8|YD717|SKYWLKR|SYMAX4|XINXUN|NIHUI||||NRF24L01| [YuXiang](Protocols_Details.md#YuXiang---100)||100|||||||||NRF24L01|XN297 @@ -2363,6 +2364,19 @@ CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9 ---|---|---|---|---|---|---|---|--- A|E|T|R|GYRO|CALIB|FLIP|RTN_ACT|RTN +## WPL - *107* +TX: "Basic", Models: D12 / D12KM / D22 / D32 / D42 / D14 + +**Only 1 ID** available. If you have a TX contact me on GitHub or RCGroups. + +Autobind protocol + +CH1|CH2|CH3|CH4|CH5|CH6|CH7 +---|---|---|---|---|---|--- +TH|ST|ST_Trim|Aux|Light|TH_Rate|ST_Rate + +Light: -100%=Off, +100%=On, Rate: -100%=Low, +100%=High + ## XERALL - *91* Model: Xerall TankCopter