8000 ❔ Question: ChargingProfile optional fields · Issue #350 · lorenzodonini/ocpp-go · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

❔ Question: ChargingProfile optional fields #350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 of 5 tasks
Vlsarro opened this issue Mar 3, 2025 · 1 comment
Open
2 of 5 tasks

❔ Question: ChargingProfile optional fields #350

Vlsarro opened this issue Mar 3, 2025 · 1 comment

Comments

@Vlsarro
Copy link
Vlsarro commented Mar 3, 2025

❔ What is your question?

Hello, I have a question regarding ChargingProfile struct. In OCPP1.6 spec ChargingProfile.transactionId is an optional field and in the code (https://github.com/lorenzodonini/ocpp-go/blob/master/ocpp1.6/types/types.go#L132) it is marked as omitempty but the field itself is not *int but int. The same applies to ChargingProfile.RecurrencyKind, I think it should be a pointer field too.

The same can be said about ClearChargingProfileRequest (https://github.com/lorenzodonini/ocpp-go/blob/master/ocpp1.6/smartcharging/clear_charging_profile.go#L36), ClearChargingProfileRequest.ChargingProfilePurpose is an optional field according to spec but in the code it is not a pointer and at the same time this field has omitempty tag.

So does it need to be fixed? Or everything is fine as it is?

Which OCPP version referring to?

  • OCPP 1.6
  • OCPP 2.0.1

Are you using any OCPP extensions?

  • OCPP 1.6 Security
  • OCPP 1.6 Plug and Charge

👀 Have you spent some time to check if this question has been asked before?

  • I checked and didn't find a similar issue
@xBlaz3kx
Copy link
Contributor
xBlaz3kx commented Mar 3, 2025

Hey,

I think this is a semantic issue. Even though the field might not be a pointer, it can be treated as optional. Thejson:"omitempty" field tag will not include the fields that have default values (0 for int and "" for string) in the marshaled JSON sent to the charge point.

Maybe it would be better for clarity, but doesnt mean the implementation is entirely wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0