diff --git a/src/devices/arexx_ml.c b/src/devices/arexx_ml.c index e09f67b89..aee2681d1 100644 --- a/src/devices/arexx_ml.c +++ b/src/devices/arexx_ml.c @@ -105,41 +105,37 @@ static int arexx_ml_decode(r_device *decoder, bitbuffer_t *bitbuffer) int sens_val = (b[3] << 8) | (b[4]); // big-endian? // Decode readings - float temp_c = 0.0, humidity = 0.0; - int is_humi = 0, is_temp = 0, is_alert = 0, temp_alert = 0; - - switch (msg_len) { - case 5: - if ((id & 0xF000) == 0x2000) { - // temperature reading from TL-3TSN, TSN-33MN, etc. - is_temp = 1; - temp_c = (int16_t)sens_val * 0.0078125f; - } - else if ((id & 0xF001) == 0x4000) { - // temperature reading from TSN-TH70E, IP-TH70EXT, etc. - is_temp = 1; - // SHT10 Temperature - temp_c = sens_val * 0.01f - 40.0f; // offset actually varies by Vdd - } - else if ((id & 0xF001) == 0x4001) { - // humidity reading from TSN-TH70E, IP-TH70EXT, etc. - is_humi = 1; - sens_val = (int16_t)sens_val; - // SHT10 Humidity - humidity = -2.0468 + 0.0367 * sens_val - 1.5955E-6 * sens_val * sens_val; - } - break; - - case 6: + float temp_c = 0.0; + float humidity = 0.0; + int is_humi = 0; + int is_temp = 0; + int is_alert = 0; + int temp_alert = 0; + + if (msg_len == 5 && (id & 0xF000) == 0x2000) { + // temperature reading from TL-3TSN, TSN-33MN, etc. + is_temp = 1; + temp_c = (int16_t)sens_val * 0.0078125f; + } + else if (msg_len == 5 && (id & 0xF001) == 0x4000) { + // temperature reading from TSN-TH70E, IP-TH70EXT, etc. + is_temp = 1; + // SHT10 Temperature + temp_c = sens_val * 0.01f - 40.0f; // offset actually varies by Vdd + } + else if (msg_len == 5 && (id & 0xF001) == 0x4001) { + // humidity reading from TSN-TH70E, IP-TH70EXT, etc. + is_humi = 1; + sens_val = (int16_t)sens_val; + // SHT10 Humidity + humidity = -2.0468 + 0.0367 * sens_val - 1.5955E-6 * sens_val * sens_val; + } + else if (msg_len == 6) { is_temp = is_alert = 1; // MCP9808 Ambient Temperature Register "5-4": temp_alert = (sens_val >> 13) & 7; int temp_raw = (int16_t)(sens_val << 3); // uses sign-extend temp_c = temp_raw / 128; - break; - - default: - break; // Will report raw result only } /* clang-format off */