gt:     	byte[] newPayload = { 	(byte) this.getNode().getNodeId(), 
context: /**
   * Copyright (c) 2010-2015, openHAB.org and others.
   *
   * All rights reserved. This program and the accompanying materials
   * are made available under the terms of the Eclipse Public License v1.0
   * which accompanies this distribution, and is available at
   * http://www.eclipse.org/legal/epl-v10.html
   */
  package org.openhab.binding.zwave.internal.protocol.commandclass;
  
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.Timer;
  import java.util.TimerTask;
  import java.util.concurrent.ArrayBlockingQueue;
  
  import org.openhab.binding.zwave.internal.protocol.SerialMessage;
  import org.openhab.binding.zwave.internal.protocol.SerialMessage.SerialMessageClass;
  import org.openhab.binding.zwave.internal.protocol.SerialMessage.SerialMessagePriority;
  import org.openhab.binding.zwave.internal.protocol.SerialMessage.SerialMessageType;
  import org.openhab.binding.zwave.internal.protocol.ZWaveController;
  import org.openhab.binding.zwave.internal.protocol.ZWaveEndpoint;
  import org.openhab.binding.zwave.internal.protocol.ZWaveEventListener;
  import org.openhab.binding.zwave.internal.protocol.ZWaveNode;
  import org.openhab.binding.zwave.internal.protocol.event.ZWaveEvent;
  import org.openhab.binding.zwave.internal.protocol.event.ZWaveTransactionCompletedEvent;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
  import com.thoughtworks.xstream.annotations.XStreamAlias;
  import com.thoughtworks.xstream.annotations.XStreamOmitField;
  
  /**
   * Wake Up Command Class. Enables a node to notify another device
   * that it woke up and is ready to receive commands.
   * @author Jan-Willem Spuij
   * @author Chris Jackson
   * @since 1.3.0
   */
  @XStreamAlias("WakeUpCommandClass")
  public class ZWaveWakeUpCommandClass extends ZWaveCommandClass implements ZWaveCommandClassInitialization, ZWaveEventListener {
  
  	@XStreamOmitField
  	private static final Logger logger = LoggerFactory.getLogger(ZWaveWakeUpCommandClass.class);
  	private static final int MAX_SUPPORTED_VERSION = 2;
  
  	public static final int WAKE_UP_INTERVAL_SET = 0x04;
  	public static final int WAKE_UP_INTERVAL_GET = 0x05;
  	public static final int WAKE_UP_INTERVAL_REPORT = 0x06;
  	public static final int WAKE_UP_NOTIFICATION = 0x07;
  	public static final int WAKE_UP_NO_MORE_INFORMATION = 0x08;
  	public static final int WAKE_UP_INTERVAL_CAPABILITIES_GET = 0x09;
  	public static final int WAKE_UP_INTERVAL_CAPABILITIES_REPORT = 0x0A;
  
  	private static final int MAX_BUFFFER_SIZE = 128;
  
  	@XStreamOmitField
  	private ArrayBlockingQueue<SerialMessage> wakeUpQueue;
  
  	// From interval report
  	@XStreamOmitField
  	private boolean initReportDone = false;
  	private int targetNodeId = 0;
  	private int interval = 0;
  
  	// From capabilities report
  	@XStreamOmitField
  	private boolean initCapabilitiesDone = false;
  	private int minInterval = 0;
  	private int maxInterval = 0;
  	private int defaultInterval = 0;
  	private int intervalStep = 0;
  	
  	@XStreamOmitField
  	private volatile boolean isAwake = false;
  	
  	@XStreamOmitField
  	private Timer timer = null;
  	@XStreamOmitField
  	private TimerTask timerTask = null;
  
  	@XStreamOmitField
  	private boolean initialiseDone = false;
  
  	/**
  	 * Creates a new instance of the ZWaveWakeUpCommandClass class.
  	 * @param node the node this command class belongs to
  	 * @param controller the controller to use
  	 * @param endpoint the endpoint this Command class belongs to
  	 */
  	public ZWaveWakeUpCommandClass(ZWaveNode node,
  			ZWaveController controller, ZWaveEndpoint endpoint) {
  		super(node, controller, endpoint);
  		wakeUpQueue = new ArrayBlockingQueue<SerialMessage>(MAX_BUFFFER_SIZE, true);
  		
  		timer = new Timer();
  	}
  	
  	/**
  	 * Resolves uninitialized fields after XML Deserialization.
  	 *
  	 * @return The current {@link ZWaveWakeUpCommandClass} instance.
  	 */
  	private Object readResolve() {
  		wakeUpQueue = new ArrayBlockingQueue<SerialMessage>(MAX_BUFFFER_SIZE, true);
  		timer = new Timer();
  		return this;
  	}	
  	
  	/**
  	 * {@inheritDoc}
  	 */
  	@Override
  	public CommandClass getCommandClass() {
  		return CommandClass.WAKE_UP;
  	}
  
  	/**
  	 * {@inheritDoc}
  	 */
  	@Override
  	public int getMaxVersion() {
  		return MAX_SUPPORTED_VERSION;
  	};
  
  	/**
  	 * {@inheritDoc}
  	 */
  	@Override
  	public void handleApplicationCommandRequest(SerialMessage serialMessage,
  			int offset, int endpoint) {
  		logger.debug("NODE {}: Received Wake Up Request", this.getNode().getNodeId());
  		int command = serialMessage.getMessagePayloadByte(offset);
  
  		switch (command) {
  			case WAKE_UP_INTERVAL_SET:
  			case WAKE_UP_INTERVAL_GET:
  			case WAKE_UP_INTERVAL_CAPABILITIES_GET:
  			case WAKE_UP_NO_MORE_INFORMATION:
  				logger.warn("Command {} not implemented.", command);
  				return;
  			case WAKE_UP_INTERVAL_REPORT:
  				logger.trace("NODE {}: Process Wake Up Interval", this.getNode().getNodeId());
  				initReportDone = true;
  
  				// according to open-zwave: it seems that some devices send incorrect interval report messages. Don't know if they are spurious.
  				// if not we should advance the node stage.
                  if(serialMessage.getMessagePayload().length < offset + 4) {
                  	logger.error("NODE {}: Unusual response: WAKE_UP_INTERVAL_REPORT with length = {}. Ignored.", this.getNode().getNodeId(), serialMessage.getMessagePayload().length);
                  	return;
                  }
  
                  targetNodeId = serialMessage.getMessagePayloadByte(offset + 4);
                  int receivedInterval = ((serialMessage.getMessagePayloadByte(offset + 1)) << 16) | ((serialMessage.getMessagePayloadByte(offset + 2)) << 8) | (serialMessage.getMessagePayloadByte(offset + 3));
  				logger.debug("NODE {}: Wake up interval report, value = {} seconds, targetNodeId = {}", this.getNode().getNodeId(), receivedInterval, targetNodeId);
  
  				this.interval = receivedInterval;
  
  				ZWaveWakeUpEvent event = new ZWaveWakeUpEvent(getNode().getNodeId(), WAKE_UP_INTERVAL_REPORT);
  				this.getController().notifyEventListeners(event);
  				break;
  			case WAKE_UP_INTERVAL_CAPABILITIES_REPORT:
  				logger.trace("NODE {}: Process Wake Up Interval Capabilities", this.getNode().getNodeId());
  				initCapabilitiesDone = true;
  				
                  this.minInterval = ((serialMessage.getMessagePayloadByte(offset + 1)) << 16) | ((serialMessage.getMessagePayloadByte(offset + 2)) << 8) | (serialMessage.getMessagePayloadByte(offset + 3));
                  this.maxInterval = ((serialMessage.getMessagePayloadByte(offset + 4)) << 16) | ((serialMessage.getMessagePayloadByte(offset + 5)) << 8) | (serialMessage.getMessagePayloadByte(offset + 6));
                  this.defaultInterval = ((serialMessage.getMessagePayloadByte(offset + 7)) << 16) | ((serialMessage.getMessagePayloadByte(offset + 8)) << 8) | (serialMessage.getMessagePayloadByte(offset + 9));
                  this.intervalStep = ((serialMessage.getMessagePayloadByte(offset + 10)) << 16) | ((serialMessage.getMessagePayloadByte(offset + 11)) << 8) | (serialMessage.getMessagePayloadByte(offset + 12));
  				
  				logger.debug("NODE {}: Wake up interval capabilities report", this.getNode().getNodeId());
  				logger.debug("NODE {}: Minimum interval = {}", this.getNode().getNodeId(), this.minInterval);
  				logger.debug("NODE {}: Maximum interval = {}", this.getNode().getNodeId(), this.maxInterval);
  				logger.debug("NODE {}: Default interval = {}", this.getNode().getNodeId(), this.defaultInterval);
  				logger.debug("NODE {}: Interval step    = {}", this.getNode().getNodeId(), this.intervalStep);
  				break;
  			case WAKE_UP_NOTIFICATION:
  				logger.debug("NODE {}: Received WAKE_UP_NOTIFICATION", this.getNode().getNodeId());
  				serialMessage.setTransactionCanceled();
  
  				// Set the awake flag. This will also empty the queue
  				this.setAwake(true);
  				break;
  			default:
  				logger.warn(String.format("NODE %d: Unsupported Command 0x%02X for command class %s (0x%02X).", 
  					this.getNode().getNodeId(),
  					command, 
  					this.getCommandClass().getLabel(),
  					this.getCommandClass().getKey()));
  		}
  	}
  	
  	/**
  	 * Gets a SerialMessage with the WAKE_UP_NO_MORE_INFORMATION command.
  	 * @return the serial message
  	 */
  	public SerialMessage getNoMoreInformationMessage() {
  		logger.debug("NODE {}: Creating new message for application command WAKE_UP_NO_MORE_INFORMATION", this.getNode().getNodeId());
  		SerialMessage result = new SerialMessage(this.getNode().getNodeId(), SerialMessageClass.SendData, SerialMessageType.Request, SerialMessageClass.SendData, SerialMessagePriority.Immediate);
      	byte[] newPayload = { 	(byte) this.getNode().getNodeId(), 
      							2, 
  								(byte) getCommandClass().getKey(), 
  								(byte) WAKE_UP_NO_MORE_INFORMATION };
      	result.setMessagePayload(newPayload);
  
      	return result;
  	}
  	
  	/**
  	 * If the device is awake, it returns true to indicate that this message can be sent
  	 * immediately. If the device is not awake, it puts the message in the wake-up queue
  	 * to send the message on next wake-up.
  	 * The message is only added if it's not the WAKE_UP_NO_MORE_INFORMATION message
  	 * since we don't want to send this at the next wakeup.
  	 * This combines the previous 'putInWakeUpQueue' with 'isAlive'.
  	 * @param serialMessage the message to put in the wake-up queue.
  	 * @return true if the message can be sent immediately
  	 */
  	public boolean processOutgoingWakeupMessage(SerialMessage serialMessage) {
  		// The message is Ok, if we're awake, send it now...
  		if(isAwake) {
  			// We're sending a frame, so we need to stop the timer if it's running
  			resetSleepTimer();
  			return true;
  		}
  
  		// Make sure we never add the WAKE_UP_NO_MORE_INFORMATION message to the queue
  		if (serialMessage.getMessagePayload().length >= 2 && serialMessage.getMessagePayload()[2] == (byte) WAKE_UP_NO_MORE_INFORMATION) {
  			logger.debug("NODE {}: Last MSG not queuing.", this.getNode().getNodeId());
  			return false;
  		}
  		if (this.wakeUpQueue.contains(serialMessage)) {
  			logger.debug("NODE {}: Message already on the wake-up queue. Removing original.", this.getNode().getNodeId());
  			this.wakeUpQueue.remove(serialMessage);
  		}
  
  		logger.debug("NODE {}: Putting message {} in wakeup queue.", this.getNode().getNodeId(), serialMessage.getMessageClass());
  		this.wakeUpQueue.add(serialMessage);
  
  		// This message has been queued - don't send it now...
  		return false;
  	}
  	
  	/**
  	 * Gets a SerialMessage with the WAKE UP INTERVAL GET command 
  	 * @return the serial message
  	 */
  	public SerialMessage getIntervalMessage() {
  		logger.debug("NODE {}: Creating new message for application command WAKE_UP_INTERVAL_GET", this.getNode().getNodeId());
  		SerialMessage result = new SerialMessage(this.getNode().getNodeId(), SerialMessageClass.SendData, SerialMessageType.Request, SerialMessageClass.ApplicationCommandHandler, SerialMessagePriority.Config);
  