/// <summary> /// Connects to the Band device specified by the device information, /// and returns a client that is used for communication. /// </summary> /// <param name="info">The Band device information to connect to.</param> /// <returns>The client instance that is used to communicate with the connected Band device.</returns> public async Task <BandClient> ConnectAsync(BandDeviceInfo info) { #if __ANDROID__ var nativeClient = NativeBandClientManager.Instance.Create(Application.Context, info.Native); if (nativeClient.IsConnected) { throw new BandException($"Aleady connected to Band '{info.Name}'.", BandErrorType.ServiceError); } var result = await nativeClient.ConnectTaskAsync() == ConnectionState.Connected; return(new BandClient(nativeClient)); #elif __IOS__ if (info.Native.IsConnected) { throw new BandException($"Aleady connected to Band '{info.Native.Name}'."); } await NativeBandClientManager.Instance.ConnectTaskAsync(info.Native); return(new BandClient(info.Native)); #elif WINDOWS_PHONE_APP var nativeClient = await NativeBandClientManager.Instance.ConnectAsync(info.Native); return(new BandClient(nativeClient)); #else return(null); #endif }
public MonitorPage(BandDeviceInfo bandDeviceInfo) : base(bandDeviceInfo,null) { InitializeComponent(); ViewModel = new MonitorViewModel(BandInfo,BandClient); }
public async Task <BandClient> ConnectAsync(BandDeviceInfo info) { #if __ANDROID__ // create a custom context if (bandContextWrapper == null) { bandContextWrapper = new BandContextWrapper(Application.Context); } // continue normally var nativeClient = NativeBandClientManager.Instance.Create(bandContextWrapper, info.Native); var result = await nativeClient.ConnectTaskAsync(); return(new BandClient(nativeClient)); #elif __IOS__ await NativeBandClientManager.Instance.ConnectTaskAsync(info.Native); return(new BandClient(info.Native)); #elif WINDOWS_PHONE_APP var nativeClient = await NativeBandClientManager.Instance.ConnectAsync(info.Native); return(new BandClient(nativeClient)); #else return(null); #endif }
/// <summary> /// Connects to the Band device specified by the device information, /// and returns a client that is used for communication. /// </summary> /// <param name="info">The Band device information to connect to.</param> /// <returns>The client instance that is used to communicate with the connected Band device.</returns> public async Task<BandClient> ConnectAsync(BandDeviceInfo info) { #if __ANDROID__ var nativeClient = NativeBandClientManager.Instance.Create(Application.Context, info.Native); var result = await nativeClient.ConnectTaskAsync() == ConnectionState.Connected; return new BandClient(nativeClient); #elif __IOS__ await NativeBandClientManager.Instance.ConnectTaskAsync(info.Native); return new BandClient(info.Native); #elif WINDOWS_PHONE_APP var nativeClient = await NativeBandClientManager.Instance.ConnectAsync(info.Native); return new BandClient(nativeClient); #else return null; #endif }
/// <summary> /// Connects to the Band device specified by the device information, /// and returns a client that is used for communication. /// </summary> /// <param name="info">The Band device information to connect to.</param> /// <returns>The client instance that is used to communicate with the connected Band device.</returns> public async Task <BandClient> ConnectAsync(BandDeviceInfo info) { #if __ANDROID__ var nativeClient = NativeBandClientManager.Instance.Create(Application.Context, info.Native); var result = await nativeClient.ConnectTaskAsync() == ConnectionState.Connected; return(new BandClient(nativeClient)); #elif __IOS__ await NativeBandClientManager.Instance.ConnectTaskAsync(info.Native); return(new BandClient(info.Native)); #elif WINDOWS_PHONE_APP var nativeClient = await NativeBandClientManager.Instance.ConnectAsync(info.Native); return(new BandClient(nativeClient)); #else return(null); #endif }
public BaseClientViewModel(BandDeviceInfo info, BandClient bandClient) { BandClient = bandClient; BandInfo = info; }
public BaseClientContentPage(BandDeviceInfo info, BandClient bandClient) { BandInfo = info; BandClient = bandClient; }
public MonitorViewModel(BandDeviceInfo info, BandClient bandClient) : base(info, bandClient) { _bandHeartRateReadings = new ConcurrentQueue<BandHeartRateReading>(); }