Beispiel #1
0
        void RangingBeaconsInRegion(object sender, RangeEventArgs e)
        {
            if (e.Beacons.Count > 0)
            {
                var beacon  = e.Beacons.FirstOrDefault();
                var message = string.Empty;

                //switch((ProximityType)beacon.Proximity)
                switch (beacon.Major)
                {
                //case ProximityType.Immediate:
                case 64994:
                    UpdateDisplay("You found Beacon 64994!", Color.Green);
                    UpdateDisplay("\n" + beacon.ProximityUuid + "\nmajor:" + beacon.Major.ToString() + "\nminor:" + beacon.Minor.ToString() + "\nphoneID:" + phoneId + "\nRSSI:" + beacon.Rssi, Color.Green);

                    break;

                //case ProximityType.Near:
                case 41596:
                    UpdateDisplay("You found Beacon 41596", Color.Aqua);
                    UpdateDisplay("\n" + beacon.ProximityUuid + "\nmajor:" + beacon.Major.ToString() + "\nminor:" + beacon.Minor.ToString() + "\nphoneID:" + phoneId + "\nRSSI:" + beacon.Rssi, Color.Aqua);
                    break;

                //case ProximityType.Far:
                case 6211:
                    UpdateDisplay("You found Beacon 6221", Color.Blue);
                    UpdateDisplay("\n" + beacon.ProximityUuid + "\nmajor:" + beacon.Major.ToString() + "\nminor:" + beacon.Minor.ToString() + "\nphoneID:" + phoneId + "\nRSSI:" + beacon.Rssi, Color.Blue);                   //
                    break;

                //case ProximityType.Unknown:
                case 34447:
                    UpdateDisplay("You found Beacon 34447", Color.BlueViolet);
                    UpdateDisplay("\n" + beacon.ProximityUuid + "\nmajor:" + beacon.Major.ToString() + "\nminor:" + beacon.Minor.ToString() + "\nphoneID:" + phoneId + "\nRSSI:" + beacon.Rssi, Color.BlueViolet);
                    break;
                }

                _previousProximity = beacon.Proximity;
            }
        }
Beispiel #2
0
        void RangingBeaconsInRegion(object sender, RangeEventArgs e)
        {
            if (e.Beacons.Count > 0)
            {
                var beacon = e.Beacons.FirstOrDefault();
                Console.WriteLine(beacon.ProximityUuid);
                var message = string.Empty;
                _actualSoundString = GetBeaconInRangeSoundString(beacon.ProximityUuid, GiveMeDictionary(_destination));

                switch ((ProximityType)beacon.Proximity)
                {
                case ProximityType.Immediate:
                    UpdateDisplay(beacon.ProximityUuid);
                    break;
                }

                _previousProximity = beacon.Proximity;
            }

            if (IsDestinationReached(GiveMeDestinationBeaconUuid(), beacon.ProximityUuid))
            {
                GetProperActivity();
            }
        }
		void RangingBeaconsInRegion(object sender, RangeEventArgs e)
		{          

			if (e.Beacons.Count > 0)
			{

                var beacon = e.Beacons.FirstOrDefault();
				var message = string.Empty;

				for (int i = 0; i < e.Beacons.Count; i++)
                {
                   
                    var beacon2 = e.Beacons.ElementAt(i);
                    if (beacon2.Major == 10)
                    {
                        var rsi = beacon2.Rssi;
                        beaconTime[beacon2.Minor - 1] += 10;
                        if (beaconTime[beacon2.Minor - 1] > 10)
                        {
                            beaconTime[beacon2.Minor - 1] = 10;
                        }

                        //Reduce all beacons
                        for (int k = 0; k < beaconTime.Count; k++)
                        {
                            beaconTime[k] -= 1;
                            if (beaconTime[k] < 0)
                            {
                                beaconTime[k] = 0;
                                beaconActive[k] = "0";
                            }
                        }
                        double exponent = 0.0;
                        switch ((ProximityType)beacon2.Proximity)
			        	{
					        case ProximityType.Immediate:
                                beaconActive[beacon2.Minor - 1] = "3";
                                exponent = (Math.Abs(beacon2.Rssi)-59)/(10.0*2.0);
                                beaconDist[beacon2.Minor - 1] = Math.Pow(10, exponent);
                                //beaconDist[beacon2.Minor - 1] = beacon2.Rssi;
                                //UpdateDisplayAdd("You are at " +  temp[beacon2.Minor - 1], Color.Green);
                                break;
					        case ProximityType.Near:
                                beaconActive[beacon2.Minor - 1] = "2";
                                exponent = (Math.Abs(beacon2.Rssi)-59) / (10.0 * 2.0);
                                beaconDist[beacon2.Minor - 1] = Math.Pow(10, exponent);
                                //beaconDist[beacon2.Minor - 1] = beacon2.Rssi;
                                //UpdateDisplayAdd("You are nearby " + temp[beacon2.Minor - 1], Color.Yellow);
                                break;
					        case ProximityType.Far:
                                beaconActive[beacon2.Minor - 1] = "1";
                                exponent = (Math.Abs(beacon2.Rssi) - 59) / (10.0 * 2.0);
                                beaconDist[beacon2.Minor - 1] = Math.Pow(10, exponent);
                                //beaconDist[beacon2.Minor - 1] = beacon2.Rssi;
                                //UpdateDisplayAdd("", Color.Blue);
                                break;
					        case ProximityType.Unknown:
                               // UpdateDisplayAdd("", Color.Red);
                                break;
				}
                         UpdateDisplay("", Color.Blue);
                    }
                    else
                    {
                        //UpdateDisplayAdd("Not found", Color.Yellow);
                    }

                }

                //  UpdateDisplayAdd("R2", Color.Green);
                //  UpdateDisplayAdd("R3", Color.Green);
                //  UpdateDisplayAdd("R4", Color.Green);
                //  UpdateDisplayAdd("R5", Color.Green);
                //  UpdateDisplayAdd("R6", Color.Green);
                //  UpdateDisplayAdd("R7", Color.Green);
                //  UpdateDisplayAdd("R8", Color.Green);
                //  UpdateDisplayAdd("R9", Color.Green);
                //UpdateDisplayAdd("R10", Color.Green);

                _previousProximity = beacon.Proximity;
			}
		}
        void RangingBeaconsInRegion(object sender, RangeEventArgs e)
        {
            if (e.Beacons.Count > 0)
            {
                var beacon = e.Beacons.FirstOrDefault();
                var message = string.Empty;

                switch((ProximityType)beacon.Proximity)
                {
                    case ProximityType.Immediate:
                        UpdateDisplay("You found the monkey!", Color.Green);
                        break;
                    case ProximityType.Near:
                        UpdateDisplay("You're getting warmer", Color.Yellow);
                        break;
                    case ProximityType.Far:
                        UpdateDisplay("You're freezing cold", Color.Blue);
                        break;
                    case ProximityType.Unknown:
                        UpdateDisplay("I'm not sure how close you are to the monkey", Color.Red);
                        break;
                }

                _previousProximity = beacon.Proximity;
            }
        }
        void RangingBeaconsInRegion(object sender, RangeEventArgs e)
        {
            if (e.Beacons.Count > 0)
            {
                var beacon  = e.Beacons.FirstOrDefault();
                var message = string.Empty;

                for (int i = 0; i < e.Beacons.Count; i++)
                {
                    var beacon2 = e.Beacons.ElementAt(i);
                    if (beacon2.Major == 10)
                    {
                        var rsi = beacon2.Rssi;
                        beaconTime[beacon2.Minor - 1] += 10;
                        if (beaconTime[beacon2.Minor - 1] > 10)
                        {
                            beaconTime[beacon2.Minor - 1] = 10;
                        }

                        //Reduce all beacons
                        for (int k = 0; k < beaconTime.Count; k++)
                        {
                            beaconTime[k] -= 1;
                            if (beaconTime[k] < 0)
                            {
                                beaconTime[k]   = 0;
                                beaconActive[k] = "0";
                            }
                        }
                        double exponent = 0.0;
                        switch ((ProximityType)beacon2.Proximity)
                        {
                        case ProximityType.Immediate:
                            beaconActive[beacon2.Minor - 1] = "3";
                            exponent = (Math.Abs(beacon2.Rssi) - 59) / (10.0 * 2.0);
                            beaconDist[beacon2.Minor - 1] = Math.Pow(10, exponent);
                            //beaconDist[beacon2.Minor - 1] = beacon2.Rssi;
                            //UpdateDisplayAdd("You are at " +  temp[beacon2.Minor - 1], Color.Green);
                            break;

                        case ProximityType.Near:
                            beaconActive[beacon2.Minor - 1] = "2";
                            exponent = (Math.Abs(beacon2.Rssi) - 59) / (10.0 * 2.0);
                            beaconDist[beacon2.Minor - 1] = Math.Pow(10, exponent);
                            //beaconDist[beacon2.Minor - 1] = beacon2.Rssi;
                            //UpdateDisplayAdd("You are nearby " + temp[beacon2.Minor - 1], Color.Yellow);
                            break;

                        case ProximityType.Far:
                            beaconActive[beacon2.Minor - 1] = "1";
                            exponent = (Math.Abs(beacon2.Rssi) - 59) / (10.0 * 2.0);
                            beaconDist[beacon2.Minor - 1] = Math.Pow(10, exponent);
                            //beaconDist[beacon2.Minor - 1] = beacon2.Rssi;
                            //UpdateDisplayAdd("", Color.Blue);
                            break;

                        case ProximityType.Unknown:
                            // UpdateDisplayAdd("", Color.Red);
                            break;
                        }
                        UpdateDisplay("", Color.Blue);
                    }
                    else
                    {
                        //UpdateDisplayAdd("Not found", Color.Yellow);
                    }
                }

                //  UpdateDisplayAdd("R2", Color.Green);
                //  UpdateDisplayAdd("R3", Color.Green);
                //  UpdateDisplayAdd("R4", Color.Green);
                //  UpdateDisplayAdd("R5", Color.Green);
                //  UpdateDisplayAdd("R6", Color.Green);
                //  UpdateDisplayAdd("R7", Color.Green);
                //  UpdateDisplayAdd("R8", Color.Green);
                //  UpdateDisplayAdd("R9", Color.Green);
                //UpdateDisplayAdd("R10", Color.Green);

                _previousProximity = beacon.Proximity;
            }
        }