Repository: pwr-Solaar/Solaar

Issue:
Power management support for G535 headset
**Information**
- Solaar version: 1.1.8
- Distribution: Ubuntu 22.04


Currently there's no support for setting the power management setting for headsets (at least for the Logitech G535)
It controls when the headset turns itself off after loosing the connection to the usb receiver (usually after turning off the pc)
![grafik](https://user-images.githubusercontent.com/52620063/210227380-cca26a55-bea8-426a-9145-732119c96cfe.png)
![grafik](https://user-images.githubusercontent.com/52620063/210227404-79183f75-ca8e-4f5e-951c-3fc38327293c.png)

Here are two wireshark captures using the G Hub software under Windows:
- Setting power management to 1 minute: [1minute.pcapng.gz](https://github.com/pwr-Solaar/Solaar/files/10331327/1minute.pcapng.gz)
-  Setting power management to never, cycling through all settings and setting it to never: [pm_loop.pcapng.gz](https://github.com/pwr-Solaar/Solaar/files/10331336/pm_loop.pcapng.gz)

If something else is needed please let me know.


Discussion:
This looks like something that Solaar might be able to do.   The relevant part of the communication appears to be using an HID++ message, but one that I do not have documentation for.  If you capture interactions for all the values it might be possible to write code for a Solaar setting for this.
Ooops I was looking at only the first capture.  I see you provided them all.
If you are using this headset under Linux is would be useful to see what values are possible for this function.    Solaar has a tool to send HID++ commands to devices which is available if you clone Solaar from this repository.

Find out the hidraw node for the headset.  Solaar shows this in the detailed information pane - click on the information or lightbulb button.

From the Solaar repository clone run `./tools/hidconsole /dev/hidrawN` for the appropriate N.  The send commands like
```
11 ff 05 2b XX 000000000000000000000000000000
```
for XX ranging from 00 up to 1e and beyond until you get uniform responses that have 05 in the fourth byte instead of the third.   (These are error responses - normal responses will have the 05 in the third byte.)  

Post the result.



Resolving patch:
diff --git a/lib/logitech_receiver/settings_templates.py b/lib/logitech_receiver/settings_templates.py
--- a/lib/logitech_receiver/settings_templates.py
+++ b/lib/logitech_receiver/settings_templates.py
@@ -1192,6 +1192,18 @@ def build(cls, setting_class, device):
             return cls(map, min_value=dbMin, max_value=dbMax, count=count, write_prefix_bytes=b'\x02')
 
 
+class ADCPower(_Setting):
+    name = 'adc_power_management'
+    label = _('Power Management')
+    description = _('Power off in minutes (0 for never).')
+    feature = _F.ADC_MEASUREMENT
+    rw_options = {'read_fnid': 0x10, 'write_fnid': 0x20}
+    validator_class = _RangeV
+    min_value = 0x00
+    max_value = 0xff
+    validator_options = {'byte_count': 1}
+
+
 SETTINGS = [
     RegisterHandDetection,  # simple
     RegisterSmoothScroll,  # simple
@@ -1236,6 +1248,7 @@ def build(cls, setting_class, device):
     Gesture2Params,  # working
     Sidetone,
     Equalizer,
+    ADCPower,
 ]
 
 #


Test patch: