Skip to content

Commit

Permalink
add eaton_abm_charger_type_fun()
Browse files Browse the repository at this point in the history
Signed-off-by: DaRK AnGeL <[email protected]>
  • Loading branch information
masterwishx committed Oct 18, 2024
1 parent a1fc115 commit e2d560d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions drivers/mge-hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ static char mge_scratch_buf[20];
#define ABM_ENABLED 1
/* Same as above but for 9E Models that using "x.ChargerType" instead and other units that has ABM when x.ChargerType = 4 */
#define ABM_ENABLED_TYPE 4
/* Define if we have battery.charger.type for 9E Models and others */
#define ABM_CHARGER_NO_TYPE -1
#define ABM_CHARGER_TYPE 5

/* Internal flag to process battery status (CHRG/DISCHRG) and ABM */
static int advanced_battery_type = ABM_CHARGER_NO_TYPE;

/* Internal flag to process battery status (CHRG/DISCHRG) and ABM */
static int advanced_battery_monitoring = ABM_UNKNOWN;
Expand Down Expand Up @@ -227,7 +233,9 @@ static const char *eaton_abm_enabled_fun(double value)
{
advanced_battery_monitoring = value;

if (dstate_getinfo("battery.charger.type"))
advanced_battery_type = value;

if (advanced_battery_monitoring == ABM_ENABLED_TYPE)
{
upsdebugx(2, "ABM is %s", (advanced_battery_monitoring == 4) ? "enabled" : "disabled");
}
Expand Down Expand Up @@ -275,7 +283,7 @@ static const char *eaton_abm_status_fun(double value)

upsdebugx(2, "ABM numeric status: %i", (int)value);

if (dstate_getinfo("battery.charger.type"))
if (advanced_battery_monitoring == ABM_ENABLED_TYPE)
{
switch ((long)value)
{
Expand Down Expand Up @@ -347,6 +355,9 @@ static const char *eaton_abm_charger_type_fun(double value)

return "ABM";
}

// Handle the case when value is not equal to ABM_ENABLED_TYPE
return NULL; // or some other appropriate action
};

static info_lkp_t eaton_charger_type_info[] = {
Expand All @@ -366,7 +377,7 @@ static const char *eaton_abm_chrg_dischrg_fun(double value)
if (advanced_battery_monitoring == ABM_DISABLED)
return NULL;

if (dstate_getinfo("battery.charger.type"))
if (advanced_battery_monitoring == ABM_ENABLED_TYPE)
{
switch ((long)value)
{
Expand Down

0 comments on commit e2d560d

Please sign in to comment.