use of org.openhab.binding.insteonplm.internal.message.FieldException 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);
}
use of org.openhab.binding.insteonplm.internal.message.FieldException 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());
}
}
use of org.openhab.binding.insteonplm.internal.message.FieldException 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();
}
}
use of org.openhab.binding.insteonplm.internal.message.FieldException in project openhab1-addons by openhab.
the class ModemDBBuilder method updateModemDB.
public void updateModemDB(InsteonAddress linkAddr, Port port, Msg m) {
HashMap<InsteonAddress, ModemDBEntry> dbes = port.getDriver().lockModemDBEntries();
ModemDBEntry dbe = dbes.get(linkAddr);
if (dbe == null) {
dbe = new ModemDBEntry(linkAddr);
dbes.put(linkAddr, dbe);
}
dbe.setPort(port);
if (m != null) {
dbe.addLinkRecord(m);
try {
byte group = m.getByte("ALLLinkGroup");
int recordFlags = m.getByte("RecordFlags") & 0xff;
if ((recordFlags & (0x1 << 6)) != 0) {
dbe.addControls(group);
} else {
dbe.addRespondsTo(group);
}
} catch (FieldException e) {
logger.error("cannot access field:", e);
}
}
port.getDriver().unlockModemDBEntries();
}
Aggregations