@@ -58,6 +58,10 @@ const char _CONTENT_TYPE_JPEG[] PROGMEM = "image/jpeg";
5858const char _CONTENT_TYPE_PNG[] PROGMEM = " image/png" ;
5959const char _CONTENT_TYPE_SVG[] PROGMEM = " image/svg+xml" ;
6060
61+ #define RAPI_RESPONSE_BLOCKED -300
62+
63+ void handleEvseClaims (MongooseHttpServerRequest *request);
64+
6165void dumpRequest (MongooseHttpServerRequest *request)
6266{
6367#ifdef ENABLE_DEBUG_WEB_REQUEST
@@ -119,7 +123,7 @@ void dumpRequest(MongooseHttpServerRequest *request)
119123// -------------------------------------------------------------------
120124// Helper function to perform the standard operations on a request
121125// -------------------------------------------------------------------
122- bool requestPreProcess (MongooseHttpServerRequest *request, MongooseHttpServerResponseStream *&response, fstr_t contentType = CONTENT_TYPE_JSON )
126+ bool requestPreProcess (MongooseHttpServerRequest *request, MongooseHttpServerResponseStream *&response, fstr_t contentType)
123127{
124128 dumpRequest (request);
125129
@@ -587,6 +591,8 @@ handleStatus(MongooseHttpServerRequest *request) {
587591
588592 create_rapi_json (doc);
589593
594+ doc[" status" ] = evse.getState ().toString ();
595+
590596 doc[" elapsed" ] = evse.getSessionElapsed ();
591597 doc[" wattsec" ] = evse.getSessionEnergy () * SESSION_ENERGY_SCALE_FACTOR;
592598 doc[" watthour" ] = evse.getTotalEnergy () * TOTAL_ENERGY_SCALE_FACTOR;
@@ -1097,12 +1103,18 @@ handleRapi(MongooseHttpServerRequest *request) {
10971103 if (request->hasParam (" rapi" ))
10981104 {
10991105 String rapi = request->getParam (" rapi" );
1106+ int ret = RAPI_RESPONSE_NK;
11001107
1101- // BUG: Really we should do this in the main loop not here...
1102- RAPI_PORT.flush ();
1103- DBUGVAR (rapi);
1104- int ret = rapiSender.sendCmdSync (rapi);
1105- DBUGVAR (ret);
1108+ if (!evse.isRapiCommandBlocked (rapi))
1109+ {
1110+ // BUG: Really we should do this in the main loop not here...
1111+ RAPI_PORT.flush ();
1112+ DBUGVAR (rapi);
1113+ ret = rapiSender.sendCmdSync (rapi);
1114+ DBUGVAR (ret);
1115+ } else {
1116+ ret = RAPI_RESPONSE_BLOCKED;
1117+ }
11061118
11071119 if (RAPI_RESPONSE_OK == ret ||
11081120 RAPI_RESPONSE_NK == ret)
@@ -1158,6 +1170,7 @@ handleRapi(MongooseHttpServerRequest *request) {
11581170 RAPI_RESPONSE_BAD_CHECKSUM == ret ? F (" RAPI_RESPONSE_BAD_CHECKSUM" ) :
11591171 RAPI_RESPONSE_BAD_SEQUENCE_ID == ret ? F (" RAPI_RESPONSE_BAD_SEQUENCE_ID" ) :
11601172 RAPI_RESPONSE_ASYNC_EVENT == ret ? F (" RAPI_RESPONSE_ASYNC_EVENT" ) :
1173+ RAPI_RESPONSE_BLOCKED == ret ? F (" RAPI_RESPONSE_BLOCKED" ) :
11611174 F (" UNKNOWN" );
11621175
11631176 if (json) {
@@ -1168,7 +1181,7 @@ handleRapi(MongooseHttpServerRequest *request) {
11681181 s += errorString;
11691182 }
11701183
1171- code = 500 ;
1184+ code = RAPI_RESPONSE_BLOCKED == ret ? 400 : 500 ;
11721185 }
11731186 }
11741187 if (false == json) {
@@ -1251,6 +1264,8 @@ web_server_setup() {
12511264 server.on (" /schedule/plan$" , handleSchedulePlan);
12521265 server.on (" /schedule" , handleSchedule);
12531266
1267+ server.on (" /claims" , handleEvseClaims);
1268+
12541269 server.on (" /override$" , handleOverride);
12551270
12561271 // Simple Firmware Update Form
0 commit comments