lorenzodonini/ocpp-go

Unable to Include LocalAuthorizationList in OCPP1.6 SendLocalList Command

KyleLehtinenDev opened this issue · 2 comments

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?

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.

Thanks for the feedback.