public Tunnel(TunnelSettings settings)
        {
            this.settings = settings;
            switch (settings.Connection.ToLower())
            {
            case  "usb":
                NXT = new USB();
                break;

            case "simulation":
                NXT = new Simulation();
                break;

            default:
                NXT = new Bluetooth(settings.Connection);
                break;
            }
            tcpListener  = new TcpListener(IPAddress.Any, settings.Port);
            listenThread = new Thread(new ThreadStart(ListenForClients));
            listenThread.IsBackground = false;
            IsRunning           = false;
            ClientDisConnected += ClientDisconnected;            //subscribe to event thrown by client thread
            this.addressRange   = settings.IPRangeToArray();
            NXT.Disconnected   += OnNXTDisconnected;
            NXT.Connected      += OnNXTConnected;
            logQueue            = new QueueThread <string>(OnLogQueue);
        }
        public TunnelSettings DeserializeFromXML(String filepath)
        {
            XmlSerializer deserializer = new XmlSerializer(typeof(TunnelSettings));
            TextReader    textReader   = new StreamReader(filepath);
            Object        obj          = deserializer.Deserialize(textReader);

            // Create the new Config that we'll return
            TunnelSettings myNewSettings = (TunnelSettings)obj;

            textReader.Close();
            return(myNewSettings);
        }