Context:
You are an expert C++/QT/WASM developer and Bluetooth Low Energy (BLE) specialist. We are working on the MaximumTrainer_Redux repository, which is currently a cycling-focused training application. We need to expand the architecture to support Rowing Machines (Ergometers).
Objective:
Implement full rowing machine support, specifically targeting FTMS-compatible rowers and the Concept2 PM5 monitor, including data synchronization with the Concept2 Logbook.
Key Requirements to Address:
- Bluetooth Protocol Implementation (FTMS & PM5)
FTMS Rowing Profile: Implement the Bluetooth Fitness Machine Service (FTMS) specifically for the Rower Data characteristic (UUID 0x2AD1). This must handle stroke rate, stroke count, average stroke rate, instantaneous pace, and power.
Concept2 PM5 Proprietary Service: Beyond standard FTMS, support the Concept2 specific BLE services (Service UUID CE060000-4351-41A0-B10B-2E32C79E03F8). Specifically, implement:
Rowing Status (0x0031): For workout state and interval data.
Additional Status (0x0032): For drag factor and drive/recovery timing.
Rowing Additional Data (0x0033): For split times and projected finish.
- Core Architecture: Workout Type Logic
Cycling vs. Rowing Abstraction: Introduce an ActivityType enum (Cycling, Rowing).
Metric Mapping: Modify the data pipeline to handle rowing-specific metrics. While Cycling focuses on Power (Watts) and Cadence (RPM), Rowing requires:
Pace (Time per 500m)
Stroke Rate (SPM)
Distance (Meters)
Drag Factor
UI/UX Adaptive Display: The dashboard must toggle between "Speed (km/h) / Cadence" for cycling and "Pace (/500m) / Stroke Rate" for rowing based on the selected activity.
- Concept2 Logbook Integration
Authentication: Implement an OAuth2 flow to connect the user’s Concept2 account.
Data Serialization: Create a service to serialize finished workout data into the Concept2 Logbook API format (JSON).
Payload Requirements: Ensure the payload includes stroke-by-stroke data (if available) or per-second intervals, including the machine type and serial number from the PM5.
- Implementation Steps Requested:
Service Layer: Define an IRowerService that extends or mirrors the existing ITrainerService.
Protocol Parser: Provide the logic to decode the byte arrays from the FTMS Rower Data and PM5 characteristics.
Data Persistence: Update the local database/file storage schema to distinguish between a .fit or .tcx file for cycling vs. rowing.
UI Components: Suggest modifications for the MainViewModel views to support the new metrics.
Constraints:
Maintain backward compatibility with existing BLE cycling trainers.
Ensure the code follows the existing MVVM pattern in MaximumTrainer_Redux.
Use asynchronous BLE communication to prevent UI blocking.
Context:
You are an expert C++/QT/WASM developer and Bluetooth Low Energy (BLE) specialist. We are working on the MaximumTrainer_Redux repository, which is currently a cycling-focused training application. We need to expand the architecture to support Rowing Machines (Ergometers).
Objective:
Implement full rowing machine support, specifically targeting FTMS-compatible rowers and the Concept2 PM5 monitor, including data synchronization with the Concept2 Logbook.
Key Requirements to Address:
FTMS Rowing Profile: Implement the Bluetooth Fitness Machine Service (FTMS) specifically for the Rower Data characteristic (UUID 0x2AD1). This must handle stroke rate, stroke count, average stroke rate, instantaneous pace, and power.
Concept2 PM5 Proprietary Service: Beyond standard FTMS, support the Concept2 specific BLE services (Service UUID CE060000-4351-41A0-B10B-2E32C79E03F8). Specifically, implement:
Rowing Status (0x0031): For workout state and interval data.
Additional Status (0x0032): For drag factor and drive/recovery timing.
Rowing Additional Data (0x0033): For split times and projected finish.
Cycling vs. Rowing Abstraction: Introduce an ActivityType enum (Cycling, Rowing).
Metric Mapping: Modify the data pipeline to handle rowing-specific metrics. While Cycling focuses on Power (Watts) and Cadence (RPM), Rowing requires:
Pace (Time per 500m)
Stroke Rate (SPM)
Distance (Meters)
Drag Factor
UI/UX Adaptive Display: The dashboard must toggle between "Speed (km/h) / Cadence" for cycling and "Pace (/500m) / Stroke Rate" for rowing based on the selected activity.
Authentication: Implement an OAuth2 flow to connect the user’s Concept2 account.
Data Serialization: Create a service to serialize finished workout data into the Concept2 Logbook API format (JSON).
Payload Requirements: Ensure the payload includes stroke-by-stroke data (if available) or per-second intervals, including the machine type and serial number from the PM5.
Service Layer: Define an IRowerService that extends or mirrors the existing ITrainerService.
Protocol Parser: Provide the logic to decode the byte arrays from the FTMS Rower Data and PM5 characteristics.
Data Persistence: Update the local database/file storage schema to distinguish between a .fit or .tcx file for cycling vs. rowing.
UI Components: Suggest modifications for the MainViewModel views to support the new metrics.
Constraints:
Maintain backward compatibility with existing BLE cycling trainers.
Ensure the code follows the existing MVVM pattern in MaximumTrainer_Redux.
Use asynchronous BLE communication to prevent UI blocking.