private CEMILData adjustMsgType(final CEMILData msg) { final boolean srcOk = msg.getSource().getRawAddress() != 0; // just return if we don't need to adjust source address and don't need LDataEx if ((srcOk || medium.getDeviceAddress().getRawAddress() == 0) && (medium instanceof TPSettings || msg instanceof CEMILDataEx)) return msg; return CEMIFactory.create(srcOk ? null : medium.getDeviceAddress(), null, msg, true); }
public final void setKNXMedium(final KNXMediumSettings settings) { if (settings == null) throw new KNXIllegalArgumentException("medium settings are mandatory"); if (medium != null && !settings.getClass().isAssignableFrom(medium.getClass()) && !medium.getClass().isAssignableFrom(settings.getClass())) throw new KNXIllegalArgumentException("medium differs"); medium = settings; }
private CEMILData cEMI(final int mc, final KNXAddress dst, final Priority p, final byte[] nsdu) { final IndividualAddress src = medium.getDeviceAddress(); // use default address 0 in system broadcast final KNXAddress d = dst == null ? new GroupAddress(0) : dst; final boolean repeat = mc == CEMILData.MC_LDATA_IND ? false : true; final boolean tp = medium.getMedium() == KNXMediumSettings.MEDIUM_TP1; if (nsdu.length <= 16 && tp) return new CEMILData(mc, src, d, nsdu, p, repeat, hopCount); final boolean pl = medium.getMedium() == KNXMediumSettings.MEDIUM_PL110; // TODO allow domain bcast for RF, currently we send all RF L_Data as system broadcast final boolean domainBcast = tp ? true : pl && dst != null ? true : false; final CEMILDataEx f = new CEMILDataEx(mc, src, d, nsdu, p, repeat, domainBcast, false, hopCount); addMediumInfo(f); return f; }
private void addMediumInfo(final CEMILData msg) { String s = ""; if (medium instanceof PLSettings) { final CEMILDataEx f = (CEMILDataEx) msg; if (f.getAdditionalInfo(CEMILDataEx.ADDINFO_PLMEDIUM) == null) f.addAdditionalInfo(CEMILDataEx.ADDINFO_PLMEDIUM, ((PLSettings) medium).getDomainAddress()); } else if (medium.getMedium() == KNXMediumSettings.MEDIUM_RF) { final CEMILDataEx f = (CEMILDataEx) msg; if (f.getAdditionalInfo(CEMILDataEx.ADDINFO_RFMEDIUM) == null) { final RFSettings rf = (RFSettings) medium; final byte[] sn = f.isDomainBroadcast() ? rf.getDomainAddress() : rf.getSerialNumber(); final byte[] ai = new RFMediumInfo(true, rf.isUnidirectional(), sn, 255).getInfo(); f.addAdditionalInfo(CEMILDataEx.ADDINFO_RFMEDIUM, ai); s = f.isDomainBroadcast() ? "(using domain address)" : "(using device SN)"; } } else return; logger.trace("add cEMI additional info for {} {}", medium.getMediumString(), s); }
public String toString() { return "monitor " + getName() + " " + medium.getMediumString() + " medium" + (notifier.decode ? ", raw frame decoding" : "") + (closed ? " (closed)" : ""); }