mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2026-08-22 09:53:15 +00:00
MoFly telemetry try 1
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_REVISION 4
|
||||
#define VERSION_PATCH_LEVEL 69
|
||||
#define VERSION_PATCH_LEVEL 70
|
||||
|
||||
#define MODE_SERIAL 0
|
||||
|
||||
|
||||
@@ -508,6 +508,7 @@
|
||||
#undef OMP_HUB_TELEMETRY
|
||||
#undef V761_HUB_TELEMETRY
|
||||
#undef FX_HUB_TELEMETRY
|
||||
#undef XK_HUB_TELEMETRY
|
||||
#undef XK2_HUB_TELEMETRY
|
||||
#undef SGF22_HUB_TELEMETRY
|
||||
#undef KAMTOM_HUB_TELEMETRY
|
||||
@@ -553,6 +554,9 @@
|
||||
#if not defined(FX_NRF24L01_INO)
|
||||
#undef FX_HUB_TELEMETRY
|
||||
#endif
|
||||
#if not defined(XK_CCNRF_INO)
|
||||
#undef XK_HUB_TELEMETRY
|
||||
#endif
|
||||
#if not defined(XK2_CCNRF_INO)
|
||||
#undef XK2_HUB_TELEMETRY
|
||||
#endif
|
||||
@@ -622,7 +626,7 @@
|
||||
//protocols using FRSKYD user frames
|
||||
#undef HUB_TELEMETRY
|
||||
#endif
|
||||
#if not defined(HOTT_FW_TELEMETRY) && not defined(DSM_TELEMETRY) && not defined(SPORT_TELEMETRY) && not defined(HUB_TELEMETRY) && not defined(HUBSAN_HUB_TELEMETRY) && not defined(BUGS_HUB_TELEMETRY) && not defined(NCC1701_HUB_TELEMETRY) && not defined(BAYANG_HUB_TELEMETRY) && not defined(CABELL_HUB_TELEMETRY) && not defined(RLINK_HUB_TELEMETRY) && not defined(AFHDS2A_HUB_TELEMETRY) && not defined(AFHDS2A_FW_TELEMETRY) && not defined(MULTI_TELEMETRY) && not defined(MULTI_STATUS) && not defined(HITEC_HUB_TELEMETRY) && not defined(HITEC_FW_TELEMETRY) && not defined(SCANNER_TELEMETRY) && not defined(FRSKY_RX_TELEMETRY) && not defined(AFHDS2A_RX_TELEMETRY) && not defined(BAYANG_RX_TELEMETRY) && not defined(DEVO_HUB_TELEMETRY) && not defined(PROPEL_HUB_TELEMETRY) && not defined(OMP_HUB_TELEMETRY) && not defined(V761_HUB_TELEMETRY) && not defined(SGF22_HUB_TELEMETRY) && not defined(XK2_HUB_TELEMETRY) && not defined(FX_HUB_TELEMETRY) && not defined(KAMTOM_HUB_TELEMETRY) && not defined(YUXIANG_HUB_TELEMETRY) && not defined(WFLY2_HUB_TELEMETRY) && not defined(LOLI_HUB_TELEMETRY) && not defined(MLINK_HUB_TELEMETRY) && not defined(MLINK_FW_TELEMETRY) && not defined(MT99XX_HUB_TELEMETRY) && not defined(MULTI_CONFIG_INO)
|
||||
#if not defined(HOTT_FW_TELEMETRY) && not defined(DSM_TELEMETRY) && not defined(SPORT_TELEMETRY) && not defined(HUB_TELEMETRY) && not defined(HUBSAN_HUB_TELEMETRY) && not defined(BUGS_HUB_TELEMETRY) && not defined(NCC1701_HUB_TELEMETRY) && not defined(BAYANG_HUB_TELEMETRY) && not defined(CABELL_HUB_TELEMETRY) && not defined(RLINK_HUB_TELEMETRY) && not defined(AFHDS2A_HUB_TELEMETRY) && not defined(AFHDS2A_FW_TELEMETRY) && not defined(MULTI_TELEMETRY) && not defined(MULTI_STATUS) && not defined(HITEC_HUB_TELEMETRY) && not defined(HITEC_FW_TELEMETRY) && not defined(SCANNER_TELEMETRY) && not defined(FRSKY_RX_TELEMETRY) && not defined(AFHDS2A_RX_TELEMETRY) && not defined(BAYANG_RX_TELEMETRY) && not defined(DEVO_HUB_TELEMETRY) && not defined(PROPEL_HUB_TELEMETRY) && not defined(OMP_HUB_TELEMETRY) && not defined(V761_HUB_TELEMETRY) && not defined(SGF22_HUB_TELEMETRY) && not defined(XK_HUB_TELEMETRY) && not defined(XK2_HUB_TELEMETRY) && not defined(FX_HUB_TELEMETRY) && not defined(KAMTOM_HUB_TELEMETRY) && not defined(YUXIANG_HUB_TELEMETRY) && not defined(WFLY2_HUB_TELEMETRY) && not defined(LOLI_HUB_TELEMETRY) && not defined(MLINK_HUB_TELEMETRY) && not defined(MLINK_FW_TELEMETRY) && not defined(MT99XX_HUB_TELEMETRY) && not defined(MULTI_CONFIG_INO)
|
||||
#undef TELEMETRY
|
||||
#undef INVERT_TELEMETRY
|
||||
#undef MULTI_TELEMETRY
|
||||
|
||||
@@ -27,6 +27,11 @@ Multiprotocol is distributed in the hope that it will be useful,
|
||||
#define XK_PAYLOAD_SIZE 16
|
||||
#define XK_BIND_COUNT 750 //3sec
|
||||
|
||||
enum {
|
||||
XK_DATA,
|
||||
XK_RX,
|
||||
};
|
||||
|
||||
static uint16_t __attribute__((unused)) XK_convert_channel(uint8_t num)
|
||||
{
|
||||
uint16_t val;
|
||||
@@ -134,10 +139,12 @@ static void __attribute__((unused)) XK_send_packet()
|
||||
crc+=packet[i];
|
||||
packet[15]=crc;
|
||||
|
||||
#if 0
|
||||
debug("C: %02X, P:",hopping_frequency[rf_ch_num]);
|
||||
for(uint8_t i=0; i<XK_PAYLOAD_SIZE; i++)
|
||||
debug(" %02X",packet[i]);
|
||||
debugln("");
|
||||
#endif
|
||||
|
||||
// Send
|
||||
XN297_SetPower(); // Set tx_power
|
||||
@@ -225,27 +232,95 @@ static void __attribute__((unused)) XK_RF_init()
|
||||
|
||||
uint16_t XK_callback()
|
||||
{
|
||||
#ifdef XK_HUB_TELEMETRY
|
||||
bool rx = false;
|
||||
#endif
|
||||
|
||||
switch(phase)
|
||||
{
|
||||
case XK_DATA:
|
||||
#ifdef MULTI_SYNC
|
||||
telemetry_set_input_sync(XK_PACKET_PERIOD);
|
||||
#endif
|
||||
#ifdef XK_HUB_TELEMETRY
|
||||
rx = XN297_IsRX();
|
||||
XN297_SetTxRxMode(TXRX_OFF);
|
||||
#endif
|
||||
XK_send_packet();
|
||||
if(bind_counter)
|
||||
if(--bind_counter==0)
|
||||
{
|
||||
BIND_DONE;
|
||||
XN297_SetTXAddr(rx_tx_addr, 5); // Normal packets address
|
||||
#ifdef XK_HUB_TELEMETRY
|
||||
XN297_SetRXAddr(rx_tx_addr, XK_PAYLOAD_SIZE); // Normal packets address
|
||||
#endif
|
||||
}
|
||||
#ifdef XK_HUB_TELEMETRY
|
||||
if(rx)
|
||||
{
|
||||
XN297_ReadPayload(packet_in, XK_PAYLOAD_SIZE);
|
||||
#if 1
|
||||
debug("RX");
|
||||
for(uint8_t i=0; i<XK_PAYLOAD_SIZE; i++)
|
||||
debug(" %02X",packet_in[i]);
|
||||
debugln("");
|
||||
#endif
|
||||
if(memcmp(&packet[7], packet_in, 3) == 0)
|
||||
{//TX_ID ok
|
||||
crc=packet_in[0]+0x68;
|
||||
for(uint8_t i=1; i<XK_PAYLOAD_SIZE-1;i++)
|
||||
crc+=packet_in[i];
|
||||
if(packet_in[15] == crc)
|
||||
{//Checksum ok
|
||||
telemetry_link = 1;
|
||||
v_lipo1 = packet_in[10] ? 137:162; // low voltage 7.1V
|
||||
}
|
||||
}
|
||||
}
|
||||
phase++;
|
||||
return 1350;
|
||||
#endif
|
||||
break;
|
||||
#ifdef XK_HUB_TELEMETRY
|
||||
default: //XK_RX
|
||||
/*{ // Wait for packet to be sent before switching to receive mode
|
||||
uint16_t start=(uint16_t)micros(), count=0;
|
||||
while ((uint16_t)((uint16_t)micros()-(uint16_t)start) < 500)
|
||||
{
|
||||
if(XN297_IsPacketSent())
|
||||
break;
|
||||
count++;
|
||||
}
|
||||
debugln("%d",count);
|
||||
}*/
|
||||
//Switch to RX
|
||||
XN297_SetTxRxMode(TXRX_OFF);
|
||||
XN297_SetTxRxMode(RX_EN);
|
||||
phase = XK_DATA;
|
||||
return XK_PACKET_PERIOD-1350;
|
||||
#endif
|
||||
}
|
||||
XK_send_packet();
|
||||
return XK_PACKET_PERIOD;
|
||||
}
|
||||
|
||||
void XK_init()
|
||||
{
|
||||
if(sub_protocol != XK_CARS && protocol != PROTO_MOFLY)
|
||||
{
|
||||
bind_counter=XK_BIND_COUNT;
|
||||
BIND_IN_PROGRESS; // Autobind protocol
|
||||
}
|
||||
else
|
||||
bind_counter=0;
|
||||
XK_initialize_txid();
|
||||
XK_RF_init();
|
||||
hopping_frequency_no = 0;
|
||||
bind_counter=XK_BIND_COUNT;
|
||||
phase = XK_DATA;
|
||||
#ifdef XK_HUB_TELEMETRY
|
||||
RX_RSSI = 100; // Dummy value
|
||||
telemetry_lost = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -357,6 +357,7 @@
|
||||
#define V761_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
||||
#define KAMTOM_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
||||
#define FX_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
||||
#define XK_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
||||
#define XK2_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
||||
#define SGF22_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
||||
#define YUXIANG_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
||||
|
||||
Reference in New Issue
Block a user