Skip to content

Commit

Permalink
added BOOTLOCK
Browse files Browse the repository at this point in the history
  • Loading branch information
lincomatic committed Feb 7, 2023
1 parent 97d2058 commit 00ba307
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 9 deletions.
3 changes: 3 additions & 0 deletions firmware/open_evse/CHANGELOG
@@ -1,5 +1,8 @@
Change Log

20230206 SCL
- added BOOTLOCK - when defined, EVSE locked until receives $SB

20220408 V8.2.1 SCL
- fix bug: SaveSettings() should save GetMaxCurrentCapacity() instead of GetCurrentCapacity(), in case called during throttling

Expand Down
6 changes: 5 additions & 1 deletion firmware/open_evse/J1772EvseController.cpp
@@ -1,7 +1,7 @@
/*
* This file is part of Open EVSE.
*
* Copyright (c) 2011-2021 Sam C. Lin
* Copyright (c) 2011-2023 Sam C. Lin
*
* Open EVSE is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -1079,6 +1079,10 @@ void J1772EVSEController::Init()

m_wVFlags = ECVF_DEFAULT;

#ifdef BOOTLOCK
m_wVFlags |= ECVF_BOOT_LOCK;
#endif

m_MaxHwCurrentCapacity = eeprom_read_byte((uint8_t*)EOFS_MAX_HW_CURRENT_CAPACITY);
if (!m_MaxHwCurrentCapacity || (m_MaxHwCurrentCapacity == (uint8_t)0xff)) {
m_MaxHwCurrentCapacity = MAX_CURRENT_CAPACITY_L2;
Expand Down
15 changes: 13 additions & 2 deletions firmware/open_evse/J1772EvseController.h
Expand Up @@ -2,7 +2,7 @@
/*
* This file is part of Open EVSE.
*
* Copyright (c) 2011-2021 Sam C. Lin
* Copyright (c) 2011-2023 Sam C. Lin
*
* Open EVSE is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -102,7 +102,7 @@ typedef uint8_t (*EvseStateTransitionReqFunc)(uint8_t prevPilotState,uint8_t cur
#define ECVF_UI_IN_MENU 0x0800 // onboard UI currently in a menu
#define ECVF_TIMER_ON 0x1000 // delay timer enabled
#define ECVF_CHARGE_LIMIT 0x2000
// reserved #define ECVF_BOOT_LOCK 0x4000 // locked at boot
#define ECVF_BOOT_LOCK 0x4000 // locked at boot
#define ECVF_MENNEKES_MANUAL 0x8000 // Mennekes lock manual mode
#if defined(AUTH_LOCK) && (AUTH_LOCK != 0)
#define ECVF_DEFAULT ECVF_AUTH_LOCKED|ECVF_SESSION_ENDED
Expand Down Expand Up @@ -389,6 +389,17 @@ class J1772EVSEController {
uint8_t ReadACPins();
#endif // ADVPWR

void ClearBootLock() {
clrVFlags(ECVF_BOOT_LOCK);
}
uint8_t IsBootLocked() {
#ifdef BOOTLOCK
return vFlagIsSet(ECVF_BOOT_LOCK) ? 1 : 0;
#else
return 0;
#endif
}

void HardFault(int8_t recoverable);

void SetLimitSleep(int8_t tf) {
Expand Down
16 changes: 13 additions & 3 deletions firmware/open_evse/main.cpp
Expand Up @@ -2,7 +2,7 @@
/*
* Open EVSE Firmware
*
* Copyright (c) 2011-2021 Sam C. Lin
* Copyright (c) 2011-2023 Sam C. Lin
* Copyright (c) 2011-2014 Chris Howell <chris1howell@msn.com>
* timer code Copyright (c) 2013 Kevin L <goldserve1@hotmail.com>
* portions Copyright (c) 2014-2015 Nick Sayer <nsayer@kfu.com>
Expand Down Expand Up @@ -2486,12 +2486,22 @@ void setup()
g_EvseController.SetStateTransitionReqFunc(&StateTransitionReqFunc);
#endif //PP_AUTO_AMPACITY

EvseReset();

#ifdef TEMPERATURE_MONITORING
g_TempMonitor.Init();
#endif

EvseReset();

#ifdef BOOTLOCK
#ifdef LCD16X2
g_OBD.LcdMsg_P(PSTR("Waiting for"),PSTR("Initialization.."));
#endif // LCD16X2
while (g_EvseController.IsBootLocked()) {
ProcessInputs();
}
#endif // BOOTLOCK


WDT_ENABLE();
} // setup()

Expand Down
3 changes: 3 additions & 0 deletions firmware/open_evse/open_evse.h
Expand Up @@ -69,6 +69,9 @@ typedef unsigned long time_t;
// auto detect L1/L2
#define AUTOSVCLEVEL

// on boot, EVSE locked until receives $SB
//#define BOOTLOCK

// show disabled tests before POST
#define SHOW_DISABLED_TESTS

Expand Down
15 changes: 14 additions & 1 deletion firmware/open_evse/rapi_proc.cpp
Expand Up @@ -2,7 +2,7 @@
/*
* Open EVSE Firmware
*
* Copyright (c) 2013-2021 Sam C. Lin <lincomatic@gmail.com>
* Copyright (c) 2013-2023 Sam C. Lin <lincomatic@gmail.com>
*
* This file is part of Open EVSE.
Expand Down Expand Up @@ -445,6 +445,19 @@ int EvseRapiProcessor::processCmd()
}
break;
#endif // AMMETER
#ifdef BOOTLOCK
case 'B':
if (g_EvseController.InFaultState()) {
strcpy(buffer,"1");
}
else {
g_EvseController.ClearBootLock();
strcpy(buffer,"0");
}
bufCnt=1;
rc = 0;
break;
#endif // BOOTLOCK
case 'C': // current capacity
if ((tokenCnt == 2) || (tokenCnt == 3)) {
u2.u8 = dtou32(tokens[1]);
Expand Down
6 changes: 5 additions & 1 deletion firmware/open_evse/rapi_proc.h
Expand Up @@ -2,7 +2,7 @@
/*
* Open EVSE Firmware
*
* Copyright (c) 2013-2021 Sam C. Lin <lincomatic@gmail.com>
* Copyright (c) 2013-2023 Sam C. Lin <lincomatic@gmail.com>
*
* This file is part of Open EVSE.
Expand Down Expand Up @@ -172,6 +172,10 @@ S5 A|M|0|1 - Mennekes lock setting
1 = lock (valid only in manual mode)
n.b. requires MENNEKES_LOCK. manual mode is volatile - always boots in automatic mode
SA currentscalefactor currentoffset - set ammeter settings
SB - clear boot lock
when BOOTLOCK is defined, EVSE won't allow charging after boot up until SB is received
response: $OK 0 = unlock success
$OK 1 = unlock fail - EVSE currently in fault state
SC amps [V|M]- set current capacity
response:
if amps < minimum current capacity, will set to minimum and return $NK ampsset
Expand Down
3 changes: 2 additions & 1 deletion platformio.ini
Expand Up @@ -24,9 +24,10 @@ upload_flags = -F -e
#platform = atmelavr@1.4.1
# Arduino 1.6.23
platform = atmelavr@1.15.0
src_build_flags =
build_src_flags =
-DOEV6
-DRELAY_PWM
# -DBOOTLOCK
# -DENABLE_CGMI
-DAUTOSVCLEVEL
-DSHOW_DISABLED_TESTS
Expand Down

0 comments on commit 00ba307

Please sign in to comment.