Skip to content

Instantly share code, notes, and snippets.

@pocki80
Last active August 19, 2022 22:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pocki80/8d5aed9a5b99e9731130819229e15a37 to your computer and use it in GitHub Desktop.
Save pocki80/8d5aed9a5b99e9731130819229e15a37 to your computer and use it in GitHub Desktop.
Decode WienerNetze Smartmeter ISKRAEMECO AM550 HDLC packets from your infrared interface
#!/usr/bin/bash
# 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=$(echo $data | cut -b 29-44)
iv=$(echo $data | cut -b 49-56)
ic=$st$iv\00000002
d=$(echo $data | cut -b 57-204)
#decode and show plaintext
plain=$(echo $d | xxd -r -p | openssl enc -d -nosalt -nopad -aes-128-ctr -K "$key" -iv "$ic" | xxd -ps -c 90)
echo $plain
#print power counter
ap=$(echo $plain | cut -b 71-78)
echo "+A is 0x$ap = $((16#$ap)) Wh"
#print current power
wp=$(echo $plain | cut -b 111-118)
echo "+P is 0x$wp = $((16#$wp)) W"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment