From f4f466d4ba7b196cc4a22e4a385e8562276341ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 4 Jan 2024 16:16:43 +0800 Subject: [PATCH] Battery: print serial number --- src/detection/battery/battery_bsd.c | 1 + src/modules/battery/battery.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/detection/battery/battery_bsd.c b/src/detection/battery/battery_bsd.c index 3edba2a62..cb1e3090e 100644 --- a/src/detection/battery/battery_bsd.c +++ b/src/detection/battery/battery_bsd.c @@ -39,6 +39,7 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* r ffStrbufInit(&battery->modelName); ffStrbufInit(&battery->status); ffStrbufInit(&battery->technology); + ffStrbufInit(&battery->serial); battery->capacity = battio.battinfo.cap; if(battio.battinfo.state == ACPI_BATT_STAT_INVALID) diff --git a/src/modules/battery/battery.c b/src/modules/battery/battery.c index 28d44679e..733983d20 100644 --- a/src/modules/battery/battery.c +++ b/src/modules/battery/battery.c @@ -6,7 +6,7 @@ #include "modules/battery/battery.h" #include "util/stringUtils.h" -#define FF_BATTERY_NUM_FORMAT_ARGS 7 +#define FF_BATTERY_NUM_FORMAT_ARGS 8 static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uint8_t index) { @@ -71,6 +71,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin {FF_FORMAT_ARG_TYPE_STRBUF, &result->status}, {FF_FORMAT_ARG_TYPE_DOUBLE, &result->temperature}, {FF_FORMAT_ARG_TYPE_UINT, &result->cycleCount}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->serial}, }); } } @@ -194,6 +195,7 @@ void ffGenerateBatteryJsonResult(FFBatteryOptions* options, yyjson_mut_doc* doc, yyjson_mut_obj_add_strbuf(doc, obj, "modelName", &battery->modelName); yyjson_mut_obj_add_strbuf(doc, obj, "status", &battery->status); yyjson_mut_obj_add_strbuf(doc, obj, "technology", &battery->technology); + yyjson_mut_obj_add_strbuf(doc, obj, "serial", &battery->serial); yyjson_mut_obj_add_real(doc, obj, "temperature", battery->temperature); yyjson_mut_obj_add_uint(doc, obj, "cycleCount", battery->cycleCount); } @@ -204,6 +206,7 @@ void ffGenerateBatteryJsonResult(FFBatteryOptions* options, yyjson_mut_doc* doc, ffStrbufDestroy(&battery->modelName); ffStrbufDestroy(&battery->technology); ffStrbufDestroy(&battery->status); + ffStrbufDestroy(&battery->serial); } } @@ -217,6 +220,7 @@ void ffPrintBatteryHelpFormat(void) "Battery status", "Battery temperature", "Battery cycle count", + "Battery serial number", }); }