public override void DidRangeBeacons(ESTBeaconManager manager, NSArray[] beacons, ESTBeaconRegion region) { if (beacons.Length > 0) { if (vc.selectedBeacon == null) { // initially pick the closest beacon vc.selectedBeacon = (ESTBeacon)beacons.GetValue(0); } else { for (int i = 0; i < beacons.Length; i++) { ESTBeacon cBeacon = (ESTBeacon)beacons.GetValue(i); // update beacon if same as selected initially if ((vc.selectedBeacon.Ibeacon.Major.UnsignedIntegerValue == cBeacon.Ibeacon.Major.UnsignedIntegerValue) && (vc.selectedBeacon.Ibeacon.Minor.UnsignedIntegerValue == cBeacon.Ibeacon.Minor.UnsignedIntegerValue)) { vc.selectedBeacon = cBeacon; } } } // based on observation rssi is not getting bigger than -30 // so it changes from -30 to -100 so we normalize float distFactor = ((float)vc.selectedBeacon.Ibeacon.Rssi + 30) / -70; // calculate and set new y position float newYPos = (vc.dotMinPos + distFactor * vc.dotRange); vc.positionDot.Center = new PointF(vc.View.Bounds.Size.Width / 2, newYPos); } }
public override void DidRangeBeacons(ESTBeaconManager manager, NSArray[] beacons, ESTBeaconRegion region) { if (beacons.Length > 0) { if (selectedBeacon == null) { // initialy pick closest beacon selectedBeacon = (ESTBeacon)beacons.GetValue(0); } else { for (int i = 0; i < beacons.Length; i++) { ESTBeacon cBeacon = (ESTBeacon)beacons.GetValue(i); // update beacon if same as selected initially if (selectedBeacon.Ibeacon.Major.UInt16Value == cBeacon.Ibeacon.Major.UInt16Value && selectedBeacon.Ibeacon.Minor.UInt16Value == cBeacon.Ibeacon.Minor.UInt16Value) { selectedBeacon = cBeacon; } } } // beacon array is sorted based on distance // closest beacon is the first one string labelTextStr = String.Format("Beacon: {0} \nMajor: {1}, Minor: {2}\nRSSI: {3}\nRegion: ", selectedBeacon.Ibeacon.ProximityUuid.AsString(), selectedBeacon.Ibeacon.Major.UInt16Value, selectedBeacon.Ibeacon.Minor.UInt16Value, selectedBeacon.Ibeacon.Rssi ); // calculate and set new y position switch (selectedBeacon.Ibeacon.Proximity) { case CLProximity.Unknown: labelTextStr += "Unknown"; break; case CLProximity.Immediate: labelTextStr += "Immediate"; break; case CLProximity.Near: labelTextStr += "Near"; break; case CLProximity.Far: labelTextStr += "Far"; break; } NSString labelText = new NSString(labelTextStr); _distanceLabel.Text = labelText; } }
public override void DidRangeBeacons(ESTBeaconManager manager, NSArray[] beacons, ESTBeaconRegion region) { if (beacons.Length > 0) { if (vc.selectedBeacon == null) { vc.selectedBeacon = (ESTBeacon)beacons.GetValue(0); } else { for (int i = 0; i < beacons.Length; i++) { ESTBeacon cBeacon = (ESTBeacon)beacons.GetValue(i); // update beacon if same as selected initially if ((vc.selectedBeacon.Ibeacon.Major.UnsignedIntegerValue == cBeacon.Ibeacon.Major.UnsignedIntegerValue) && (vc.selectedBeacon.Ibeacon.Minor.UnsignedIntegerValue == cBeacon.Ibeacon.Minor.UnsignedIntegerValue)) { vc.selectedBeacon = cBeacon; } } } // beacon array is sorted based on distance // closest beacon is the first one string labelText = string.Format("Major: {0}, Minor: {1}\nRegion: ", vc.selectedBeacon.Ibeacon.Major.UnsignedIntegerValue, vc.selectedBeacon.Ibeacon.Minor.UnsignedIntegerValue); // calculate and set new y position switch (vc.selectedBeacon.Ibeacon.Proximity) { case CLProximity.Unknown: labelText += "Unknown"; break; case CLProximity.Immediate: labelText += "Immediate"; break; case CLProximity.Near: labelText += "Near"; break; case CLProximity.Far: labelText += "Far"; break; default: break; } vc.distanceLabel.Text = labelText; } }
public override void DidRangeBeacons(ESTBeaconManager manager, NSArray[] beacons, ESTBeaconRegion region) { if(beacons.Length > 0) { if(selectedBeacon == null) { // initialy pick closest beacon selectedBeacon = (ESTBeacon)beacons.GetValue(0); } else { for(int i=0;i<beacons.Length;i++) { ESTBeacon cBeacon = (ESTBeacon)beacons.GetValue(i); // update beacon if same as selected initially if(selectedBeacon.Ibeacon.Major.UInt16Value == cBeacon.Ibeacon.Major.UInt16Value && selectedBeacon.Ibeacon.Minor.UInt16Value == cBeacon.Ibeacon.Minor.UInt16Value) { selectedBeacon = cBeacon; } } } // beacon array is sorted based on distance // closest beacon is the first one string labelTextStr = String.Format("Beacon: {0} \nMajor: {1}, Minor: {2}\nRSSI: {3}\nRegion: ", selectedBeacon.Ibeacon.ProximityUuid.AsString(), selectedBeacon.Ibeacon.Major.UInt16Value, selectedBeacon.Ibeacon.Minor.UInt16Value, selectedBeacon.Ibeacon.Rssi ); // calculate and set new y position switch(selectedBeacon.Ibeacon.Proximity) { case CLProximity.Unknown: labelTextStr += "Unknown"; break; case CLProximity.Immediate: labelTextStr += "Immediate"; break; case CLProximity.Near: labelTextStr += "Near"; break; case CLProximity.Far: labelTextStr += "Far"; break; } NSString labelText = new NSString(labelTextStr); _distanceLabel.Text = labelText; } }