Neues Ladestationsmodul mit ocpp Modul erstellt.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
class OCPPTransport
|
||||
{
|
||||
public static function buildEnvelope(OCPPMessage $message, int $targetInstance = 0): array
|
||||
{
|
||||
return [
|
||||
'TargetInstance' => $targetInstance,
|
||||
'ChargePointId' => $message->chargePointId,
|
||||
'Version' => $message->version,
|
||||
'Frame' => $message->toJson(),
|
||||
'Timestamp' => time()
|
||||
];
|
||||
}
|
||||
|
||||
public static function decodeEnvelope(string $json): array
|
||||
{
|
||||
$data = json_decode($json, true);
|
||||
if (!is_array($data)) {
|
||||
return [];
|
||||
}
|
||||
return [
|
||||
'TargetInstance' => (int)($data['TargetInstance'] ?? 0),
|
||||
'ChargePointId' => (string)($data['ChargePointId'] ?? ''),
|
||||
'Version' => (string)($data['Version'] ?? 'auto'),
|
||||
'Frame' => (string)($data['Frame'] ?? ''),
|
||||
'Timestamp' => (int)($data['Timestamp'] ?? time())
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user