Search in sources :

Example 1 with GroupMessage

use of org.openhab.binding.insteonplm.internal.device.GroupMessageStateMachine.GroupMessage in project openhab1-addons by openhab.

the class MessageHandler method isDuplicate.

/**
     * Determines is an incoming ALL LINK message is a duplicate
     * 
     * @param msg the received ALL LINK message
     * @return true if this message is a duplicate
     */
protected boolean isDuplicate(Msg msg) {
    boolean isDuplicate = false;
    try {
        MsgType t = MsgType.s_fromValue(msg.getByte("messageFlags"));
        int hops = msg.getHopsLeft();
        if (t == MsgType.ALL_LINK_BROADCAST) {
            int group = msg.getAddress("toAddress").getLowByte() & 0xff;
            byte cmd1 = msg.getByte("command1");
            // if the command is 0x06, then it's success message
            // from the original broadcaster, with which the device
            // confirms that it got all cleanup replies successfully.
            GroupMessage gm = (cmd1 == 0x06) ? GroupMessage.SUCCESS : GroupMessage.BCAST;
            isDuplicate = !updateGroupState(group, hops, gm);
        } else if (t == MsgType.ALL_LINK_CLEANUP) {
            // the cleanup messages are direct messages, so the
            // group # is not in the toAddress, but in cmd2
            int group = msg.getByte("command2") & 0xff;
            isDuplicate = !updateGroupState(group, hops, GroupMessage.CLEAN);
        }
    } catch (IllegalArgumentException e) {
        logger.error("cannot parse msg: {}", msg, e);
    } catch (FieldException e) {
        logger.error("cannot parse msg: {}", msg, e);
    }
    return (isDuplicate);
}
Also used : FieldException(org.openhab.binding.insteonplm.internal.message.FieldException) GroupMessage(org.openhab.binding.insteonplm.internal.device.GroupMessageStateMachine.GroupMessage) MsgType(org.openhab.binding.insteonplm.internal.message.MsgType)

Aggregations

GroupMessage (org.openhab.binding.insteonplm.internal.device.GroupMessageStateMachine.GroupMessage)1 FieldException (org.openhab.binding.insteonplm.internal.message.FieldException)1 MsgType (org.openhab.binding.insteonplm.internal.message.MsgType)1