From a336fb2acffde75990a1487c334bb97e6b46b734 Mon Sep 17 00:00:00 2001 From: Michael Keller Date: Tue, 29 Sep 2026 11:04:22 +1300 Subject: [PATCH] descriptor: make dc_filter_suunto descriptor-specific for each EON Steel model The filter previously ignored the descriptor parameter and checked USB HID PID or BLE name prefix against the entire family's combined list. This caused all four EON Steel descriptors (EON Steel, EON Core, D5, EON Steel Black) to match any Suunto EONSTEEL family device, preventing automatic model selection. Refactor to index each flat array by dc_descriptor_get_model(descriptor) so only the descriptor that corresponds to the connected device's USB PID or BLE name prefix matches. Unknown model numbers return 0 (no match). The two data arrays are left in the same form as upstream so that upstream additions of new models merge cleanly. This affects only the device selector presented to the user before a download begins. The import process itself is unchanged: the Suunto EON Steel driver echoes the descriptor model number back in DC_EVENT_DEVINFO, so the coarse-model refinement path in the consumer never fires, and the hw_id field is never populated, so the hw_id refinement path is also a no-op. A user who selects the correct model manually sees no difference in behaviour. The benefit is for automatic descriptor selection, which now returns exactly one match instead of four. Signed-off-by: Michael Keller --- src/descriptor.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/descriptor.c b/src/descriptor.c index 16c4c372..2c9c4ab0 100644 --- a/src/descriptor.c +++ b/src/descriptor.c @@ -770,10 +770,16 @@ dc_filter_suunto (const dc_descriptor_t *descriptor, dc_transport_t transport, c "EON Steel Black", }; + /* Both arrays are indexed by descriptor model number. + * Select only the entry for this specific descriptor. */ + unsigned int model = dc_descriptor_get_model (descriptor); + if (model >= C_ARRAY_SIZE (usbhid) || model >= C_ARRAY_SIZE (bluetooth)) + return 0; + if (transport == DC_TRANSPORT_USBHID) { - return DC_FILTER_INTERNAL (userdata, usbhid, 0, dc_match_usbhid); + return dc_match_usbhid (userdata, &usbhid[model]); } else if (transport == DC_TRANSPORT_BLE) { - return DC_FILTER_INTERNAL (userdata, bluetooth, 0, dc_match_prefix); + return dc_match_prefix (userdata, &bluetooth[model]); } return 1;