Skip to content

Commit

Permalink
Add FormationError and OccurrenceConstraintViolationError (#490)
Browse files Browse the repository at this point in the history
In OCPP 1.6, two errors were misspelled. "FormationViolation" Error
should be "FormatViolation" Error, "OccurenceConstraintViolation" Error
should be "OccurrenceConstraintViolation" Error.

The OCA decided not to correct the spelling in OCPP 1.6, since that
would be a breaking change. FormationViolation has been fixed as of OCPP
2.0.1. OccurenceConstraintViolation Error is used for 1.6 and 2.0.1.
"OccurrenceConstraintViolation" Error is used for OCPP 2.1 and up.

This library doesn't support "FormationViolation" Error (for OCPP 1.6
and up)

This commit  adds support for those errors.

See the discussion at #381
and OCPP 1.6-J Errata sheet v1.0, section 5 "Known issues that won't be
fixed".
  • Loading branch information
Jared-Newell-Mobility authored Oct 24, 2023
1 parent ad79b31 commit 02a532d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change log


- [#381](https://github.com/mobilityhouse/ocpp/issues/381) FormatViolation serialization bug with OCPP 1.6-J

## 0.21.0 (2023-10-19)

- [#492] Minor fixes _handle_call doc string - Thanks @drc38
Expand Down
41 changes: 41 additions & 0 deletions ocpp/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,31 @@ class SecurityError(OCPPError):


class FormatViolationError(OCPPError):
"""
Not strict OCPP 1.6 - see FormationViolationError
Valid OCPP 2.0.1
"""

code = "FormatViolation"
default_description = (
"Payload for Action is syntactically incorrect or " "structure for Action"
)


class FormationViolationError(OCPPError):
"""
To allow for strict OCPP 1.6 compliance
5. Known issues that will not be fixed
5.2. Page 14, par 4.2.3. CallError: incorrect name in enum: FormationViolation
Incorrect name in enum: FormationViolation
"""

code = "FormationViolation"
default_description = (
"Payload for Action is syntactically incorrect or structure for Action"
)


class PropertyConstraintViolationError(OCPPError):
code = "PropertyConstraintViolation"
default_description = (
Expand All @@ -83,6 +102,14 @@ class PropertyConstraintViolationError(OCPPError):


class OccurenceConstraintViolationError(OCPPError):
"""
To allow for strict OCPP 1.6 compliance
ocpp-j-1.6-errata-sheet.pdf
5. Known issues that will not be fixed
5.1. Page 14, par 4.2.3: CallError: Typo in enum
Typo in enum: OccurenceConstraintViolation
"""

code = "OccurenceConstraintViolation"
default_description = (
"Payload for Action is syntactically correct but "
Expand All @@ -91,6 +118,20 @@ class OccurenceConstraintViolationError(OCPPError):
)


class OccurrenceConstraintViolationError(OCPPError):
"""
Not strict OCPP 1.6 - see OccurenceConstraintViolationError
Valid OCPP 2.0.1
"""

code = "OccurrenceConstraintViolation"
default_description = (
"Payload for Action is syntactically correct but "
"at least one of the fields violates occurence "
"constraints"
)


class TypeConstraintViolationError(OCPPError):
code = "TypeConstraintViolation"
default_description = (
Expand Down

0 comments on commit 02a532d

Please sign in to comment.