Exemplo n.º 1
0
 public void Found(Beacon beacon)
 {
     if (!Contains (beacon.Major, beacon.Minor)) {
         beacons.Add (beacon);
     } else {
         beacons.FirstOrDefault (b => (b.Major == beacon.Major && b.Minor == beacon.Minor)).InRange = true;
         beacons.FirstOrDefault (b => (b.Major == beacon.Major && b.Minor == beacon.Minor)).Proximity = beacon.Proximity;
         beacons.FirstOrDefault (b => (b.Major == beacon.Major && b.Minor == beacon.Minor)).Accuracy = beacon.Accuracy;
     }
 }
Exemplo n.º 2
0
 public void Found(Beacon beacon)
 {
     if (!Contains(beacon.Major, beacon.Minor))
     {
         beacons.Add(beacon);
     }
     else
     {
         beacons.FirstOrDefault(b => (b.Major == beacon.Major && b.Minor == beacon.Minor)).InRange   = true;
         beacons.FirstOrDefault(b => (b.Major == beacon.Major && b.Minor == beacon.Minor)).Proximity = beacon.Proximity;
         beacons.FirstOrDefault(b => (b.Major == beacon.Major && b.Minor == beacon.Minor)).Accuracy  = beacon.Accuracy;
     }
 }
Exemplo n.º 3
0
        private void RangingBeaconsInRegion(object sender, RangeEventArgs e)
        {
            try {
                if (e.Beacons == null)
                {
                    return;
                }

                MainApplication.DiscoveredBeacons.SetAllOutOfRange();

                if (e.Beacons.Count > 0)
                {
                    Console.WriteLine("Found " + e.Beacons.Count + " beacons.");


                    foreach (var beacon in e.Beacons)
                    {
                        if (beacon != null)
                        {
                            String id   = beacon.Major + "." + beacon.Minor;
                            String name = "Beacon: " + id;

                            MainApplication.DiscoveredBeacons.Found(new Beacon()
                            {
                                Major        = Int32.Parse(beacon.Major.ToString()),
                                Minor        = Int32.Parse(beacon.Minor.ToString()),
                                FriendlyName = name,
                                Proximity    = (ProximityType)beacon.Proximity,
                                Accuracy     = beacon.Accuracy
                            });
                        }
                    }

                    // check to see whether the first beacon has changed
                    if (firstBeacon == null)
                    {
                        firstBeacon = MainApplication.DiscoveredBeacons.First;
                    }

                    if (MainApplication.DiscoveredBeacons.First != null)
                    {
                        if (firstBeacon != MainApplication.DiscoveredBeacons.First)
                        {
                            // new beacon in first position
                            firstBeacon = MainApplication.DiscoveredBeacons.First;
                            Toast.MakeText(this, "Welcome to " + firstBeacon.FriendlyName, ToastLength.Short).Show();

                            // perform a checkin
                            MainApplication.DiscoveredBeacons.SetCheckedIn(firstBeacon.Major, firstBeacon.Minor, true);
                            Sound.Play();
                        }
                    }
                }
                else
                {
                    Console.WriteLine("No beacons found");
                }

                // Update the UI?
                ListAdapter = new BeaconDataAdapter(this);
            } catch (Exception ex) {
                Console.WriteLine(ex.ToString());
            }
        }
Exemplo n.º 4
0
        private void RangingBeaconsInRegion(object sender, RangeEventArgs e)
        {
            try {
                if (e.Beacons == null)
                    return;

                MainApplication.DiscoveredBeacons.SetAllOutOfRange ();

                if (e.Beacons.Count > 0) {
                    Console.WriteLine ("Found " + e.Beacons.Count + " beacons.");

                    foreach (var beacon in e.Beacons) {
                        if (beacon != null) {
                            String id = beacon.Major + "." + beacon.Minor;
                            String name = "Beacon: "+id;

                            MainApplication.DiscoveredBeacons.Found (new Beacon () {Major = Int32.Parse (beacon.Major.ToString ()),
                                Minor = Int32.Parse (beacon.Minor.ToString ()),
                                FriendlyName = name,
                                Proximity = (ProximityType)beacon.Proximity,
                                Accuracy = beacon.Accuracy
                            });
                        }
                    }

                    // check to see whether the first beacon has changed
                    if (firstBeacon == null) {
                        firstBeacon = MainApplication.DiscoveredBeacons.First;
                    }

                    if (MainApplication.DiscoveredBeacons.First != null) {
                        if (firstBeacon != MainApplication.DiscoveredBeacons.First) {
                            // new beacon in first position
                            firstBeacon = MainApplication.DiscoveredBeacons.First;
                            Toast.MakeText(this, "Welcome to "+firstBeacon.FriendlyName, ToastLength.Short).Show();

                            // perform a checkin
                            MainApplication.DiscoveredBeacons.SetCheckedIn(firstBeacon.Major, firstBeacon.Minor, true);
                            Sound.Play ();
                        }
                    }

                } else {
                    Console.WriteLine ("No beacons found");
                }

                // Update the UI?
                ListAdapter = new BeaconDataAdapter (this);

            } catch (Exception ex) {
                Console.WriteLine (ex.ToString ());
            }
        }