private void OnBeaconRanged(BeaconRangedEventArgs beaconData)
        {
            var handler = BeaconRanged;

            if (handler != null)
            {
                BeaconRanged(this, beaconData);
            }
        }
Exemplo n.º 2
0
        private void ExitedRegion(object sender, MonitorEventArgs e)
        {
            Console.WriteLine("ExitedRegion");

            // even
            var message = new BeaconRangedEventArgs {
                Inside = false
            };

            OnBeaconRanged(message);
        }
        private void OnBeaconRanged(BeaconRangedEventArgs beaconData)
        {
            Log.Debug("FLBEACON", "OnBeaconRanged");
            var handler = BeaconRanged;

            if (handler != null)
            {
                BeaconRanged(this, beaconData);
            }

            logService.WriteToLog(LOG_FILENAME, "OnBeaconRanged");
        }
        private void ExitedRegion(object sender, MonitorEventArgs e)
        {
            Log.Debug("FLBEACON", "ExitedRegion");

            // even
            var message = new BeaconRangedEventArgs {
                Inside = false
            };

            OnBeaconRanged(message);

            Log.Debug("FLBEACON", "Stop Request Updates from Beacon");
            LocationManagerService.StopRequestLocationUpdates();

            notificationService.SendNotification("Beacon", "Exited Region");

            logService.WriteToLog(LOG_FILENAME, "ExitedRegion");
        }
        private void LocationManager_BeaconRanged(object sender, BeaconRangedEventArgs beaconData)
        {
            var sendEventArgs = true;

            if (beaconData.Inside)
            {
                if (beaconData.Proximity != BeaconProximity.Unknown)
                {
                    sendEventArgs = isLinkingBeacon || !beaconData.Rssi.Equals(previousRssi);
                }

                previousRssi = beaconData.Rssi;
            }

            if (sendEventArgs)
            {
                OnBeaconRanged(beaconData);
            }
        }
        private void RangingBeaconsInRegion(object sender, RangeEventArgs e)
        {
            if (e.Beacons.Count > 0)
            {
                var beacon = e.Beacons.FirstOrDefault();

                if (beacon.Id1.ToString().Equals(uuid, StringComparison.OrdinalIgnoreCase))
                {
                    // convert proximity to internal type
                    var beaconProximity = BeaconProximity.Unknown;
                    if (beacon.Distance > 0)
                    {
                        if (beacon.Distance < 0.50)
                        {
                            beaconProximity = BeaconProximity.Immediate;
                        }
                        else if (beacon.Distance < 2)
                        {
                            beaconProximity = BeaconProximity.Near;
                        }
                        else
                        {
                            beaconProximity = BeaconProximity.Far;
                        }
                    }

                    // event
                    var message = new BeaconRangedEventArgs
                    {
                        Inside    = true,
                        Uuid      = beacon.Id1.ToString(),
                        Major     = beacon.Id2.ToInt(),
                        Minor     = beacon.Id3.ToInt(),
                        Proximity = beaconProximity,
                        Distance  = beacon.Distance,
                        Rssi      = beacon.Rssi
                    };
                    OnBeaconRanged(message);
                }
            }
        }
Exemplo n.º 7
0
 protected virtual void OnDidRangeBeacons(BeaconRangedEventArgs e)
 {
     DidRangeBeacons?.Invoke(this, e);
 }