mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 00:39:50 +03:00
fix ems line quality calculation
This commit is contained in:
@@ -218,7 +218,11 @@ class RxService : public EMSbus {
|
||||
if (telegram_error_count_ == 0) {
|
||||
return 100; // all good, 100%
|
||||
}
|
||||
if (telegram_error_count_ >= telegram_count_) {
|
||||
return 100;
|
||||
}
|
||||
uint8_t q = ((float)telegram_error_count_ / telegram_count_ * 100);
|
||||
|
||||
return (q <= EMS_BUS_QUALITY_RX_THRESHOLD ? 100 : 100 - q);
|
||||
}
|
||||
|
||||
@@ -308,6 +312,9 @@ class TxService : public EMSbus {
|
||||
if (telegram_fail_count_ == 0) {
|
||||
return 100; // all good, 100%
|
||||
}
|
||||
if (telegram_fail_count_ >= telegram_read_count_) {
|
||||
return 100;
|
||||
}
|
||||
return (100 - (uint8_t)(((float)telegram_fail_count_ / telegram_read_count_ * 100)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user