Use permenant id for MSP_SET_MODE_RANGE.

This commit is contained in:
Dominic Clifton 2014-10-13 01:08:41 +01:00
parent c5280cd9d7
commit 59c55b4a19
1 changed files with 16 additions and 3 deletions

View File

@ -318,13 +318,26 @@ void serializeNames(const char *s)
serialize8(*c); serialize8(*c);
} }
const box_t *findBoxByActiveBoxId(uint8_t boxId) const box_t *findBoxByActiveBoxId(uint8_t activeBoxId)
{ {
uint8_t boxIndex; uint8_t boxIndex;
const box_t *candidate; const box_t *candidate;
for (boxIndex = 0; boxIndex < sizeof(boxes) / sizeof(box_t); boxIndex++) { for (boxIndex = 0; boxIndex < sizeof(boxes) / sizeof(box_t); boxIndex++) {
candidate = &boxes[boxIndex]; candidate = &boxes[boxIndex];
if (candidate->boxId == boxId) { if (candidate->boxId == activeBoxId) {
return candidate;
}
}
return NULL;
}
const box_t *findBoxByPermenantId(uint8_t permenantId)
{
uint8_t boxIndex;
const box_t *candidate;
for (boxIndex = 0; boxIndex < sizeof(boxes) / sizeof(box_t); boxIndex++) {
candidate = &boxes[boxIndex];
if (candidate->permanentId == permenantId) {
return candidate; return candidate;
} }
} }
@ -825,7 +838,7 @@ static bool processInCommand(void)
if (i < MAX_MODE_ACTIVATION_CONDITION_COUNT) { if (i < MAX_MODE_ACTIVATION_CONDITION_COUNT) {
modeActivationCondition_t *mac = &currentProfile->modeActivationConditions[i]; modeActivationCondition_t *mac = &currentProfile->modeActivationConditions[i];
i = read8(); i = read8();
const box_t *box = findBoxByActiveBoxId(i); const box_t *box = findBoxByPermenantId(i);
if (box) { if (box) {
mac->modeId = box->boxId; mac->modeId = box->boxId;
mac->auxChannelIndex = read8(); mac->auxChannelIndex = read8();