diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index e2c6e8c..59aacb7 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 31 +#define VERSION_PATCH_LEVEL 32 //****************** // Protocols @@ -1086,35 +1086,8 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p -- DSM: Stream[27..33] Forward Programming */ /* - Multimodule Status - Based on #define MULTI_STATUS - - Serial: 100000 Baud 8e2 (same as input) - - Format: header (2 bytes) + data (variable) - [0] = 'M' (0x4d) - [1] Length (excluding the 2 header bytes) - [2-xx] data - - Type = 0x01 Multimodule Status: - [2] Flags - 0x01 = Input signal detected - 0x02 = Serial mode enabled - 0x04 = Protocol is valid - 0x08 = Module is in binding mode - 0x10 = Module waits a bind event to load the protocol - 0x20 = Current protocol supports failsafe - 0x40 = Current protocol supports disable channel mapping - 0x80 = Data buffer is almost full - [3] major - [4] minor - [5] revision - [6] patchlevel, - version of multi code, should be displayed as major.minor.revision.patchlevel -*/ -/* - Multiprotocol telemetry/command definition for OpenTX - Based on #define MULTI_TELEMETRY enables OpenTX to get the multimodule status and select the correct telemetry type automatically. + Multiprotocol telemetry/command definition for OpenTX and erskyTX + Based on #define MULTI_TELEMETRY enables OpenTX and erskyTX to get the multimodule status and select the correct telemetry type automatically. Serial: 100000 Baud 8e2 (same as input) diff --git a/Multiprotocol/Multiprotocol.ino b/Multiprotocol/Multiprotocol.ino index 7f3187f..ba9bde2 100644 --- a/Multiprotocol/Multiprotocol.ino +++ b/Multiprotocol/Multiprotocol.ino @@ -839,7 +839,7 @@ bool Update_All() #endif //ENABLE_PPM update_led_status(); #if defined(TELEMETRY) - #if ( !( defined(MULTI_TELEMETRY) || defined(MULTI_STATUS) ) ) + #ifndef MULTI_TELEMETRY if((protocol == PROTO_BAYANG_RX) || (protocol == PROTO_AFHDS2A_RX) || (protocol == PROTO_FRSKY_RX) || (protocol == PROTO_SCANNER) || (protocol==PROTO_FRSKYD) || (protocol==PROTO_BAYANG) || (protocol==PROTO_NCC1701) || (protocol==PROTO_BUGS) || (protocol==PROTO_BUGSMINI) || (protocol==PROTO_HUBSAN) || (protocol==PROTO_AFHDS2A) || (protocol==PROTO_FRSKYX) || (protocol==PROTO_FRSKYX2) || (protocol==PROTO_DSM) || (protocol==PROTO_CABELL) || (protocol==PROTO_HITEC) || (protocol==PROTO_HOTT) || (protocol==PROTO_PROPEL) || (protocol==PROTO_OMP) || (protocol==PROTO_DEVO) || (protocol==PROTO_DSM_RX) || (protocol==PROTO_FRSKY_R9) || (protocol==PROTO_RLINK) || (protocol==PROTO_WFLY2) || (protocol==PROTO_LOLI) || (protocol==PROTO_MLINK)) #endif if(IS_DISABLE_TELEM_off) diff --git a/Multiprotocol/Telemetry.ino b/Multiprotocol/Telemetry.ino index 4b11377..92707cf 100644 --- a/Multiprotocol/Telemetry.ino +++ b/Multiprotocol/Telemetry.ino @@ -19,7 +19,7 @@ uint8_t RetrySequence ; -#if ( defined(MULTI_TELEMETRY) || defined(MULTI_STATUS) ) +#ifdef MULTI_TELEMETRY uint32_t lastMulti = 0; #define MULTI_TIME 500 //in ms #ifdef MULTI_SYNC @@ -28,7 +28,7 @@ uint8_t RetrySequence ; uint32_t lastInputSync = 0; uint16_t inputDelay = 0; #endif // MULTI_SYNC -#endif // MULTI_TELEMETRY/MULTI_STATUS +#endif // MULTI_TELEMETRY #if defined SPORT_TELEMETRY #define FRSKY_SPORT_PACKET_SIZE 8 @@ -62,16 +62,12 @@ uint8_t RetrySequence ; uint8_t pktx[MAX_PKTX]; uint8_t frame[18]; -#if ( defined(MULTI_TELEMETRY) || defined(MULTI_STATUS) ) +#ifdef MULTI_TELEMETRY static void multi_send_header(uint8_t type, uint8_t len) { Serial_write('M'); - #ifdef MULTI_TELEMETRY - Serial_write('P'); - Serial_write(type); - #else - (void)type; - #endif + Serial_write('P'); + Serial_write(type); Serial_write(len); } @@ -119,15 +115,7 @@ static void telemetry_set_input_sync(uint16_t refreshRate) static void multi_send_status() { - #ifdef MULTI_TELEMETRY - #ifdef MULTI_NAMES - multi_send_header(MULTI_TELEMETRY_STATUS, 24); - #else - multi_send_header(MULTI_TELEMETRY_STATUS, 5); - #endif - #else - multi_send_header(MULTI_TELEMETRY_STATUS, 5); - #endif + multi_send_header(MULTI_TELEMETRY_STATUS, 24); // Build flags uint8_t flags=0; @@ -138,23 +126,18 @@ static void multi_send_status() if (remote_callback != 0) { flags |= 0x04; - #ifdef MULTI_NAMES - if(multi_protocols_index == 0xFF) - { - if(protocol!=PROTO_SCANNER) - flags &= ~0x04; //Invalid protocol - } - else if(sub_protocol&0x07) - { - uint8_t nbr=multi_protocols[multi_protocols_index].nbrSubProto; - //if(protocol==PROTO_DSM) nbr++; //Auto sub_protocol - if((sub_protocol&0x07)>=nbr) - flags &= ~0x04; //Invalid sub protocol - } - #else - if(remote_callback==0) + if(multi_protocols_index == 0xFF) + { + if(protocol!=PROTO_SCANNER) flags &= ~0x04; //Invalid protocol - #endif + } + else if(sub_protocol&0x07) + { + uint8_t nbr=multi_protocols[multi_protocols_index].nbrSubProto; + //if(protocol==PROTO_DSM) nbr++; //Auto sub_protocol + if((sub_protocol&0x07)>=nbr) + flags &= ~0x04; //Invalid sub protocol + } if (IS_WAIT_BIND_on) flags |= 0x10; else @@ -177,89 +160,69 @@ static void multi_send_status() Serial_write(VERSION_REVISION); Serial_write(VERSION_PATCH_LEVEL); - #ifdef MULTI_TELEMETRY - // Channel order - Serial_write(RUDDER<<6|THROTTLE<<4|ELEVATOR<<2|AILERON); - #endif + // Channel order + Serial_write(RUDDER<<6|THROTTLE<<4|ELEVATOR<<2|AILERON); - #ifdef MULTI_NAMES - if(multi_protocols_index == 0xFF) // selection out of list... send first available protocol + if(multi_protocols_index == 0xFF) // selection out of list... send first available protocol + { + Serial_write(multi_protocols[0].protocol); // begining of list + Serial_write(multi_protocols[0].protocol); // begining of list + for(uint8_t i=0;i<16;i++) + Serial_write(0x00); // everything else is invalid + } + else + { + // Protocol next/prev + if(multi_protocols[multi_protocols_index+1].protocol != 0) + Serial_write(multi_protocols[multi_protocols_index+1].protocol); // next protocol number + else + Serial_write(multi_protocols[multi_protocols_index].protocol); // end of list + if(multi_protocols_index>0) + Serial_write(multi_protocols[multi_protocols_index-1].protocol); // prev protocol number + else + Serial_write(multi_protocols[multi_protocols_index].protocol); // begining of list + // Protocol + for(uint8_t i=0;i<7;i++) + Serial_write(multi_protocols[multi_protocols_index].ProtoString[i]); // protocol name + // Sub-protocol + uint8_t nbr=multi_protocols[multi_protocols_index].nbrSubProto; + Serial_write(nbr | (multi_protocols[multi_protocols_index].optionType<<4)); // number of sub protocols && option type + uint8_t j=0; + if(nbr && (sub_protocol&0x07)0) - Serial_write(multi_protocols[multi_protocols_index-1].protocol); // prev protocol number - else - Serial_write(multi_protocols[multi_protocols_index].protocol); // begining of list - // Protocol - for(uint8_t i=0;i<7;i++) - Serial_write(multi_protocols[multi_protocols_index].ProtoString[i]); // protocol name - // Sub-protocol - uint8_t nbr=multi_protocols[multi_protocols_index].nbrSubProto; - Serial_write(nbr | (multi_protocols[multi_protocols_index].optionType<<4)); // number of sub protocols && option type - uint8_t j=0; - if(nbr && (sub_protocol&0x07) MULTI_TIME))&& protocol != PROTO_SCANNER) { @@ -923,63 +870,63 @@ void TelemetryUpdate() } #endif // SPORT_TELEMETRY - #if defined DSM_TELEMETRY - if(telemetry_link && protocol == PROTO_DSM) - { // DSM - DSM_frame(); - telemetry_link=0; - return; - } - #endif - #if defined AFHDS2A_FW_TELEMETRY - if(telemetry_link == 2 && protocol == PROTO_AFHDS2A) - { - AFHDSA_short_frame(); - telemetry_link=0; - return; - } - #endif - #if defined HITEC_FW_TELEMETRY - if(telemetry_link == 2 && protocol == PROTO_HITEC) - { - HITEC_short_frame(); - telemetry_link=0; - return; - } - #endif - #if defined HOTT_FW_TELEMETRY - if(telemetry_link == 2 && protocol == PROTO_HOTT) - { - HOTT_short_frame(); - telemetry_link=0; - return; - } - #endif - - #if defined SCANNER_TELEMETRY - if (telemetry_link && protocol == PROTO_SCANNER) - { - spectrum_scanner_frame(); - telemetry_link = 0; - return; - } - #endif - - #if defined (FRSKY_RX_TELEMETRY) || defined(AFHDS2A_RX_TELEMETRY) || defined (BAYANG_RX_TELEMETRY) || defined (DSM_RX_CYRF6936_INO) - if ((telemetry_link & 1) && (protocol == PROTO_FRSKY_RX || protocol == PROTO_AFHDS2A_RX || protocol == PROTO_BAYANG_RX || protocol == PROTO_DSM_RX) ) - { - receiver_channels_frame(); - telemetry_link &= ~1; - return; - } - #endif - - if( telemetry_link & 1 ) - { // FrSkyD + Hubsan + AFHDS2A + Bayang + Cabell + Hitec + Bugs + BugsMini + NCC1701 + PROPEL + RLINK + OMP + MLINK - // FrSkyX telemetry if in PPM - frsky_link_frame(); - return; - } + #ifdef MULTI_TELEMETRY + #if defined DSM_TELEMETRY + if(telemetry_link && protocol == PROTO_DSM) + { // DSM + DSM_frame(); + telemetry_link=0; + return; + } + #endif + #if defined AFHDS2A_FW_TELEMETRY + if(telemetry_link == 2 && protocol == PROTO_AFHDS2A) + { + AFHDSA_short_frame(); + telemetry_link=0; + return; + } + #endif + #if defined HITEC_FW_TELEMETRY + if(telemetry_link == 2 && protocol == PROTO_HITEC) + { + HITEC_short_frame(); + telemetry_link=0; + return; + } + #endif + #if defined HOTT_FW_TELEMETRY + if(telemetry_link == 2 && protocol == PROTO_HOTT) + { + HOTT_short_frame(); + telemetry_link=0; + return; + } + #endif + #if defined SCANNER_TELEMETRY + if (telemetry_link && protocol == PROTO_SCANNER) + { + spectrum_scanner_frame(); + telemetry_link = 0; + return; + } + #endif + #if defined (FRSKY_RX_TELEMETRY) || defined(AFHDS2A_RX_TELEMETRY) || defined (BAYANG_RX_TELEMETRY) || defined (DSM_RX_CYRF6936_INO) + if ((telemetry_link & 1) && (protocol == PROTO_FRSKY_RX || protocol == PROTO_AFHDS2A_RX || protocol == PROTO_BAYANG_RX || protocol == PROTO_DSM_RX) ) + { + receiver_channels_frame(); + telemetry_link &= ~1; + return; + } + #endif + #endif //MULTI_TELEMETRY + + if( telemetry_link & 1 ) + { // FrSkyD + Hubsan + AFHDS2A + Bayang + Cabell + Hitec + Bugs + BugsMini + NCC1701 + PROPEL + RLINK + OMP + MLINK + // FrSkyX telemetry if in PPM + frsky_link_frame(); + return; + } #if defined HUB_TELEMETRY if((telemetry_link & 2) && ( protocol == PROTO_FRSKYD || protocol == PROTO_BAYANG || protocol == PROTO_MLINK ) ) { // FrSkyD + Bayang + MLINK diff --git a/Multiprotocol/Validate.h b/Multiprotocol/Validate.h index 1e8e15c..b5f3c58 100644 --- a/Multiprotocol/Validate.h +++ b/Multiprotocol/Validate.h @@ -223,10 +223,6 @@ #define NRF24L01_INSTALLED #define SX1276_INSTALLED #undef ENABLE_PPM - #ifdef MLINK_CYRF6936_INO - #undef MLINK_CYRF6936_INO - #warning "Disabling the MLink protocol to fit in the Flash." - #endif #endif //Make sure protocols are selected correctly @@ -345,7 +341,6 @@ #undef SPORT_TELEMETRY #undef SPORT_SEND #undef DSM_TELEMETRY - #undef MULTI_STATUS #undef MULTI_TELEMETRY #undef SCANNER_TELEMETRY #undef SCANNER_CC2500_INO @@ -365,9 +360,6 @@ #undef WFLY2_HUB_TELEMETRY #undef LOLI_HUB_TELEMETRY #else - #if defined(MULTI_TELEMETRY) && defined(MULTI_STATUS) - #error You should choose either MULTI_TELEMETRY or MULTI_STATUS but not both. - #endif #if not defined(SCANNER_CC2500_INO) || not defined(SCANNER_TELEMETRY) #undef SCANNER_TELEMETRY #undef SCANNER_CC2500_INO @@ -448,7 +440,6 @@ #undef TELEMETRY #undef INVERT_TELEMETRY #undef MULTI_TELEMETRY - #undef MULTI_STATUS #endif #endif diff --git a/Multiprotocol/_Config.h b/Multiprotocol/_Config.h index 238c5d9..83b475c 100644 --- a/Multiprotocol/_Config.h +++ b/Multiprotocol/_Config.h @@ -304,13 +304,9 @@ //For STM32 and OrangeRX modules, comment to prevent the TX from forcing the serial telemetry polarity normal/invert. #define INVERT_TELEMETRY_TX -//Uncomment if you want to send Multi status telemetry frames (Protocol available, Bind in progress, version...) -//Use with er9x/erskyTX, for OpenTX you must select MULTI_TELEMETRY below -//#define MULTI_STATUS - -//Sends Multi status and allow OpenTX to autodetect the telemetry format. Comment to disable. -//Supported by OpenTX version 2.2 RC9 and newer. NOT supported by er9x/erskyTX use MULTI_STATUS instead. +//Sends Multi status and allow OpenTX and erskyTX to autodetect the telemetry format. Comment to disable. #define MULTI_TELEMETRY + //Work in progress: Sync OpenTX frames with the current protocol timing. This feature is only available on the STM32 module. Uncomment to enable. //#define MULTI_SYNC @@ -332,7 +328,7 @@ #define WFLY2_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX #define LOLI_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX #define MLINK_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX -#define HITEC_HUB_TELEMETRY // Use FrSkyD Hub format to send basic telemetry to the radios which can decode it like er9x, erskyTX and OpenTX +//#define HITEC_HUB_TELEMETRY // Use FrSkyD Hub format to send basic telemetry to the radios which can decode it like er9x, erskyTX and OpenTX #define HITEC_FW_TELEMETRY // Forward received telemetry packets to be decoded by erskyTX and OpenTX #define SCANNER_TELEMETRY // Forward spectrum scanner data to TX #define FRSKY_RX_TELEMETRY // Forward channels data to TX diff --git a/Multiprotocol/_MyConfig.h.example b/Multiprotocol/_MyConfig.h.example index f679b5a..64cbba4 100644 --- a/Multiprotocol/_MyConfig.h.example +++ b/Multiprotocol/_MyConfig.h.example @@ -10,7 +10,6 @@ #define Module_1 //#define Module_2 //#define Module_3 -//#define Module_4 //Example on how to force the "Flash from TX" feature for all modules #define CHECK_FOR_BOOTLOADER @@ -48,11 +47,6 @@ #undef INVERT_TELEMETRY #elif defined Module_3 - //Example of a module which will be used with OpenTX - #undef MULTI_STATUS - #define MULTI_TELEMETRY - -#elif defined Module_4 //Example of a module which will be PPM only with a different protocol table #undef ENABLE_SERIAL #undef NBR_BANKS