-
Notifications
You must be signed in to change notification settings - Fork 133
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
Issue with DataTransfer on both ocpp 1.6 and 2.0.1 #257
Comments
Now, I'm using this code on
But I'm still not sure if it will work on the real scenario. |
Hey @KatyushaScarlet , you don't need to marshal anything beforehand. If pre-marshaled, the data field will effectively be a byte array, which will be transformed to base64 when marshaled, which is probably not what you want. Just pass the following: data := DataSample{SampleString: "dummyData", SampleValue: 42}
dataConf, err := chargePoint.DataTransfer("vendor1", func(request *core.DataTransferRequest) {
request.MessageId = "message1"
request.Data = &data
}) The go struct will be automatically marshaled to JSON. On the receiving end, since the parser has no idea what type to expect when initially unmarshaling the message, the data is unmarshaled into an interface type (typically a Nevertheless, I'll add a utility function to the data transfer feature to help with unmarshaling the payload into arbitrary types. |
Hi, I'm trying to develop a program to convert OCPP 1.6 requests to OCPP 2.0.1 requests and I'm running into a strange problem:
Filling the data field in DataTransferRequest with bytes[] obtained from json or string conversion is converted to base64 on the receiving end.
This problem occurs in my attempts to use either 1.6 or 2.0.1 examples.
For example, on the charge point my code like this:
However, in the DataTransferRequest on the receiving end, I will get an object of type
{interface{} | string}
with this value:It is a string using base64 encoding with the original value:
If this is normal?
but when I look at the 2.0.1 example, I see that the
csms
code is like this:When I tested this on example, I found that both 1.6 and 2.0.1 exmaple get a base64 string for
request.Data
and cause a fatal exception oncsms
(due to json.Unmarshal decoding failure).I've also looked at the test package, but in 2.0.1 I only see
suite.chargingStation.DataTransfer(vendorId)
, and I don't find a place to setrequest.Data
.Since I don't have access to a physical charging post at the moment, I don't know which type of data is the correct one to pass in a real usage scenario.
I'm not sure if I'm missing some setting somewhere, or if there's something wrong with my code.
Thanks!
The text was updated successfully, but these errors were encountered: