dallmann-consulting/OCPP.Core

Example of how to send a message from server to client

Closed this issue · 6 comments

Could you please provide an example of how to send a message from the server to a ChargePoint using the library. Say, for example, a SetChargingProfile message. There doesn't seem to be a way via the UI, but it looks like the library supports it.

hi @profnimrod

you can expose what you want to send via API and let the UI call that endpoint , l haven't checked the UI only the server but @dallmann-consulting can advice

but want l think is expose the functionality via API like what was done on the reset , you can post your values as body or query params of the properties you need in the chargeprofile and have a method which formats those to SetChargeProfile

for example check how reset is done
image

calling the endpoint /API/Reset/{chargepointId}
[this is a call on the API and will then send to the chargepoint a reset command if charge is online]

so in this case you can have
calling the endpoint /API/SetChargeProfile/{chargepointId}
and have also another method to handle response

Hope this helps

Thank you @billywatsy. Absolutely correct :-)

You need to implement the message in the server API. The UI uses the server's API to send a reset or unlock message. The server blocks your call until it receives an answer from the charger and sends you a result. So from an API perspective it seems like a synchronous call.
To set a charging profile with a power limit was not in my focus for the first version. It would make sense with the semi dynamic power management described in issue #21.

Thanks for your comments guys - I'll take a crack at a charge profile message and let you know how I get on.

I've nearly got this working now... I'm afraid I don't have the time to detail my approach (it is based on guidance above), but I have included a link the full updated VS Solution for both the server and management tool in case anyone is interested. At the moment a hard-coded profile is pushed out, so that'll need to change, but on the whole I think it is close to what is needed. At the moment my test charger is rejecting the message, but I suspect I just have a minor bug somewhere.

VS Solution

SetChargingProfile is implemented now and the usage (API) is documented.
So I'm closing the ticket.