Beispiel #1
0
        //TODO Item# 1 Swap Protocol
        /// <summary>
        /// Establish TCP connections to the data and command ports on the Otis
        /// Wi-Fi dongle
        /// Init the DBC library
        /// Setup event handlers
        /// </summary>
        /// <returns></returns>
        internal async Task ConnectDongle()
        {
            data    = new Data();
            command = new Command();

            await data.Connect();

            await command.Connect();

            dbc       = new DBC(data);
            SrdoLocal = new SRDO(dbc);

            command.InitPort += async(sender, e) => await InitPort();

            command.DefaultBaud += async(sender, e) => await DefaultBaud();

            command.OnDisconnected += (sender, e) => CommandDisconnect();

            data.OnEscapeResponse += async(sender, e) => await EscapeResponse(e);

            data.OnPassThrough += async(sender, e) => await dbc.ProcessRaw(e);

            data.OnDisconnected += (sender, e) => DataDisconnect();

            dbc.OnMessageReceived += (sender, e) => MessageForUI(e);
            dbc.OnStatusChanged   += (sender, e) => DBCErrorHandler(e);
            dbc.OnConfigChanged   += async(sender, e) => await DBCWriteConfig(e);

            dbc.OnRDOError   += (sender, e) => RDOErrorHandler(e);
            dbc.OnZkipStatus += (sender, e) => ZKIP(e);
            PortState         = (int)State.RAW;
        }