From b4684d226868a0c6cd345b5e3a79baab4ddd5492 Mon Sep 17 00:00:00 2001 From: Michael Maroszek Date: Fri, 8 Sep 2023 10:05:28 +0200 Subject: [PATCH] request MeterValues always for a ConnectorId --- OCPP Charging Point/module.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/OCPP Charging Point/module.php b/OCPP Charging Point/module.php index e427b70..bf1a0dc 100644 --- a/OCPP Charging Point/module.php +++ b/OCPP Charging Point/module.php @@ -76,7 +76,6 @@ public function ReceiveData($JSONString) public function Update() { $this->send($this->getTriggerMessageRequest('BootNotification')); - $this->send($this->getTriggerMessageRequest('MeterValues')); $this->send($this->getTriggerMessageRequest('StatusNotification')); } @@ -237,6 +236,10 @@ private function processStatusNotification(string $messageID, $payload) $this->RemoteStartTransaction($payload['connectorId']); } } + + // Request meter values for specific connector on each status notification + // In particular we want to use this in combination of the Update function + $this->send($this->getTriggerMessageRequest('MeterValues', $payload['connectorId'])); } private function processStartTransaction(string $messageID, $payload) @@ -297,20 +300,24 @@ private function generateTransactionID() return rand(1, 5000); } - private function getTriggerMessageRequest(string $messageType) + private function getTriggerMessageRequest(string $messageType, int $connectorId = -1) { /** * OCPP-1.6 edition 2.pdf * Page 89 * TriggerMessage.req */ + $data = [ + 'requestedMessage' => $messageType + ]; + if ($connectorId >= 0) { + $data['connectorId'] = $connectorId; + } return [ CALL, $this->generateMessageID(), 'TriggerMessage', - [ - 'requestedMessage' => $messageType - ] + $data ]; }