From 59c55b4a19fac71b2a0376c8a9b9ce99c75b88a9 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Mon, 13 Oct 2014 01:08:41 +0100 Subject: [PATCH] Use permenant id for MSP_SET_MODE_RANGE. --- src/main/io/serial_msp.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/io/serial_msp.c b/src/main/io/serial_msp.c index 1c8c0604e3..6d1d484fcf 100755 --- a/src/main/io/serial_msp.c +++ b/src/main/io/serial_msp.c @@ -318,13 +318,26 @@ void serializeNames(const char *s) serialize8(*c); } -const box_t *findBoxByActiveBoxId(uint8_t boxId) +const box_t *findBoxByActiveBoxId(uint8_t activeBoxId) { uint8_t boxIndex; const box_t *candidate; for (boxIndex = 0; boxIndex < sizeof(boxes) / sizeof(box_t); 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; } } @@ -825,7 +838,7 @@ static bool processInCommand(void) if (i < MAX_MODE_ACTIVATION_CONDITION_COUNT) { modeActivationCondition_t *mac = ¤tProfile->modeActivationConditions[i]; i = read8(); - const box_t *box = findBoxByActiveBoxId(i); + const box_t *box = findBoxByPermenantId(i); if (box) { mac->modeId = box->boxId; mac->auxChannelIndex = read8();