main.c --> Entry point of the code, it initiates the OCPP1.6 Process
ocpp_process.c/.h --> This library handles the events occurring w.r.t to OCPP, the machine states can be found here. Moreover this library start Websockets connection with the CMS URL mentioned in config.json
ocpp_helper.c/.h --> This library is a helper library for OCPP1.6 Process, it has functions which helps in achieving OCPP client functionalities.For generating UUID the reference is taken from here
ocpp_ws_client.c/.h --> This library is responsible for connecting OCPP client to CMS with the help of WebSockets. It has process of handshaking according to OCPPJ1.6 and once accepted it has events which helps in knowing the nature of communication over Transport Layer.The main refrence of this library can be found here
utils.c/.h --> This library is the helper library of ocpp_ws_client.
cJSON.c/.h --> This library is taken from here. Since OCPP1.6J is mostly based on JSON packets over sockets, hence heavy use of this library is done in complete client. This library is written in C and does not require any other dependecy and can be easily ported.
config.json --> This is configuration file, all the OCPP1.6J configuration to be set here in JSON format
compile.sh --> This compiles the complete source code and generate executable with name of "main"
This code is tested with Steve server for OCPPJ1.6. The steve server code can be found here.To start connection with your respective server below mentioned are the steps to be followed.
- In config.json file, put the WS URL of server in WS_URL field.
- Put the client ID in chargePointID field.
- The chargePointProfile is used in boot notification message from client side for providing charger information to the server.
- If the dev platform supports gcc, then simply run compile.sh file and you will get an executable with name of test
- Use this executable to run and connect with ocpp complaint CMS server
Currently this client only supports bootNotification message and it's response, since OCPP is completely functionality dependent, it's better to use your own use cases for further developement, but there are already functions that can be used to create OCPP message or parse occpp messages.
- Use parseOCPPFrame function to parse any message from CMS and it will return a structure of ocpp_frame type from which further JSON packet can be retrieved.
- To form any OCPP frame, use formOCPPFrame function and to send it to server use sendFrameToCMS function.
If further support is required, you can write me at [email protected]. Also if this source codes helps you in some way, don't forget to award a star to this repo. Happy Coding !!