use of org.openhab.binding.zwave.internal.protocol.SerialMessage in project openhab1-addons by openhab.
the class ZWaveBasicCommandClass method getValueMessage.
/**
* Gets a SerialMessage with the BASIC GET command
*
* @return the serial message
*/
@Override
public SerialMessage getValueMessage() {
if (isGetSupported == false) {
logger.debug("NODE {}: Node doesn't support get requests", this.getNode().getNodeId());
return null;
}
logger.debug("NODE {}: Creating new message for application command BASIC_GET", this.getNode().getNodeId());
SerialMessage result = new SerialMessage(this.getNode().getNodeId(), SerialMessageClass.SendData, SerialMessageType.Request, SerialMessageClass.ApplicationCommandHandler, SerialMessagePriority.Get);
byte[] newPayload = { (byte) this.getNode().getNodeId(), 2, (byte) getCommandClass().getKey(), (byte) BASIC_GET };
result.setMessagePayload(newPayload);
return result;
}
use of org.openhab.binding.zwave.internal.protocol.SerialMessage in project openhab1-addons by openhab.
the class ZWaveBasicCommandClass method setValueMessage.
/**
* Gets a SerialMessage with the BASIC SET command
*
* @param the level to set.
* @return the serial message
*/
@Override
public SerialMessage setValueMessage(int level) {
logger.debug("NODE {}: Creating new message for application command BASIC_SET", this.getNode().getNodeId());
SerialMessage result = new SerialMessage(this.getNode().getNodeId(), SerialMessageClass.SendData, SerialMessageType.Request, SerialMessageClass.SendData, SerialMessagePriority.Set);
byte[] newPayload = { (byte) this.getNode().getNodeId(), 3, (byte) getCommandClass().getKey(), (byte) BASIC_SET, (byte) level };
result.setMessagePayload(newPayload);
return result;
}
use of org.openhab.binding.zwave.internal.protocol.SerialMessage in project openhab1-addons by openhab.
the class ZWaveBatteryCommandClass method getValueMessage.
/**
* Gets a SerialMessage with the BATTERY_GET command
*
* @return the serial message
*/
@Override
public SerialMessage getValueMessage() {
if (isGetSupported == false) {
logger.debug("NODE {}: Node doesn't support get requests", this.getNode().getNodeId());
return null;
}
logger.debug("NODE {}: Creating new message for application command BATTERY_GET", this.getNode().getNodeId());
SerialMessage result = new SerialMessage(this.getNode().getNodeId(), SerialMessageClass.SendData, SerialMessageType.Request, SerialMessageClass.ApplicationCommandHandler, SerialMessagePriority.Get);
byte[] newPayload = { (byte) this.getNode().getNodeId(), 2, (byte) getCommandClass().getKey(), (byte) BATTERY_GET };
result.setMessagePayload(newPayload);
return result;
}
use of org.openhab.binding.zwave.internal.protocol.SerialMessage in project openhab1-addons by openhab.
the class ZWaveCentralSceneCommandClass method getValueMessage.
@Override
public SerialMessage getValueMessage() {
logger.debug("NODE {}: Creating new message for application command SCENE_GET", this.getNode().getNodeId());
SerialMessage result = new SerialMessage(this.getNode().getNodeId(), SerialMessageClass.SendData, SerialMessageType.Request, SerialMessageClass.ApplicationCommandHandler, SerialMessagePriority.Get);
byte[] newPayload = { (byte) this.getNode().getNodeId(), 2, (byte) getCommandClass().getKey(), (byte) SCENE_GET };
result.setMessagePayload(newPayload);
return result;
}
use of org.openhab.binding.zwave.internal.protocol.SerialMessage in project openhab1-addons by openhab.
the class ZWaveClockCommandClass method getSetMessage.
/**
* Gets a SerialMessage with the CLOCK_SET command
*
* @return the serial message.
*/
public SerialMessage getSetMessage(Calendar cal) {
logger.debug("NODE {}: Creating new message for command CLOCK_SET", getNode().getNodeId());
int day = cal.get(Calendar.DAY_OF_WEEK) == 1 ? 7 : cal.get(Calendar.DAY_OF_WEEK) - 1;
int hour = cal.get(Calendar.HOUR_OF_DAY);
int minute = cal.get(Calendar.MINUTE);
SerialMessage result = new SerialMessage(getNode().getNodeId(), SerialMessageClass.SendData, SerialMessageType.Request, SerialMessageClass.SendData, SerialMessagePriority.Immediate);
ByteArrayOutputStream outputData = new ByteArrayOutputStream();
outputData.write(getNode().getNodeId());
outputData.write(4);
outputData.write(getCommandClass().getKey());
outputData.write(CLOCK_SET);
outputData.write((day << 5) | hour);
outputData.write(minute);
result.setMessagePayload(outputData.toByteArray());
return result;
}
Aggregations