コード例 #1
0
ファイル: iOSGPSAdapter.cs プロジェクト: sk8tz/quantfabric
 private void LocationManagerOnFailed(
     object sender,
     NSErrorEventArgs nsErrorEventArgs)
 {
     throw new LocationException(
               StringResources.GPSDisabledConnectivityException);
 }
コード例 #2
0
        private void HandleDiscoveredService(object sender, NSErrorEventArgs e)
        {
            CBPeripheral peripheral = sender as CBPeripheral;
            if (peripheral == null || peripheral != Peripheral)
                return;

            int servicesCount = peripheral.Services.Length;
            peripheral.DiscoveredCharacteristic += (o, es) =>
            {
                servicesCount--;
                if (servicesCount == 0)
                {
                    IsServiceDiscovered = true;
                    if (e.Error == null)
                    {
                        OnServicesDiscovered(this, new BleServicesDiscoveredEventArgs(BleGattOperationState.Success));
                        ConnectionState = BleConnectionState.ConnectedWithServices;
                    }
                    else
                    {
                        OnServicesDiscovered(this, new BleServicesDiscoveredEventArgs(BleGattOperationState.Failure));
                    }
                }
            };
            foreach (CBService service in peripheral.Services)
            {
                peripheral.DiscoverCharacteristics(service);
            }

        }
 private void OnFailed(object sender, NSErrorEventArgs e)
 {
     if ((CLError)(int)e.Error.Code == CLError.Network)
     {
         this.OnPositionError(new PositionErrorEventArgs(new GeolocationPositionUnavailableException()));
     }
 }
コード例 #4
0
 private void OnFailed(object sender, NSErrorEventArgs e)
 {
     if ((int)e.Error.Code == (int)CLError.Network)
     {
         OnPositionError(new PositionErrorEventArgs(GeolocationError.PositionUnavailable));
     }
 }
コード例 #5
0
        void Peripheral_DiscoveredServices(object sender, NSErrorEventArgs e)
        {
            var peripheral     = (CBPeripheral)sender;
            var ble_peripheral = devices [peripheral.Identifier.ToString()];

            foreach (var service in peripheral.Services)
            {
                var ble_service = new BleService()
                {
                    Name = service.ToString(),
                };
                if (service.Characteristics != null)
                {
                    foreach (var characteristic in service.Characteristics)
                    {
                        ble_service.Characteristics.Add(new BleCharacteristic()
                        {
                            Name = characteristic.ToString(),
                        });
                    }
                }
                ble_peripheral.Services.Add(ble_service);
            }

            OnSomethingHappened();
        }
コード例 #6
0
 void OnFailure(object sender, NSErrorEventArgs e)
 {
     if (IsMonitoring)
     {
         StopMonitoringAllRegions();
     }
     CrossGeofence.GeofenceListener.OnError(e.Error.LocalizedDescription);
 }
コード例 #7
0
ファイル: GeolocationService.cs プロジェクト: Redth/f50
        private async void OnFailed(object sender, NSErrorEventArgs e)
        {
            if ((CLError)(int)e.Error.Code == CLError.Network)
            {
                await StopListeningAsync();

                OnPositionError(new PositionErrorEventArgs(GeolocationError.PositionUnavailable));
            }
        }
コード例 #8
0
        private void LocationManager_OnFailed(object sender, NSErrorEventArgs args)
        {
            if ((CLError)(int)args.Error.Code != CLError.Network)
            {
                return;
            }

            this.LocationStatus = PositionStatus.NotAvailable;
            this.StatusChanged?.Invoke(this, new StatusChangedEventArgs(this.LocationStatus));
        }
コード例 #9
0
        private void HandleRssiUpdated(object sender, NSErrorEventArgs e)
        {
            CBPeripheral peripheral = sender as CBPeripheral;
            if (peripheral == null || peripheral != Peripheral)
                return;

            if (e.Error == null)
                OnReadRemoteRssi(this, new BleReadRemoteRssiEventArgs(Peripheral.RSSI.Int32Value, BleGattOperationState.Success));
            else
                OnReadRemoteRssi(this, new BleReadRemoteRssiEventArgs(Peripheral.RSSI.Int32Value, BleGattOperationState.Failure));
        }
コード例 #10
0
        static async void OnFailed(object sender, NSErrorEventArgs e)
        {
            var error = (CLError)(int)e.Error.Code;

            if (error == CLError.Network)
            {
                await PositionError.RaiseOn(Thread.Pool, new Exception(UNAVAILABLE_ERROR));
            }

            if (error == CLError.Denied)
            {
                await PositionError.RaiseOn(Thread.Pool, new Exception(UNAUTHORISED_ERROR));
            }
        }
コード例 #11
0
ファイル: Device.cs プロジェクト: byBrick/Xamarin.BluetoothLE
        private void DiscoveredService(object sender, NSErrorEventArgs args)
        {
            if (_peripheral.Services != null)
            {
                Services.Clear();
                foreach (var s in _peripheral.Services)
                {
                    var service = new Service(_peripheral, s);
                    Services.Add(service);
                }
                ServicesDiscovered(this, new ServicesDiscoveredEventArgs(Services));
            }

            _peripheral.DiscoveredService -= DiscoveredService;
        }
コード例 #12
0
 private void OnDiscoveredService(object sender, NSErrorEventArgs e)
 {
     if (e.Error != null)
     {
         RaiseDiscoverServicesFailed(e.Error.ToShared());
     }
     else
     {
         var services = Peripheral
                        .Services
                        .Select(s => new BLEService(_peripheralWrapper, s))
                        .ToList();
         RaiseServicesDiscovered(services);
     }
 }
コード例 #13
0
        void HandleDiscoveredService(object sender, NSErrorEventArgs e)
        {
            var peripheral = (CBPeripheral)sender;

            foreach (CBService service in peripheral.Services)
            {
                Console.WriteLine("Discovered Service: {0}", service.Description);

                if (!services.Contains(service))
                {
                    services.Add(service);
                }
            }

            ServicesTableView.ReloadData();
        }
コード例 #14
0
 private void DiscoveredService(object sender, NSErrorEventArgs args)
 {
     if (_peripheral.Services != null)
     {
         foreach (var s in _peripheral.Services)
         {
             var serviceId = s.UUID.ToString().ToGuid();
             if (Services.All(x => x.Id != serviceId))
             {
                 var service = new Service(_peripheral, s);
                 Services.Add(service);
                 ServiceDiscovered(this, new ServiceDiscoveredEventArgs(service));
             }
         }
     }
 }
コード例 #15
0
        static void OnPeripheralDiscoveredService(object sender, NSErrorEventArgs e)
        {
            if (e.Error != null)
            {
                Console.WriteLine(e.Error);

                peripheral.DiscoverServices();

                return;
            }

            foreach (CBService s in (sender as CBPeripheral).Services)
            {
                Console.WriteLine("Discovered service {0}", s);

                peripheral.DiscoverCharacteristics(s);
            }
        }
コード例 #16
0
        void OnDiscoveredService(object sender, NSErrorEventArgs e)
        {
            foreach (CBService cbs in nativePeripheral.Services)
            {
                BLEService bles = new BLEService(cbs);

                services.Add(bles);
            }

            EventHandler <BLEErrorEventArgs> handler = DiscoveredService;

            if (handler != null)
            {
                BLEErrorEventArgs args = new BLEErrorEventArgs();
                args.Error = e.Error?.ToString();

                handler(this, args);
            }
        }
コード例 #17
0
ファイル: MacOsBluetooth.cs プロジェクト: trocken2/Eco2
        void DiscoveredService(object sender, NSErrorEventArgs e)
        {
            // In Swift, we get a single "peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?)"
            // callback, but for some reason the Mono folks decided to send an
            // event for each discovered service - without telling us which
            // actual service the individual event is for. So we'll need to
            // remove the event handler.
            connectedCbPeripheral.DiscoveredService -= DiscoveredService;

            if (e.Error != null)
            {
                Console.Error.WriteLine($"Could not discover services: {e.Error.Description}");
                Environment.Exit(1);
            }

            Console.Error.WriteLine("Discovered services");
            var services = Array.ConvertAll(connectedCbPeripheral.Services, service => new Service(service.UUID.Uuid));

            connectedPeripheral = new Peripheral(connectedCbPeripheral.Name, connectedCbPeripheral.Identifier.ToString(), services);
            ConnectedToPeripheralEventHandler?.Invoke(this, new ConnectedToPeripheralEventArgs(connectedPeripheral));
        }
コード例 #18
0
        /// <summary>
        /// Get Called on Failure.
        /// </summary>
        /// <param name="sender">Sender who fired the event.</param>
        /// <param name="e">Event arguemnts</param>
        private void OnFailure(object sender, NSErrorEventArgs e)
        {
            if (this.IsMonitoring)
            {
                this.StopMonitoringAllRegions();
            }

            CrossGeofence.GeofenceListener.OnError(e.Error.LocalizedDescription);
        }
コード例 #19
0
ファイル: GeoLocator.cs プロジェクト: jakkaj/Xamling-Core
 private void OnFailed(object sender, NSErrorEventArgs e)
 {
     if ((CLError)(int)e.Error.Code == CLError.Network)
         OnPositionError(new PositionErrorEventArgs(GeolocationError.PositionUnavailable));
 }
コード例 #20
0
 private void ClManagerOnDeferredUpdatesFinished(object sender, NSErrorEventArgs nsErrorEventArgs)
 {
     Log.Debug("ClManagerOnDeferredUpdatesFinished");
 }
コード例 #21
0
 private void DidAdvertisingStarted(object sender, NSErrorEventArgs e)
 {
     System.Diagnostics.Debug.WriteLine("DidAdvertisingStarted");
 }
コード例 #22
0
		void OnFailed (object sender, NSErrorEventArgs e)
		{
			LocationManager.StopUpdatingLocation ();
		}
コード例 #23
0
 private void OnRssiUpdated(object sender, NSErrorEventArgs e)
 => _wes.RaiseEvent(nameof(RSSIUpdated), sender, e);
コード例 #24
0
 private void OnDiscoveredService(object sender, NSErrorEventArgs args)
 {
     if (_peripheral.Services == null)
     {
         _discoveryTaskSource.TrySetException(new Exception("Bluetooth: Failed to discover service"));
     }
     else
     {
         _peripheral.DiscoverCharacteristics(_peripheral.Services.First());
     }
 }
コード例 #25
0
 void nativeDevice_DiscoveredService(object sender, NSErrorEventArgs e)
 {
     _servicesDiscovered.Set();
 }
コード例 #26
0
 private void OnDiscoveredService(object sender, NSErrorEventArgs e)
 => _wes.RaiseEvent(nameof(DiscoveredService), sender, e);
コード例 #27
0
 private void locMgr_OnFailure(object sender, NSErrorEventArgs e)
 {
     Console.WriteLine("didFailWithError " + e.Error);
     Console.WriteLine("didFailWithError coe " + e.Error.Code);
 }
コード例 #28
0
 private void OriginMapView_DidFailToLocateUser(object sender, NSErrorEventArgs e)
 {
     // throw new NotImplementedException();
 }
コード例 #29
0
 static void OnDeferredUpdatedFinished(object sender, NSErrorEventArgs e)
 {
     IsDeferringUpdates = false;
 }
コード例 #30
0
ファイル: GeolocationService.cs プロジェクト: Redth/f50
 private void OnDeferredUpdatedFinished(object sender, NSErrorEventArgs e) => deferringUpdates = false;
コード例 #31
0
 void OnFailed(object sender, NSErrorEventArgs e)
 {
     locationManager.StopUpdatingLocation();
 }
コード例 #32
0
 /// <summary>
 /// Converts the <see cref="NSErrorEventArgs"/> to <see cref="ErrorEvent"/>.
 /// </summary>
 /// <param name="args">The arguments.</param>
 /// <returns>The notification.</returns>
 public static ErrorEvent ToNotification(this NSErrorEventArgs args) =>
 new ErrorEvent
 {
 };
コード例 #33
0
 void OnDeferredUpdatedFinished (object sender, NSErrorEventArgs e)
 {
     deferringUpdates = false;
 }
コード例 #34
0
ファイル: Geolocator.cs プロジェクト: shamnu/Xamarin.Plugins
 void _locationManager_Failed(object sender, NSErrorEventArgs e)
 {
     this.PositionError(sender, new PositionErrorEventArgs(GeolocationError.Unauthorized));
 }
コード例 #35
0
		void HandleDiscoveredService (object sender, NSErrorEventArgs e)
		{
			var peripheral = (CBPeripheral)sender;

			foreach (CBService service in peripheral.Services) {
				Console.WriteLine ("Discovered Service: {0}", service.Description);

				if (!services.Contains (service))
					services.Add (service);
			}

			ServicesTableView.ReloadData ();
		}
コード例 #36
0
		private void DiscoveredService(object sender, NSErrorEventArgs args)
		{
			if (_peripheral.Services != null) 
			{
				foreach (var s in _peripheral.Services)
				{
					var serviceId = s.UUID.ToString().ToGuid();
					if (Services.All(x => x.Id != serviceId))
					{
						var service = new Service(_peripheral, s);
						Services.Add(service);
						ServiceDiscovered(this, new ServiceDiscoveredEventArgs(service));
					}
				}
			}
		}
コード例 #37
0
 private void _peripheral_DiscoveredService(object sender, NSErrorEventArgs e)
 {
     _servicesHandle.Set();
 }