Exemplo n.º 1
0
        void ConnectPrinter(IPeripheral selectedPeripheral)
        {
            if (!selectedPeripheral.IsConnected())
            {
                selectedPeripheral.Connect();
            }

            _perifDisposable = selectedPeripheral.WhenAnyCharacteristicDiscovered().Subscribe((characteristic) =>
            {
                System.Diagnostics.Debug.WriteLine(characteristic.Description);
                if (characteristic.CanWrite() && characteristic.CanRead() && characteristic.CanNotify())
                {
                    IsReadyToPrint       = true;
                    _savedCharacteristic = characteristic;


                    conn();
                    TriggerSettings();
                    Thread.SpinWait(800);

                    flagg       = "!!";
                    TextToPrint = "0";
                    PrintText();
                    Thread.SpinWait(300);
                    System.Diagnostics.Debug.WriteLine($"Writing {characteristic.Uuid} - {characteristic.CanRead()} - {characteristic.CanIndicate()} - {characteristic.CanNotify()}");
                    _perifDisposable.Dispose();
                }
            });
        }