Skip to content

Commit b9d56e3

Browse files
committed
Use IsCANwrite()
1 parent de597f1 commit b9d56e3

6 files changed

Lines changed: 21 additions & 21 deletions

File tree

vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_cmds_override.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ OvmsVehicle::vehicle_command_t OvmsVehicleSmartEQ::CommandClimateControl(bool en
6565
return Success;
6666
}
6767
// force enable write access for sending the command, even when user has not enabled it (can be required for some vehicles to wake up the car)
68-
bool force = !m_enable_write && !m_enable_write_caron ? true : false;
68+
bool force = !IsCANwrite() ? true : false;
6969
if(force)
7070
{
7171
m_enable_write_caron = true;
@@ -201,7 +201,7 @@ OvmsVehicle::vehicle_command_t OvmsVehicleSmartEQ::CommandHomelink(int button, i
201201
}
202202

203203
OvmsVehicle::vehicle_command_t OvmsVehicleSmartEQ::CommandWakeup() {
204-
if(!m_enable_write && !m_enable_write_caron)
204+
if(!IsCANwrite())
205205
{
206206
ESP_LOGE(TAG, "CommandWakeup failed: no write access!");
207207
return Fail;
@@ -245,7 +245,7 @@ OvmsVehicle::vehicle_command_t OvmsVehicleSmartEQ::CommandWakeup() {
245245
}
246246

247247
OvmsVehicle::vehicle_command_t OvmsVehicleSmartEQ::CommandWakeup2() {
248-
if(!m_enable_write && !m_enable_write_caron)
248+
if(!IsCANwrite())
249249
{
250250
ESP_LOGE(TAG, "CommandWakeup2 failed: no write access!");
251251
return Fail;
@@ -289,7 +289,7 @@ OvmsVehicle::vehicle_command_t OvmsVehicleSmartEQ::CommandWakeup2() {
289289

290290
// lock: can can1 tx st 745 04 30 01 00 00
291291
OvmsVehicle::vehicle_command_t OvmsVehicleSmartEQ::CommandLock(const char* pin) {
292-
if(!m_enable_write && !m_enable_write_caron)
292+
if(!IsCANwrite())
293293
{
294294
ESP_LOGE(TAG, "CommandLock failed / no write access");
295295
return Fail;
@@ -326,7 +326,7 @@ OvmsVehicle::vehicle_command_t OvmsVehicleSmartEQ::CommandLock(const char* pin)
326326
// unlock: can can1 tx st 745 04 30 01 00 01
327327
OvmsVehicle::vehicle_command_t OvmsVehicleSmartEQ::CommandUnlock(const char* pin) {
328328

329-
if(!m_enable_write && !m_enable_write_caron)
329+
if(!IsCANwrite())
330330
{
331331
ESP_LOGE(TAG, "CommandUnlock failed / no write access");
332332
return Fail;

vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_commands.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static const char *TAG = "v-smarteq";
3636

3737
// CommandCanVector(txid, rxid, hexbytes = {"30010000","30082002"}, reset CAN = true/false, CommandWakeup = true/ CommandWakeup2 = false)
3838
OvmsVehicle::vehicle_command_t OvmsVehicleSmartEQ::CommandCanVector(uint32_t txid,uint32_t rxid, std::vector<std::string> hexbytes,bool reset,bool wakeup) {
39-
if(!m_enable_write && !m_enable_write_caron)
39+
if(!IsCANwrite())
4040
{
4141
ESP_LOGE(TAG, "CommandCanVector failed / no write access");
4242
return Fail;
@@ -184,7 +184,7 @@ void OvmsVehicleSmartEQ::xsq_canwrite(int verbosity, OvmsWriter* writer, OvmsCom
184184
if (!smarteq)
185185
return;
186186

187-
if(!smarteq->m_ddt4all || !smarteq->m_enable_write) {
187+
if(!smarteq->m_ddt4all || !smarteq->IsCANwrite()) {
188188
ESP_LOGE(TAG, "DDT4all failed / no Canbus write access or DDT4all not enabled");
189189
writer->puts("DDT4all failed / no Canbus write access or DDT4all not enabled");
190190
return;
@@ -574,7 +574,8 @@ OvmsVehicle::vehicle_command_t OvmsVehicleSmartEQ::CommandPreset(int verbosity,
574574
"obdii_79b",
575575
"obdii_7e4",
576576
"obdii_7e4_modify",
577-
"basic_tpms"
577+
"basic_tpms",
578+
"calc.adcfactor.samples"
578579
};
579580

580581
int removed_count = 0;

vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_ddt4all.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ OvmsVehicle::vehicle_command_t OvmsVehicleSmartEQ::CommandDDT4all(int number, Ov
6363
return Success;
6464
}
6565

66-
if((!m_ddt4all || !m_enable_write) && number > 9) {
66+
if((!m_ddt4all || !IsCANwrite()) && number > 9) {
6767
ESP_LOGE(TAG, "DDT4all failed / no Canbus write access or DDT4all not enabled");
6868
writer->printf("DDT4all failed / no Canbus write access or DDT4all not enabled");
6969
return Fail;

vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_features.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ void OvmsVehicleSmartEQ::ReCalcADCfactor(float can12V, OvmsWriter* writer) {
380380
mt_adc_factor_history->SetElemValues(0, n, hist);
381381
mt_adc_factor->SetValue(adc_factor_new);
382382
MyConfig.SetParamValueFloat("system.adc", "factor12v", adc_factor_new);
383+
MyConfig.SetParamValueBool("xsq", "calc.adcfactor", false);
383384
if (writer) writer->printf("New ADC factor stored: %.3f (prev %.3f, history size %u)\n", adc_factor_new, adc_factor_prev, (unsigned)n);
384385
#else
385386
ESP_LOGD(TAG, "ADC support not enabled");
@@ -470,7 +471,7 @@ void OvmsVehicleSmartEQ::smartOn()
470471
// reset idle ticker when vehicle turned on to prevent trigger every 60 sec.
471472
m_idle_ticker = 15 * 60;
472473
// canwrite enable write access, only when car is on
473-
if(m_enable_write || m_enable_write_caron)
474+
if(IsCANwrite())
474475
{
475476
smartCANmode(true);
476477
}
@@ -517,11 +518,11 @@ void OvmsVehicleSmartEQ::smartChargeStart()
517518
// trigger ADC factor recalculation when HV charging started
518519
if(m_enable_calcADCfactor && !m_ADCfactor_recalc)
519520
{
520-
m_ADCfactor_recalc_timer = 4; // wait at least 4 min. before recalculation
521+
m_ADCfactor_recalc_timer = 2; // wait at least 2 min. before recalculation
521522
m_ADCfactor_recalc = true; // recalculate ADC factor when HV charging
522523
}
523524
// canwrite enable write access, only when car is on
524-
if(m_enable_write || m_enable_write_caron)
525+
if(IsCANwrite())
525526
{
526527
m_poll_on_charge = true;
527528
smartCANmode(true);
@@ -553,7 +554,7 @@ void OvmsVehicleSmartEQ::smartChargeStop()
553554
StdMetrics.ms_v_charge_substate->SetValue("onrequest");
554555
}
555556
// stop recalculation when HV charging stopped
556-
m_ADCfactor_recalc_timer = 0;
557+
m_ADCfactor_recalc_timer = 2;
557558
m_ADCfactor_recalc = false;
558559
ESP_LOGD(TAG, "smartChargeStop()");
559560
}
@@ -563,7 +564,7 @@ void OvmsVehicleSmartEQ::smartChargePrepare()
563564
if (m_charge_finished) ResetChargingValues();
564565
if (m_resettrip) ResetTripCounters();
565566
// canwrite enable write access, only when car is on
566-
if(m_enable_write || m_enable_write_caron)
567+
if(IsCANwrite())
567568
{
568569
m_poll_on_charge = true;
569570
smartCANmode(true);
@@ -581,7 +582,7 @@ void OvmsVehicleSmartEQ::smartChargeFinish()
581582

582583
void OvmsVehicleSmartEQ::smartCANmode(bool activate)
583584
{
584-
if(!m_enable_write && !m_enable_write_caron)
585+
if(!IsCANwrite())
585586
{
586587
m_can1->Stop();
587588
vTaskDelay(200 / portTICK_PERIOD_MS);

vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_handle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void OvmsVehicleSmartEQ::HandlePollState() {
3939

4040
static const char* state_names[] = {"Off", "Awake", "Running", "Charging"};
4141
static const char* state_disabled = "Pollstate Off (write disabled)";
42-
if (!m_enable_write && !m_enable_write_caron)
42+
if (!IsCANwrite())
4343
{
4444
if (m_poll_state != POLLSTATE_OFF)
4545
{

vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_ticker.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,9 @@ void OvmsVehicleSmartEQ::Ticker1(uint32_t ticker)
4444
HandleCharging();
4545

4646
if(IsOnEQ())
47-
{
4847
HandleEnergy();
49-
if(StdMetrics.ms_v_env_gear->AsInt(0) != m_gear)
50-
StdMetrics.ms_v_env_gear->SetValue(m_gear);
51-
}
48+
49+
smartCAN2Metrics();
5250
}
5351

5452
void OvmsVehicleSmartEQ::Ticker10(uint32_t ticker)
@@ -76,7 +74,7 @@ void OvmsVehicleSmartEQ::Ticker60(uint32_t ticker) {
7674
DoorLockState();
7775
if(m_enable_door_state && !m_warning_dooropen && StdMetrics.ms_v_env_parktime->AsInt() > m_park_timeout_secs +10)
7876
DoorOpenState();
79-
if(IsOnEQ())
77+
if(IsOnEQ())
8078
setTPMSValue(); // update TPMS metrics
8179

8280
#if defined(CONFIG_OVMS_COMP_WIFI) || defined(CONFIG_OVMS_COMP_CELLULAR)

0 commit comments

Comments
 (0)