From 982f1d4e0e825ad2e1f5a816b92a125157633612 Mon Sep 17 00:00:00 2001 From: Carsten Schmiemann Date: Sat, 16 Apr 2022 20:40:40 +0200 Subject: [PATCH] Fix mt_bus_awake --- .../src/vehicle_renaultzoe_ph2.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/vehicle_renaultzoe_ph2.cpp b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/vehicle_renaultzoe_ph2.cpp index a4fb848..6997618 100644 --- a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/vehicle_renaultzoe_ph2.cpp +++ b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/vehicle_renaultzoe_ph2.cpp @@ -96,10 +96,10 @@ OvmsVehicleRenaultZoePh2::~OvmsVehicleRenaultZoePh2() { void OvmsVehicleRenaultZoePh2::IncomingFrameCan1(CAN_frame_t* p_frame) { uint8_t *data = p_frame->data.u8; ESP_LOGI(TAG, "PID:%x DATA: %02x %02x %02x %02x %02x %02x %02x %02x", p_frame->MsgID, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]); - ESP_LOGD(TAG, "Status CAN Bus: %s", mt_bus_awake ? "true" : "false"); + ESP_LOGD(TAG, "Status CAN Bus: %s", mt_bus_awake->AsBool() ? "true" : "false"); // Poll reply gives 0x83 0xc0 that means zoe is sleeping and CAN gateway does not respond to anything - if (mt_bus_awake && data[0] == 0x83 && data[1] == 0xc0) { + if (mt_bus_awake->AsBool() && data[0] == 0x83 && data[1] == 0xc0) { ESP_LOGI(TAG,"Zoe has gone to sleep (CAN Gateway NAK response)"); mt_bus_awake->SetValue(false); StandardMetrics.ms_v_env_awake->SetValue(false); @@ -110,7 +110,7 @@ void OvmsVehicleRenaultZoePh2::IncomingFrameCan1(CAN_frame_t* p_frame) { POLLSTATE_OFF; } //There are some free frames on wakeup and start and stop charging.... I try to use them to see if Car is awake and charging, see /Reference/ZOE_Ph2_xxx text files - if (!mt_bus_awake && (data[0] == 0x05 || data[0] == 0x06 || data[0] == 0x07)) { //listen for SingleFrames (0x0) with length of 5-7 + if (!mt_bus_awake->AsBool() && (data[0] == 0x05 || data[0] == 0x06 || data[0] == 0x07)) { //listen for SingleFrames (0x0) with length of 5-7 ESP_LOGI(TAG,"Zoe woke up (CAN Bus activity detected)"); mt_bus_awake->SetValue(true); StandardMetrics.ms_v_env_awake->SetValue(true); @@ -119,23 +119,23 @@ void OvmsVehicleRenaultZoePh2::IncomingFrameCan1(CAN_frame_t* p_frame) { StandardMetrics.ms_v_env_charging12v->SetValue(true); POLLSTATE_ON; } - if (mt_bus_awake && !CarIsCharging && data[2] == 0x92 && data[3] == 0x10) { //received 0x9210 from LBC, only sent freely on starting charge so far + if (mt_bus_awake->AsBool() && !CarIsCharging && data[2] == 0x92 && data[3] == 0x10) { //received 0x9210 from LBC, only sent freely on starting charge so far ESP_LOGI(TAG,"Zoe stared charging"); StandardMetrics.ms_v_env_on->SetValue(false); StandardMetrics.ms_v_charge_state->SetValue("charging"); POLLSTATE_CHARGING; } - if (mt_bus_awake && CarIsCharging && data[2] == 0x92 && data[3] == 0x43) { //received 0x9243 from LBC, only sent freely on stopping charge so far + if (mt_bus_awake->AsBool() && CarIsCharging && data[2] == 0x92 && data[3] == 0x43) { //received 0x9243 from LBC, only sent freely on stopping charge so far ESP_LOGI(TAG,"Zoe stopped charging"); StandardMetrics.ms_v_charge_state->SetValue("stopped"); POLLSTATE_ON; } - if (mt_bus_awake && !CarIsDriving && StandardMetrics.ms_v_pos_gpsspeed->AsFloat() > 5) { //If GPS speed bigger than 5km/h then assume Vehicle driving, later I used OBD speed for that + if (mt_bus_awake->AsBool() && !CarIsDriving && StandardMetrics.ms_v_pos_gpsspeed->AsFloat() > 5) { //If GPS speed bigger than 5km/h then assume Vehicle driving, later I used OBD speed for that ESP_LOGI(TAG,"Zoe is driving"); StandardMetrics.ms_v_env_on->SetValue(false); POLLSTATE_RUNNING; CarIsDriving = true; - } else if (mt_bus_awake && CarIsDriving && StandardMetrics.ms_v_pos_gpsspeed->AsFloat() < 5) { + } else if (mt_bus_awake->AsBool() && CarIsDriving && StandardMetrics.ms_v_pos_gpsspeed->AsFloat() < 5) { ESP_LOGI(TAG,"Zoe stopped driving"); POLLSTATE_ON; }