lorenzodonini / ocpp-go

Open Charge Point Protocol implementation in Go
MIT License
277 stars 126 forks source link

Unable to Include LocalAuthorizationList in OCPP1.6 SendLocalList Command #201

Closed KyleLehtinenDev closed 1 year ago

KyleLehtinenDev commented 1 year ago

Greetings! I wanted to ask about including the optional LocalAuthorizationList data member of the localAuth.SendLocalListRequest with CentralSystem.SendLocalList method. There doesn't seem to be a way to include the Authorization List array for that command from what I'm seeing.

Per the OCPP1.6 spec that data is optional for a SendLocalList.req, however I don't see how to include it in the implementation for that feature action. Is this currently not supported or is there a misunderstanding on my part for how to include updated authorization list data for this OCPP1.6 command?

lorenzodonini commented 1 year ago

Hey there, all optional fields may be passed via a variadic function. This is to keep the signature of the methods lean but still guarantee that required fields are always set.

To pass the local list along with the request:

err := suite.centralSystem.SendLocalList(clientID, myCallback, listVersion, updateType, func(request *localauth.SendLocalListRequest) {
    request.LocalAuthorizationList = []localauth.AuthorizationData{localAuthEntry}
})

You can also initialize the request struct manually, if desired:

req := localauth.SendLocalListRequest{
    ListVersion:            listVersion,
    LocalAuthorizationList: []localauth.AuthorizationData{localAuthEntry},
    UpdateType:             updateType,
}
err := suite.centralSystem.SendRequestAsync(clientID, req, myCallback)

Keep in mind that for manual initialization you won't know which fields are actually required.

KyleLehtinenDev commented 1 year ago

Thanks for the feedback.