Skip to content

drivers: Standardize device identification to device_id().#142

Merged
nedseb merged 2 commits intomainfrom
fix/standardize-device-id
Mar 15, 2026
Merged

drivers: Standardize device identification to device_id().#142
nedseb merged 2 commits intomainfrom
fix/standardize-device-id

Conversation

@nedseb
Copy link
Copy Markdown
Contributor

@nedseb nedseb commented Mar 15, 2026

Closes #77

Summary

Standardize all device identification methods to device_id(), consistent with WSEN-HIDS and WSEN-PADS which already use this name.

Driver Before After
hts221 who_am_i() device_id()
ism330dl who_am_i() device_id()
lis2mdl read_who_am_i() device_id()
vl53l1x read_model_id() device_id()
bq27441 device_type() device_id()
apds9960 (none) device_id() added
wsen-hids device_id() (unchanged)
wsen-pads device_id() (unchanged)

Drivers without an ID register (MCP23009E, SSD1327) are not concerned.

Also updated README to document the device_id() convention.

Test plan

ruff check lib/                          # All checks passed
python3 -m pytest tests/ -k "mock" -v    # 99 passed

@nedseb nedseb force-pushed the fix/standardize-device-id branch from f2a0060 to b1705b6 Compare March 15, 2026 08:11
@nedseb nedseb requested a review from Copilot March 15, 2026 08:11
@nedseb nedseb self-assigned this Mar 15, 2026
@nedseb nedseb added the enhancement New feature or request label Mar 15, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Standardizes device identification APIs across multiple I2C drivers by introducing/renaming to a common device_id() method, and updates scenario tests and documentation to use the unified interface.

Changes:

  • Rename per-driver ID methods (e.g., who_am_i(), read_who_am_i(), read_model_id(), device_type()) to device_id() across several drivers.
  • Update YAML scenario tests (mock + hardware) and an example script to call device_id().
  • Document the device_id() convention in the root README and add device_id() to the APDS9960 driver.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tests/scenarios/vl53l1x.yaml Updates identity check to call device_id()
tests/scenarios/lis2mdl.yaml Updates WHO_AM_I checks/scripts to call device_id()
tests/scenarios/ism330dl.yaml Updates WHO_AM_I method call to device_id()
tests/scenarios/hts221.yaml Updates WHO_AM_I method call to device_id()
README.md Documents repo-wide device_id() convention for drivers
lib/vl53l1x/vl53l1x/device.py Renames read_model_id() to device_id() and updates init check
lib/lis2mdl/lis2mdl/device.py Renames read_who_am_i() to device_id()
lib/lis2mdl/examples/magnet_test.py Updates example to call device_id()
lib/ism330dl/ism330dl/device.py Renames who_am_i() to device_id() and updates device check
lib/hts221/hts221/device.py Renames who_am_i() to device_id()
lib/bq27441/bq27441/device.py Renames device_type() to device_id() and updates validity check
lib/apds9960/apds9960/device.py Adds device_id() helper method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/vl53l1x/vl53l1x/device.py
Comment thread lib/lis2mdl/lis2mdl/device.py
Comment thread lib/ism330dl/ism330dl/device.py
Comment thread lib/hts221/hts221/device.py
Comment thread lib/bq27441/bq27441/device.py
Comment thread lib/apds9960/apds9960/device.py Outdated
Comment thread lib/apds9960/apds9960/device.py Outdated
@nedseb nedseb merged commit 50e2ec0 into main Mar 15, 2026
3 checks passed
@nedseb nedseb deleted the fix/standardize-device-id branch March 15, 2026 09:28
@semantic-release-updater
Copy link
Copy Markdown

🎉 This PR is included in version 0.0.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

enhancement New feature or request released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

drivers: Standardize device identification method naming.

2 participants