Commit 9a45d3d0 authored by Christian Kellner's avatar Christian Kellner Committed by Christian Kellner
Browse files

gbb info: report the name of batteries

parent 631998da
......@@ -36,6 +36,7 @@ static GOptionEntry info_options[] =
static void
info_txt_battery(GbbBattery *bat, const char *prefix)
{
g_autofree char *name = NULL;
g_autofree char *vendor = NULL;
g_autofree char *model = NULL;
double volt_design;
......@@ -43,6 +44,7 @@ info_txt_battery(GbbBattery *bat, const char *prefix)
double energy_full_design;
g_object_get(bat,
"name", &name,
"vendor", &vendor,
"model", &model,
"voltage-design", &volt_design,
......@@ -51,6 +53,7 @@ info_txt_battery(GbbBattery *bat, const char *prefix)
NULL);
g_print("%s Battery:\n", prefix);
g_print("%s Name: %s\n", prefix, name);
g_print("%s Vendor: %s\n", prefix, vendor);
g_print("%s Model: %s\n", prefix, model);
g_print("%s Voltage Design: %5.2f V\n", prefix, volt_design);
......
......@@ -601,6 +601,7 @@ gbb_system_info_to_json (const GbbSystemInfo *info, JsonBuilder *builder)
json_builder_begin_array(builder);
for (int i = 0; i < info->batteries->len; i++) {
GbbBattery *bat = g_ptr_array_index(info->batteries, i);
g_autofree char *name = NULL;
g_autofree char *vendor = NULL;
g_autofree char *model = NULL;
double volt_design;
......@@ -608,6 +609,7 @@ gbb_system_info_to_json (const GbbSystemInfo *info, JsonBuilder *builder)
double energy_full_design;
g_object_get(bat,
"name", &name,
"vendor", &vendor,
"model", &model,
"voltage-design", &volt_design,
......@@ -616,6 +618,10 @@ gbb_system_info_to_json (const GbbSystemInfo *info, JsonBuilder *builder)
NULL);
json_builder_begin_object(builder);
json_builder_set_member_name(builder, "name");
json_builder_add_string_value(builder, name);
json_builder_set_member_name(builder, "vendor");
json_builder_add_string_value(builder, vendor);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment