lorenzodonini / ocpp-go

Open Charge Point Protocol implementation in Go
MIT License
258 stars 120 forks source link

Firmware Status Notification #213

Closed MattGrouchy closed 1 year ago

MattGrouchy commented 1 year ago

The OCPP 2.0.1 ID L02.FR.06:

Every FirmwareStatusNotificationRequest sent for a firmware update SHALL contain the same requestId as the UpdateFirmwareRequest that started this firmware update.

How can I provide the requestId to the ChargingStation.FirmwareStatusNotification method?

lorenzodonini commented 1 year ago

The RequestID field is optional and may be set in one of two ways.

Option 1

cs := ocpp2.NewChargingStation(...)
someRequestID := 42
resp, err := cs.FirmwareStatusNotification(firmware.FirmwareStatusDownloading, func(request *firmware.FirmwareStatusNotificationRequest) {
    request.RequestID = &someRequestID
})
// Handle response/error

Option 2

cs := ocpp2.NewChargingStation(...)
someRequestID := 42
req := firmware.NewFirmwareStatusNotificationRequest(firmware.FirmwareStatusDownloading)
req.RequestID = &someRequestID
resp, err := cs.SendRequest(req)
// Handle response/error

The approach via variadic function paramter holds true for setting every optional field.

Does this answer your question?

MattGrouchy commented 1 year ago

Yes, thank you!