|
@@ -68,7 +68,6 @@ static char CurrentChargingProfileScheduleStr[30] = {0};
|
|
|
// OCPP status/previous related variables
|
|
|
//========================================
|
|
|
static int GunStatusInterval = 10;
|
|
|
-static uint8_t statusModeChage[CONNECTOR_QUANTITY] = {FALSE};
|
|
|
static uint8_t ChademoPreviousSystemStatus[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
|
|
|
static uint8_t CcsPreviousSystemStatus[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
|
|
|
static uint8_t GbPreviousSystemStatus[(GB_QUANTITY>0?GB_QUANTITY:1)];
|
|
@@ -130,10 +129,11 @@ typedef union
|
|
|
struct
|
|
|
{
|
|
|
//CsMsgValue[0]
|
|
|
- unsigned char StatusNotificationReq:1; //bit 0,
|
|
|
- unsigned char StatusNotificationConf:1; //bit 1,
|
|
|
- unsigned char TriggerMeterValue:1; //bit 2,
|
|
|
- unsigned char :5; //bit 5~7
|
|
|
+ unsigned char StatusNotificationReq:1; //bit 0,
|
|
|
+ unsigned char StatusNotificationConf:1; //bit 1,
|
|
|
+ unsigned char TriggerMeterValue:1; //bit 2,
|
|
|
+ unsigned char TriggerStatusNotificationReq:1; //bit 3,
|
|
|
+ unsigned char :4; //bit 4~7
|
|
|
}bits[CONNECTOR_QUANTITY];
|
|
|
}CpinitiateMsg;
|
|
|
|
|
@@ -3022,7 +3022,6 @@ void CheckSystemValue(void)
|
|
|
ChademoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
|
|
|
ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
|
|
|
cpinitateMsg.bits[gun_index].StatusNotificationReq = 1;
|
|
|
- statusModeChage[gun_index] = TRUE;
|
|
|
}
|
|
|
|
|
|
if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARING))) // complete
|
|
@@ -3080,7 +3079,6 @@ void CheckSystemValue(void)
|
|
|
CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
|
|
|
CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
|
|
|
cpinitateMsg.bits[gun_index].StatusNotificationReq = 1;
|
|
|
- statusModeChage[gun_index] = TRUE;
|
|
|
}
|
|
|
|
|
|
if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_PREPARING))) // complete
|
|
@@ -3137,7 +3135,6 @@ void CheckSystemValue(void)
|
|
|
GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
|
|
|
GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
|
|
|
cpinitateMsg.bits[gun_index].StatusNotificationReq = 1;
|
|
|
- statusModeChage[gun_index] = TRUE;
|
|
|
}
|
|
|
|
|
|
if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_PREPARING))) // complete
|
|
@@ -3186,7 +3183,6 @@ void CheckSystemValue(void)
|
|
|
DoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus;
|
|
|
DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn;
|
|
|
cpinitateMsg.bits[gun_index].StatusNotificationReq = 1;
|
|
|
- statusModeChage[gun_index] = TRUE;
|
|
|
}
|
|
|
|
|
|
if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARING))) // complete
|
|
@@ -3242,7 +3238,6 @@ void CheckSystemValue(void)
|
|
|
AcPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
|
|
|
AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
|
|
|
cpinitateMsg.bits[gun_index].StatusNotificationReq = 1;
|
|
|
- statusModeChage[gun_index] = TRUE;
|
|
|
}
|
|
|
|
|
|
if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_PREPARING))) // complete
|
|
@@ -3268,11 +3263,9 @@ void CheckSystemValue(void)
|
|
|
}// END
|
|
|
}
|
|
|
|
|
|
- if(isWebsocketSendable && (server_sign == TRUE) &&
|
|
|
+ if(isWebsocketSendable && (server_sign == TRUE) && ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > 5) &&
|
|
|
(
|
|
|
- (statusModeChage[gun_index] == TRUE) ||
|
|
|
- //((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > (server_cycle_Status + (GunStatusInterval*gun_index))) ||
|
|
|
- ((cpinitateMsg.bits[gun_index].StatusNotificationReq == 1) && ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > 5))
|
|
|
+ (cpinitateMsg.bits[gun_index].StatusNotificationReq == 1) || (cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq == 1)
|
|
|
)
|
|
|
)
|
|
|
{
|
|
@@ -3282,7 +3275,6 @@ void CheckSystemValue(void)
|
|
|
memcpy(&ShmOCPP16DataPH->StatusNotification[gun_index], &ShmOCPP16DataPH->StatusNotification[gun_index], sizeof(struct StructStatusNotification));
|
|
|
sendStatusNotificationRequest(gun_index);
|
|
|
clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
|
|
|
- statusModeChage[gun_index] = FALSE;
|
|
|
}
|
|
|
|
|
|
//==============================================
|
|
@@ -4463,11 +4455,11 @@ S_FAULT =12
|
|
|
|
|
|
//it's option
|
|
|
if(((strstr((char *)ShmOCPP16DataPH->StatusNotification[gun_index].Status, ChargePointStatusStr[currentStatus]) != NULL) || (((currentStatus == SuspendedEV) || (currentStatus == SuspendedEVSE)) && ShmOCPP16DataPH->CsMsg.bits[gun_index].RemoteStopTransactionReq)) &&
|
|
|
- !ShmOCPP16DataPH->CsMsg.bits[gun_index].TriggerMessageReq)
|
|
|
+ !cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq)
|
|
|
{
|
|
|
isStateChanged = FALSE;
|
|
|
}
|
|
|
- ShmOCPP16DataPH->CsMsg.bits[gun_index].TriggerMessageReq = 0;
|
|
|
+ cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = 0;
|
|
|
|
|
|
strcpy((char *)ShmOCPP16DataPH->StatusNotification[gun_index].Timestamp, buf);
|
|
|
strcpy((char *)ShmOCPP16DataPH->StatusNotification[gun_index].VendorId, (char*)ShmSysConfigAndInfo->SysConfig.chargePointVendor);
|
|
@@ -4503,6 +4495,7 @@ S_FAULT =12
|
|
|
else
|
|
|
{
|
|
|
cpinitateMsg.bits[gun_index].StatusNotificationReq = 0;
|
|
|
+ cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = 0;
|
|
|
result = PASS;
|
|
|
}
|
|
|
|
|
@@ -8767,6 +8760,95 @@ 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, "ID_CpConfiguration") != 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, "MaxChargingCurrent") != NULL)
|
|
|
+ {
|
|
|
+ if(json_object_get_int(json_object_object_get(data, "MaxChargingCurrent")) >= 0)
|
|
|
+ ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent = json_object_get_int(json_object_object_get(data, "MaxChargingCurrent"));
|
|
|
+ else
|
|
|
+ {
|
|
|
+ json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
+ json_object_object_add(response, "data", json_object_new_string("Configuration content something wrong."));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(json_object_object_get(data, "MaxChargingDuration") != NULL)
|
|
|
+ {
|
|
|
+ if(json_object_get_int(json_object_object_get(data, "MaxChargingDuration")) >= 0)
|
|
|
+ ShmSysConfigAndInfo->SysConfig.MaxChargingDuration = json_object_get_int(json_object_object_get(data, "MaxChargingDuration"));
|
|
|
+ else
|
|
|
+ {
|
|
|
+ json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
+ json_object_object_add(response, "data", json_object_new_string("Configuration content something wrong."));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(json_object_object_get(data, "MaxChargingEnergy") != NULL)
|
|
|
+ {
|
|
|
+ if(json_object_get_int(json_object_object_get(data, "MaxChargingEnergy")) >= 0)
|
|
|
+ ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy = json_object_get_int(json_object_object_get(data, "MaxChargingEnergy"));
|
|
|
+ else
|
|
|
+ {
|
|
|
+ json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
+ json_object_object_add(response, "data", json_object_new_string("Configuration content something wrong."));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(json_object_object_get(data, "MaxChargingPower") != NULL)
|
|
|
+ {
|
|
|
+ if(json_object_get_int(json_object_object_get(data, "MaxChargingPower")) >= 0)
|
|
|
+ ShmSysConfigAndInfo->SysConfig.MaxChargingPower = json_object_get_int(json_object_object_get(data, "MaxChargingPower"));
|
|
|
+ else
|
|
|
+ {
|
|
|
+ json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
+ json_object_object_add(response, "data", json_object_new_string("Configuration content something wrong."));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(json_object_object_get(data, "OfflineMaxChargeEnergy") != NULL)
|
|
|
+ {
|
|
|
+ if(json_object_get_int(json_object_object_get(data, "OfflineMaxChargeEnergy")) >= 0)
|
|
|
+ ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy = json_object_get_int(json_object_object_get(data, "OfflineMaxChargeEnergy"));
|
|
|
+ else
|
|
|
+ {
|
|
|
+ json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
+ json_object_object_add(response, "data", json_object_new_string("Configuration content something wrong."));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(json_object_object_get(data, "OfflinePolicy") != NULL)
|
|
|
+ {
|
|
|
+ if((json_object_get_int(json_object_object_get(data, "OfflinePolicy")) == 0) ||
|
|
|
+ (json_object_get_int(json_object_object_get(data, "OfflinePolicy")) == 2) ||
|
|
|
+ (json_object_get_int(json_object_object_get(data, "OfflinePolicy")) == 3))
|
|
|
+ ShmSysConfigAndInfo->SysConfig.OfflinePolicy = json_object_get_int(json_object_object_get(data, "OfflinePolicy"));
|
|
|
+ else
|
|
|
+ {
|
|
|
+ json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
+ json_object_object_add(response, "data", json_object_new_string("Configuration content something wrong."));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(strstr(json_object_get_string(json_object_object_get(response, "status")), "Accepted") != NULL)
|
|
|
+ StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
+ json_object_object_add(response, "data", json_object_new_string("Configuration content something wrong."));
|
|
|
+ }
|
|
|
+ json_object_put(data);
|
|
|
+
|
|
|
+ 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
|
|
|
{
|
|
|
// Can not find valid message id
|
|
@@ -11769,7 +11851,8 @@ int handleTriggerMessageRequest(char *uuid, char *payload)
|
|
|
if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
|
|
|
{
|
|
|
ShmOCPP16DataPH->CsMsg.bits[connectorIdInt-1].TriggerMessageReq = 1;
|
|
|
- cpinitateMsg.bits[connectorIdInt -1].StatusNotificationReq = 1;
|
|
|
+ cpinitateMsg.bits[connectorIdInt -1].TriggerStatusNotificationReq = 1;
|
|
|
+ //clientTime.StatusNotification[connectorIdInt-1] = time((time_t*)NULL);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -11777,7 +11860,8 @@ int handleTriggerMessageRequest(char *uuid, char *payload)
|
|
|
for(int idx=0;idx< gunTotalNumber;idx++)
|
|
|
{
|
|
|
ShmOCPP16DataPH->CsMsg.bits[idx].TriggerMessageReq = 1;
|
|
|
- cpinitateMsg.bits[idx].StatusNotificationReq = 1;
|
|
|
+ cpinitateMsg.bits[idx].TriggerStatusNotificationReq = 1;
|
|
|
+ //clientTime.StatusNotification[idx] = time((time_t*)NULL);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -12751,6 +12835,7 @@ void handleStatusNotificationResponse(char *payload, int gun_index)
|
|
|
mtrace();
|
|
|
DEBUG_INFO("handleStatusNotificationResponse...\n");
|
|
|
|
|
|
+ cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = 0;
|
|
|
cpinitateMsg.bits[gun_index].StatusNotificationReq = 0;
|
|
|
cpinitateMsg.bits[gun_index].StatusNotificationConf = 1;
|
|
|
|
|
@@ -17919,7 +18004,6 @@ void InitialSystemValue(void)
|
|
|
DiagnosticsStatusNotificationStatus = DIAGNOSTIC_STATUS_IDLE; // Idle
|
|
|
|
|
|
memset(CurrentChargingProfileScheduleStr, 0, ARRAY_SIZE(CurrentChargingProfileScheduleStr));
|
|
|
- memset(statusModeChage, 0, ARRAY_SIZE(statusModeChage));
|
|
|
memset(ChademoPreviousSystemStatus, 0, ARRAY_SIZE(ChademoPreviousSystemStatus));
|
|
|
memset(CcsPreviousSystemStatus, 0, ARRAY_SIZE(CcsPreviousSystemStatus));
|
|
|
memset(GbPreviousSystemStatus, 0, ARRAY_SIZE(GbPreviousSystemStatus));
|
|
@@ -18052,10 +18136,10 @@ void InitialSystemValue(void)
|
|
|
|
|
|
for(int gun_index=0; gun_index < gunTotalNumber; gun_index++ )
|
|
|
{
|
|
|
+ cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = 0;
|
|
|
cpinitateMsg.bits[gun_index].StatusNotificationReq = 0;
|
|
|
cpinitateMsg.bits[gun_index].StatusNotificationConf = 0;
|
|
|
//clientTime.MeterValues[gun_index] = time((time_t*)NULL);
|
|
|
- clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
|
|
|
memset(&ShmOCPP16DataPH->StatusNotification[gun_index], 0x00, sizeof(struct StructStatusNotification));
|
|
|
}
|
|
|
|