Fix for Ruuvi voltage parsing of RAWv2 format (#1267)

Power_info should be 2 bytes, so changed uint8 to uint16. With uint8 voltage is always reported to be near 1.6V.
This commit is contained in:
akoivist 2020-09-02 01:17:15 +03:00 committed by GitHub
parent 0918f452a0
commit e24d5c172f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -50,7 +50,7 @@ bool parse_ruuvi_data_byte(const esp32_ble_tracker::adv_data_t &adv_data, RuuviP
const float acceleration_y = (int16_t(data[8] << 8) + int16_t(data[9])) / 1000.0f;
const float acceleration_z = (int16_t(data[10] << 8) + int16_t(data[11])) / 1000.0f;
const uint8_t power_info = (data[12] << 8) | data[13];
const uint16_t power_info = (uint16_t(data[12] << 8) | data[13]);
const float battery_voltage = ((power_info >> 5) + 1600.0f) / 1000.0f;
const float tx_power = ((power_info & 0x1F) * 2.0f) - 40.0f;