diff --git a/vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_can.cpp b/vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_can.cpp index dbb458a00..d33ae2a39 100644 --- a/vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_can.cpp +++ b/vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_can.cpp @@ -298,8 +298,8 @@ void OvmsVehicleSmartEQ::IncomingFrameCan1(CAN_frame_t* p_frame) { vehicle_smart_car_on((CAN_BYTE(0) & 0x40) > 0); // Drive Ready break; case 0x673: - // TPMS values only used, when CAN write is disabled, otherwise utilize PollReply_TPMS_InputCapt - if ( !m_enable_write ) + // TPMS pressure values only used, when CAN write is disabled, otherwise utilize PollReply_TPMS_InputCapt + if (!m_enable_write) { REQ_DLC(7); // Read TPMS pressure values: @@ -307,7 +307,7 @@ void OvmsVehicleSmartEQ::IncomingFrameCan1(CAN_frame_t* p_frame) { { if (CAN_BYTE(2 + i) != 0xff) { - m_tpms_pressure[i] = (float) CAN_BYTE(2 + i) * 3.1; // kPa + m_tpms_pressure[3-i] = (float) CAN_BYTE(2 + i) * 3.1; // kPa, counter m_tpms_pressure indexing FL=3, FR=2, RL=1, RR=0 } } } diff --git a/vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_commands.cpp b/vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_commands.cpp index a472da0b1..59ff8914c 100644 --- a/vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_commands.cpp +++ b/vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_commands.cpp @@ -803,16 +803,32 @@ void OvmsVehicleSmartEQ::xsq_tpms_set(int verbosity, OvmsWriter* writer, OvmsCom smarteq->CommandTPMSset(verbosity, writer); } + OvmsVehicle::vehicle_command_t OvmsVehicleSmartEQ::CommandTPMSset(int verbosity, OvmsWriter* writer) { float dummy_pressure = mt_dummy_pressure->AsFloat(); + writer->printf("Setting dummy TPMS values (base pressure: %.1f kPa)\n", dummy_pressure); + for (int i = 0; i < 4; i++) { m_tpms_pressure[i] = dummy_pressure + (i * 10); // kPa m_tpms_temperature[i] = 21 + i; // Celsius m_tpms_lowbatt[i] = false; m_tpms_missing_tx[i] = false; + writer->printf(" Sensor %d: pressure=%.1f kPa, temp=%.1f°C\n", + i, m_tpms_pressure[i], m_tpms_temperature[i]); } - writer->printf("set TPMS dummy pressure: %.2f temp: %.2f\n", dummy_pressure, m_tpms_temperature[0]); + setTPMSValue(); // update TPMS metrics + + // Show what was actually set in metrics + writer->puts("\nAfter setTPMSValue():"); + auto pressure = StdMetrics.ms_v_tpms_pressure->AsVector(); + auto temp = StdMetrics.ms_v_tpms_temp->AsVector(); + for (size_t i = 0; i < pressure.size(); i++) { + writer->printf(" Wheel %d: pressure=%.1f kPa, temp=%.1f°C\n", + (int)i, pressure[i], temp[i]); + } + + writer->puts("TPMS dummy values set"); return Success; } diff --git a/vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_features.cpp b/vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_features.cpp index e4c3c4213..d494f5214 100644 --- a/vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_features.cpp +++ b/vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_features.cpp @@ -41,9 +41,9 @@ void OvmsVehicleSmartEQ::setTPMSValue() { std::vector tpms_layout = OvmsVehicle::GetTpmsLayout(); int count = (int)tpms_layout.size(); - std::vector tpms_pressure(count); - std::vector tpms_temp(count); - std::vector tpms_alert(count); + std::vector tpms_pressure(count, 0.0f); + std::vector tpms_temp(count, 0.0f); + std::vector tpms_alert(count, 0); float _threshold_front = m_front_pressure; float _threshold_rear = m_rear_pressure; @@ -54,22 +54,11 @@ void OvmsVehicleSmartEQ::setTPMSValue() { static const float PRESSURE_MIN = 10.0f; // Below this = sensor not working static const float PRESSURE_MAX = 500.0f; // Above this = invalid reading static const float TEMP_MIN = -40.0f; - static const float TEMP_MAX = 150.0f; + static const float TEMP_MAX = 90.0f; for (int i=0; i < count; i++) { int indexcar = m_tpms_index[i]; - - // Bounds check for indexcar - if (indexcar < 0 || indexcar >= count) - { - ESP_LOGW(TAG, "Invalid TPMS index mapping: %d -> %d (max: %d)", i, indexcar, count-1); - tpms_pressure[i] = 0.0f; - tpms_temp[i] = 0.0f; - tpms_alert[i] = 0; - continue; - } - float _pressure = m_tpms_pressure[indexcar]; float _temp = m_tpms_temperature[indexcar]; bool _lowbatt = m_tpms_lowbatt[indexcar]; @@ -87,20 +76,12 @@ void OvmsVehicleSmartEQ::setTPMSValue() { tpms_pressure[i] = _pressure; _flag = true; } - else - { - tpms_pressure[i] = 0.0f; - } // Validate and set temperature if (m_tpms_temp_enable && _temp >= TEMP_MIN && _temp < TEMP_MAX) { tpms_temp[i] = _temp; } - else - { - tpms_temp[i] = 0.0f; - } // Handle alert conditions only if sensor is working and alerts are enabled if (!pressure_valid || !alerts_enabled) diff --git a/vehicle/OVMS.V3/components/vehicle_smarteq/src/vehicle_smarteq.cpp b/vehicle/OVMS.V3/components/vehicle_smarteq/src/vehicle_smarteq.cpp index 28eb73099..02cc0dad1 100644 --- a/vehicle/OVMS.V3/components/vehicle_smarteq/src/vehicle_smarteq.cpp +++ b/vehicle/OVMS.V3/components/vehicle_smarteq/src/vehicle_smarteq.cpp @@ -132,7 +132,7 @@ OvmsVehicleSmartEQ::OvmsVehicleSmartEQ() { mt_tpms_alert = MyMetrics.InitVector ("xsq.tpms.alert", SM_STALE_MID, nullptr, Other); mt_tpms_low_batt = MyMetrics.InitVector ("xsq.tpms.lowbatt", SM_STALE_MID, nullptr, Other); mt_tpms_missing_tx = MyMetrics.InitVector ("xsq.tpms.missing", SM_STALE_MID, nullptr, Other); - mt_dummy_pressure = MyMetrics.InitFloat("xsq.tpms.dummy", SM_STALE_NONE, 230, kPa); // Dummy pressure for TPMS alert testing + mt_dummy_pressure = MyMetrics.InitFloat("xsq.tpms.dummy", SM_STALE_NONE, 210, kPa); // Dummy pressure for TPMS alert testing // 0x765 BCM metrics mt_bcm_vehicle_state = MyMetrics.InitString("xsq.bcm.state", SM_STALE_MIN, "UNKNOWN", Other); mt_bcm_gen_mode = MyMetrics.InitString("xsq.bcm.gen.mode", SM_STALE_MID, "UNKNOWN", Other);