Skip to content

Commit

Permalink
Allow connectorID 0 for trigger message v1.6
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenzo <lorenzo.donini90@gmail.com>
  • Loading branch information
lorenzodonini committed Mar 29, 2024
1 parent 2000d27 commit 6503096
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions ocpp1.6/remotetrigger/trigger_message.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package remotetrigger

import (
"reflect"

"github.com/lorenzodonini/ocpp-go/ocpp1.6/core"
"github.com/lorenzodonini/ocpp-go/ocpp1.6/firmware"
"github.com/lorenzodonini/ocpp-go/ocpp1.6/types"
"gopkg.in/go-playground/validator.v9"
"reflect"
)

// -------------------- Trigger Message (CS -> CP) --------------------
Expand Down Expand Up @@ -47,7 +48,7 @@ func isValidMessageTrigger(fl validator.FieldLevel) bool {
// The field definition of the TriggerMessage request payload sent by the Central System to the Charge Point.
type TriggerMessageRequest struct {
RequestedMessage MessageTrigger `json:"requestedMessage" validate:"required,messageTrigger16"`
ConnectorId *int `json:"connectorId,omitempty" validate:"omitempty,gt=0"`
ConnectorId *int `json:"connectorId,omitempty" validate:"omitempty,gte=0"`
}

// This field definition of the TriggerMessage confirmation payload, sent by the Charge Point to the Central System in response to a TriggerMessageRequest.
Expand Down
3 changes: 2 additions & 1 deletion ocpp1.6_test/trigger_message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ func (suite *OcppV16TestSuite) TestTriggerMessageRequestValidation() {
{remotetrigger.TriggerMessageRequest{RequestedMessage: core.StatusNotificationFeatureName, ConnectorId: newInt(1)}, true},
{remotetrigger.TriggerMessageRequest{RequestedMessage: core.StatusNotificationFeatureName}, true},
{remotetrigger.TriggerMessageRequest{}, false},
{remotetrigger.TriggerMessageRequest{RequestedMessage: core.StatusNotificationFeatureName, ConnectorId: newInt(0)}, false},
{remotetrigger.TriggerMessageRequest{RequestedMessage: core.StatusNotificationFeatureName, ConnectorId: newInt(0)}, true},
{remotetrigger.TriggerMessageRequest{RequestedMessage: core.StatusNotificationFeatureName, ConnectorId: newInt(-1)}, false},
{remotetrigger.TriggerMessageRequest{RequestedMessage: core.StartTransactionFeatureName}, false},
}
ExecuteGenericTestTable(t, requestTable)
Expand Down

0 comments on commit 6503096

Please sign in to comment.