Replies: 3 comments 6 replies
-
Thank you for you feedback. I think I like the idea of decoupling the websocket connection from the charge point implementation. One drawback of this tight coupling is that the Now I'm thinking longer about it I'm not sure why the websocket connection is passed to the How would you expect I'm happy to explore this idea further with you. One thing we need to keep in mind if and how we want to keep backwards compatibility. |
Beta Was this translation helpful? Give feedback.
-
I did some prototyping with AWS API Gateway WebSocket API and AWS Lamda. The code is here: https://github.com/villekr/ocpp-serverless-example. API Gateway doesn't support occp-j endpoint format but it was good reference for what kind of data the event handler in Lambda would get. In the example code now Call message is send to API Gateway WebSocket API and it trigger AWS Lambda. Within AWS Lambda Call message is routed using ocpp library to specific action handler and CallResult is sent back to Call initiator via WebSocket API. I did not yet solve how to get CallResult/CallError back to Call initiator, which is awaiting response. In stateless serverless cloud environment this will need:
Also creating route map would be ideally done only once, which can be achieved by instantiating charging_station as global variable. Furthermore patching id and connection to charging_station before calling route_message are "hacky". So proper interface for building route map and then routing events should be defined. |
Beta Was this translation helpful? Give feedback.
-
Now prototype for event based message handling in AWS is fully functional. I introduced strategy pattern to allow changing response and after-hook behaviour. Also connection and queue are injected to ChargePoint object. In order to get this working I had to override route_message and _handle_call from ChargePoint. In AWS environment connection communicates towards API Gateway Websockets API and queue is implemented using Redis (instead of ChargePoint asyncio.Queue()). I also drafted initial idea how ocpp library interface should be designed to allow event based message handling. Basically the idea is to create router once and then route message by providing invocation specific context. Please provide any feedback about draft ocpp router interface. The code is here: https://github.com/villekr/ocpp-serverless-example. |
Beta Was this translation helpful? Give feedback.
-
First of all thanks for building this library, I've been successfully using it for some time. I know websocket is in the core of ocpp specification but it doesn't mean that message handling library has to necessarily make tight coupling with it. Instead of receiving/sending messages from the given websocket, library could offer alternative interface for message handling, which decouples from the actual connection. This would enable e.g. running ocpp message handling logic in a serverless fashion where the connections are managed and actual messaging via websocket is done elsewhere.
Basically this should be possible already now in a little bit hacky way: provide websocket interface (recv, send) with custom logic, and instead of issuing ChargePoint.start() just using use ChargePoint.route_message(...). After-action handlers might be a little awkward in this hacky approach but perhaps manageable. (In general I really like how on and after action handlers make you to separate message handling logic and allow you to provide as fast response to charging station as possible).
What I'm looking here is if anyone has already thought of this and if there would be interest to discuss possible modifications to library's interface. I'm happy to prototype ideas and assist in development.
Beta Was this translation helpful? Give feedback.
All reactions