public CentralExtensionsViewModel(IBleManager centralManager, IDialogs dialogs) { this.Tasks = new List <TaskViewModel> { new TaskViewModel( "Scan Find Peripheral", ct => centralManager .ScanUntilPeripheralFound(this.PeripheralName) .ToTask(ct), this.WhenAny( x => x.PeripheralName, x => !x.GetValue().IsEmpty() ) ), new TaskViewModel( "Scan For Unique Peripherals", ct => centralManager .ScanForUniquePeripherals() .ToTask(ct) ), new TaskViewModel( "Scan Interval", ct => centralManager .ScanInterval( TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10) ) .ToTask(ct) ) }; }
public QuickIdeasViewModel(IBleManager bleManager) { this.FindItAndRead = ReactiveCommand.Create(() => { bleManager .ScanUntilPeripheralFound("My Peripheral Name", true) .Select(x => x.WithConnectIf()) .Switch() .Select(x => x.ReadCharacteristic("ServiceUUID", "CharUUID")) .Switch() .Take(1) .SubOnMainThread( data => this.ReadText = Encoding.ASCII.GetString(data) ); }); }