Search in sources :

Example 1 with Msg

use of org.openhab.binding.insteonplm.internal.message.Msg in project openhab1-addons by openhab.

the class InsteonDevice method makeExtendedMessageCRC2.

/**
     * Helper method to make extended message, but with different CRC calculation
     * 
     * @param flags
     * @param cmd1
     * @param cmd2
     * @param data array with user data
     * @return extended message
     * @throws FieldException
     * @throws IOException
     */
public Msg makeExtendedMessageCRC2(byte flags, byte cmd1, byte cmd2, byte[] data) throws FieldException, IOException {
    Msg m = Msg.s_makeMessage("SendExtendedMessage");
    m.setAddress("toAddress", getAddress());
    m.setByte("messageFlags", (byte) (((flags & 0xff) | 0x10) & 0xff));
    m.setByte("command1", cmd1);
    m.setByte("command2", cmd2);
    m.setUserData(data);
    m.setCRC2();
    return m;
}
Also used : Msg(org.openhab.binding.insteonplm.internal.message.Msg)

Example 2 with Msg

use of org.openhab.binding.insteonplm.internal.message.Msg in project openhab1-addons by openhab.

the class MessageHandler method sendExtendedQuery.

/**
     * Method to send an extended insteon message for querying a device
     * 
     * @param f DeviceFeature that is being currently handled
     * @param aCmd1 cmd1 for message to be sent
     * @param aCmd2 cmd2 for message to be sent
     */
public void sendExtendedQuery(DeviceFeature f, byte aCmd1, byte aCmd2) {
    InsteonDevice d = f.getDevice();
    try {
        Msg m = d.makeExtendedMessage((byte) 0x1f, aCmd1, aCmd2);
        m.setQuietTime(500L);
        d.enqueueMessage(m, f);
    } catch (IOException e) {
        logger.warn("i/o problem sending query message to device {}", d.getAddress());
    } catch (FieldException e) {
        logger.warn("field exception sending query message to device {}", d.getAddress());
    }
}
Also used : Msg(org.openhab.binding.insteonplm.internal.message.Msg) FieldException(org.openhab.binding.insteonplm.internal.message.FieldException) IOException(java.io.IOException)

Example 3 with Msg

use of org.openhab.binding.insteonplm.internal.message.Msg in project openhab1-addons by openhab.

the class ModemDBBuilder method logModemDB.

private void logModemDB() {
    try {
        logger.debug("MDB ------- start of modem link records ------------------");
        HashMap<InsteonAddress, ModemDBEntry> dbes = m_port.getDriver().lockModemDBEntries();
        for (Entry<InsteonAddress, ModemDBEntry> db : dbes.entrySet()) {
            ArrayList<Msg> lrs = db.getValue().getLinkRecords();
            for (Msg m : lrs) {
                int recordFlags = m.getByte("RecordFlags") & 0xff;
                String ms = ((recordFlags & (0x1 << 6)) != 0) ? "CTRL" : "RESP";
                logger.debug("MDB {}: {} group: {} data1: {} data2: {} data3: {}", db.getKey(), ms, toHex(m.getByte("ALLLinkGroup")), toHex(m.getByte("LinkData1")), toHex(m.getByte("LinkData2")), toHex(m.getByte("LinkData2")));
            }
            logger.debug("MDB -----");
        }
        logger.debug("MDB ---------------- end of modem link records -----------");
    } catch (FieldException e) {
        logger.error("cannot access field:", e);
    } finally {
        m_port.getDriver().unlockModemDBEntries();
    }
}
Also used : Msg(org.openhab.binding.insteonplm.internal.message.Msg) FieldException(org.openhab.binding.insteonplm.internal.message.FieldException) ModemDBEntry(org.openhab.binding.insteonplm.internal.driver.ModemDBEntry)

Example 4 with Msg

use of org.openhab.binding.insteonplm.internal.message.Msg in project openhab1-addons by openhab.

the class DeviceFeature method makePollMsg.

/**
     * Make a poll message using the configured poll message handler
     * 
     * @return the poll message
     */
public Msg makePollMsg() {
    if (m_pollHandler == null) {
        return null;
    }
    logger.trace("{} making poll msg for {} using handler {}", getName(), getDevice().getAddress(), m_pollHandler.getClass().getSimpleName());
    Msg m = m_pollHandler.makeMsg(m_device);
    return m;
}
Also used : Msg(org.openhab.binding.insteonplm.internal.message.Msg)

Example 5 with Msg

use of org.openhab.binding.insteonplm.internal.message.Msg in project openhab1-addons by openhab.

the class InsteonDevice method makeExtendedMessage.

/**
     * Helper method to make extended message
     * 
     * @param flags
     * @param cmd1
     * @param cmd2
     * @param data array with userdata
     * @return extended message
     * @throws FieldException
     * @throws IOException
     */
public Msg makeExtendedMessage(byte flags, byte cmd1, byte cmd2, byte[] data) throws FieldException, IOException {
    Msg m = Msg.s_makeMessage("SendExtendedMessage");
    m.setAddress("toAddress", getAddress());
    m.setByte("messageFlags", (byte) (((flags & 0xff) | 0x10) & 0xff));
    m.setByte("command1", cmd1);
    m.setByte("command2", cmd2);
    m.setUserData(data);
    m.setCRC();
    return m;
}
Also used : Msg(org.openhab.binding.insteonplm.internal.message.Msg)

Aggregations

Msg (org.openhab.binding.insteonplm.internal.message.Msg)8 FieldException (org.openhab.binding.insteonplm.internal.message.FieldException)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 ModemDBEntry (org.openhab.binding.insteonplm.internal.driver.ModemDBEntry)1