Hitec: new sub_protocol to support forward telemetry

OPT_FW (0) : OPTIMA + forward telemetry packets to TX to be decoded
OPT_HUB (1) : OPTIMA + basic telemetry using FrSky Hub format
MINIMA (2) : Minima/Micro/RED
This commit is contained in:
Pascal Langer 2018-08-09 19:51:07 +02:00
parent eb89b5be1b
commit 2f5252ab88
5 changed files with 48 additions and 40 deletions

View File

@ -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,6 +327,8 @@ 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)
if(sub_protocol==OPT_FW)
{
// 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
@ -334,14 +336,18 @@ uint16_t ReadHITEC()
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)
}
#endif
#if defined(HITEC_HUB_TELEMETRY)
if(sub_protocol==OPT_HUB)
{
switch(pkt[5]) // telemetry frame number
{
case 0x00:
v_lipo1 = (pkt[12])<<5 | (pkt[11])>>3; // calculation in float is volt=(pkt[12]<<8+pkt[11])/28
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[11])<<5 | (pkt[10])>>3; // calculation in float is volt=(pkt[11]<<8+pkt[10])/28
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
@ -354,6 +360,7 @@ uint16_t ReadHITEC()
TX_RSSI += 128;
TX_LQI = pkt[14]&0x7F;
telemetry_link=1; // telemetry hub available
}
#endif
}
debugln("");
@ -385,6 +392,7 @@ 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)
if(sub_protocol==OPT_HUB)
init_frskyd_link_telemetry();
#endif
phase = HITEC_START;

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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
*/