Merged
Conversation
Implement Nordic Thingy:52 support with vendor characteristic adapters Co-authored-by: RonanB96 <22995167+RonanB96@users.noreply.github.com>
Co-authored-by: RonanB96 <22995167+RonanB96@users.noreply.github.com>
- Create thingy52_bluepy.py with full BluePy integration - Implement Thingy52 class for device connection and reading - Add CLI with flexible sensor selection and continuous reading - Fix bot review comments (duplicate comment, long line formatting) - Update README with BluePy usage instructions Addresses user feedback: now supports real device connection, not just mock data Co-authored-by: RonanB96 <22995167+RonanB96@users.noreply.github.com>
- Create custom characteristic classes extending CustomBaseCharacteristic - Register with CharacteristicRegistry using translator.register_custom_characteristic_class() - Implement ConnectionManagerProtocol for BluePy integration - Use Device class for unified SIG + vendor characteristic access - Add comprehensive tests (26 tests, all passing) - Demonstrates proper library extension, not bypassing it Files: - examples/thingy52_characteristics.py: 8 custom characteristic classes - examples/thingy52_example.py: Real device example using Device class - tests/integration/test_thingy52_characteristics.py: Comprehensive tests Co-authored-by: RonanB96 <22995167+RonanB96@users.noreply.github.com>
…ec.Struct, reusable BluePy adapter Major improvements addressing all feedback: 1. Use templates: Sint8Template, Uint8Template, Uint16Template, Uint32Template instead of struct.unpack 2. Use DataParser.parse_int32() instead of struct.unpack for heading 3. Use proper exceptions: InsufficientDataError, ValueRangeError from bluetooth_sig.gatt.exceptions 4. Use msgspec.Struct: ThingyGasData, ThingyColorData for structured returns (no raw dict) 5. Create reusable BluePy adapter: examples/connection_managers/bluepy.py (follows bleak/simpleble pattern) 6. Address all 27 bot review comments: proper exceptions, msgspec structs, correct docstrings Files: - examples/connection_managers/bluepy.py: Reusable BluePy connection manager (NEW) - examples/thingy52_characteristics.py: 8 characteristics using templates & proper patterns - examples/thingy52_example.py: Real device example using reusable BluePy adapter - tests/integration/test_thingy52_characteristics.py: 26 tests, all passing Quality gates: ✅ ALL PASSING (ruff, pylint, mypy, shellcheck, pydocstyle, 26 tests) Co-authored-by: RonanB96 <22995167+RonanB96@users.noreply.github.com>
…classes BREAKING CHANGE: CharacteristicData moved from types to gatt.characteristics.base Major Changes: - Move CharacteristicData to gatt.characteristics.base with back-reference to characteristic - Remove properties field from CharacteristicInfo (now runtime attribute on BaseCharacteristic) - Extract CustomBaseCharacteristic to gatt.characteristics.custom module - Extract UnknownCharacteristic to gatt.characteristics.unknown module - Add CustomBaseGattService in gatt.services.custom module - Add UnknownService in gatt.services.unknown module - Create descriptor_utils.py module with helper functions - Add location.py types module for PositionStatus enum - Add last_parsed attribute to BaseCharacteristic for result caching - Remove descriptor_data parameter from CharacteristicData constructor Architecture: - CharacteristicData now stores characteristic reference instead of CharacteristicInfo - Properties are discovered at runtime from actual devices, not YAML specs - Cleaner separation between SIG characteristics, custom, and unknown types - Descriptor utilities extracted for reusability - Registry validation skips base classes via _is_base_class flag API Changes: - CharacteristicDataProtocol updated with property accessors - DeviceService.characteristics now stores BaseCharacteristic instances - parse_characteristic no longer accepts descriptor_data parameter - Custom characteristics support auto_register parameter (defaults True) Testing: - Update all imports from types.CharacteristicData to gatt.characteristics.base - Fix test mocks to use UnknownCharacteristic for test data - Remove properties from CharacteristicInfo in test fixtures - Update examples and integration tests Benefits: - Single source of truth: characteristic owns its last parsed result - Type safety: CharacteristicData always linked to parsing characteristic - Cleaner module organization with focused responsibilities - Better support for runtime device discovery patterns - Simplified descriptor access through utility functions
bfaa01f to
69a54f9
Compare
…ED_* variables and UUIDs; add code block tests for docs; improve enum-based workflows and test coverage; clarify standards compliance in examples
69a54f9 to
d2d50eb
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request primarily improves documentation and usage clarity for the Bluetooth SIG Python library, focusing on making BLE integration and characteristic parsing easier to understand for users. It introduces simulated data examples across guides and API docs, clarifies best practices and prohibited implementation patterns, and simplifies async usage by consolidating the API to a single
BluetoothSIGTranslatorclass for both sync and async methods. The changes also enhance explanations around UUID handling and parsing, making it clear that users do not need to know characteristic meanings in advance.Documentation and Usage Example Improvements:
SIMULATED_BATTERY_DATA, etc.), making it clear how to replace these with actual BLE reads in real-world scenarios. This change affectsREADME.md,docs/api/core.md,docs/api/gatt.md, and async usage guides. [1] [2] [3] [4] [5] [6]bluetooth-sigautomatically identifies and parses them, removing the need for users to understand UUID meanings.Async API Simplification:
AsyncBluetoothSIGTranslatorclass, consolidating all async and sync methods intoBluetoothSIGTranslatorfor a simpler, unified API. All async usage examples and migration notes have been updated accordingly. [1] [2] [3]Python Implementation Guidelines Update:
.github/instructions/python-implementation.instructions.md. This section now includes additional forbidden patterns and clarifies type safety requirements. [1] [2]Linting and Quality Gate Clarifications:
.github/copilot-instructions.mdprohibiting the use of grep/tail on linter output for performance reasons, and clarified linting workflow expectations.Minor Documentation Corrections: