/** * Updates the current device reference with the data provided for the * given device. * * <p><b>This is only for internal use.</b></p> * * @param device The XBee Device to get the data from. */ public void UpdateDeviceDataFrom(AbstractXBeeDevice device) { // TODO Should the devices have the same protocol?? // TODO Should be allow to update a local from a remote or viceversa?? Maybe // this must be in the Local/Remote device class(es) and not here... // Only update the Node Identifier if the provided is not null. if (device.NodeID != null) this.nodeID = device.NodeID; // Only update the 64-bit address if the original is null or unknown. XBee64BitAddress addr64 = device.Get64BitAddress(); if (addr64 != null && addr64 != XBee64BitAddress.UNKNOWN_ADDRESS && !addr64.Equals(xbee64BitAddress) && (xbee64BitAddress == null || xbee64BitAddress.Equals(XBee64BitAddress.UNKNOWN_ADDRESS))) { xbee64BitAddress = addr64; } // TODO Change here the 16-bit address or maybe in ZigBee and 802.15.4? // TODO Should the 16-bit address be always updated? Or following the same rule as the 64-bit address. XBee16BitAddress addr16 = device.Get16BitAddress(); if (addr16 != null && !addr16.Equals(xbee16BitAddress)) { xbee16BitAddress = addr16; } //this.deviceType = device.deviceType; // This is not yet done. // The operating mode: only API/API2. Do we need this for a remote device? // The protocol of the device should be the same. // The hardware version should be the same. // The firmware version can change... }
public CustomPacketReceiveListener(AbstractXBeeDevice device) { _xbeeDevice = device; }
/** * Class constructor. Instantiates a new {@code RemoteXBeeDevice} object * with the given local {@code XBeeDevice} which contains the connection * interface to be used. * * @param localXBeeDevice The local XBee device that will behave as * connection interface to communicate with this * remote XBee device. * @param addr64 The 64-bit address to identify this XBee device. * @param addr16 The 16-bit address to identify this XBee device. It might * be {@code null}. * @param id The node identifier of this XBee device. It might be * {@code null}. * * @throws ArgumentException If {@code localXBeeDevice.isRemote() == true}. * @throws ArgumentNullException If {@code localXBeeDevice == null} or * if {@code addr64 == null}. * * @see #AbstractXBeeDevice(IConnectionInterface) * @see #AbstractXBeeDevice(String, int) * @see #AbstractXBeeDevice(String, SerialPortParameters) * @see #AbstractXBeeDevice(XBeeDevice, XBee64BitAddress) * @see #AbstractXBeeDevice(String, int, int, int, int, int) * @see com.digi.xbee.api.models.XBee16BitAddress * @see com.digi.xbee.api.models.XBee64BitAddress */ public AbstractXBeeDevice(XBeeDevice localXBeeDevice, XBee64BitAddress addr64, XBee16BitAddress addr16, String id) { if (localXBeeDevice == null) throw new ArgumentNullException("Local XBee device cannot be null."); if (addr64 == null) throw new ArgumentNullException("XBee 64-bit address of the device cannot be null."); if (localXBeeDevice.IsRemote) throw new ArgumentException("The given local XBee device is remote."); XBeeProtocol = XBeeProtocol.UNKNOWN; this.localXBeeDevice = localXBeeDevice; this.connectionInterface = localXBeeDevice.GetConnectionInterface(); this.xbee64BitAddress = addr64; this.xbee16BitAddress = addr16; if (addr16 == null) xbee16BitAddress = XBee16BitAddress.UNKNOWN_ADDRESS; this.nodeID = id; this.logger = LogManager.GetLogger(this.GetType()); logger.DebugFormat(ToString() + "Using the connection interface {0}.", connectionInterface.GetType().Name); this.IOPacketReceiveListener = new CustomPacketReceiveListener(this); }
public MyPacketReceiveListener(AbstractXBeeDevice device, XBeePacket sentPacket, IList<XBeePacket> responseList) { _device = device; _sentPacket = sentPacket; _responseList = responseList; }