|
@@ -126,7 +126,7 @@ struct ClientTime
|
|
|
struct timespec StopTransaction;
|
|
|
struct timespec MeterValues[CONNECTOR_QUANTITY];
|
|
|
struct timespec RemoteStartWait;
|
|
|
- struct timespec YesCustomCallReader;
|
|
|
+ struct timespec TcciQueryDeduct;
|
|
|
}clientTime;
|
|
|
|
|
|
typedef union
|
|
@@ -808,6 +808,84 @@ int OCPP_insert_transaction_msg(uint8_t isStartTransaction, char *transactionMsg
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+int OCPP_insert_deduct_info(int txId, char *creditNo, uint8_t deductResult, uint8_t isDonateInvoice)
|
|
|
+{
|
|
|
+ int result = PASS;
|
|
|
+ char* errMsg = NULL;
|
|
|
+ char sqlStr[8192];
|
|
|
+
|
|
|
+ sprintf(sqlStr, "insert into report_deduct_info(transactionId, creditNo, deductResult, isDonateInvoice, isUploaded) values('%d', '%s', '%d', '%d', '0');", txId, creditNo, deductResult, isDonateInvoice);
|
|
|
+
|
|
|
+ if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
|
|
|
+ {
|
|
|
+ result = FAIL;
|
|
|
+ DEBUG_WARN( "Insert local report_deduct_info error message: %s\n", errMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ sprintf(sqlStr, "delete from report_deduct_info where (idx < (select idx from report_deduct_info order by idx desc limit 1)-5000);");
|
|
|
+ if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
|
|
|
+ {
|
|
|
+ result = FAIL;
|
|
|
+ DEBUG_WARN( "delete local report_deduct_info error message: %s\n", errMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+int OCPP_update_deduct_info(int txId, char *creditNo)
|
|
|
+{
|
|
|
+ int result = PASS;
|
|
|
+ char* errMsg = NULL;
|
|
|
+ char sqlStr[8192];
|
|
|
+
|
|
|
+ sprintf(sqlStr, "update report_deduct_info set isUploaded='1' where txId='%d' and creditNo='%s';", txId, creditNo);
|
|
|
+
|
|
|
+ if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
|
|
|
+ {
|
|
|
+ result = FAIL;
|
|
|
+ DEBUG_WARN( "Update local report_deduct_info error message: %s\n", errMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+int queryDeductCallBack(void *data, int columenCount, char **columnValue, char **columnName)
|
|
|
+{
|
|
|
+ json_object *deductData = json_object_new_object();
|
|
|
+
|
|
|
+ json_object_object_add(deductData, "txId", json_object_new_int(atoi(columnValue[1])));
|
|
|
+ json_object_object_add(deductData, "creditNo", json_object_new_string(columnValue[2]));
|
|
|
+ json_object_object_add(deductData, "deductResult", json_object_new_boolean(atoi(columnValue[3])));
|
|
|
+ json_object_object_add(deductData, "isDonateInvoice", json_object_new_boolean(atoi(columnValue[4])));
|
|
|
+
|
|
|
+ sprintf((char*)ShmOCPP16DataPH->DataTransfer[0].VendorId, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
|
|
|
+ sprintf((char*)ShmOCPP16DataPH->DataTransfer[0].MessageId,"ID_CreditDeductResult");
|
|
|
+ sprintf((char*)ShmOCPP16DataPH->DataTransfer[0].Data, json_object_to_json_string_ext(deductData, JSON_C_TO_STRING_PLAIN));
|
|
|
+ json_object_put(deductData);
|
|
|
+
|
|
|
+ ShmOCPP16DataPH->CsMsg.bits[0].DataTransferReq = 1;
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+void OCPP_query_deduct_info()
|
|
|
+{
|
|
|
+ int rc = 0;
|
|
|
+
|
|
|
+ char sql[100];
|
|
|
+ char zErrMsg[100];
|
|
|
+
|
|
|
+ sprintf(sql,"select * from report_deduct_info where isUploaded='0' order by idx limit 1");
|
|
|
+
|
|
|
+ /* Execute SQL statement */
|
|
|
+ rc = sqlite3_exec(db, sql, queryDeductCallBack, 0, (char **)&zErrMsg);
|
|
|
+
|
|
|
+ if( rc != SQLITE_OK )
|
|
|
+ {
|
|
|
+ DEBUG_INFO("SQL error: %s\n", zErrMsg);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
//==========================================
|
|
|
// Check time passed since today
|
|
|
//==========================================
|
|
@@ -3947,16 +4025,19 @@ void CheckSystemValue(void)
|
|
|
}
|
|
|
|
|
|
//===============================
|
|
|
- // send YES CallReader
|
|
|
+ // Credit deduct report
|
|
|
//===============================
|
|
|
- if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP16DataPH->YesCustomData.CallReaderReq == 1) && (getDiffSecNow(clientTime.YesCustomCallReader) >= 5))
|
|
|
+ if(ShmOCPP16DataPH->TcciCustomData.ReportCreditDeductReq)
|
|
|
{
|
|
|
- sprintf((char*)ShmOCPP16DataPH->DataTransfer[0].VendorId, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
|
|
|
- sprintf((char*)ShmOCPP16DataPH->DataTransfer[0].MessageId,"call_reader");
|
|
|
- sprintf((char*)ShmOCPP16DataPH->DataTransfer[0].Data," ");
|
|
|
- ShmOCPP16DataPH->CsMsg.bits[0].DataTransferReq = 1;
|
|
|
- //ShmOCPP16Data->YesCustomData.CallReaderReq = 0;
|
|
|
- refreshStartTimer(&clientTime.YesCustomCallReader);
|
|
|
+ OCPP_insert_deduct_info(ShmOCPP16DataPH->TcciCustomData.DeductInfo.txId, (char*)ShmOCPP16DataPH->TcciCustomData.DeductInfo.creditNo, ShmOCPP16DataPH->TcciCustomData.DeductInfo.deductResult, ShmOCPP16DataPH->TcciCustomData.DeductInfo.isDonateInvoice);
|
|
|
+
|
|
|
+ ShmOCPP16DataPH->TcciCustomData.ReportCreditDeductReq = FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(getDiffSecNow(clientTime.TcciQueryDeduct) > 5)
|
|
|
+ {
|
|
|
+ OCPP_query_deduct_info();
|
|
|
+ refreshStartTimer(&clientTime.TcciQueryDeduct);
|
|
|
}
|
|
|
|
|
|
for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
|
|
@@ -10332,255 +10413,6 @@ int handleDataTransferRequest(char *uuid, char *payload)
|
|
|
sprintf(message,"[%d,\"%s\",%s]",MESSAGE_TYPE_CALLRESULT, uuid, json_object_to_json_string_ext(response, JSON_C_TO_STRING_PLAIN));
|
|
|
json_object_put(response);
|
|
|
}
|
|
|
- else if(strstr(tempmessageId, "refund_status") != NULL)
|
|
|
- {
|
|
|
- json_object *data;
|
|
|
- data = json_tokener_parse(tempdata);
|
|
|
- if(!is_error(data))
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Accepted"));
|
|
|
-
|
|
|
- if(json_object_object_get(data, "status") != NULL)
|
|
|
- {
|
|
|
- //DEBUG_INFO("status: %s\n", json_object_get_string(json_object_object_get(data, "status")));
|
|
|
- if(strcmp(json_object_get_string(json_object_object_get(data, "status")), "T") || strcmp(json_object_get_string(json_object_object_get(data, "status")), "F"))
|
|
|
- {
|
|
|
- sprintf((char*)ShmOCPP16DataPH->YesCustomData.RefundStatus.status, "%s", json_object_get_string(json_object_object_get(data, "status")));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("status value is invalid."));
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("status data can not get."));
|
|
|
- }
|
|
|
-
|
|
|
- if(json_object_object_get(data, "chargeDate") != NULL)
|
|
|
- {
|
|
|
- sprintf((char *)ShmOCPP16DataPH->YesCustomData.RefundStatus.chargeDate, "%s", json_object_get_string(json_object_object_get(data,"chargeDate")));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("chargeDate data can not get."));
|
|
|
- }
|
|
|
-
|
|
|
- if(json_object_object_get(data, "holdAmt") != NULL)
|
|
|
- {
|
|
|
- if(json_object_get_int(json_object_object_get(data, "holdAmt")) >= 0)
|
|
|
- ShmOCPP16DataPH->YesCustomData.RefundStatus.holdAmt = json_object_get_int(json_object_object_get(data, "holdAmt"));
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("holdAmt data is invalid."));
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("holdAmt data can not get."));
|
|
|
- }
|
|
|
-
|
|
|
- if(json_object_object_get(data, "chargeAmt") != NULL)
|
|
|
- {
|
|
|
- if(json_object_get_int(json_object_object_get(data, "chargeAmt")) >= 0)
|
|
|
- ShmOCPP16DataPH->YesCustomData.RefundStatus.chargeAmt = json_object_get_int(json_object_object_get(data, "chargeAmt"));
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("chargeAmt data is invalid."));
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("chargeAmt data can not get."));
|
|
|
- }
|
|
|
-
|
|
|
- if(json_object_object_get(data, "refundAmt") != NULL)
|
|
|
- {
|
|
|
- if(json_object_get_int(json_object_object_get(data, "refundAmt")) >= 0)
|
|
|
- ShmOCPP16DataPH->YesCustomData.RefundStatus.refundAmt = json_object_get_int(json_object_object_get(data, "refundAmt"));
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("refundAmt data is invalid."));
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("refundAmt data can not get."));
|
|
|
- }
|
|
|
-
|
|
|
- if(json_object_object_get(data, "page") != NULL)
|
|
|
- {
|
|
|
- if(json_object_get_int(json_object_object_get(data, "page")) >= 0 && json_object_get_int(json_object_object_get(data, "page")) <= 3)
|
|
|
- ShmOCPP16DataPH->YesCustomData.RefundStatus.page = json_object_get_int(json_object_object_get(data, "page"));
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("page data is invalid."));
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("page data can not get."));
|
|
|
- }
|
|
|
-
|
|
|
- if(strcmp(json_object_get_string(json_object_object_get(response,"status")),"Accepted")==0)
|
|
|
- {
|
|
|
- ShmOCPP16DataPH->YesCustomData.RefundStatusReq = 1;
|
|
|
- DEBUG_INFO("<<< RefundStatus:{status:%s, chargeDate:%s, holdAmt:%d, chargeAmt:%d, refundAmt:%d, page:%d}\n",
|
|
|
- ShmOCPP16DataPH->YesCustomData.RefundStatus.status,
|
|
|
- ShmOCPP16DataPH->YesCustomData.RefundStatus.chargeDate,
|
|
|
- ShmOCPP16DataPH->YesCustomData.RefundStatus.holdAmt,
|
|
|
- ShmOCPP16DataPH->YesCustomData.RefundStatus.chargeAmt,
|
|
|
- ShmOCPP16DataPH->YesCustomData.RefundStatus.refundAmt,
|
|
|
- ShmOCPP16DataPH->YesCustomData.RefundStatus.page);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("refund_status content got something wrong."));
|
|
|
- }
|
|
|
- sprintf(message,"[%d,\"%s\",%s]",MESSAGE_TYPE_CALLRESULT, uuid, json_object_to_json_string_ext(response, JSON_C_TO_STRING_PLAIN));
|
|
|
- json_object_put(response);
|
|
|
- }
|
|
|
- else if(strstr(tempmessageId, "deduct_status") != NULL)
|
|
|
- {
|
|
|
- json_object *data;
|
|
|
- data = json_tokener_parse(tempdata);
|
|
|
- if(!is_error(data))
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Accepted"));
|
|
|
-
|
|
|
- if(json_object_object_get(data, "status") != NULL)
|
|
|
- {
|
|
|
- //DEBUG_INFO("status: %s\n", json_object_get_string(json_object_object_get(data, "status")));
|
|
|
- if((strcmp(json_object_get_string(json_object_object_get(data, "status")), "T")==0) || (strcmp(json_object_get_string(json_object_object_get(data, "status")), "F")==0))
|
|
|
- {
|
|
|
- sprintf((char*)ShmOCPP16DataPH->YesCustomData.DeductStatus.status, "%s", json_object_get_string(json_object_object_get(data, "status")));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("status value is invalid."));
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("status data can not get."));
|
|
|
- }
|
|
|
-
|
|
|
- if(json_object_object_get(data, "autoLoadAmt") != NULL)
|
|
|
- {
|
|
|
- if(json_object_get_int(json_object_object_get(data, "autoLoadAmt")) >= 0)
|
|
|
- ShmOCPP16DataPH->YesCustomData.DeductStatus.autoLoadAmt = json_object_get_int(json_object_object_get(data, "autoLoadAmt"));
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("autoLoadAmt is invalid."));
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("autoLoadAmt data can not get."));
|
|
|
- }
|
|
|
-
|
|
|
- if(json_object_object_get(data, "beforeAmt") != NULL)
|
|
|
- {
|
|
|
- if(json_object_get_int(json_object_object_get(data, "beforeAmt")) >= 0)
|
|
|
- ShmOCPP16DataPH->YesCustomData.DeductStatus.beforeAmt = json_object_get_int(json_object_object_get(data, "beforeAmt"));
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("beforeAmt data is invalid."));
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("beforeAmt data can not get."));
|
|
|
- }
|
|
|
-
|
|
|
- if(json_object_object_get(data, "chargeAmt") != NULL)
|
|
|
- {
|
|
|
- if(json_object_get_int(json_object_object_get(data, "chargeAmt")) >= 0)
|
|
|
- ShmOCPP16DataPH->YesCustomData.DeductStatus.chargeAmt = json_object_get_int(json_object_object_get(data, "chargeAmt"));
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("chargeAmt data is invalid."));
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("chargeAmt data can not get."));
|
|
|
- }
|
|
|
-
|
|
|
- if(json_object_object_get(data, "afterAmt") != NULL)
|
|
|
- {
|
|
|
- if(json_object_get_int(json_object_object_get(data, "afterAmt")) >= 0)
|
|
|
- ShmOCPP16DataPH->YesCustomData.DeductStatus.afterAmt = json_object_get_int(json_object_object_get(data, "afterAmt"));
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("afterAmt data is invalid."));
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("afterAmt data can not get."));
|
|
|
- }
|
|
|
-
|
|
|
- if(json_object_object_get(data, "page") != NULL)
|
|
|
- {
|
|
|
- if(json_object_get_int(json_object_object_get(data, "page")) >= 0)
|
|
|
- ShmOCPP16DataPH->YesCustomData.DeductStatus.page = json_object_get_int(json_object_object_get(data, "page"));
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("page data is invalid."));
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("page data can not get."));
|
|
|
- }
|
|
|
-
|
|
|
- if(strcmp(json_object_get_string(json_object_object_get(response,"status")),"Accepted")==0)
|
|
|
- {
|
|
|
- ShmOCPP16DataPH->YesCustomData.DeductStatusReq = 1;
|
|
|
- DEBUG_INFO("<<< deduct_status:{status:%s, autoLoadAmt:%d, beforeAmt:%d, chargeAmt:%d, afterAmt:%d, page:%d}\n",
|
|
|
- ShmOCPP16DataPH->YesCustomData.DeductStatus.status,
|
|
|
- ShmOCPP16DataPH->YesCustomData.DeductStatus.autoLoadAmt,
|
|
|
- ShmOCPP16DataPH->YesCustomData.DeductStatus.beforeAmt,
|
|
|
- ShmOCPP16DataPH->YesCustomData.DeductStatus.chargeAmt,
|
|
|
- ShmOCPP16DataPH->YesCustomData.DeductStatus.afterAmt,
|
|
|
- ShmOCPP16DataPH->YesCustomData.DeductStatus.page);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("deduct_status content got something wrong."));
|
|
|
- }
|
|
|
-
|
|
|
- sprintf(message,"[%d,\"%s\",%s]",MESSAGE_TYPE_CALLRESULT, uuid, json_object_to_json_string_ext(response, JSON_C_TO_STRING_PLAIN));
|
|
|
- json_object_put(response);
|
|
|
- }
|
|
|
else if(strstr(tempmessageId, "ID_Station_Location") != NULL)
|
|
|
{
|
|
|
json_object *data;
|
|
@@ -10591,7 +10423,7 @@ int handleDataTransferRequest(char *uuid, char *payload)
|
|
|
|
|
|
if(json_object_object_get(data, "stationName") != NULL)
|
|
|
{
|
|
|
- sprintf((char *)ShmOCPP16DataPH->YesCustomData.ChargerInfo.station_name, "%s", json_object_get_string(json_object_object_get(data,"stationName")));
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->TcciCustomData.ChargerInfo.station_name, "%s", json_object_get_string(json_object_object_get(data,"stationName")));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -10599,34 +10431,11 @@ int handleDataTransferRequest(char *uuid, char *payload)
|
|
|
json_object_object_add(response, "data", json_object_new_string("station_name data can not get."));
|
|
|
}
|
|
|
|
|
|
- /*if(json_object_object_get(data, "station_id") != NULL)
|
|
|
- {
|
|
|
- sprintf((char *)ShmOCPP16Data->YesCustomData.ChargerInfo.station_id, "%s", json_object_get_string(json_object_object_get(data,"station_id")));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("station_id data can not get."));
|
|
|
- }
|
|
|
-
|
|
|
- if(json_object_object_get(data, "charge_id") != NULL)
|
|
|
- {
|
|
|
- for(int idx=0;idx<json_object_array_length(json_object_object_get(data, "charge_id"));idx++)
|
|
|
- {
|
|
|
- sprintf((char*)ShmOCPP16Data->YesCustomData.ChargerInfo.charge_id[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(data, "charge_id"), idx)));
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("charge_id data can not get."));
|
|
|
- }*/
|
|
|
-
|
|
|
if(strcmp(json_object_get_string(json_object_object_get(response,"status")),"Accepted")==0)
|
|
|
{
|
|
|
- ShmOCPP16DataPH->YesCustomData.ChargerInfoReq = 1;
|
|
|
+ ShmOCPP16DataPH->TcciCustomData.ChargerInfoReq = 1;
|
|
|
DEBUG_INFO("<<< ID_Station_Location:{station_name:%s}\n",
|
|
|
- ShmOCPP16DataPH->YesCustomData.ChargerInfo.station_name);
|
|
|
+ ShmOCPP16DataPH->TcciCustomData.ChargerInfo.station_name);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -10648,7 +10457,7 @@ int handleDataTransferRequest(char *uuid, char *payload)
|
|
|
|
|
|
if(json_object_object_get(data, "weatherId") != NULL)
|
|
|
{
|
|
|
- ShmOCPP16DataPH->YesCustomData.WeatherInfo.weatherId = json_object_get_int(json_object_object_get(data, "weatherId"));
|
|
|
+ ShmOCPP16DataPH->TcciCustomData.WeatherInfo.weatherId = json_object_get_int(json_object_object_get(data, "weatherId"));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -10658,7 +10467,7 @@ int handleDataTransferRequest(char *uuid, char *payload)
|
|
|
|
|
|
if(json_object_object_get(data, "Temperature") != NULL)
|
|
|
{
|
|
|
- ShmOCPP16DataPH->YesCustomData.WeatherInfo.temperature = json_object_get_double(json_object_object_get(data,"Temperature"));
|
|
|
+ ShmOCPP16DataPH->TcciCustomData.WeatherInfo.temperature = json_object_get_double(json_object_object_get(data,"Temperature"));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -10668,65 +10477,44 @@ int handleDataTransferRequest(char *uuid, char *payload)
|
|
|
|
|
|
if(strcmp(json_object_get_string(json_object_object_get(response,"status")),"Accepted")==0)
|
|
|
{
|
|
|
- ShmOCPP16DataPH->YesCustomData.WeatherInfoReq = 1;
|
|
|
+ ShmOCPP16DataPH->TcciCustomData.WeatherInfoReq = 1;
|
|
|
DEBUG_INFO("<<< ID_Weather_Info:{weather:%d, temperature:%.1f}\n",
|
|
|
- ShmOCPP16DataPH->YesCustomData.WeatherInfo.weatherId,
|
|
|
- ShmOCPP16DataPH->YesCustomData.WeatherInfo.temperature);
|
|
|
+ ShmOCPP16DataPH->TcciCustomData.WeatherInfo.weatherId,
|
|
|
+ ShmOCPP16DataPH->TcciCustomData.WeatherInfo.temperature);
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
+ else if(strstr(tempmessageId, "ID_TriggerCreditReader") != NULL)
|
|
|
{
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("weather_info content got something wrong."));
|
|
|
- }
|
|
|
-
|
|
|
- sprintf(message,"[%d,\"%s\",%s]",MESSAGE_TYPE_CALLRESULT, uuid, json_object_to_json_string_ext(response, JSON_C_TO_STRING_PLAIN));
|
|
|
- json_object_put(response);
|
|
|
- }
|
|
|
- else if(strstr(tempmessageId, "set_qrcode") != NULL)
|
|
|
- {
|
|
|
- json_object *data;
|
|
|
- data = json_tokener_parse(tempdata);
|
|
|
- if(!is_error(data))
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Accepted"));
|
|
|
-
|
|
|
- if(json_object_object_get(data, "connectorId") != NULL)
|
|
|
+ json_object *data;
|
|
|
+ data = json_tokener_parse(tempdata);
|
|
|
+ if(!is_error(data))
|
|
|
{
|
|
|
- if((json_object_get_int(json_object_object_get(data, "connectorId")) > 0) && (json_object_get_int(json_object_object_get(data, "connectorId")) <= gunTotalNumber))
|
|
|
+ json_object_object_add(response, "status", json_object_new_string("Accepted"));
|
|
|
+
|
|
|
+ if(json_object_get_int(json_object_object_get(data, "ConnectorId")) > 0)
|
|
|
{
|
|
|
- int idx = json_object_get_int(json_object_object_get(data, "connectorId"))-1;
|
|
|
- if(json_object_object_get(data, "qrcode") != NULL)
|
|
|
- {
|
|
|
- sprintf((char *)ShmOCPP16DataPH->YesCustomData.QrCode[idx], "%s", json_object_get_string(json_object_object_get(data,"qrcode")));
|
|
|
- ShmOCPP16DataPH->YesCustomData.SetQrCodeReq = 1;
|
|
|
- DEBUG_INFO("<<< set_qrcode:{connectorId:%d, qrcode:%s}\n",
|
|
|
- idx,
|
|
|
- ShmOCPP16DataPH->YesCustomData.QrCode[idx]
|
|
|
- );
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("qrcode data can not get."));
|
|
|
- }
|
|
|
+ ShmOCPP16DataPH->TcciCustomData.TriggerReaderReq[json_object_get_int(json_object_object_get(data, "ConnectorId")) -1] = TRUE;
|
|
|
+ DEBUG_INFO("<<< ID_TriggerCreditReader:{ConnectorId: %d}\n", json_object_get_int(json_object_object_get(data, "ConnectorId")));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("connectorId data is invalid."));
|
|
|
+ json_object_object_add(response, "data", json_object_new_string("ConnectorId does not valid."));
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("connectorId data can not get."));
|
|
|
+ json_object_object_add(response, "data", json_object_new_string("charger_info content got something wrong."));
|
|
|
}
|
|
|
+
|
|
|
+ sprintf(message,"[%d,\"%s\",%s]",MESSAGE_TYPE_CALLRESULT, uuid, json_object_to_json_string_ext(response, JSON_C_TO_STRING_PLAIN));
|
|
|
+ json_object_put(response);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string("set_qrcode content got something wrong."));
|
|
|
+ json_object_object_add(response, "data", json_object_new_string("weather_info content got something wrong."));
|
|
|
}
|
|
|
|
|
|
sprintf(message,"[%d,\"%s\",%s]",MESSAGE_TYPE_CALLRESULT, uuid, json_object_to_json_string_ext(response, JSON_C_TO_STRING_PLAIN));
|
|
@@ -14817,28 +14605,32 @@ void handleBootNotificationResponse(char *payload, int gun_index)
|
|
|
void handleDataTransferResponse(char *payload, int gun_index)
|
|
|
{
|
|
|
json_object *DataTransfer = json_tokener_parse(payload);
|
|
|
- char status[32];
|
|
|
|
|
|
if(!is_error(DataTransfer))
|
|
|
{
|
|
|
-
|
|
|
// Required data
|
|
|
- sprintf(status, "%s", json_object_get_string(json_object_object_get(DataTransfer, "status")));
|
|
|
- DEBUG_INFO("Status: %s.\n", status);
|
|
|
+ DEBUG_INFO("Status: %s.\n", json_object_get_string(json_object_object_get(DataTransfer, "status")));
|
|
|
|
|
|
// Optional data
|
|
|
if(json_object_object_get(DataTransfer, "data") != NULL)
|
|
|
- DEBUG_INFO("Data: %s\n", json_object_get_string(json_object_object_get(DataTransfer, "data")));
|
|
|
-
|
|
|
- // YES call_reader message confirm
|
|
|
- if(ShmOCPP16DataPH->YesCustomData.CallReaderReq == 1)
|
|
|
{
|
|
|
- sprintf((char *)ShmOCPP16DataPH->YesCustomData.CallReaderStatus, "%s",status);
|
|
|
- ShmOCPP16DataPH->YesCustomData.CallReaderConf = 1;
|
|
|
- ShmOCPP16DataPH->YesCustomData.CallReaderReq = 0;
|
|
|
- DEBUG_INFO("Report CallReader status to CSU: %s\n",ShmOCPP16DataPH->YesCustomData.CallReaderStatus);
|
|
|
+ DEBUG_INFO("Data: %s\n", json_object_get_string(json_object_object_get(DataTransfer, "data")));
|
|
|
+ json_object *Data = json_tokener_parse(json_object_get_string(json_object_object_get(DataTransfer, "data")));
|
|
|
+
|
|
|
+ if(!is_error(Data))
|
|
|
+ {
|
|
|
+ if(json_object_object_get(Data, "msgId") != NULL)
|
|
|
+ {
|
|
|
+ if(strstr(json_object_get_string(json_object_object_get(Data, "msgId")), "ID_CreditDeductResult") != NULL)
|
|
|
+ {
|
|
|
+ OCPP_update_deduct_info(json_object_get_int(json_object_object_get(Data, "txId")), (char*)json_object_get_string(json_object_object_get(Data, "creditNo")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ json_object_put(Data);
|
|
|
}
|
|
|
}
|
|
|
+ json_object_put(DataTransfer);
|
|
|
}
|
|
|
|
|
|
void handleDiagnosticsStatusNotificationResponse(char *payload, int gun_index)
|