Skip to content
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.

Problem when trying to get bandwidth #180

Closed
nicolabracchini opened this issue Mar 16, 2021 · 2 comments
Closed

Problem when trying to get bandwidth #180

nicolabracchini opened this issue Mar 16, 2021 · 2 comments

Comments

@nicolabracchini
Copy link

Hi James,

according to example in github, i'm trying to get the bandwith of current network:

var optimalSpeed = 50000;
var connectionTypes = CrossConnectivity.Current.ConnectionTypes;
var speeds = CrossConnectivity.Current.Bandwidths;

if (!connectionTypes.Any(speeds => speeds > optimalSpeed))// Limite segnale per TX
{
stopWS = true;
await DisplayAlert("Potenza del Segnale SCARSO!", "Spostarsi vicino all'AP", "CHIUDI");
return;
}

But this doesn't work.
The error is this:
Errore CS0019 Non è possibile applicare l'operatore '>' a operandi di tipo 'ConnectionType' e 'int'

Thanks in advance
Nicola

Bug Information

Version Number of Plugin: 3.2.0
Device Tested On: M3 device with Android 10
Version of VS: 16.8.6
Version of Xamarin: 16.8.000.262 (d16-8@4d60f9c)

Steps to reproduce the Behavior

var optimalSpeed = 50000;
var connectionTypes = CrossConnectivity.Current.ConnectionTypes;
var speeds = CrossConnectivity.Current.Bandwidths;

if (!connectionTypes.Any(speeds => speeds > optimalSpeed))// Limite segnale per TX
{
stopWS = true;
await DisplayAlert("Potenza del Segnale SCARSO!", "Spostarsi vicino all'AP", "CHIUDI");
return;
}

@mvietri
Copy link

mvietri commented Mar 17, 2021

Hi!

This is wrong, connectionTypes is no needed here.

if (!connectionTypes.Any(speeds => speeds > optimalSpeed))// Limite segnale per TX

should be

if (!speeds.Any(speed => speed > optimalSpeed))// Limite segnale per TX

also declare optimalSpeed as ulong or cast it on the Any()

@nicolabracchini
Copy link
Author

Thank you @mvietri, i've followed the example in the documentation...now everithing is ok.

Thank you
Nicola

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants