Selaa lähdekoodia

2020.06.01 / Folus Wen

Actions:
1. EVSE/Modularization/ocppfiles/MessageHandler.c add sendFirmwareVersionByDataTransfer() when receive BootNotification response.
2. EVSE/Modularization/ocppfiles/MessageHandler.c handleChangeAvailabilityRequest() modify operation Accepted, Scheduled, Rejected logic .

Files:
1. As follow commit history

Image version: D0.00.XX.XXXX.XX
Image checksum: XXXXXXXX

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen 4 vuotta sitten
vanhempi
commit
030d3139d3

+ 92 - 30
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -3116,8 +3116,7 @@ int sendDataTransferRequest(int gun_index)
 	LWS_Send(message);
 
 	sprintf(tempdata, "DataTransfer,%d", (gun_index + 1));
-
-	if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)//if(hashmap_operation(0,NULL/*hashMap*/, mapItem[0].key_string, mapItem[0].key_value/*mapItem*/, (void**)(&mapItem)/*(void**)(&mapItem)*/) ==  MAP_OK/*hashmap_put(hashMap, mapItem->key_string, mapItem) == MAP_OK*/)
+	if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
 	{
 		result = PASS;
 		DEBUG_INFO("DataTransfer mapItem pass\n");
@@ -3126,6 +3125,50 @@ int sendDataTransferRequest(int gun_index)
 	return result;
 }
 
+int sendFirmwareVersionByDataTransfer(void)
+{
+	int8_t result = FAIL;
+	json_object *FirmwareDataTransfer = json_object_new_object();
+
+	// AC & DC model
+	json_object_object_add(FirmwareDataTransfer, "CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev));
+	json_object_object_add(FirmwareDataTransfer, "CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev));
+	json_object_object_add(FirmwareDataTransfer, "CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev));
+	json_object_object_add(FirmwareDataTransfer, "CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev));
+
+	// DC model
+	if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D'))
+	{
+		json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
+		json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
+		json_object_object_add(FirmwareDataTransfer, "LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.LedModuleFwRev));
+		json_object_object_add(FirmwareDataTransfer, "Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector1FwRev));
+	}
+
+	if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
+	   ((gunType[1] != '0') || (gunType[2] != '0') || (gunType[3] != '0')))
+	{
+		json_object_object_add(FirmwareDataTransfer, "Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector2FwRev));
+	}
+
+	// 4G model
+	if((ShmSysConfigAndInfo->SysConfig.ModelName[10]=='T'))
+	{
+		json_object_object_add(FirmwareDataTransfer, "TelcomModemFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
+	}
+
+	sprintf((char*)ShmOCPP16Data->DataTransfer[0].VendorId, "Phihong Technology");
+	sprintf((char*)ShmOCPP16Data->DataTransfer[0].MessageId, "ID_FirmwareVersion");
+	sprintf((char*)ShmOCPP16Data->DataTransfer[0].Data, json_object_to_json_string(FirmwareDataTransfer));
+
+	if(sendDataTransferRequest(0))
+	{
+		result = PASS;
+	}
+
+	return result;
+}
+
 int sendDiagnosticsStatusNotificationRequest(char *status)
 {
 	mtrace();
@@ -5806,16 +5849,6 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
 	if(specificId == FALSE)
 		goto end;
 
-	if(gunIndex != 0)
-	{
-		ShmOCPP16Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = 1;
-	}
-	else
-	{
-		for(int i=0; i < gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/; i++)
-			ShmOCPP16Data->CsMsg.bits[i].ChangeAvailabilityReq = 1;
-	}
-
 	if(strcmp((const char *)typeStr, AvailabilityTypeStr[Inoperative]) == 0)
 	{
 	    //check Transaction active
@@ -5823,24 +5856,26 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
 		{
 			if ((gunIndex  == 0) || ((gunIndex > 0)&&(gunType[gunIndex-1] == 'J')))
 			{
-				if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) // S_PRECHARGE
+				if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) // S_PRECHARGE
 				{
 					sprintf(comfirmstr, "%s", AvailabilityStatusStr[Rejected] );
 					goto end;
 				}
-				else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING)  // S_CHARGING
+				else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
+						(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
+						(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
+						(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
+						(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE))  // S_CHARGING
 				{
 					sprintf(comfirmstr, "%s", AvailabilityStatusStr[Scheduled] );
 					goto end;
 				}
 				else
 				{
-					DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.ChademoChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus);
+					DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.ChademoChargingData[%d].SystemStatus = %d\n",index, ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus);
 					sprintf(comfirmstr, "%s", AvailabilityStatusStr[Accepted] );
 					goto end;
 				}
-
-
 			}
 		}//END FOR CHAdeMO_QUANTITY
 
@@ -5848,12 +5883,16 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
 		{
 			if ((gunIndex  == 0)||  ((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E'))))
 			{
-				if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING)// S_PRECHARGE
+				if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) )// S_PRECHARGE
 				{
 					sprintf(comfirmstr, "%s", AvailabilityStatusStr[Rejected] );
 					goto end;
 				}
-				else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) // S_CHARGING
+				else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
+						(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
+						(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
+						(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
+						(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
 				{
 					sprintf(comfirmstr, "%s", AvailabilityStatusStr[Scheduled] );
 					goto end;
@@ -5871,12 +5910,16 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
 		{
 			if ((gunIndex  == 0)|| ((gunIndex > 0)&&(gunType[gunIndex-1] == 'G')))
 			{
-				if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) // S_PRECHARGE
+				if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
 				{
 					sprintf(comfirmstr, "%s", AvailabilityStatusStr[Rejected] );
 					goto end;
 				}
-				else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) // S_CHARGING
+				else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
+						(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
+						(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
+						(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
+						(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
 				{
 					sprintf(comfirmstr, "%s", AvailabilityStatusStr[Scheduled] );
 					goto end;
@@ -5896,12 +5939,16 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
 		{
 			if ((gunIndex  == 0) || ((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9'))))
 			{
-				if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) // S_PRECHARGE
+				if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
 				{
 					sprintf(comfirmstr, "%s", AvailabilityStatusStr[Rejected] );
 					goto end;
 				}
-				else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING)  // S_CHARGING
+				else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
+						(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
+						(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
+						(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
+						(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
 				{
 					sprintf(comfirmstr, "%s", AvailabilityStatusStr[Scheduled] );
 					goto end;
@@ -5918,14 +5965,13 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
 	}//END FOR AvailabilityTypeStr[Inoperative]
 	
 
-
 	if(strcmp((const char *)typeStr, AvailabilityTypeStr[Operative]) == 0)
 	{
 	    //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
 	    //check Transaction active
 		for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 		{
-			if (((gunIndex  == 0)|| ((gunIndex > 0)&&(gunType[gunIndex-1] == 'J')) ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT))  //S_FAULT
+			if (((gunIndex  == 0) || ((gunIndex > 0) && (gunType[gunIndex-1] == 'J'))) && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT))  //S_FAULT
 			{
 				sprintf(comfirmstr, "%s", AvailabilityStatusStr[Accepted] );
 				goto end;
@@ -5934,7 +5980,7 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
 
 		for (int index = 0; index < CCS_QUANTITY; index++)
 		{
-			if (((gunIndex  == 0)|| ((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E'))) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
+			if (((gunIndex  == 0) || ((gunIndex > 0) && ((gunType[gunIndex - 1] == 'U') || (gunType[gunIndex - 1] == 'E')))) && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
 			{
 				sprintf(comfirmstr, "%s", AvailabilityStatusStr[Accepted] );
 				goto end;
@@ -5943,7 +5989,7 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
 
 		for (int index = 0; index < GB_QUANTITY; index++)
 		{
-			if (((gunIndex  == 0)|| ((gunIndex > 0)&&(gunType[gunIndex-1] == 'G')))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
+			if (((gunIndex  == 0) || ((gunIndex > 0)&&(gunType[gunIndex-1] == 'G'))) && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
 			{
 				sprintf(comfirmstr, "%s", AvailabilityStatusStr[Accepted] );
 				goto end;
@@ -5952,13 +5998,12 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
 
 		for (int index = 0; index < AC_QUANTITY; index++)
 		{
-			if (((gunIndex  == 0)|| ((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9')))) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT))  //S_FAULT
+			if( ((gunIndex  == 0) || ((gunIndex > 0) && ((gunType[gunIndex-1] > '0') && (gunType[gunIndex-1] <= '9')))) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT))  //S_FAULT
 			{
 				sprintf(comfirmstr, "%s", AvailabilityStatusStr[Accepted] );
 				goto end;
 			}
-		}//END FOR CHAdeMO_QUANTITY
-
+		}//END FOR AC_QUANTITY
 	}//END FOR AvailabilityTypeStr[Operative]
 
 end:
@@ -5970,6 +6015,21 @@ end:
 	{
 		sprintf((char *)ShmOCPP16Data->ChangeAvailability[0].ResponseStatus, "%s", comfirmstr );
 	}
+
+	if(gunIndex != 0)
+	{
+		if(strstr(comfirmstr, AvailabilityStatusStr[Rejected]) == NULL)
+			ShmOCPP16Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = 1;
+	}
+	else
+	{
+		if(strstr(comfirmstr, AvailabilityStatusStr[Rejected]) == NULL)
+		{
+			for(int i=0; i < gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/; i++)
+				ShmOCPP16Data->CsMsg.bits[i].ChangeAvailabilityReq = 1;
+		}
+	}
+
 	sendChangeAvailabilityConfirmation(uuid, comfirmstr);
 
 	return result;
@@ -10954,6 +11014,8 @@ void handleBootNotificationResponse(char *payload, int gun_index)
 
 	ShmOCPP16Data->OcppConnStatus = 1; ////0: disconnected, 1: connected
 	ShmOCPP16Data->SpMsg.bits.BootNotificationConf = 1;
+
+	sendFirmwareVersionByDataTransfer();
 }
 
 void handleDataTransferResponse(char *payload, int gun_index)

+ 1 - 0
EVSE/Modularization/ocppfiles/MessageHandler.h

@@ -29,6 +29,7 @@ void GetStartTransactionIdTag(int gun_index);
 int sendAuthorizeRequest(int gun_index);
 int sendBootNotificationRequest(void);
 int sendDataTransferRequest(int gun_index);
+int sendFirmwareVersionByDataTransfer(void);
 int sendDiagnosticsStatusNotificationRequest(char *status);
 int sendFirmwareStatusNotificationRequest(char *status);
 int sendHeartbeatRequest(int gun_index);

+ 0 - 0
EVSE/Modularization/ocppfiles/Module_OcppBackend.c