lorenzodonini/ocpp-go

Firmware Status Notification

MattGrouchy opened this issue · 2 comments

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?

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?

Yes, thank you!