Skip to content

Marc roy#713

Merged
doudar merged 9 commits intodevelopfrom
Marc_Roy
Jan 10, 2026
Merged

Marc roy#713
doudar merged 9 commits intodevelopfrom
Marc_Roy

Conversation

@doudar
Copy link
Copy Markdown
Owner

@doudar doudar commented Jan 10, 2026

No description provided.

@doudar doudar merged commit e6ce99d into develop Jan 10, 2026
2 checks passed
@doudar
Copy link
Copy Markdown
Owner Author

doudar commented Mar 16, 2026

--- Part 1/2 ---

Ahoy there, matey! This here pull request be a hefty one, but worry not—I’ll be navigating through these murky code waters to raise me flag on some observations! Let’s dive straight into the depths!


1. Code Quality and Potential Issues ⚙️

(a) General Code Cleanup and Structure

  • Consistent Formatting: Ye code styles be a little inconsistent, like white space gallivanting wherever it pleases. Look at BLE_ss2kCustomCharacteristic::process:

    case BLE_UDPLogging:  // 0x2E
    ...

    There be extra spaces here and there—likely harmless to the ship but makes it harder for landlubbers to read. Tighten it up, matey!

  • Unnecessary Comments: Some comments, like:

    // What used to be in the ERGTaskLoop(). This is the main control function for ERG Mode and the powertable operations.

    …don’t be adding too much value. Ye might want to make it concise or explain what "ERGTaskLoop" actually be!

(b) Implicit/Explicit Conversions

  • Found near FitnessMachineIndoorBikeData.cpp:
    double_t result   = double_t(static_cast<int>(std::round((value * resolutions[typeIndex] * 10) + 0.5)) / 10.0);
    Ye be overly complicated here, laddie! That std::round already does most of the heavy liftin’, and ye can safely remove + 0.5 from inside the rounding. Trim down this line before it starts hoggin' all me memory!

(c) DRYer Code Approach

Yer duplicatin' notable portions of yer code—like how ye be checking cadence to ensure it falls within bounds. Examples:

  • CscSensorData.cpp:
    if (cadence > 1) {
      if (cadence > 200 || cadence < 0) {
  • Similar pattern appears in CyclePowerData.cpp.

Ye could extract such validation into a helper function like validateCadence(cadence) to avoid repeating yerself across multiple areas.


2. Security Concerns 🏴‍☠️

(a) UDP Logging with BLE_UDPLogging

Yer new case handling for BLE_UDPLogging introduces toggles for UDP logging. While ye be smart enough to include read/write operations like so:

if (rxValue[0] == cc_write) {
    userConfig->setUdpLogEnabled(rxValue[2]);
}

Ye might want to validate that rxValue[2] contains only expected values (likely 0 or 1). Otherwise, ye ship leaves room for invalid toggles or unexpected behavior!

(b) BLE Security

In SpinBLEClient::postConnect():

if (adevName.startsWith("IC Bike")) {
    resistanceRangeCharacteristic = nullptr;
}

It’s great ye be filterin' out erroneous devices like Schwinn IC4 bikes. But do bear in mind: spoofing device names can lead to bypasses. Secure this by more deterministic means, like verifying specific device characteristics or IDs.

(c) Floating-Point Precision Issues

Ye be heavy on calculations involvin’ floatin’ point numbers (e.g., cadence computations). These could suffer from precision drift, especially over time or when scaled to high values. Potential for edge-case issues—be cautious and test thoroughly.


3. Performance Implications

(a) Rounding/Precision

Ye be liberal with yer std::round() calls in methods like decode. On a humble microcontroller, this constant rounding could result in clock cycles runnin’ wild. If ye environment be limited in computational power, consider rounding only when absolutely necessary—e.g., directly before rendering values or sending results.

(b) ResistanceModel Computation

Yer ResistanceModel introduces some heavy computation for normalization and solving matrices (solveMatrix). I see no constraints on how often these calculations can run. Be wary of performance hits if such models be invoked at rapid intervals during runtime.

(c) BLE Logging Spam

Too much logging, like here:

String rrLog = "FTMS Resistance Range raw data:";
for (size_t i = 0; i < rr.size(); i++) {
    ...
    rrLog += " " + String(buf);
}

Logs be growin' exponentially. If UDP

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant