mirror of
https://github.com/cagnulein/qdomyos-zwift.git
synced 2026-02-17 16:07:43 +01:00
Add KS-NG- Bluetooth device support for Kingsmith X218 treadmill (#4301)
This commit is contained in:
51
CLAUDE.md
51
CLAUDE.md
@@ -98,6 +98,57 @@ The application follows a hierarchical device architecture:
|
||||
4. Update `qdomyos-zwift.pri` with new source files
|
||||
5. Add tests in `tst/Devices/` following existing patterns
|
||||
|
||||
### Adding Device Detection to bluetooth.cpp
|
||||
|
||||
**CRITICAL: Always verify device pattern conflicts before adding to bluetooth.cpp**
|
||||
|
||||
When adding a new device pattern to `src/devices/bluetooth.cpp`, you **MUST** follow these verification steps:
|
||||
|
||||
1. **Search for Similar Patterns**: Use grep/search to find all existing device patterns that might conflict
|
||||
- Search for device name prefixes (e.g., if adding "KS-NG-", search for all "KS-" patterns)
|
||||
- Check patterns in all device type cases (bikes, treadmills, ellipticals, rowers, etc.)
|
||||
|
||||
2. **Analyze Pattern Specificity**: Understand the pattern hierarchy
|
||||
- More specific patterns should be checked BEFORE less specific ones
|
||||
- Example: "KS-NGCH-" is more specific than "KS-NG-"
|
||||
- The order matters: devices are matched by the FIRST matching pattern in the if-else chain
|
||||
|
||||
3. **Check Case Order**: Verify the order of device type cases in bluetooth.cpp
|
||||
- Earlier cases take precedence over later cases
|
||||
- Ensure more specific patterns in earlier cases won't prevent your pattern from matching
|
||||
- Ensure your pattern won't incorrectly match devices intended for other cases
|
||||
|
||||
4. **Document Conflicts**: When conflicts exist, verify they are intentional
|
||||
- More specific patterns earlier in the chain should catch specific devices
|
||||
- Your pattern should only catch devices not matched by more specific patterns
|
||||
- Example: "KS-NGCH-X21C" (kingsmithR2Treadmill) should match before "KS-NG-" (horizontreadmill)
|
||||
|
||||
5. **Test Pattern Matching**: Consider these scenarios
|
||||
- Will your pattern match the intended device? (e.g., "KS-NG-X218")
|
||||
- Will it incorrectly match other devices? (e.g., "KS-NGCH-X21C")
|
||||
- Are there existing patterns that would match your device first?
|
||||
|
||||
**Example Verification Process:**
|
||||
|
||||
```bash
|
||||
# Search for similar patterns
|
||||
grep -n "KS-" src/devices/bluetooth.cpp
|
||||
|
||||
# Review each match for conflicts
|
||||
# - kingsmithR2Treadmill has "KS-NGCH-X21C" (line 1323)
|
||||
# - horizontreadmill has "KS-MC" (line 1562)
|
||||
# - Adding "KS-NG-" to horizontreadmill is safe because:
|
||||
# 1. "KS-NGCH-" patterns are more specific
|
||||
# 2. kingsmithR2Treadmill case comes first (line 1312 vs 1560)
|
||||
# 3. "KS-NG-X218" won't match "KS-NGCH-" patterns
|
||||
```
|
||||
|
||||
**Common Pitfalls:**
|
||||
- Adding a pattern without checking existing patterns
|
||||
- Not considering pattern order in the if-else chain
|
||||
- Adding overly broad patterns that match unintended devices
|
||||
- Not testing with actual device names
|
||||
|
||||
### Characteristics & Protocols
|
||||
- Bluetooth characteristics handlers in `src/characteristics/`
|
||||
- FTMS (Fitness Machine Service) protocol support
|
||||
|
||||
@@ -1567,6 +1567,7 @@ void bluetooth::deviceDiscovered(const QBluetoothDeviceInfo &device) {
|
||||
(b.name().toUpper().startsWith(QStringLiteral("TP1")) && b.name().length() == 3) ||
|
||||
(b.name().toUpper().startsWith(QStringLiteral("KS-HD-Z1D"))) || // Kingsmith WalkingPad Z1
|
||||
(b.name().toUpper().startsWith(QStringLiteral("KS-AP-"))) || // Kingsmith WalkingPad R3 Hybrid+
|
||||
(b.name().toUpper().startsWith(QStringLiteral("KS-NG-"))) || // Kingsmith X218 / Walking Pad
|
||||
(b.name().toUpper().startsWith(QStringLiteral("NOBLEPRO CONNECT")) && deviceHasService(b, QBluetoothUuid((quint16)0x1826))) || // FTMS
|
||||
(b.name().toUpper().startsWith(QStringLiteral("TT8")) && deviceHasService(b, QBluetoothUuid((quint16)0x1826))) ||
|
||||
(b.name().toUpper().startsWith(QStringLiteral("ST90")) && deviceHasService(b, QBluetoothUuid((quint16)0x1826))) ||
|
||||
|
||||
Reference in New Issue
Block a user