| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397 |
- /*
- * Copyright (C) 2007-2012 Siemens AG
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /*******************************************************************
- *
- * @author Sebastian.Kaebisch.EXT@siemens.com
- * @version 0.6
- * @contact Joerg.Heuer@siemens.com
- *
- ********************************************************************/
- /* includes of the 15118 messaging */
- #include "v2g_service.h"
- #include "v2g_serviceDataTypes.h"
- #include "v2g_serviceClientStubs.h"
- #include "EXITypes.h"
- /* includes for the application handshake protocol */
- #include "appHand_service.h"
- #include "appHand_dataTypes.h"
- /* includes V2GTP */
- #include "v2gtp.h"
- /* includes for example data transmitter */
- #include "serviceClientDataTransmitter.h"
- #include <stdio.h>
- #define MAX_BYTE_SIZE 128
- #define MAX_STRING_SIZE 256
- #define MAX_STREAM_SIZE 100
- static void printErrorMessage(struct EXIService* service);
- static void printDCEVSEStatus(struct DC_EVSEStatusType* status);
- static void printACEVSEStatus(struct AC_EVSEStatusType* status);
- static void printASCIIString(uint32_t* string, uint32_t len);
- static void printBinaryArray(uint8_t* byte, uint32_t len);
- static int writeStringToEXIString(char* string, uint32_t* exiString);
- /** Example implementation of the handshake protocol (EV side) */
- static int appHandshake()
- {
- static uint8_t byte_array[MAX_BYTE_SIZE]; /* define MAX_BYTE_SIZE before*/
- static uint32_t string_array[MAX_STRING_SIZE]; /* define MAX_STRING_SIZE before*/
- /* define in and out byte stream */
- uint8_t inStream[MAX_STREAM_SIZE]; /* define MAX_STREAM_SIZE before */
- uint8_t outStream[MAX_STREAM_SIZE]; /* define MAX_STREAM_SIZE before */
- /* BINARY memory setup */
- bytes_t bytes = { MAX_BYTE_SIZE, byte_array, 0 };
- /* STRING memory setup */
- string_ucs_t string = { MAX_STRING_SIZE, string_array, 0 };
- struct EXIDatabinder appHandService;
- struct EXIDocumentType_appHand exiDoc;
- struct AnonType_supportedAppProtocolReq handshake;
- struct AnonType_supportedAppProtocolRes resultHandshake;
- uint16_t length, payloadLength;
- /* init the app handshake serializer.
- * Important: also provide the offset of the V2GTP header */
- init_appHandSerializer(&appHandService,bytes,string,MAX_STREAM_SIZE, V2GTP_HEADER_LENGTH);
- init_EXIDocumentType_appHand(&exiDoc);
- printf("EV side: setup data for the supported application handshake request message\n");
- /* set up ISO/IEC 15118 Version 1.0 information */
- length = writeStringToEXIString("urn:iso:15118:2:2010:MsgDef", handshake.AppProtocol[0].ProtocolNamespace.data);
- handshake.AppProtocol[0].ProtocolNamespace.arraylen.data = length; /* length of the string */
- handshake.AppProtocol[0].SchemaID=1;
- handshake.AppProtocol[0].VersionNumberMajor=1;
- handshake.AppProtocol[0].VersionNumberMinor=0;
- handshake.AppProtocol[0].Priority=1;
- handshake.arraylen.AppProtocol=1; /* we have only one protocol implemented */
- /* assign handshake request structure to the exiDoc and signal it */
- exiDoc.supportedAppProtocolReq = &handshake;
- exiDoc.isused.supportedAppProtocolReq=1;
- payloadLength=0;
- if(serialize_appHand(&appHandService, outStream,&payloadLength, &exiDoc))
- {
- /* an error occurred */
- return -1;
- }
- printf("EV side: send message to the EVSE \n");
- /* Use here your sending / receiving mechanism to / from the EVSE. The following serviceDataTransmitter method
- * is only an exemplary implementation which also shows how to add the V2GTP header information to
- * the output stream.
- * */
- serviceDataTransmitter(outStream, payloadLength, inStream);
- /* Init deserializer
- * Provide here also the offset of the transport protocol */
- init_appHandDeserializer(&appHandService,bytes,string,V2GTP_HEADER_LENGTH);
- init_EXIDocumentType_appHand(&exiDoc);
- exiDoc.supportedAppProtocolRes=&resultHandshake;
- exiDoc.isused.supportedAppProtocolRes=1;
- if(deserialize_appHand(&appHandService,inStream,100,&exiDoc))
- {
- /* an error occurred */
- return -1;
- }
- printf("EV side: Response of the EVSE \n");
- if(resultHandshake.ResponseCode==OK_SuccessfulNegotiation_responseCodeType)
- {
- printf("\t\tResponseCode=OK_SuccessfulNegotiation\n");
- printf("\t\tSchemaID=%d\n",resultHandshake.SchemaID );
- }
- return 0;
- }
- static int ac_charging()
- {
- static uint8_t byte_array[MAX_BYTE_SIZE]; /* define MAX_BYTE_SIZE before*/
- static uint32_t string_array[MAX_STRING_SIZE]; /* define MAX_STRING_SIZE before*/
- /* define in and out byte stream */
- uint8_t inStream[MAX_STREAM_SIZE]; /* define MAX_STREAM_SIZE before */
- uint8_t outStream[MAX_STREAM_SIZE]; /* define MAX_STREAM_SIZE before */
- /* define offset variable for transport header data */
- uint16_t transportHeaderOffset;
- /* service data structure for AC*/
- struct EXIService service;
- struct MessageHeaderType v2gHeader;
- struct SessionSetupReqType sessionSetup;
- struct SessionSetupResType resultSessionSetup;
- struct ServiceDiscoveryReqType serviceDiscovery;
- struct ServiceDiscoveryResType resultServiceDiscovery;
- struct ServicePaymentSelectionReqType servicePayment;
- struct ServicePaymentSelectionResType resultServicePayment;
- struct ChargeParameterDiscoveryReqType powerDiscovery;
- struct ChargeParameterDiscoveryResType resultPowerDiscovery;
- struct PowerDeliveryReqType powerDelivery;
- struct PowerDeliveryResType resultPowerDelivery;
- struct ChargingStatusResType resultChargingStatus;
- struct SessionStopResType resultSessionStop;
- struct AC_EVSEStatusType evseStatus;
- struct AC_EVChargeParameterType EVChargeParameter;
- struct AC_EVSEChargeParameterType evseChargeParameter;
- struct SAScheduleListType scheduleInfo;
- struct SalesTariffType sales;
- struct PhysicalValueType float_type;
- enum responseMessages resMsg;
- uint32_t outPayloadLength;
- /* BINARY memory setup */
- bytes_t bytes = { MAX_BYTE_SIZE, byte_array, 0 };
- /* STRING memory setup */
- string_ucs_t string = { MAX_STRING_SIZE, string_array, 0 };
- /* setup offset for DoIP header (otherwise set
- * transportHeaderOffset=0 if no transfer protocol is used)*/
- transportHeaderOffset = V2GTP_HEADER_LENGTH;
- /*******************
- * Init V2G Client *
- *******************/
- init_v2gServiceClient(&service,bytes,string,inStream,MAX_STREAM_SIZE, outStream, MAX_STREAM_SIZE, &outPayloadLength, transportHeaderOffset);
- /*******************************
- * Setup data for sessionSetup *
- *******************************/
- /* setup header information */
- v2gHeader.SessionID.data[0] = 0; /* sessionID is always '0' at the beginning (the response contains the valid sessionID)*/
- v2gHeader.SessionID.data[1] = 0;
- v2gHeader.SessionID.data[2] = 0;
- v2gHeader.SessionID.data[3] = 0;
- v2gHeader.SessionID.data[4] = 0;
- v2gHeader.SessionID.data[5] = 0;
- v2gHeader.SessionID.data[6] = 0;
- v2gHeader.SessionID.data[7] = 0;
- v2gHeader.SessionID.arraylen.data = 8; /* length of the byte session array is always 8*/
- v2gHeader.isused.Notification=0; /* no notification */
- v2gHeader.isused.Signature=0; /* no security */
- /* setup sessionSetup parameter */
- sessionSetup.EVCCID.data[0]=1;
- sessionSetup.EVCCID.arraylen.data=1;
- /************************
- * Prepare sessionSetup *
- ************************/
- prepare_sessionSetup(&service,&v2gHeader, &sessionSetup,&resultSessionSetup);
- printf("EV side: call EVSE sessionSetup\n");
- /* Use here your sending / receiving mechanism to / from the EVSE. The following serviceDataTransmitter method
- * is only an exemplary implementation which also shows how to add the V2GTP header information to
- * the output stream.
- * */
- serviceDataTransmitter(outStream, outPayloadLength, inStream);
- /* this method deserializes the response EXI stream */
- if( determineResponseMesssage(&service, &resMsg))
- {
- printErrorMessage(&service);
- }
- /* check, if this is the sessionSetup response message */
- if(resMsg==SESSIONSETUPRES)
- {
- /* show result of the answer message of EVSE sessionSetup */
- printf("EV side: received response message from EVSE\n");
- printf("\tHeader SessionID=");
- printBinaryArray(v2gHeader.SessionID.data,v2gHeader.SessionID.arraylen.data );
- printf("\tResponseCode=%d\n",resultSessionSetup.ResponseCode);
- printf("\tEVSEID=%d\n", resultSessionSetup.EVSEID.data[0]);
- printf("\tDateTimeNow=%d\n",resultSessionSetup.DateTimeNow);
- }
- /*******************************************
- * Setup data for serviceDiscovery *
- *******************************************/
- serviceDiscovery.isused.ServiceCategory=1;
- serviceDiscovery.ServiceCategory = EVCharging_serviceCategoryType;
- serviceDiscovery.isused.ServiceScope=0;
- /****************************
- * Prepare serviceDiscovery *
- ****************************/
- prepare_serviceDiscovery(&service,&v2gHeader, &serviceDiscovery,&resultServiceDiscovery);
- printf("EV side: call EVSE serviceDiscovery \n");
- /* Use here your sending / receiving mechanism to / from the EVSE. The following serviceDataTransmitter method
- * is only an exemplary implementation which also shows how to add the V2GTP header information to
- * the output stream.
- * */
- serviceDataTransmitter(outStream, outPayloadLength, inStream);
- /* this methods deserialize the response EXI stream and determines the kind of
- * the response message */
- if(determineResponseMesssage(&service, &resMsg))
- {
- printErrorMessage(&service);
- }
- /* check, if this is the serviceDiscovery response message */
- if(resMsg==SERVICEDISCOVERYRES)
- {
- /* show result of the answer message of EVSE serviceDiscovery */
- printf("EV side: received response message from EVSE\n");
- printf("\tHeader SessionID=");
- printBinaryArray(v2gHeader.SessionID.data,v2gHeader.SessionID.arraylen.data );
- printf("\t ResponseCode=%d\n",resultServiceDiscovery.ResponseCode);
- printf("\t ServiceID=%d\n", resultServiceDiscovery.ChargeService.ServiceTag.ServiceID);
- printf("\t ServiceName=");
- printASCIIString(resultServiceDiscovery.ChargeService.ServiceTag.ServiceName.data,(uint32_t)resultServiceDiscovery.ChargeService.ServiceTag.ServiceName.arraylen.data );
- printf("\t PaymentOption=%d\n", resultServiceDiscovery.PaymentOptions.PaymentOption[0]);
- printf("\t EnergyTransferType=%d\n", resultServiceDiscovery.ChargeService.EnergyTransferType);
- }
- /*******************************************
- * Setup data for ServicePaymentSelection *
- *******************************************/
- servicePayment.SelectedPaymentOption = ExternalPayment_paymentOptionType;
- servicePayment.SelectedServiceList.SelectedService[0].ServiceID=1; /* charge server ID */
- servicePayment.SelectedServiceList.SelectedService[0].isused.ParameterSetID=0; /* is not used */
- servicePayment.SelectedServiceList.arraylen.SelectedService=1; /* only one service was selected */
- /***********************************
- * Prepare ServicePaymentSelection *
- ***********************************/
- if(prepare_servicePaymentSelection(&service,&v2gHeader, &servicePayment,&resultServicePayment))
- {
- printErrorMessage(&service);
- return 0;
- }
- printf("EV side: call EVSE ServicePaymentSelection \n");
- /* Use here your sending / receiving mechanism to / from the EVSE. The following serviceDataTransmitter method
- * is only an exemplary implementation which also shows how to add the V2GTP header information to
- * the output stream.
- * */
- serviceDataTransmitter(outStream, outPayloadLength, inStream);
- /* this methods deserialize the response EXI stream and determines the kind of
- * the response message */
- if(determineResponseMesssage(&service, &resMsg))
- {
- printErrorMessage(&service);
- }
- /* check, if this is the servicePaymentSelection response message */
- if(resMsg==SERVICEPAYMENTSELECTIONRES)
- {
- /* show result of the answer message of EVSE servicePaymentSelection */
- printf("EV side: received response message from EVSE\n");
- printf("\tHeader SessionID=");
- printBinaryArray(v2gHeader.SessionID.data,v2gHeader.SessionID.arraylen.data );
- printf("\t ResponseCode=%d\n",resultServicePayment.ResponseCode);
- }
- /*******************************************
- * Setup data for chargeParameterDiscovery *
- *******************************************/
- printf("\n\nEV side: prepare EVSE chargeParameterDiscovery\n");
- powerDiscovery.EVRequestedEnergyTransferType = AC_three_phase_core_EVRequestedEnergyTransferType;
- EVChargeParameter.DepartureTime = 12345;
- float_type.Multiplier = 0;
- float_type.Unit = W_unitSymbolType;
- float_type.isused.Unit=1;
- float_type.Value = 100;
- EVChargeParameter.EAmount = float_type;
- float_type.Unit = A_unitSymbolType;
- float_type.Value = 200;
- EVChargeParameter.EVMaxCurrent= float_type;
- float_type.Unit = V_unitSymbolType;
- float_type.Value = 400;
- EVChargeParameter.EVMaxVoltage=float_type;
- float_type.Unit = A_unitSymbolType;
- float_type.Value = 500;
- EVChargeParameter.EVMinCurrent=float_type;
- powerDiscovery.AC_EVChargeParameter = &EVChargeParameter;
- powerDiscovery.isused.AC_EVChargeParameter = 1; /* we use here DC based charging parameters */
- powerDiscovery.isused.DC_EVChargeParameter = 0;
- resultPowerDiscovery.AC_EVSEChargeParameter = &evseChargeParameter; /* we expect AC-based parameters from the evse*/
- resultPowerDiscovery.SAScheduleList = &scheduleInfo; /* EVSE may send a schedule for us; should be always assigned here! */
- resultPowerDiscovery.SAScheduleList->SAScheduleTuple[0].SalesTariff = &sales;
- prepare_chargeParameterDiscovery(&service,&v2gHeader,&powerDiscovery,&resultPowerDiscovery);
- printf("EV side: call EVSE chargeParameterDiscovery \n");
- /* Use here your sending / receiving mechanism to / from the EVSE. The following serviceDataTransmitter method
- * is only an exemplary implementation which also shows how to add the V2GTP header information to
- * the output stream.
- * */
- serviceDataTransmitter(outStream, outPayloadLength, inStream);
- /* this methods deserialize the response EXI stream and determines the kind of
- * the response message */
- if(determineResponseMesssage(&service, &resMsg))
- {
- printErrorMessage(&service);
- }
- /* check, if this is the chargeParameterDiscovery response message */
- if(resMsg==CHARGEPARAMETERDISCOVERYRES)
- {
- /* show result of the answer message of EVSE sessionSetup*/
- printf("EV side: received response message from EVSE\n");
- printf("\tHeader SessionID=");
- printBinaryArray(v2gHeader.SessionID.data,v2gHeader.SessionID.arraylen.data );
- printf("\tResponseCode=%d\n",resultPowerDiscovery.ResponseCode);
- printACEVSEStatus(&(resultPowerDiscovery.AC_EVSEChargeParameter->AC_EVSEStatus));
- printf("\t EVSEMaxCurrent=%d\n",resultPowerDiscovery.AC_EVSEChargeParameter->EVSEMaxCurrent.Value);
- printf("\t EVSEMaxVoltage=%d\n",resultPowerDiscovery.AC_EVSEChargeParameter->EVSEMaxVoltage.Value);
- printf("\t EVSEMinimumCurrentLimit=%d\n",resultPowerDiscovery.AC_EVSEChargeParameter->EVSEMinCurrent.Value);
- }
- /*********************************
- * Setup data for powerDelivery *
- *********************************/
- powerDelivery.ReadyToChargeState = 1;
- powerDelivery.isused.ChargingProfile= 0;
- powerDelivery.isused.DC_EVPowerDeliveryParameter=0; /* only used for DC charging */
- resultPowerDelivery.AC_EVSEStatus = &evseStatus; /* we expect an evse status */
- prepare_powerDelivery(&service,&v2gHeader,&powerDelivery,&resultPowerDelivery);
- printf("EV side: call EVSE powerDelivery \n");
- /* Use here your sending / receiving mechanism to / from the EVSE. The following serviceDataTransmitter method
- * is only an exemplary implementation which also shows how to add the V2GTP header information to
- * the output stream.
- * */
- serviceDataTransmitter(outStream, outPayloadLength, inStream);
- /* this methods deserialize the response EXI stream and determines the kind of
- * the response message */
- if(determineResponseMesssage(&service, &resMsg))
- {
- printErrorMessage(&service);
- }
- /* check, if this is the powerDelivery response message */
- if(resMsg==POWERDELIVERYRES)
- {
- /* show result of the answer message of EVSE sessionSetup*/
- printf("EV side: received response message from EVSE\n");
- printf("\tResponseCode=%d\n",resultPowerDelivery.ResponseCode);
- printACEVSEStatus(&evseStatus);
- }
- /*********************************
- * Setup data for chargingStatus *
- *********************************/
- /***************************
- * Prepare chargingStatus *
- ***************************/
- if(prepare_chargingStatus(&service,&v2gHeader,&resultChargingStatus))
- {
- printErrorMessage(&service);
- return 0; /* stop here */
- }
- printf("EV side: call EVSE chargingStatus \n");
- /* Use here your sending / receiving mechanism to / from the EVSE. The following serviceDataTransmitter method
- * is only an exemplary implementation which also shows how to add the V2GTP header information to
- * the output stream.
- * */
- serviceDataTransmitter(outStream, outPayloadLength, inStream);
- /* this methods deserialize the response EXI stream and determines the kind of
- * the response message */
- if(determineResponseMesssage(&service, &resMsg))
- {
- printErrorMessage(&service);
- }
- /* check, if this is the chargingStatus response message */
- if(resMsg==CHARGINGSTATUSRES)
- {
- /* show result of the answer message of EVSE sessionSetup*/
- printf("EV side: received response message from EVSE\n");
- /* show result of the answer message of EVSE powerDiscovery*/
- printf("\tResponseCode=%d\n",resultChargingStatus.ResponseCode);
- printACEVSEStatus(&evseStatus);
- printf("\tReceiptRequired=%d\n",resultChargingStatus.ReceiptRequired);
- printf("\tEVSEID=%d\n",resultChargingStatus.EVSEID.data[0]);
- printf("\tEVSEMaxCurrent=%d\n",resultChargingStatus.EVSEMaxCurrent.Value);
- printf("\tisused.MeterInfo=%d\n", resultChargingStatus.isused.MeterInfo);
- printf("\t\tMeterInfo.MeterID=%d\n", resultChargingStatus.MeterInfo.MeterID.data[0]);
- printf("\t\tMeterInfo.MeterReading.Value=%d\n", resultChargingStatus.MeterInfo.MeterReading.Value);
- printf("\t\tMeterInfo.MeterStatus=%d\n", resultChargingStatus.MeterInfo.MeterStatus);
- printf("\t\tMeterInfo.TMeter=%d\n", resultChargingStatus.MeterInfo.TMeter);
- }
- /***********************************
- * Setup data for stopSession *
- ***********************************/
- /************************
- * Prepare stopSession *
- ************************/
- if(prepare_sessionStop(&service,&v2gHeader,&resultSessionStop))
- {
- printErrorMessage(&service);
- return 0; /* stop here */
- }
- printf("EV side: call EVSE stopSession \n");
- /* Use here your sending / receiving mechanism to / from the EVSE. The following serviceDataTransmitter method
- * is only an exemplary implementation which also shows how to add the V2GTP header information to
- * the output stream.
- * */
- serviceDataTransmitter(outStream, outPayloadLength, inStream);
- /* this methods deserialize the response EXI stream and determines the kind of
- * the response message */
- if(determineResponseMesssage(&service, &resMsg))
- {
- printErrorMessage(&service);
- }
- /* check, if this is the stopSession response message */
- if(resMsg==SESSIONSTOPRES)
- {
- /* show result of the answer message of EVSE sessionSetup*/
- printf("EV side: received response message from EVSE\n");
- /* show result of the answer message of EVSE powerDiscovery*/
- printf("\tResponseCode=%d\n",resultSessionStop.ResponseCode);
- }
- return 0;
- }
- static int dc_charging()
- {
- static uint8_t byte_array[MAX_BYTE_SIZE]; /* define MAX_BYTE_SIZE before*/
- static uint32_t string_array[MAX_STRING_SIZE]; /* define MAX_STRING_SIZE before*/
- /* define in and out byte stream */
- uint8_t inStream[MAX_STREAM_SIZE]; /* define MAX_STREAM_SIZE before */
- uint8_t outStream[MAX_STREAM_SIZE]; /* define MAX_STREAM_SIZE before */
- /* define offset variable for transport header data */
- uint16_t transportHeaderOffset;
- /* service data structure for DC*/
- struct EXIService service;
- struct MessageHeaderType v2gHeader;
- struct SessionSetupReqType sessionSetup;
- struct SessionSetupResType resultSessionSetup;
- struct ServiceDiscoveryReqType serviceDiscovery;
- struct ServiceDiscoveryResType resultServiceDiscovery;
- struct ServicePaymentSelectionReqType servicePayment;
- struct ServicePaymentSelectionResType resultServicePayment;
- struct ChargeParameterDiscoveryReqType powerDiscovery;
- struct ChargeParameterDiscoveryResType resultPowerDiscovery;
- struct CableCheckReqType cableCheck;
- struct CableCheckResType resultCableCheck;
- struct PowerDeliveryReqType powerDelivery;
- struct PowerDeliveryResType resultPowerDelivery;
- struct PreChargeReqType preCharge;
- struct PreChargeResType resultPreCharge;
- struct CurrentDemandReqType currentDemand;
- struct CurrentDemandResType resultCurrentDemand;
- struct WeldingDetectionReqType weldingDetection;
- struct WeldingDetectionResType resultWeldingDetection;
- struct SessionStopResType resultSessionStop;
- struct DC_EVStatusType EVStatus;
- struct DC_EVSEStatusType evseStatus;
- struct DC_EVChargeParameterType EVChargeParameter;
- struct DC_EVSEChargeParameterType evseChargeParameter;
- struct DC_EVPowerDeliveryParameterType EVPowerDelivery;
- struct SAScheduleListType pmaxScheduleList;
- enum responseMessages resMsg;
- struct PhysicalValueType float_type;
- uint32_t outPayloadLength;
- size_t i, j;
- /* BINARY memory setup */
- bytes_t bytes = { MAX_BYTE_SIZE, byte_array, 0 };
- /* STRING memory setup */
- string_ucs_t string = { MAX_STRING_SIZE, string_array, 0 };
- /* setup offset for DoIP header (otherwise set
- * transportHeaderOffset=0 if no transfer protocol is used)*/
- transportHeaderOffset = V2GTP_HEADER_LENGTH;
- /*******************
- * Init V2G Client *
- *******************/
- init_v2gServiceClient(&service,bytes,string,inStream,MAX_STREAM_SIZE, outStream, MAX_STREAM_SIZE, &outPayloadLength, transportHeaderOffset);
- /*******************************
- * Setup data for sessionSetup *
- *******************************/
- /* setup header information */
- v2gHeader.SessionID.data[0] = 0; /* sessionID is always '0' at the beginning (the response message contains the valid sessionID)*/
- v2gHeader.SessionID.data[1] = 0;
- v2gHeader.SessionID.data[2] = 0;
- v2gHeader.SessionID.data[3] = 0;
- v2gHeader.SessionID.data[4] = 0;
- v2gHeader.SessionID.data[5] = 0;
- v2gHeader.SessionID.data[6] = 0;
- v2gHeader.SessionID.data[7] = 0;
- v2gHeader.SessionID.arraylen.data = 8; /* length of the byte session array is always 8*/
- v2gHeader.isused.Notification=0; /* no notification */
- v2gHeader.isused.Signature=0; /* no security */
- /* setup sessionSetup parameter */
- sessionSetup.EVCCID.data[0]=10;
- sessionSetup.EVCCID.arraylen.data=1;
- printf("EV side: prepare EVSE sessionSetup\n");
- /************************
- * Prepare sessionSetup *
- ************************/
- prepare_sessionSetup(&service,&v2gHeader, &sessionSetup,&resultSessionSetup);
- printf("EV side: call EVSE sessionSetup\n");
- /* Use here your sending / receiving mechanism to / from the EVSE. The following serviceDataTransmitter method
- * is only an exemplary implementation which also shows how to add the V2GTP header information to
- * the output stream.
- * */
- serviceDataTransmitter(outStream, outPayloadLength, inStream);
- /* this methods deserialize the response EXI stream */
- if(determineResponseMesssage(&service, &resMsg))
- {
- printErrorMessage(&service);
- }
- /* check, if this is the sessionSetup response message */
- if(resMsg==SESSIONSETUPRES)
- {
- /* show result of the answer message of EVSE sessionSetup */
- printf("EV: received response message from EVSE\n");
- printf("\tHeader SessionID=");
- printBinaryArray(v2gHeader.SessionID.data,v2gHeader.SessionID.arraylen.data );
- printf("\tResponseCode=%d\n",resultSessionSetup.ResponseCode);
- printf("\tEVSEID=%d\n", resultSessionSetup.EVSEID.data[0]);
- printf("\tDateTimeNow=%d\n",resultSessionSetup.DateTimeNow);
- }
- /*******************************************
- * Setup data for serviceDiscovery *
- *******************************************/
- serviceDiscovery.isused.ServiceCategory=1;
- /* we are only interested in charging */
- serviceDiscovery.ServiceCategory = EVCharging_serviceCategoryType;
- serviceDiscovery.isused.ServiceScope=0;
- printf("\n\nEV side: prepare EVSE serviceDiscovery\n");
- /****************************
- * Prepare serviceDiscovery *
- ****************************/
- prepare_serviceDiscovery(&service,&v2gHeader, &serviceDiscovery,&resultServiceDiscovery);
- printf("EV side: call EVSE serviceDiscovery \n");
- /* Use here your sending / receiving mechanism to / from the EVSE. The following serviceDataTransmitter method
- * is only an exemplary implementation which also shows how to add the V2GTP header information to
- * the output stream.
- * */
- serviceDataTransmitter(outStream, outPayloadLength, inStream);
- /* this methods deserialize the response EXI stream and determines the kind of
- * the response message */
- if(determineResponseMesssage(&service, &resMsg))
- {
- printErrorMessage(&service);
- }
- /* check, if this is the serviceDiscovery response message */
- if(resMsg==SERVICEDISCOVERYRES)
- {
- /* show result of the answer message of EVSE sessionSetup */
- printf("\nEV side: received response message from EVSE\n");
- printf("\tHeader SessionID=");
- printBinaryArray(v2gHeader.SessionID.data,v2gHeader.SessionID.arraylen.data );
- printf("\t ResponseCode=%d\n",resultServiceDiscovery.ResponseCode);
- printf("\t ServiceID=%d\n", resultServiceDiscovery.ChargeService.ServiceTag.ServiceID);
- printf("\t ServiceName=");
- printASCIIString(resultServiceDiscovery.ChargeService.ServiceTag.ServiceName.data,(uint32_t)resultServiceDiscovery.ChargeService.ServiceTag.ServiceName.arraylen.data );
- printf("\t PaymentOption=%d\n", resultServiceDiscovery.PaymentOptions.PaymentOption[0]);
- printf("\t EnergyTransferType=%d\n", resultServiceDiscovery.ChargeService.EnergyTransferType);
- }
- /*******************************************
- * Setup data for ServicePaymentSelection *
- *******************************************/
- servicePayment.SelectedPaymentOption = ExternalPayment_paymentOptionType;
- servicePayment.SelectedServiceList.SelectedService[0].ServiceID=1; /* charge server ID */
- servicePayment.SelectedServiceList.SelectedService[0].isused.ParameterSetID=0; /* is not used */
- servicePayment.SelectedServiceList.arraylen.SelectedService=1; /* only one service was selected */
- printf("\n\nEV side: prepare EVSE servicePaymentSelection\n");
- /**************************************
- * Prepare ServicePaymentSelection *
- **************************************/
- if(prepare_servicePaymentSelection(&service,&v2gHeader, &servicePayment,&resultServicePayment))
- {
- printErrorMessage(&service);
- return 0;
- }
- printf("EV side: call EVSE ServicePaymentSelection \n");
- /* Use here your sending / receiving mechanism to / from the EVSE. The following serviceDataTransmitter method
- * is only an exemplary implementation which also shows how to add the V2GTP header information to
- * the output stream.
- * */
- serviceDataTransmitter(outStream, outPayloadLength, inStream);
- /* this methods deserialize the response EXI stream and determines the kind of
- * the response message */
- if(determineResponseMesssage(&service, &resMsg))
- {
- printErrorMessage(&service);
- }
- /* check, if this is the servicePaymentSelection response message */
- if(resMsg==SERVICEPAYMENTSELECTIONRES)
- {
- /* show result of the answer message of EVSE sessionSetup */
- printf("EV: received response message from EVSE\n");
- printf("\tHeader SessionID=");
- printBinaryArray(v2gHeader.SessionID.data,v2gHeader.SessionID.arraylen.data );
- printf("\t ResponseCode=%d\n",resultServicePayment.ResponseCode);
- }
- /*******************************************
- * Setup data for chargeParameterDiscovery *
- *******************************************/
- /* setup EVStatus */
- EVStatus.EVRESSSOC = 30;
- EVStatus.EVReady = 1;
- EVStatus.EVCabinConditioning = 1;
- EVStatus.EVRESSConditioning = 1;
- EVStatus.isused.EVCabinConditioning=1;
- EVStatus.isused.EVRESSConditioning=1;
- EVStatus.EVErrorCode = NO_ERROR_DC_EVErrorCodeType;
- EVChargeParameter.DC_EVStatus = EVStatus;
- float_type.Multiplier = 0;
- float_type.Unit = A_unitSymbolType;
- float_type.isused.Unit=1;
- float_type.Value = 60;
- EVChargeParameter.EVMaximumCurrentLimit = float_type;
- float_type.Unit = W_unitSymbolType;
- float_type.Value = 20000;
- EVChargeParameter.EVMaximumPowerLimit = float_type;
- EVChargeParameter.isused.EVMaximumPowerLimit = 1;
- float_type.Unit = V_unitSymbolType;
- float_type.Value = 420;
- EVChargeParameter.EVMaximumVoltageLimit= float_type;
- float_type.Unit = W_s_unitSymbolType;
- float_type.Value = 15000;
- EVChargeParameter.EVEnergyCapacity= float_type;
- EVChargeParameter.isused.EVEnergyCapacity = 1;
- float_type.Unit = W_s_unitSymbolType;
- float_type.Value = 5000;
- EVChargeParameter.EVEnergyRequest= float_type;
- EVChargeParameter.isused.EVEnergyRequest = 1;
- EVChargeParameter.FullSOC=99;
- EVChargeParameter.isused.FullSOC = 1;
- EVChargeParameter.BulkSOC=80;
- EVChargeParameter.isused.BulkSOC = 1;
- powerDiscovery.EVRequestedEnergyTransferType = DC_combo_core_EVRequestedEnergyTransferType;
- powerDiscovery.DC_EVChargeParameter = &EVChargeParameter;
- powerDiscovery.isused.DC_EVChargeParameter = 1; /* we use here DC based charging parameters */
- powerDiscovery.isused.AC_EVChargeParameter = 0;
- resultPowerDiscovery.DC_EVSEChargeParameter = &evseChargeParameter; /* we expect DC-based parameters from the evse*/
- resultPowerDiscovery.SAScheduleList = &pmaxScheduleList; /* the EVSE can provide some PMax information; should be always assign here! */
- printf("\n\nEV side: prepare EVSE chargeParameterDiscovery\n");
- /************************************
- * Prepare chargeParameterDiscovery *
- ************************************/
- if(prepare_chargeParameterDiscovery(&service,&v2gHeader, &powerDiscovery,&resultPowerDiscovery))
- {
- printErrorMessage(&service);
- return 0;
- }
- printf("EV side: call EVSE chargeParameterDiscovery \n");
- /* Use here your sending / receiving mechanism to / from the EVSE. The following serviceDataTransmitter method
- * is only an exemplary implementation which also shows how to add the V2GTP header information to
- * the output stream.
- * */
- serviceDataTransmitter(outStream, outPayloadLength, inStream);
- /* this methods deserialize the response EXI stream and determines the kind of
- * the response message */
- if(determineResponseMesssage(&service, &resMsg))
- {
- printErrorMessage(&service);
- }
- /* check, if this is the chargeParameterDiscovery response message */
- if(resMsg==CHARGEPARAMETERDISCOVERYRES)
- {
- /* show result of the answer message of EVSE sessionSetup*/
- printf("\nEV side: received response message from EVSE\n");
- printf("\t\t Header SessionID=%d\n",v2gHeader.SessionID.data[0]);
- printf("\tResponseCode=%d\n",resultPowerDiscovery.ResponseCode);
- printDCEVSEStatus(&(resultPowerDiscovery.DC_EVSEChargeParameter->DC_EVSEStatus));
- printf("\tEVSEMaximumCurrentLimit=%d\n",resultPowerDiscovery.DC_EVSEChargeParameter->EVSEMaximumCurrentLimit.Value);
- printf("\tEVSEMaximumPowerLimit=%d\n",resultPowerDiscovery.DC_EVSEChargeParameter->EVSEMaximumPowerLimit.Value);
- printf("\tEVSEMaximumVoltageLimit=%d\n",resultPowerDiscovery.DC_EVSEChargeParameter->EVSEMaximumVoltageLimit.Value);
- printf("\tEVSEMinimumCurrentLimit=%d\n",resultPowerDiscovery.DC_EVSEChargeParameter->EVSEMinimumCurrentLimit.Value);
- printf("\tEVSEMinimumVoltageLimit=%d\n",resultPowerDiscovery.DC_EVSEChargeParameter->EVSEMinimumVoltageLimit.Value);
- printf("\tEVSECurrentRegulationTolerance=%d\n",resultPowerDiscovery.DC_EVSEChargeParameter->EVSECurrentRegulationTolerance.Value);
- printf("\tEVSEPeakCurrentRipple=%d\n",resultPowerDiscovery.DC_EVSEChargeParameter->EVSEPeakCurrentRipple.Value);
- printf("\tEVSEEnergyToBeDelivered=%d\n",resultPowerDiscovery.DC_EVSEChargeParameter->EVSEEnergyToBeDelivered.Value);
- /* show PMax schedule, if there one provided */
- if(resultPowerDiscovery.isused.SAScheduleList)
- {
- printf("\tSAScheduleList: \n");
- for(i=0; i< pmaxScheduleList.arraylen.SAScheduleTuple;i++)
- {
- printf("\t\t Tuple#%d: \n",(i+1));
- printf("\t\t SAScheduleTupleID=%d: \n", pmaxScheduleList.SAScheduleTuple[i].SAScheduleTupleID);
- printf("\t\t PMaxScheduleID=%d: \n",pmaxScheduleList.SAScheduleTuple[i].PMaxSchedule.PMaxScheduleID);
- for(j=0; j< pmaxScheduleList.SAScheduleTuple[i].PMaxSchedule.arraylen.PMaxScheduleEntry;j++)
- {
- printf("\t\t\t Entry#%d: \n",(j+1));
- printf("\t\t\t\t PMax=%d \n",pmaxScheduleList.SAScheduleTuple[i].PMaxSchedule.PMaxScheduleEntry[j].PMax);
- printf("\t\t\t\t Start=%d \n",pmaxScheduleList.SAScheduleTuple[i].PMaxSchedule.PMaxScheduleEntry[j].RelativeTimeInterval.start);
- if(pmaxScheduleList.SAScheduleTuple[i].PMaxSchedule.PMaxScheduleEntry[j].RelativeTimeInterval.isused.duration)
- printf("\t\t\t\t Duration=%d \n",pmaxScheduleList.SAScheduleTuple[i].PMaxSchedule.PMaxScheduleEntry[j].RelativeTimeInterval.duration);
- }
- }
- }
- }
- /*****************************
- * Setup data for cableCheck *
- *****************************/
- /* setup EVStatus */
- cableCheck.DC_EVStatus =EVStatus;
- printf("\n\nEV side: prepare EVSE cableCheck\n");
- /**********************
- * Prepare cableCheck *
- **********************/
- if(prepare_cableCheck(&service,&v2gHeader,&cableCheck,&resultCableCheck))
- {
- printErrorMessage(&service);
- return 0; /* stop here */
- }
- printf("EV side: call EVSE cableCheck \n");
- /* Use here your sending / receiving mechanism to / from the EVSE. The following serviceDataTransmitter method
- * is only an exemplary implementation which also shows how to add the V2GTP header information to
- * the output stream.
- * */
- serviceDataTransmitter(outStream, outPayloadLength, inStream);
- /* this methods deserialize the response EXI stream and determines the kind of
- * the response message */
- if(determineResponseMesssage(&service, &resMsg))
- {
- printErrorMessage(&service);
- }
- /* check, if this is the cableCheck response message */
- if(resMsg==CABLECHECKRES)
- {
- /* show result of the answer message of EVSE sessionSetup*/
- printf("EV side: received response message from EVSE\n");
- printf("\t\t Header SessionID=%d\n",v2gHeader.SessionID.data[0]);
- printf("\tResponseCode=%d\n",resultCableCheck.ResponseCode);
- printDCEVSEStatus(&(resultCableCheck.DC_EVSEStatus));
- }
- /*****************************
- * Setup data for preCharge *
- *****************************/
- /* setup EVStatus */
- preCharge.DC_EVStatus =EVStatus;
- float_type.Unit = V_unitSymbolType;
- float_type.Value = 100;
- preCharge.EVTargetCurrent = float_type;
- float_type.Unit = V_unitSymbolType;
- float_type.Value = 200;
- preCharge.EVTargetVoltage = float_type;
- printf("\n\nEV side: prepare EVSE preCharge\n");
- /**********************
- * Prepare preCharge *
- **********************/
- if(prepare_preCharge(&service,&v2gHeader,&preCharge,&resultPreCharge))
- {
- printErrorMessage(&service);
- return 0; /* stop here */
- }
- printf("EV side: call EVSE preCharge \n");
- /* Use here your sending / receiving mechanism to / from the EVSE. The following serviceDataTransmitter method
- * is only an exemplary implementation which also shows how to add the V2GTP header information to
- * the output stream.
- * */
- serviceDataTransmitter(outStream, outPayloadLength, inStream);
- /* this methods deserialize the response EXI stream and determines the kind of
- * the response message */
- if(determineResponseMesssage(&service, &resMsg))
- {
- printErrorMessage(&service);
- }
- /* check, if this is the preCharge response message */
- if(resMsg==PRECHARGERES)
- {
- /* show result of the answer message of EVSE sessionSetup*/
- printf("EV side: received response message from EVSE\n");
- /* show result of the answer message of EVSE powerDiscovery*/
- printf("\tResponseCode=%d\n",resultPreCharge.ResponseCode);
- printDCEVSEStatus(&resultPreCharge.DC_EVSEStatus);
- printf("\tEVSEPresentVoltage=%d\n",resultPreCharge.EVSEPresentVoltage.Value);
- }
- /*********************************
- * Setup data for powerDelivery *
- *********************************/
- powerDelivery.ReadyToChargeState = 1;
- EVPowerDelivery.DC_EVStatus = EVStatus;
- EVPowerDelivery.BulkChargingComplete = 1;
- EVPowerDelivery.isused.BulkChargingComplete = 1;
- EVPowerDelivery.ChargingComplete = 0;
- powerDelivery.DC_EVPowerDeliveryParameter = &EVPowerDelivery;
- powerDelivery.isused.DC_EVPowerDeliveryParameter = 1; /* DC parameters are send */
- /* we are using a charging profile */
- powerDelivery.isused.ChargingProfile=1;
- powerDelivery.ChargingProfile.SAScheduleTupleID = pmaxScheduleList.SAScheduleTuple[0].SAScheduleTupleID;
- /* set up 3 entries */
- powerDelivery.ChargingProfile.ProfileEntry[0].ChargingProfileEntryMaxPower=0;
- powerDelivery.ChargingProfile.ProfileEntry[0].ChargingProfileEntryStart=0;
- powerDelivery.ChargingProfile.ProfileEntry[1].ChargingProfileEntryMaxPower=20000;
- powerDelivery.ChargingProfile.ProfileEntry[1].ChargingProfileEntryStart=300; /* 5min */
- powerDelivery.ChargingProfile.ProfileEntry[2].ChargingProfileEntryMaxPower=0;
- powerDelivery.ChargingProfile.ProfileEntry[2].ChargingProfileEntryStart=1200; /* 20min */
- powerDelivery.ChargingProfile.arraylen.ProfileEntry=3;
- resultPowerDelivery.DC_EVSEStatus = &evseStatus; /* we expect the DC-based EVSE status */
- printf("\n\nEV side: prepare EVSE powerDelivery\n");
- /**************************
- * Prepare powerDelivery *
- **************************/
- if(prepare_powerDelivery(&service,&v2gHeader,&powerDelivery,&resultPowerDelivery))
- {
- printErrorMessage(&service);
- return 0; /* stop here */
- }
- printf("EV side: call EVSE powerDelivery \n");
- /* Use here your sending / receiving mechanism to / from the EVSE. The following serviceDataTransmitter method
- * is only an exemplary implementation which also shows how to add the V2GTP header information to
- * the output stream.
- * */
- serviceDataTransmitter(outStream, outPayloadLength, inStream);
- /* this methods deserialize the response EXI stream and determines the kind of
- * the response message */
- if(determineResponseMesssage(&service, &resMsg))
- {
- printErrorMessage(&service);
- }
- /* check, if this is the powerDelivery response message */
- if(resMsg==POWERDELIVERYRES)
- {
- /* show result of the answer message of EVSE sessionSetup*/
- printf("\nEV side: received response message from EVSE\n");
- /* show result of the answer message of EVSE powerDiscovery*/
- printf("\tResponseCode=%d\n",resultPreCharge.ResponseCode);
- printDCEVSEStatus(&resultPreCharge.DC_EVSEStatus);
- }
- /*********************************
- * Setup data for currentDemand *
- *********************************/
- currentDemand.DC_EVStatus = EVStatus;
- float_type.Unit = A_unitSymbolType;
- float_type.Value = 50;
- currentDemand.EVTargetCurrent = float_type;
- float_type.Unit = V_unitSymbolType;
- float_type.Value = 400;
- currentDemand.EVMaximumVoltageLimit = float_type;
- currentDemand.isused.EVMaximumVoltageLimit = 1;
- float_type.Unit = W_unitSymbolType;
- float_type.Value = 20000;
- currentDemand.EVMaximumPowerLimit = float_type;
- currentDemand.isused.EVMaximumPowerLimit = 1;
- float_type.Unit = A_unitSymbolType;
- float_type.Value = 50;
- currentDemand.EVMaximumCurrentLimit = float_type;
- currentDemand.isused.EVMaximumCurrentLimit = 1;
- currentDemand.BulkChargingComplete = 0;
- currentDemand.isused.BulkChargingComplete = 1;
- currentDemand.ChargingComplete = 0;
- /* float_type.Unit = s_unitSymbolType;
- float_type.Value = 1200;
- currentDemand.RemainingTimeToFullSoC = float_type; */
- currentDemand.isused.RemainingTimeToFullSoC = 0;
- /* float_type.Unit = s_unitSymbolType;
- float_type.Value = 1200;
- currentDemand.RemainingTimeToBulkSoC = float_type; */
- currentDemand.isused.RemainingTimeToBulkSoC = 0;
- float_type.Unit = V_unitSymbolType;
- float_type.Value = 400;
- currentDemand.EVTargetVoltage = float_type;
- printf("\n\nEV side: prepare EVSE currentDemand\n");
- /**************************
- * Prepare currentDemand *
- **************************/
- if(prepare_currentDemand(&service,&v2gHeader,¤tDemand,&resultCurrentDemand))
- {
- printErrorMessage(&service);
- return 0; /* stop here */
- }
- printf("EV side: call EVSE currentDemand \n");
- /* Use here your sending / receiving mechanism to / from the EVSE. The following serviceDataTransmitter method
- * is only an exemplary implementation which also shows how to add the V2GTP header information to
- * the output stream.
- * */
- serviceDataTransmitter(outStream, outPayloadLength, inStream);
- /* this methods deserialize the response EXI stream and determines the kind of
- * the response message */
- if(determineResponseMesssage(&service, &resMsg))
- {
- printErrorMessage(&service);
- }
- /* check, if this is the sessionSetup response message */
- if(resMsg==CURRENTDEMANDRES)
- {
- /* show result of the answer message of EVSE sessionSetup*/
- printf("\nEV side: received response message from EVSE\n");
- /* show result of the answer message of EVSE powerDiscovery*/
- printf("\tResponseCode=%d\n",resultCurrentDemand.ResponseCode);
- printDCEVSEStatus(&resultCurrentDemand.DC_EVSEStatus);
- printf("\t EVSEPresentVoltage=%d\n",resultCurrentDemand.EVSEPresentVoltage.Value);
- printf("\t EVSEPresentCurrent=%d\n",resultCurrentDemand.EVSEPresentCurrent.Value);
- printf("\t EVSECurrentLimitAchieved=%d\n",resultCurrentDemand.EVSECurrentLimitAchieved);
- printf("\t EVSEVoltageLimitAchieved=%d\n",resultCurrentDemand.EVSEVoltageLimitAchieved);
- printf("\t EVSEPowerLimitAchieved=%d\n",resultCurrentDemand.EVSEPowerLimitAchieved);
- printf("\t EVSEMaximumVoltageLimit=%d\n",resultCurrentDemand.EVSEMaximumVoltageLimit.Value);
- printf("\t EVSEMaximumCurrentLimit=%d\n",resultCurrentDemand.EVSEMaximumCurrentLimit.Value);
- printf("\t EVSEMaximumPowerLimit=%d\n",resultCurrentDemand.EVSEMaximumPowerLimit.Value);
- }
- /***********************************
- * Setup data for weldingDetection *
- ***********************************/
- weldingDetection.DC_EVStatus =EVStatus;
- printf("\n\nEV side: prepare EVSE weldingDetection\n");
- /**************************
- * Prepare weldingDetection *
- **************************/
- if(prepare_weldingDetection(&service,&v2gHeader,&weldingDetection,&resultWeldingDetection))
- {
- printErrorMessage(&service);
- return 0; /* stop here */
- }
- printf("EV side: call EVSE weldingDetection \n");
- /* Use here your sending / receiving mechanism to / from the EVSE. The following serviceDataTransmitter method
- * is only an exemplary implementation which also shows how to add the V2GTP header information to
- * the output stream.
- * */
- serviceDataTransmitter(outStream, outPayloadLength, inStream);
- /* this methods deserialize the response EXI stream and determines the kind of
- * the response message */
- if(determineResponseMesssage(&service, &resMsg))
- {
- printErrorMessage(&service);
- }
- /* check, if this is the sessionSetup response message */
- if(resMsg==WELDINGDETECTIONRES)
- {
- /* show result of the answer message of EVSE sessionSetup*/
- printf("EV side: received response message from EVSE\n");
- /* show result of the answer message of EVSE powerDiscovery*/
- printf("\tResponseCode=%d\n",resultCurrentDemand.ResponseCode);
- printDCEVSEStatus(&resultCurrentDemand.DC_EVSEStatus);
- printf("\tEVSEPresentVoltage=%d\n",resultWeldingDetection.EVSEPresentVoltage.Value);
- }
- /***********************************
- * Setup data for stopSession *
- ***********************************/
- printf("\n\nEV side: prepare EVSE stopSession\n");
- /************************
- * Prepare stopSession *
- ************************/
- if(prepare_sessionStop(&service,&v2gHeader,&resultSessionStop))
- {
- printErrorMessage(&service);
- return 0; /* stop here */
- }
- printf("EV side: call EVSE stopSession \n");
- /* Use here your sending / receiving mechanism to / from the EVSE. The following serviceDataTransmitter method
- * is only an exemplary implementation which also shows how to add the V2GTP header information to
- * the output stream.
- * */
- serviceDataTransmitter(outStream, outPayloadLength, inStream);
- /* this methods deserialize the response EXI stream and determines the kind of
- * the response message */
- if(determineResponseMesssage(&service, &resMsg))
- {
- printErrorMessage(&service);
- }
- /* check, if this is the sessionSetup response message */
- if(resMsg==SESSIONSTOPRES)
- {
- /* show result of the answer message of EVSE sessionSetup*/
- printf("EV side: received response message from EVSE\n");
- /* show result of the answer message of EVSE powerDiscovery*/
- printf("\tResponseCode=%d\n",resultCurrentDemand.ResponseCode);
- }
- return 0;
- }
- int main_service()
- {
- printf("+++ Start application handshake protocol example +++\n\n");
- appHandshake();
- printf("+++ Terminate application handshake protocol example +++\n\n");
- printf("\n\nPlease press enter for AC charging!\n");
- fflush(stdout);
- getchar();
- printf("+++ Start V2G client / service example for AC charging +++\n\n");
- ac_charging();
- printf("\n+++Terminate V2G Client / Service example for AC charging +++\n");
- printf("Please press enter for DC charging!\n");
- fflush(stdout);
- getchar();
- printf("+++ Start V2G client / service example for DC charging +++\n\n");
- dc_charging();
- printf("\n+++Terminate V2G client / service example for DC charging +++");
- return 0;
- }
- static void printACEVSEStatus(struct AC_EVSEStatusType* status)
- {
- printf("\tEVSEStatus:\n");
- printf("\t\tPowerSwitchClosed=%d\n",status->PowerSwitchClosed);
- printf("\t\tRCD=%d\n",status->RCD);
- printf("\t\tShutDownTime=%d\n",status->ShutDownTime);
- printf("\t\tStopCharging=%d\n",status->StopCharging);
- }
- static void printDCEVSEStatus(struct DC_EVSEStatusType* status)
- {
- if(status->isused.EVSEIsolationStatus)
- printf("\tEVSEStatus:\n\t\tEVSEIsolationStatus=%d\n",status->EVSEIsolationStatus);
- printf("\t\tEVSEStatusCode=%d\n",status->EVSEStatusCode);
- }
- static void printErrorMessage(struct EXIService* service)
- {
- if(service->errorCode==EXI_NON_VALID_MESSAGE)
- {
- printf("EV did not send a valid V2G message!\n");
- }
- else if(service->errorCode==EXI_SERIALIZATION_FAILED)
- {
- printf("EVSE error: Could not serialize the response message\n");
- } else if(service->errorCode==EXI_SERIALIZATION_FAILED)
- {
- printf("EVSE error: Could not serialize the response message\n");
- }
- }
- static void printASCIIString(uint32_t* string, uint32_t len) {
- unsigned int i;
- for(i=0; i<len; i++) {
- printf("%c",(char)string[i]);
- }
- printf("\n");
- }
- static void printBinaryArray(uint8_t* byte, uint32_t len) {
- unsigned int i;
- for(i=0; i<len; i++) {
- printf("%d ",byte[i]);
- }
- printf("\n");
- }
- static int writeStringToEXIString(char* string, uint32_t* exiString)
- {
- int pos=0;
- while(string[pos]!='\0')
- {
- exiString[pos] = string[pos];
- pos++;
- }
- return pos;
- }
|