Last active
April 28, 2021 06:23
-
-
Save pocki80/36144abf1582ec1cb0b5aa30f677494f to your computer and use it in GitHub Desktop.
Decode WienerNetze Smartmeter ISKRAEMECO AM550 HDLC packets from your infrared interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# use this to decode WienerNetze Smartmeter ISKRAEMECO AM550 HDLC packets from your infrared interface | |
# example key and data is designed to decipher as real example | |
#paste your AES-key here, taken from WienerNetze Webportal https://www.wienernetze.at/wnapp/smapp/ -> Anlagedaten | |
$key='aabbccddeeff00112233445566778899'; | |
#paste a full HDLC frame here: starting 7ea067 ending 7e, should be 210 hex digits = 105 bytes = 0x69 -> length byte 3 shows 0x67 | |
$data='7ea067cf022313fbf1e6e700db0844556677889900aa4f20888877775540d5496ab897685e9b7e469942209b881fe280526f77c9d1dee763afb463a9bbe88449cb3fe79725875de945a405cb0f3119d3e06e3c4790130a29bc090cdf4b323cd7019d628ca255fce57e'; | |
#prepare | |
$st=substr($data, 28,16); | |
$ic=substr($data, 48, 8); | |
$iv=$st.$ic.'00000002'; | |
$enc=substr($data, 56, 148); | |
#decode | |
$dec=bin2hex(openssl_decrypt(hex2bin($enc), 'aes-128-ctr', hex2bin($key), 1, hex2bin($iv))); | |
print $dec; | |
#parse | |
$a=substr($dec, 70, 8); | |
$b=substr($dec, 80, 8); | |
$c=substr($dec, 90, 8); | |
$d=substr($dec,100, 8); | |
$e=substr($dec,110, 8); | |
$f=substr($dec,120, 8); | |
$g=substr($dec,130, 8); | |
$h=substr($dec,140, 8); | |
#output | |
print "+A: ".hexdec($a)/1000 . "kWh"; | |
print "-A: ".hexdec($b)/1000 . "kWh"; | |
print "+R: ".hexdec($c)/1000 . "kvarh"; | |
print "-R: ".hexdec($d)/1000 . "kvarh"; | |
print "+P: ".hexdec($e) . "W"; | |
print "-P: ".hexdec($f) . "W"; | |
print "+Q: ".hexdec($g) . "var"; | |
print "-Q: ".hexdec($h) . "var"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment