Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Conversation

@hughsie
Copy link
Member

@hughsie hughsie commented Jan 8, 2026

Type of pull request:

@hughsie
Copy link
Member Author

hughsie commented Jan 8, 2026

@lenovo-li I've done quite a few fixups -- I really hope I've not broken anything -- apologies if so.

@hughsie hughsie requested a review from lenovo-li January 8, 2026 14:32
@hughsie hughsie self-assigned this Jan 8, 2026
@hughsie hughsie added needs-emulation Needs an emulation for CI before it can be merged enhancement labels Jan 8, 2026
@hughsie
Copy link
Member Author

hughsie commented Jan 8, 2026

@lenovo-li maybe it's obvious to say but please just commit fixes to the lenovo-li/lenovo-accessory branch on origin -- there's no need to do a new PR to merge fixes.

@hughsie
Copy link
Member Author

hughsie commented Jan 8, 2026

@lenovo-li and if you want to send me hardware in the UK to help test this (or to generate the emulation) that's totally fine too -- just email me and I'll share my postal address with you. 100% okay if you don't want (or can't) do this. :)

@lenovo-li
Copy link
Collaborator

Hi @hughsie,

Thank you so much for your kind offer to help with testing and emulation! We truly appreciate you taking the extra time to support this plugin.

I've consulted with my supervisor, and we'd be happy to send you the hardware! Please send your postal address to my email ([email protected]), and I will arrange the shipment as soon as possible.

I will also push the code fixes (README updates, udev removal, GET/SET macro fix, and the enum/address cleanups we discussed) to this branch shortly. Thanks again for your guidance!

@hughsie
Copy link
Member Author

hughsie commented Jan 9, 2026

@lenovo-li yell when you've pushed your changes -- I think there's quite a bit simplification if we use a GObject interface -- i.e. the only difference between fu_lenovo_accessory_ble_*() and fu_lenovo_accessory_hid_*() is the message processing; the request and responses look the same. I'm happy to do this, but I don't want to clash with your changes.

- Add necessary enumeration data for the protocol.
- Update README.md to detail HID (single-bank) and BLE (dual-bank) update behaviors.
- Remove redundant USB subsystem restriction from the quirk file.
- Fix command direction for DFU attribute retrieval.
@lenovo-li
Copy link
Collaborator

@hughsie I've pushed the updates to the branch.

Regarding your plan to use a GObject interface, I would truly appreciate your help with that! To be honest, I'm not yet very proficient with GObject, and I was worried my implementation might be a bit messy. Thank you so much for taking the time to refactor and simplify the code!
Ready for your further review!

@hughsie
Copy link
Member Author

hughsie commented Jan 12, 2026

@lenovo-li I've split it out as an interface as we talked about and I think it's a lot cleaner. The BLE and HID devices now implement FuLenovoAccessoryImplInterface which has ->read(), ->write() and ->process() optional vfuncs. All the common code is now in fu-lenovo-accessory-impl.c

I wasn't sure if fu_lenovo_accessory_impl_get_mode() was needed -- it looks unused now perhaps. I've also simplified how you were constructing the HID Set/Get reports -- i.e. only putting the protocol payload data in the .rs file structs and hardcoding the reportid in the code.

It's highly likely I've broken this on real hardware, and apologies if so :) Once this plugin has an emulation recorded and uploaded to the LVFS (which I can do for you if required...) I'd be happy to approve merging.

Comment on lines 64 to 68
static gboolean
fu_lenovo_accessory_hid_device_probe(FuDevice *device, GError **error)
{
return TRUE;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove this -- or do you need to skip the parent fu_hidraw_device_setup() from running? I think removing the ->_probe() completely would populate more (helpful) properties from FuHidrawDevice.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pointer! I will remove the ->probe() implementation as suggested to allow the parent fu_hidraw_device_setup() to run and populate the properties correctly.

- ble-device: Add notes regarding CRC discrepancy between stream and GBytes methods

- hid-device: Remove probe function

- rust: Ensure FuStructLenovoAccessoryCmd remains 6 bytes per protocol
@lenovo-li
Copy link
Collaborator

@hughsie Regarding fu_lenovo_accessory_impl_get_mode(), I added this interface because I anticipate we will need it in the future to determine the device's state—specifically, whether it is currently in firmware update (FW) mode or normal operational mode. I'd prefer to keep it for now as a placeholder for that functionality.

@hughsie
Copy link
Member Author

hughsie commented Jan 13, 2026

because I anticipate we will need it in the future to determine the device's state

Should we do this in FuLenovoAccessoryHidDevice->setup or FuLenovoAccessoryBleDevice->setup perhaps?

@lenovo-li
Copy link
Collaborator

I don't think we need to add it there. The HID device is already in the bootloader state when in DFU mode, so it behaves as a separate device entity. Also, for BLE devices, the fu_lenovo_accessory_impl_get_mode command isn't supported yet.

@lenovo-li
Copy link
Collaborator

Hi,@hughsie
Thanks a lot for taking the time to refactor the code! The new interface approach looks much cleaner indeed.
I've finished polishing the remaining details based on your changes and have verified it on real hardware—firmware updates are working successfully now.
Please let me know if there’s anything else I should focus on or if you have further guidance.
Thanks again for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement needs-emulation Needs an emulation for CI before it can be merged

Development

Successfully merging this pull request may close these issues.

4 participants