Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/141, OCPP 1.6 Security White Paper Ed 2 #206

Merged
merged 2 commits into from
Jun 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
71 changes: 71 additions & 0 deletions ocpp/v16/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
Reason,
ResetType,
UpdateType,
CertificateUse,
Log,
UploadLogStatus,
)

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


@dataclass
class CertificateSignedPayload:
certificate_chain: str


@dataclass
class ChangeAvailabilityPayload:
connector_id: int
Expand All @@ -63,6 +71,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 +103,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 +167,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 +230,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: FirmwareStatus
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