diff --git a/Multiprotocol/Hitec_cc2500.ino b/Multiprotocol/Hitec_cc2500.ino index 276c6c8..cdcc3ee 100644 --- a/Multiprotocol/Hitec_cc2500.ino +++ b/Multiprotocol/Hitec_cc2500.ino @@ -150,10 +150,10 @@ static void __attribute__((unused)) HITEC_build_packet() packet[5]=hopping_frequency[13]>>1; // if not there the Optima link is jerky... break; } - if(sub_protocol==OPTIMA) - packet[4] = bind_phase; // increments based on RX answer - else + if(sub_protocol==MINIMA) packet[4] = bind_phase+0x10; + else + packet[4] = bind_phase; // Optima: increments based on RX answer packet[19] = 0x08; // packet sequence offset=20; // packet[20] and [21] } @@ -327,33 +327,40 @@ uint16_t ReadHITEC() // 0C,1C,A1,2B,00,18,00,00,00,00,00,18,00,50,92 debug(",telem"); #if defined(HITEC_FW_TELEMETRY) - // 8 bytes telemetry packets => see at the end of this file how to fully decode it - pkt[0]=pkt[13]; // TX RSSI - pkt[1]=pkt[14]&0x7F; // TX LQI - uint8_t offset=pkt[5]==0?1:0; - for(uint8_t i=5;i < 11; i++) - pkt[i-3]=pkt[i+offset]; // frame number followed by 5 bytes of data - telemetry_link=2; // telemetry forward available - #elif defined(HITEC_HUB_TELEMETRY) - switch(pkt[5]) // telemetry frame number + if(sub_protocol==OPT_FW) { - case 0x00: - v_lipo1 = (pkt[12])<<5 | (pkt[11])>>3; // calculation in float is volt=(pkt[12]<<8+pkt[11])/28 - break; - case 0x11: - v_lipo1 = (pkt[11])<<5 | (pkt[10])>>3; // calculation in float is volt=(pkt[11]<<8+pkt[10])/28 - break; - case 0x18: - v_lipo2 = (pkt[6])<<5 | (pkt[7])>>3; // calculation in float is volt=(pkt[6]<<8+pkt[7])/10 - break; + // 8 bytes telemetry packets => see at the end of this file how to fully decode it + pkt[0]=pkt[13]; // TX RSSI + pkt[1]=pkt[14]&0x7F; // TX LQI + uint8_t offset=pkt[5]==0?1:0; + for(uint8_t i=5;i < 11; i++) + pkt[i-3]=pkt[i+offset]; // frame number followed by 5 bytes of data + telemetry_link=2; // telemetry forward available + } + #endif + #if defined(HITEC_HUB_TELEMETRY) + if(sub_protocol==OPT_HUB) + { + switch(pkt[5]) // telemetry frame number + { + case 0x00: + v_lipo1 = (pkt[10])<<5 | (pkt[11])>>3; // calculation in float is volt=(pkt[10]<<8+pkt[11])/28 + break; + case 0x11: + v_lipo1 = (pkt[9])<<5 | (pkt[10])>>3; // calculation in float is volt=(pkt[9]<<8+pkt[10])/28 + break; + case 0x18: + v_lipo2 = (pkt[6])<<5 | (pkt[7])>>3; // calculation in float is volt=(pkt[6]<<8+pkt[7])/10 + break; + } + TX_RSSI = pkt[13]; + if(TX_RSSI >=128) + TX_RSSI -= 128; + else + TX_RSSI += 128; + TX_LQI = pkt[14]&0x7F; + telemetry_link=1; // telemetry hub available } - TX_RSSI = pkt[13]; - if(TX_RSSI >=128) - TX_RSSI -= 128; - else - TX_RSSI += 128; - TX_LQI = pkt[14]&0x7F; - telemetry_link=1; // telemetry hub available #endif } debugln(""); @@ -385,7 +392,8 @@ uint16_t initHITEC() memcpy((void *)hopping_frequency,(void *)"\x00\x3A\x4A\x32\x0C\x58\x2A\x10\x26\x20\x08\x60\x68\x70\x78\x80\x88\x56\x5E\x66\x6E",HITEC_NUM_FREQUENCE); #endif #if defined(HITEC_HUB_TELEMETRY) - init_frskyd_link_telemetry(); + if(sub_protocol==OPT_HUB) + init_frskyd_link_telemetry(); #endif phase = HITEC_START; return 10000; diff --git a/Multiprotocol/Multi.txt b/Multiprotocol/Multi.txt index fe2630f..577f81d 100644 --- a/Multiprotocol/Multi.txt +++ b/Multiprotocol/Multi.txt @@ -36,4 +36,4 @@ 36,H8_3D,H8_3D,H20H,H20Mini,H30Mini 37,CORONA,COR_V1,COR_V2,FD_V3 38,CFlie -39,Hitec,Optima,Minima +39,Hitec,OPT_FW,OPT_HUB,MINIMA diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index b25b4f1..c39ffbb 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -19,7 +19,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 2 #define VERSION_REVISION 0 -#define VERSION_PATCH_LEVEL 30 +#define VERSION_PATCH_LEVEL 31 //****************** // Protocols @@ -234,8 +234,9 @@ enum CORONA }; enum HITEC { - OPTIMA = 0, - MINIMA = 1, + OPT_FW = 0, + OPT_HUB = 1, + MINIMA = 2, }; #define NONE 0 @@ -689,8 +690,9 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p -- COR_V2 1 FD_V3 2 sub_protocol==HITEC - OPTIMA 0 - MINIMA 1 + OPT_FW 0 + OPT_HUB 1 + MINIMA 2 Power value => 0x80 0=High/1=Low Stream[3] = option_protocol; diff --git a/Multiprotocol/Validate.h b/Multiprotocol/Validate.h index a60561d..17a31ba 100644 --- a/Multiprotocol/Validate.h +++ b/Multiprotocol/Validate.h @@ -217,9 +217,6 @@ #undef HITEC_HUB_TELEMETRY #undef HITEC_FW_TELEMETRY #endif - #if defined(HITEC_HUB_TELEMETRY) && defined(HITEC_FW_TELEMETRY) - #error You need to choose between HITEC HUB or HITEC FW telemetry but not both. - #endif #if not defined(FRSKYD_CC2500_INO) #undef HUB_TELEMETRY #endif diff --git a/Multiprotocol/_Config.h b/Multiprotocol/_Config.h index 648af1f..6d10453 100644 --- a/Multiprotocol/_Config.h +++ b/Multiprotocol/_Config.h @@ -249,7 +249,7 @@ #define HUBSAN_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX #define CABELL_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, ersky9x and OpenTX -//#define HITEC_FW_TELEMETRY // Under development: Forward received telemetry packets to be decoded by ersky9x and OpenTX +#define HITEC_FW_TELEMETRY // Under development: Forward received telemetry packets to be decoded by ersky9x and OpenTX //SPORT_POLLING is an implementation of the same polling routine as XJT module for sport telemetry bidirectional communication. //This is useful for passing sport control frames from TX to RX(ex: changing Betaflight PID or VTX channels on the fly using LUA scripts with OpentX). @@ -551,7 +551,8 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= { PROTO_CFLIE NONE PROTO_HITEC - OPTIMA + OPT_FW + OPT_HUB MINIMA */