示例#1
0
        private async Task DoConnect()
        {
            try
            {
                //Always stop scanning before trying to connect to a device
                scanner.Stop();

                addLog($"<Connect> Last BLE Address = {this.lastBleAddress.ToString("X")}");

                if (this.lastBleAddress == 0)
                {
                    addLog($"- Connect Error BLE Address");
                    return;
                }

                con = new BLEAuthenticatorConnector();
                //con.PacketSizeByte = 155;       // AllinPass
                con.ConnectedDevice    += OnConnectedDevice;
                con.DisconnectedDevice += OnDisconnectedDevice;
                con.KeepAlive          += OnKeepAlive;
                var result = await con.ConnectAsync(this.lastBleAddress);

                if (result == false)
                {
                    addLog("- Connect Error");
                }
                addLog($"Connect OK");
            }
            catch (Exception ex)
            {
                addLog($"- Connect Error Exception: {ex.Message}");
            }
        }
示例#2
0
        private async Task <bool> connectBLE()
        {
            conBLE = new BLEAuthenticatorConnector();

            conBLE.PacketSizeByte = 155;       // AllinPass
            //con.ConnectedDevice += OnConnectedDevice;
            //con.DisconnectedDevice += OnDisconnectedDevice;
            var result = await conBLE.ConnectAsync(this.addressBLE);

            if (result == false)
            {
                return(false);
            }
            return(true);
        }