org.universAAL.lddi.knx.utils
Class KnxEncoder

Package class diagram package KnxEncoder
java.lang.Object
  extended by org.universAAL.lddi.knx.utils.KnxEncoder

public class KnxEncoder
extends Object

Provides bottom-up (knx to uAAL) and top-down (uAAL to knx) translation of commands.

Author:
Enrico Allione (enrico.allione@gmail.com), Thomas Fuxreiter (foex@gmx.at)

Nested Class Summary
static class KnxEncoder.KnxMessageType
           
 
Constructor Summary
KnxEncoder()
           
 
Method Summary
static String clearHexValue(String hexValue)
          This method remove, if present, the "0x" prefix of the hexValue variable.
static String convertDeviceAddressToHex(String address)
          Translates readable device addresses to knx hex code. x is 0-15 on 4bits; y is 0-15 on 4bits; z is 0-255 on 8bits;
static String convertGroupAddressToHex(String address)
          Converts a readable knx group address to hex encoded string. x is 0-15 on 5 bits; y is 0-7 on 3 bits; z is 0-255 on 8 bits;
static String convertGroupAddressToReadable(byte[] buffer)
          Convert knx group address from knx encoded bytes to readable x/y/z format.
static byte[] convertToByteArray(String hexString)
          Converts a hex-encoded knx message to byte array.
static String convertToHex(byte[] b)
          Convert byte array to hex encoded string without delimiters.
static String convertToReadableHex(byte[] b)
          Convert byte array to readable hex-encoded string.
static KnxTelegram decode(byte[] knxMessage)
          Decode knx byte array and create KnxTelegram object.
static byte[] encode(boolean repeatBit, byte[] sourceByte, String targetAddress, byte[] dataByte, KnxCommand commandType, boolean multicast)
          Encode a knx telegram for sending to a knx bus.
static byte[] removeTrailingZeros(byte[] original)
          Remove trailing Zero bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KnxEncoder

public KnxEncoder()
Method Detail

encode

public static byte[] encode(boolean repeatBit,
                            byte[] sourceByte,
                            String targetAddress,
                            byte[] dataByte,
                            KnxCommand commandType,
                            boolean multicast)
Encode a knx telegram for sending to a knx bus. For all datapoint types!

Parameters:
repeatBit - has this telegram been sent already?
sourceByte - sending KNX address
targetAddress - knx address - could be device or group address
dataByte - knx command
messageType - (read, write, scenario)
Returns:
knx telegram for sending to knx bus

decode

public static KnxTelegram decode(byte[] knxMessage)
Decode knx byte array and create KnxTelegram object.

Parameters:
knx - telegram
Returns:
KnxTelegram object; null if telegram is not valid

removeTrailingZeros

public static byte[] removeTrailingZeros(byte[] original)
Remove trailing Zero bytes.

Parameters:
original -
Returns:
cropped byte array

convertDeviceAddressToHex

public static String convertDeviceAddressToHex(String address)
Translates readable device addresses to knx hex code. x is 0-15 on 4bits; y is 0-15 on 4bits; z is 0-255 on 8bits;

Parameters:
address - of the device as x.y.z
Returns:
the address as hex String (2 bytes)

convertGroupAddressToHex

public static String convertGroupAddressToHex(String address)
Converts a readable knx group address to hex encoded string. x is 0-15 on 5 bits; y is 0-7 on 3 bits; z is 0-255 on 8 bits;

Parameters:
readable - string "x/y/z" group address
Returns:
hex-encoded string "xy" hexadecimal group address

convertToByteArray

public static byte[] convertToByteArray(String hexString)
Converts a hex-encoded knx message to byte array.

Parameters:
a - hex-encoded message string
Returns:
the message as byte array

convertToReadableHex

public static String convertToReadableHex(byte[] b)
Convert byte array to readable hex-encoded string.

Parameters:
-
Returns:
hex representation of the byte array as a String with semicolons as delimiter

convertToHex

public static String convertToHex(byte[] b)
Convert byte array to hex encoded string without delimiters.


convertGroupAddressToReadable

public static String convertGroupAddressToReadable(byte[] buffer)
Convert knx group address from knx encoded bytes to readable x/y/z format.

Parameters:
buffer - group device address in bytes
Returns:
group address as String

clearHexValue

public static String clearHexValue(String hexValue)
This method remove, if present, the "0x" prefix of the hexValue variable.

Parameters:
hexValue - string containing an hex value
Returns:
the same string without prefix


Copyright © 2014 universAAL Consortium. All Rights Reserved.