module/battery: initialize state in constructor

This commit is contained in:
Daniel Eklöf 2019-01-13 15:08:09 +01:00
parent f04ff31d0f
commit 65cfcfb2de

View file

@ -332,9 +332,17 @@ battery_new(const char *battery, struct particle *label, int poll_interval_secs)
m->label = label;
m->poll_interval = poll_interval_secs;
m->battery = strdup(battery);
m->manufacturer = NULL;
m->model = NULL;
m->energy_full_design = 0;
m->energy_full = 0;
m->state = STATE_DISCHARGING;
m->capacity = 0;
m->energy = 0;
m->power = 0;
struct module *mod = module_common_new();
mod->private = m;
mod->run = &run;