public override async Task <bool> UpdateRssiAsync() { var tcs = new TaskCompletionSource <bool>(); EventHandler <CBRssiEventArgs> handler = null; handler = (sender, args) => { Trace.Message("Read RSSI async for {0} {1}: {2}", Id, Name, args.Rssi); _nativeDevice.RssiRead -= handler; var success = args.Error == null; if (success) { Rssi = args.Rssi?.Int32Value ?? 0; } tcs.TrySetResult(success); }; _nativeDevice.RssiRead += handler; _nativeDevice.ReadRSSI(); return(await tcs.Task); }
internal void Update(CBPeripheral nativeDevice) { nativeDevice.ReadRSSI(); //Rssi = nativeDevice.RSSI?.Int32Value ?? 0; //It's maybe not the best idea to updated the name based on CBPeripherial name because this might be stale. //Name = nativeDevice.Name; }
public void RequestRSSIUpdate() { if (_updatingRSSI) { return; } _updatingRSSI = true; _peripheral?.ReadRSSI(); }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { UITableViewCell cell = tableView.DequeueReusableCell(cellID); cell = cell ?? new UITableViewCell(UITableViewCellStyle.Subtitle, cellID); CBPeripheral peripheral = Peripherals [indexPath.Row]; //TODO: convert to async and update? peripheral.ReadRSSI(); cell.TextLabel.Text = peripheral.Name; cell.DetailTextLabel.Text = string.Format("UUID: {0}, Signal Strength: {1}", GetIdentifier(peripheral), peripheral.RSSI); return(cell); }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { UITableViewCell cell = tableView.DequeueReusableCell(cellID); if (cell == null) { cell = new UITableViewCell(UITableViewCellStyle.Subtitle, cellID); } CBPeripheral peripheral = this._peripherals [indexPath.Row]; //TODO: convert to async and update? peripheral.ReadRSSI(); cell.TextLabel.Text = peripheral.Name; cell.DetailTextLabel.Text = "UUID: " + peripheral.UUID.ToString() + ", Signal Strength: " + peripheral.RSSI; return(cell); }
public override void ReadRssi() { _nativeDevice.ReadRSSI(); }
public Task <int> GetRssiAsync() { deviceTaskCompletitionSource.RssiTCS = new TaskCompletionSource <int>(); _device.ReadRSSI(); return(deviceTaskCompletitionSource.RssiTCS.Task); }
/// <summary> /// Refresh RSSI value from the device. /// </summary> public void RefreshRssi() { _peripheral.RssiRead += PeripheralOnRssiUpdated; _peripheral.ReadRSSI(); }