Skip to content

Commit

Permalink
request MeterValues always for a ConnectorId
Browse files Browse the repository at this point in the history
  • Loading branch information
paresy committed Sep 8, 2023
1 parent 8e46e4a commit b4684d2
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions OCPP Charging Point/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
];
}

Expand Down

0 comments on commit b4684d2

Please sign in to comment.