Added LIPO 2 Reading
This commit is contained in:
+6
-10
@@ -33,18 +33,14 @@ static bool append_battery_sample(alox_BatteryStatusResponse *resp,
|
||||
return lipo1_valid || lipo2_valid;
|
||||
}
|
||||
|
||||
static bool append_master_cached(alox_BatteryStatusResponse *resp) {
|
||||
static bool append_master_sample(alox_BatteryStatusResponse *resp) {
|
||||
board_lipo_reading_t reading;
|
||||
uint32_t age_ms = 0;
|
||||
|
||||
if (!client_registry_get_master_battery(&reading, &age_ms)) {
|
||||
board_input_read_lipo(&reading);
|
||||
client_registry_set_master_battery(&reading);
|
||||
age_ms = 0;
|
||||
}
|
||||
board_input_read_lipo(&reading);
|
||||
client_registry_set_master_battery(&reading);
|
||||
|
||||
return append_battery_sample(resp, 0, reading.lipo1_valid, reading.lipo1_mv,
|
||||
reading.lipo2_valid, reading.lipo2_mv, age_ms);
|
||||
reading.lipo2_valid, reading.lipo2_mv, 0);
|
||||
}
|
||||
|
||||
static bool append_slave_cached(alox_BatteryStatusResponse *resp,
|
||||
@@ -102,7 +98,7 @@ static void handle_battery_status(const uint8_t *data, size_t len) {
|
||||
bool any = false;
|
||||
|
||||
if (req.all_clients) {
|
||||
any |= append_master_cached(resp);
|
||||
any |= append_master_sample(resp);
|
||||
for (size_t i = 0; i < client_registry_count(); i++) {
|
||||
const client_info_t *client = client_registry_at(i);
|
||||
if (client == NULL) {
|
||||
@@ -113,7 +109,7 @@ static void handle_battery_status(const uint8_t *data, size_t len) {
|
||||
ESP_LOGI(TAG, "battery cache all_clients → %u samples",
|
||||
(unsigned)resp->samples_count);
|
||||
} else if (req.client_id == 0) {
|
||||
any = append_master_cached(resp);
|
||||
any = append_master_sample(resp);
|
||||
ESP_LOGI(TAG, "battery cache master");
|
||||
} else {
|
||||
const client_info_t *client = client_registry_find_by_id(req.client_id);
|
||||
|
||||
Reference in New Issue
Block a user