@@ -56,6 +56,8 @@ const char _CONTENT_TYPE_JPEG[] PROGMEM = "image/jpeg";
5656const char _CONTENT_TYPE_PNG[] PROGMEM = " image/png" ;
5757const char _CONTENT_TYPE_SVG[] PROGMEM = " image/svg+xml" ;
5858
59+ #define RAPI_RESPONSE_BLOCKED -300
60+
5961void dumpRequest (MongooseHttpServerRequest *request)
6062{
6163#ifdef ENABLE_DEBUG_WEB_REQUEST
@@ -1093,12 +1095,18 @@ handleRapi(MongooseHttpServerRequest *request) {
10931095 if (request->hasParam (" rapi" ))
10941096 {
10951097 String rapi = request->getParam (" rapi" );
1098+ int ret = RAPI_RESPONSE_NK;
10961099
1097- // BUG: Really we should do this in the main loop not here...
1098- RAPI_PORT.flush ();
1099- DBUGVAR (rapi);
1100- int ret = rapiSender.sendCmdSync (rapi);
1101- DBUGVAR (ret);
1100+ if (!evse.isRapiCommandBlocked (rapi))
1101+ {
1102+ // BUG: Really we should do this in the main loop not here...
1103+ RAPI_PORT.flush ();
1104+ DBUGVAR (rapi);
1105+ ret = rapiSender.sendCmdSync (rapi);
1106+ DBUGVAR (ret);
1107+ } else {
1108+ ret = RAPI_RESPONSE_BLOCKED;
1109+ }
11021110
11031111 if (RAPI_RESPONSE_OK == ret ||
11041112 RAPI_RESPONSE_NK == ret)
@@ -1154,6 +1162,7 @@ handleRapi(MongooseHttpServerRequest *request) {
11541162 RAPI_RESPONSE_BAD_CHECKSUM == ret ? F (" RAPI_RESPONSE_BAD_CHECKSUM" ) :
11551163 RAPI_RESPONSE_BAD_SEQUENCE_ID == ret ? F (" RAPI_RESPONSE_BAD_SEQUENCE_ID" ) :
11561164 RAPI_RESPONSE_ASYNC_EVENT == ret ? F (" RAPI_RESPONSE_ASYNC_EVENT" ) :
1165+ RAPI_RESPONSE_BLOCKED == ret ? F (" RAPI_RESPONSE_BLOCKED" ) :
11571166 F (" UNKNOWN" );
11581167
11591168 if (json) {
@@ -1164,7 +1173,7 @@ handleRapi(MongooseHttpServerRequest *request) {
11641173 s += errorString;
11651174 }
11661175
1167- code = 500 ;
1176+ code = RAPI_RESPONSE_BLOCKED == ret ? 400 : 500 ;
11681177 }
11691178 }
11701179 if (false == json) {
0 commit comments