-
-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2188 from kellybyrd/krb/arduino_report_more_things
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
/* arduino-hid.c - subdriver to monitor Arduino USB/HID devices with NUT | ||
* | ||
* This was written assuming it would be used to communicate with code | ||
* using this Arduino library: https://github.com/abratchik/HIDPowerDevice | ||
* | ||
* Copyright (C) | ||
* 2003 - 2012 Arnaud Quette <[email protected]> | ||
* 2005 - 2006 Peter Selinger <[email protected]> | ||
* 2008 - 2009 Arjen de Korte <[email protected]> | ||
* 2013 Charles Lepple <[email protected]> | ||
* 2021 Alex Bratchik <[email protected]> | ||
* 2023 Kelly Byrd <[email protected]> | ||
* | ||
* Note: this subdriver was initially generated as a "stub" by the | ||
* gen-usbhid-subdriver script. It must be customized. | ||
|
@@ -32,7 +36,7 @@ | |
#include "main.h" /* for getval() */ | ||
#include "usb-common.h" | ||
|
||
#define ARDUINO_HID_VERSION "Arduino HID 0.2" | ||
#define ARDUINO_HID_VERSION "Arduino HID 0.21" | ||
/* FIXME: experimental flag to be put in upsdrv_info */ | ||
|
||
/* Arduino */ | ||
|
@@ -90,6 +94,37 @@ static hid_info_t arduino_hid2nut[] = { | |
{ "shutdown.stop", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, "-1", HU_TYPE_CMD, NULL }, | ||
{ "shutdown.reboot", 0, 0, "UPS.PowerSummary.DelayBeforeReboot", NULL, "10", HU_TYPE_CMD, NULL }, | ||
|
||
/* Battery */ | ||
{ "battery.type", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%s", HU_FLAG_STATIC, stringid_conversion}, | ||
/* In the sample for the Arduino library, this isn't a date */ | ||
/*{ "battery.mfr.date", 0, 0, "UPS.PowerSummary.iOEMInformation", NULL, "%s", HU_FLAG_STATIC, stringid_conversion},*/ | ||
{ "battery.voltage.nominal", 0, 0, "UPS.PowerSummary.ConfigVoltage", NULL, "%.2f", HU_FLAG_QUICK_POLL, NULL}, | ||
{ "battery.voltage", 0, 0, "UPS.PowerSummary.Voltage", NULL, "%.2f", HU_FLAG_QUICK_POLL, NULL}, | ||
{ "battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL}, | ||
{ "battery.runtime.low", 0, 0, "UPS.PowerSummary.RemainingTimeLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, | ||
/* Parse `*Capacity` values assuming `UPS.PowerSummary.CapacityMode` is set to 2, which means the `*Capacity` | ||
units are percent. The Arduino HID Powerdevice library is capable of doing other modes, if the Sketch wants | ||
to use them, but it appears most drivers just assume percent. | ||
*/ | ||
{ "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", 0, NULL }, | ||
{ "battery.charge.low", 0, 0, "UPS.PowerSummary.RemainingCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL}, | ||
{ "battery.charge.warning", 0, 0, "UPS.PowerSummary.WarningCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL}, | ||
|
||
/* USB HID PresentStatus Flags | ||
TODO: Parse these into battery.charger.status | ||
*/ | ||
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, online_info}, | ||
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, discharging_info}, | ||
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, charging_info}, | ||
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.NeedReplacement", NULL, NULL, 0, replacebatt_info}, | ||
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ShutdownImminent", NULL, NULL, 0, shutdownimm_info }, | ||
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit", NULL, NULL, HU_FLAG_QUICK_POLL, lowbatt_info }, | ||
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Overload", NULL, NULL, 0, overload_info }, | ||
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.RemainingTimeLimitExpired", NULL, NULL, 0, timelimitexpired_info }, | ||
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BatteryPresent", NULL, NULL, 0, nobattery_info }, | ||
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.FullyCharged", NULL, NULL, HU_FLAG_QUICK_POLL, fullycharged_info }, | ||
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.FullyDischarged", NULL, NULL, HU_FLAG_QUICK_POLL, depleted_info }, | ||
|
||
/* end of structure. */ | ||
{ NULL, 0, 0, NULL, NULL, NULL, 0, NULL } | ||
}; | ||
|