/// <summary> /// Gets or creates a new <see cref="XbeeSerialCommunication"/> device with specified port name and address. /// When needed, a new <see cref="XbeeNetwork"/> is initialized on the specified port. /// </summary> /// <param name="networkNameOrPort">The serial port (use as network name) the device is connected to (e.g. <c>COM1</c> or <c>/dev/ttyS0</c>)</param> /// <param name="deviceName">The 64-bit <c>Xbee</c> address in hexadecimal string format (e.g. 0013A20041BB64A6)</param> /// <returns>The corresponding <see cref="XbeeSerialCommunication"/> instance</returns> private ISerialCommunication GetXbeeDevice(string networkNameOrPort, string deviceName) { if (!this.xbeeNetworks.ContainsKey(networkNameOrPort)) { this.xbeeNetworks.Add(networkNameOrPort, new XbeeNetwork(networkNameOrPort, this.cancellationToken)); } XbeeNetwork xbeeNet = this.xbeeNetworks[networkNameOrPort]; return(xbeeNet.GetDevice(deviceName)); }
/// <summary> /// Initializes a new instance of the <see cref="XbeeSerialCommunication" /> class. /// Only for use through the <see cref="XbeeNetwork" /> class. /// </summary> /// <param name="address">The 64-bit address of this device.</param> /// <param name="xbeeNetwork">The network this devices belongs to.</param> /// <param name="transmitFrameId">The frame ID to be used by this device</param> internal XbeeSerialCommunication(XBee64BitAddress address, XbeeNetwork xbeeNetwork, byte transmitFrameId) { this.xbee64address = address; this.network = xbeeNetwork; this.frameId = transmitFrameId; }