public static byte[] queryDeviceVariable(int var_number) { String req = "02 52 vn 10 03"; byte[] message = PrimareUtils.hexStringToByteArray(req.replaceAll(" ", "").toLowerCase()); message[2] = (byte) var_number; logger.trace( String.format( "PrimareSPA20Message.queryDeviceVariable %d (0x%02x), msg: %s", var_number, var_number, PrimareUtils.byteArrayToHex(message))); return message; }
public static byte[] setDeviceVariable(int var_number, byte var_value) { String req = "02 57 vn vv 10 03"; byte[] message = PrimareUtils.hexStringToByteArray(req.replaceAll(" ", "").toLowerCase()); message[2] = (byte) (var_number | 0x80); // OR with 0x80 required when setting variable message[3] = var_value; logger.debug( String.format( "PrimareSPA20Message.setDeviceVariable %d (0x%02x) = %d (0x%02x), msg: %s", var_number, var_number, var_value, var_value, PrimareUtils.byteArrayToHex(message))); return message; }