Skip to content

Commit 9517ab6

Browse files
guelfeylorenzodonini
authored andcommitted
OCPP1.6: correct field name in SetChargingProfile
Section 6.43 of the spec pretty clearly states that the field name is "csChargingProfiles".
1 parent 9b24d56 commit 9517ab6

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

ocpp1.6/smartcharging/set_charging_profile.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package smartcharging
22

33
import (
4+
"reflect"
5+
46
"github.com/lorenzodonini/ocpp-go/ocpp1.6/types"
57
"gopkg.in/go-playground/validator.v9"
6-
"reflect"
78
)
89

910
// -------------------- Set Charging Profile (CS -> CP) --------------------
@@ -32,7 +33,7 @@ func isValidChargingProfileStatus(fl validator.FieldLevel) bool {
3233
// The field definition of the SetChargingProfile request payload sent by the Central System to the Charge Point.
3334
type SetChargingProfileRequest struct {
3435
ConnectorId int `json:"connectorId" validate:"gte=0"`
35-
ChargingProfile *types.ChargingProfile `json:"chargingProfile" validate:"required"`
36+
ChargingProfile *types.ChargingProfile `json:"csChargingProfiles" validate:"required"`
3637
}
3738

3839
// This field definition of the SetChargingProfile confirmation payload, sent by the Charge Point to the Central System in response to a SetChargingProfileRequest.

ocpp1.6_test/set_charging_profile_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package ocpp16_test
22

33
import (
44
"fmt"
5+
56
"github.com/lorenzodonini/ocpp-go/ocpp1.6/smartcharging"
67
"github.com/lorenzodonini/ocpp-go/ocpp1.6/types"
78
"github.com/stretchr/testify/assert"
@@ -50,7 +51,7 @@ func (suite *OcppV16TestSuite) TestSetChargingProfileE2EMocked() {
5051
status := smartcharging.ChargingProfileStatusAccepted
5152
chargingSchedule := types.NewChargingSchedule(chargingRateUnit, types.NewChargingSchedulePeriod(startPeriod, limit))
5253
chargingProfile := types.NewChargingProfile(chargingProfileId, stackLevel, chargingProfilePurpose, chargingProfileKind, chargingSchedule)
53-
requestJson := fmt.Sprintf(`[2,"%v","%v",{"connectorId":%v,"chargingProfile":{"chargingProfileId":%v,"stackLevel":%v,"chargingProfilePurpose":"%v","chargingProfileKind":"%v","chargingSchedule":{"chargingRateUnit":"%v","chargingSchedulePeriod":[{"startPeriod":%v,"limit":%v}]}}}]`,
54+
requestJson := fmt.Sprintf(`[2,"%v","%v",{"connectorId":%v,"csChargingProfiles":{"chargingProfileId":%v,"stackLevel":%v,"chargingProfilePurpose":"%v","chargingProfileKind":"%v","chargingSchedule":{"chargingRateUnit":"%v","chargingSchedulePeriod":[{"startPeriod":%v,"limit":%v}]}}}]`,
5455
messageId,
5556
smartcharging.SetChargingProfileFeatureName,
5657
connectorId,
@@ -119,7 +120,7 @@ func (suite *OcppV16TestSuite) TestSetChargingProfileInvalidEndpoint() {
119120
limit := 10.0
120121
chargingSchedule := types.NewChargingSchedule(chargingRateUnit, types.NewChargingSchedulePeriod(startPeriod, limit))
121122
chargingProfile := types.NewChargingProfile(chargingProfileId, stackLevel, chargingProfilePurpose, chargingProfileKind, chargingSchedule)
122-
requestJson := fmt.Sprintf(`[2,"%v","%v",{"connectorId":%v,"chargingProfile":{"chargingProfileId":%v,"stackLevel":%v,"chargingProfilePurpose":"%v","chargingProfileKind":"%v","chargingSchedule":{"chargingRateUnit":"%v","chargingSchedulePeriod":[{"startPeriod":%v,"limit":%v}]}}}]`,
123+
requestJson := fmt.Sprintf(`[2,"%v","%v",{"connectorId":%v,"csChargingProfiles":{"chargingProfileId":%v,"stackLevel":%v,"chargingProfilePurpose":"%v","chargingProfileKind":"%v","chargingSchedule":{"chargingRateUnit":"%v","chargingSchedulePeriod":[{"startPeriod":%v,"limit":%v}]}}}]`,
123124
messageId,
124125
smartcharging.SetChargingProfileFeatureName,
125126
connectorId,

0 commit comments

Comments
 (0)