76
76
#define I2C_ESC 0x20 // Electronic Speed Control
77
77
#define I2C_ALPHA6 0x24 // Alpha6 Stabilizer - Blade Helis
78
78
#define I2C_GPS_BIN 0x26 // GPS, binary format
79
+ #define I2C_REMOTE_ID 0x27 // Spektrum SkyID/RemoteID
79
80
#define I2C_FP_BATT 0x34 // Flight Battery Capacity (Dual)
80
81
#define I2C_CELLS 0x3A // 6S Cell Monitor (LiPo taps)
81
82
#define I2C_VARIO 0x40 // Vario
@@ -562,6 +563,7 @@ void processSpektrumPacket(const uint8_t *packet)
562
563
#if TEST_CAPTURED_MESSAGE
563
564
// Only for Testing when we don't have the sensor, but have sample data
564
565
i2cAddress = replaceForTestingPackage (packet);
566
+ instance = packet[3 ];
565
567
#endif
566
568
567
569
if (i2cAddress == I2C_FWD_PGM) {
@@ -611,13 +613,13 @@ void processSpektrumPacket(const uint8_t *packet)
611
613
else if (i2cAddress == I2C_FLITECTRL) {
612
614
// AS3X + SAFE information: Flight Mode
613
615
processAS3XPacket (packet);
614
- // Continue for backward compatibility with scripts using 05XX sensors
616
+ return ; // not a sensor... this is to cleanup many auto-generated 05XX sensors
615
617
} // I2C_FLITECTRL
616
618
617
619
else if (i2cAddress == I2C_ALPHA6) {
618
620
// Alpha6 Flight Controller (Blade Helis): Flight Mode
619
621
processAlpha6Packet (packet);
620
- // Continue for backward compatibility with scripts using 24XX sensors
622
+ return ; // not a sensor... this is to cleanup many auto-generated 24XX sensors
621
623
} // I2C_ALPHA6
622
624
623
625
else if (i2cAddress == I2C_SMART_BAT_BASE_ADDRESS) {
@@ -626,6 +628,24 @@ void processSpektrumPacket(const uint8_t *packet)
626
628
i2cAddress = i2cAddress + (packet[4 ] >> 4 );
627
629
} // I2C_SMART_BAT_BASE_ADDRESS
628
630
631
+ else if (i2cAddress == I2C_REMOTE_ID) {
632
+ if (instance == I2C_GPS_LOC || instance == I2C_GPS_STAT) {
633
+ // RemoteID/SkyID GPS Data embeded in RemoteID packages
634
+ // The format is exactly the same (with the exception of the I2C_ID and Instance),
635
+ // so we just need to continue processing it as if the frame was a GPS telemetry data.
636
+ // The instance is populated with 0x16/0x17 when is GPS, and 0x00 when it is the
637
+ // usual RemoteID data
638
+ i2cAddress = instance;
639
+ instance = 0 ;
640
+ } else {
641
+ // Currently we are not processing any other of the RemoteID telemetry frames
642
+ // we can add in the future a new sensor(s) to record the Remote system ID if we want
643
+ // to log it as part of the telemetry data.
644
+ return ; // not a sensor... this is to cleanup many auto-generated 27XX sensors
645
+ }
646
+ } // I2C_REMOTE_ID
647
+
648
+
629
649
bool handled = false ;
630
650
for (const SpektrumSensor * sensor = spektrumSensors; sensor->i2caddress ; sensor++) {
631
651
// Optimization... the sensor table is sorted incrementally by i2cAddress
@@ -1092,6 +1112,7 @@ static bool real0x16 = false;
1092
1112
static bool real0x17 = false ;
1093
1113
static bool real0x34 = false ;
1094
1114
static bool real0x3A = false ;
1115
+ static bool real0x27 = false ;
1095
1116
1096
1117
// *********** GPS LOC (BCD) ******************************
1097
1118
// Example 0x16: 0 1 2 3 4 5 6 7 8 9 10 11 12 13
@@ -1126,6 +1147,13 @@ static char test3Adata[] = {0x3A, 0x00, 0x01, 0x9A, 0x01, 0x9B, 0x01, 0x9C,
1126
1147
0x01 , 0x91 };
1127
1148
1128
1149
1150
+ // RemoteID (0x27), embeds Gps data in its frames, but by puting the real I2C frame
1151
+ // address as the instance, everything else is the same
1152
+ static char test27data_16[] = {0x27 , 0x16 , 0x97 , 0x00 , 0x54 , 0x71 , 0x12 , 0x28 ,
1153
+ 0x40 , 0x80 , 0x09 , 0x11 , 0x85 , 0x14 , 0x13 , 0xBD }; // > 99 Flag
1154
+ static char test27data_17[] = {0x27 , 0x17 , 0x25 , 0x00 , 0x00 ,
1155
+ 0x28 , 0x18 , 0x21 , 0x06 , 0x00 };
1156
+
1129
1157
static uint8_t replaceForTestingPackage (const uint8_t *packet)
1130
1158
{
1131
1159
uint8_t i2cAddress = packet[2 ] & 0x7f ;
@@ -1135,6 +1163,7 @@ static uint8_t replaceForTestingPackage(const uint8_t *packet)
1135
1163
else if (i2cAddress == I2C_GPS_STAT) real0x17 = true ;
1136
1164
else if (i2cAddress == I2C_FP_BATT) real0x34 = true ;
1137
1165
else if (i2cAddress == I2C_CELLS) real0x3A = true ;
1166
+ else if (i2cAddress == I2C_REMOTE_ID) real0x27 = true ;
1138
1167
1139
1168
// Only Substiture AS3X/SAFE I2C_FLITECTRL packages, since they are constantly brodcast
1140
1169
if (i2cAddress != I2C_FLITECTRL) {
@@ -1146,13 +1175,23 @@ static uint8_t replaceForTestingPackage(const uint8_t *packet)
1146
1175
// return original packet
1147
1176
break ;
1148
1177
case 1 : // return GSP LOG
1178
+ if (!real0x27) {
1179
+ test27data_16[4 ]=test27data_16[4 ]+1 ;
1180
+ test27data_16[8 ]=test27data_16[8 ]+1 ;
1181
+ memcpy ((char *)packet + 2 , test27data_16, 16 );
1182
+ real0x16=true ; // disable test of regular GPS frames, and use the RemoteID
1183
+ }
1149
1184
if (!real0x16) {
1150
1185
test16data[4 ]=test16data[4 ]+1 ;
1151
1186
test16data[8 ]=test16data[8 ]+1 ;
1152
1187
memcpy ((char *)packet + 2 , test16data, 16 );
1153
1188
}
1154
1189
break ;
1155
1190
case 2 : // Return GPS STAT
1191
+ if (!real0x27) {
1192
+ memcpy ((char *)packet + 2 , test27data_17, 10 );
1193
+ real0x17=true ; // disable test of regular GPS frames, and use the RemoteID
1194
+ }
1156
1195
if (!real0x17) memcpy ((char *)packet + 2 , test17data, 10 );
1157
1196
break ;
1158
1197
case 3 : // Return Dual Bat monitor
0 commit comments