Skip to content

Commit

Permalink
feature/197, backported 2.0 schema files to 1.6 according to Improved…
Browse files Browse the repository at this point in the history
… security for OCPP 1.6-J specification
  • Loading branch information
villekr committed May 6, 2021
1 parent fdfb5b1 commit 8f91098
Show file tree
Hide file tree
Showing 28 changed files with 986 additions and 1 deletion.
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Question
about: Describe this issue template's purpose here.
title: ''
labels: question
assignees: ''

---

When your question is related to code that isn't working as expected, please
enable debug logs:

``` python
import logging
logging.basicConfig(level=logging.DEBUG)
```

More info can be found in the [Debugging
section](https://github.com/mobilityhouse/ocpp#debugging) of the README.

If these actions didn't help to find the cause of your issue, please provide
code samples and logs with your question.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,6 @@ venv.bak/
.mypy_cache/

.idea/*

### OSX ###
*.DS_Store
23 changes: 23 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,29 @@ Charge point
if __name__ == '__main__':
asyncio.run(main())
Debugging
---------

Python's default log level is `logging.WARNING`. As result most of the logs
generated by this package are discarded. To see the log output of this package
lower the log level to `logging.DEBUG`.

.. code-block:: python
import logging
logging.basicConfig(level=logging.DEBUG)
However, this approach defines the log level for the complete logging system.
In other words: the log level of all dependencies is set to `logging.DEBUG`.

To lower the logs for this package only use the following code:

.. code-block:: python
import logging
logging.getLogger('ocpp').setLevel(level=logging.DEBUG)
logging.getLogger('ocpp').addHandler(logging.StreamHandler())
License
-------

Expand Down
72 changes: 72 additions & 0 deletions ocpp/v16/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
Reason,
ResetType,
UpdateType,
CertificateUse,
SignedFirmwareStatus,
Log,
UploadLogStatus,
)

# Most types of CALL messages can originate from only 1 source, either
Expand All @@ -38,6 +42,11 @@ class CancelReservationPayload:
reservation_id: int


@dataclass
class CertificateSignedPayload:
certificate_chain: str


@dataclass
class ChangeAvailabilityPayload:
connector_id: int
Expand All @@ -63,6 +72,17 @@ class ClearChargingProfilePayload:
stack_level: Optional[int] = None


@dataclass
class DeleteCertificatePayload:
certificate_hash_data: Dict


@dataclass
class ExtendedTriggerMessagePayload:
requested_message: MessageTrigger
connector_id: Optional[int] = None


@dataclass
class GetCompositeSchedulePayload:
connector_id: int
Expand All @@ -84,11 +104,31 @@ class GetDiagnosticsPayload:
stop_time: Optional[str] = None


@dataclass
class GetInstalledCertificateIdsPayload:
certificate_type: CertificateUse


@dataclass
class GetLocalListVersionPayload:
pass


@dataclass
class GetLogPayload:
log: Dict
log_type: Log
request_id: int
retries: Optional[int] = None
retry_interval: Optional[int] = None


@dataclass
class InstallCertificatePayload:
certificate_type: CertificateUse
certificate: str


@dataclass
class RemoteStartTransactionPayload:
id_tag: str
Expand Down Expand Up @@ -128,6 +168,14 @@ class SetChargingProfilePayload:
cs_charging_profiles: Dict


@dataclass
class SignedUpdateFirmwarePayload:
request_id: int
firmware: Dict
retries: Optional[int] = None
retry_interval: Optional[int] = None


@dataclass
class TriggerMessagePayload:
requested_message: MessageTrigger
Expand Down Expand Up @@ -183,13 +231,37 @@ class HeartbeatPayload:
pass


@dataclass
class LogStatusNotificationPayload:
status: UploadLogStatus
request_id: int


@dataclass
class MeterValuesPayload:
connector_id: int
meter_value: List = field(default_factory=list)
transaction_id: Optional[int] = None


@dataclass
class SecurityEventNotificationPayload:
type: str
timestamp: str
tech_info: Optional[str]


@dataclass
class SignCertificatePayload:
csr: str


@dataclass
class SignedFirmwareStatusNotificationPayload:
status: SignedFirmwareStatus
request_id: int


@dataclass
class StartTransactionPayload:
connector_id: int
Expand Down
64 changes: 64 additions & 0 deletions ocpp/v16/call_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
TriggerMessageStatus,
UpdateStatus,
UnlockStatus,
CertificateSignedStatus,
CertificateStatus,
DeleteCertificateStatus,
GenericStatus,
GetInstalledCertificateStatus,
LogStatus,
UpdateFirmwareStatus
)

# Most types of CALLRESULT messages can originate from only 1 source, either
Expand Down Expand Up @@ -63,6 +70,21 @@ class HeartbeatPayload:
current_time: str


@dataclass
class LogStatusNotificationPayload:
pass


@dataclass
class SecurityEventNotificationPayload:
pass


@dataclass
class SignCertificatePayload:
status: GenericStatus


@dataclass
class MeterValuesPayload:
pass
Expand Down Expand Up @@ -93,6 +115,11 @@ class CancelReservationPayload:
status: CancelReservationStatus


@dataclass
class CertificateSignedPayload:
status: CertificateSignedStatus


@dataclass
class ChangeAvailabilityPayload:
status: AvailabilityStatus
Expand All @@ -113,6 +140,22 @@ class ClearChargingProfilePayload:
status: ClearChargingProfileStatus


@dataclass
class DeleteCertificatePayload:
status: DeleteCertificateStatus


@dataclass
class ExtendedTriggerMessagePayload:
status: TriggerMessageStatus


@dataclass
class GetInstalledCertificateIdsPayload:
status: GetInstalledCertificateStatus
certificate_hash_data: Optional[List] = None


@dataclass
class GetCompositeSchedulePayload:
status: GetCompositeScheduleStatus
Expand All @@ -137,6 +180,17 @@ class GetLocalListVersionPayload:
list_version: int


@dataclass
class GetLogPayload:
status: LogStatus
filename: Optional[str] = None


@dataclass
class InstallCertificatePayload:
status: CertificateStatus


@dataclass
class RemoteStartTransactionPayload:
status: RemoteStartStopStatus
Expand Down Expand Up @@ -167,6 +221,16 @@ class SetChargingProfilePayload:
status: ChargingProfileStatus


@dataclass
class SignedFirmwareStatusNotificationPayload:
pass


@dataclass
class SignedUpdateFirmwarePayload:
status: UpdateFirmwareStatus


@dataclass
class TriggerMessagePayload:
status: TriggerMessageStatus
Expand Down
Loading

0 comments on commit 8f91098

Please sign in to comment.