Rework DSM2/X support, auto protocol selection for DSM2
Support more than 31 protocols for the multi module. Breaks existing multi eeproms, need to reselect protocols
This commit is contained in:
@@ -331,47 +331,39 @@ void processSpektrumPacket(const uint8_t *packet)
|
||||
6 1 byte -> RX version but you don't care...
|
||||
7 1 byte -> number of channels, example 0x06=6 channels
|
||||
8 1 byte -> max DSM type allowed:
|
||||
0x01 =>22ms 1024 DSM2 1 packet => number of channels is <8 and no telemetry
|
||||
0x01 => 22ms 1024 DSM2 1 packet => number of channels is <8 and no telemetry
|
||||
0x02 => 22ms 1024 DSM2 2 packets => either a number of channel >7 or telemetry enable RX
|
||||
0x12 => 11ms 2048 DSM2 2 packets => can be any number of channels with/without telemetry -> this mode might be supported following Mike's trials, note the channels should be duplicated between the packets which is not the case today
|
||||
0xa2 => 22ms 2048 DSMX 1 packet => number of channels is <8 and no telemetry
|
||||
0xb2 => 11ms 2048 DSMX => can be any number of channels with/without telemetry -> this mode is only half supported since the channels should be duplicated between the packets which is not the case but might be supported following Mike's trials
|
||||
9 0x00: not sure of the use of this byte since I've always seen it at 0...
|
||||
10 2 bytes CRC but you don't care as I've checked it already...
|
||||
|
||||
Examples: DSM #Chan RXver
|
||||
Inductrix 0xa2 07 1
|
||||
LemonRX+Sat+tele 0xb2 07 1
|
||||
|
||||
*/
|
||||
void processDSMBindPacket(const uint8_t *packet)
|
||||
{
|
||||
uint32_t debugval;
|
||||
if (g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_MULTIMODULE && g_model.moduleData[EXTERNAL_MODULE].subType == MM_RF_PROTO_DSM2
|
||||
if (g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_MULTIMODULE && g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol() == MM_RF_PROTO_DSM2
|
||||
&& g_model.moduleData[EXTERNAL_MODULE].multi.autoBindMode) {
|
||||
|
||||
int channels = packet[7];
|
||||
// Only sets channel etc when in DSM multi mode
|
||||
g_model.moduleData[EXTERNAL_MODULE].channelsCount = channels - 8;
|
||||
if (packet[8] & 0xa0) {
|
||||
g_model.moduleData[EXTERNAL_MODULE].subType = MM_RF_DSM2_SUBTYPE_DSMX;
|
||||
} else {
|
||||
g_model.moduleData[EXTERNAL_MODULE].subType = MM_RF_DSM2_SUBTYPE_DSM2;
|
||||
}
|
||||
|
||||
bool use11ms = false;
|
||||
// 11ms mode (and less than 8 channels since more channels don't worke with 11ms for now
|
||||
if ((packet[8] & 0x10) && (channels < 8)) {
|
||||
use11ms = true;
|
||||
}
|
||||
// bool use11ms = (packet[8] & 0x10) ;
|
||||
if (packet[8] >= 0xb2)
|
||||
g_model.moduleData[EXTERNAL_MODULE].subType = MM_RF_DSM2_SUBTYPE_DSMX_11;
|
||||
else if (packet[8] >= 0xa2)
|
||||
g_model.moduleData[EXTERNAL_MODULE].subType = MM_RF_DSM2_SUBTYPE_DSMX_22;
|
||||
else if (packet[8] >= 0x12)
|
||||
g_model.moduleData[EXTERNAL_MODULE].subType = MM_RF_DSM2_SUBTYPE_DSM2_11;
|
||||
else
|
||||
g_model.moduleData[EXTERNAL_MODULE].subType = MM_RF_DSM2_SUBTYPE_DSM2_22;
|
||||
|
||||
// 4 - 7 => 4-7 ch @ 11ms
|
||||
if (use11ms) {
|
||||
g_model.moduleData[EXTERNAL_MODULE].multi.optionValue = limit(4, channels, 7);
|
||||
} else {
|
||||
if (channels <= 7) {
|
||||
// 0 -3 => 4-7 ch @ 22ms
|
||||
g_model.moduleData[EXTERNAL_MODULE].multi.optionValue = limit(0, channels - 4, 3);
|
||||
} else {
|
||||
// 8 - 12 => 8-12 ch @ 22ms
|
||||
g_model.moduleData[EXTERNAL_MODULE].multi.optionValue = limit(8, channels, 12);
|
||||
}
|
||||
}
|
||||
storageDirty(EE_MODEL);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user