void VerityBluetooth() { try { if (!BeaconManager.GetInstanceForApplication(this).CheckAvailability()) { var builder = new AlertDialog.Builder(this); builder.SetTitle("Bluetooth not enabled"); builder.SetMessage("Please enable bluetooth in settings and restart this application."); EventHandler <DialogClickEventArgs> handler = null; builder.SetPositiveButton(Android.Resource.String.Ok, handler); builder.SetOnDismissListener(this); builder.Show(); } } catch (BleNotAvailableException e) { Log.Debug("BleNotAvailableException", e.Message); var builder = new AlertDialog.Builder(this); builder.SetTitle("Bluetooth LE not available"); builder.SetMessage("Sorry, this device does not support Bluetooth LE."); EventHandler <DialogClickEventArgs> handler = null; builder.SetPositiveButton(Android.Resource.String.Ok, handler); builder.SetOnDismissListener(this); builder.Show(); } }
public async void StartRagingBeacons() { await Task.Run(() => { _beaconManager = BeaconManager.GetInstanceForApplication(this); _rangeNotifier = new RangeNotifier(); _connection = DependencyService.Get <ISQLiteConnectionProvider>().GetConnection(); _connection.CreateTable <BeaconDataModel>(); //iBeacon _beaconManager.BeaconParsers.Add(new BeaconParser().SetBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24")); _beaconManager.Bind(this); _rangeNotifier.DidRangeBeaconsInRegionComplete += DidRangeBeaconsInRegionComplete; _beaconManager.AddRangeNotifier(_rangeNotifier); _rangingRegion = new Region(AppConstants.AppName, Identifier.Parse(AppConstants.iBeaconAppUuid), null, null); try { _beaconManager.StartRangingBeaconsInRegion(_rangingRegion); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("StartRangingException: " + ex.Message); } }); }
public async override void ViewDidLoad () { base.ViewDidLoad (); this.Title = "Cloud Beacons"; cloudAPI = new CloudManager (); beaconManager = new BeaconManager (); try { cloudAPI.FetchEstimoteBeaconsWithCompletion(new ArrayCompletionBlock(delegate { try { TableView.ReloadData(); } catch { new UIAlertView ("Error", "Unable to fetch cloud beacons, ensure you have set Config in AppDelegate", null, "OK").Show (); } })); TableView.ReloadData(); } catch(Exception ex) { new UIAlertView ("Error", "Unable to fetch cloud beacons, ensure you have set Config in AppDelegate", null, "OK").Show (); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here beaconManager = new BeaconManager(this); beaconManager.Eddystone += (sender, e) => { if (e.Eddystones.Count == 0) { return; } RunOnUiThread(() => { var items = e.Eddystones.Select(n => "Url: " + n.Url + "Proximity: " + RegionUtils.ComputeProximity(n)); ListAdapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, Android.Resource.Id.Text1, items.ToArray()); ActionBar.Subtitle = string.Format("Found {0} eddystones.", items.Count()); }); }; }
public override void ViewDidLoad() { base.ViewDidLoad (); Title = "Proximity Demo"; View.BackgroundColor = UIColor.White; zoneLabel = new UILabel (new CGRect (0, 100, View.Frame.Size.Width, 40)); zoneLabel.TextAlignment = UITextAlignment.Center; View.AddSubview (zoneLabel); imageView = new UIImageView (new CGRect (0, 64, View.Frame.Size.Width, View.Frame.Size.Height - 64)); imageView.ContentMode = UIViewContentMode.Center; View.AddSubview (imageView); //beacon setup beaconManager = new BeaconManager (); beaconRegion = new CLBeaconRegion (beacon.ProximityUuid,ushort.Parse( beacon.Major.ToString()), ushort.Parse(beacon.Minor.ToString()), "RegionIdentifier"); beaconManager.StartRangingBeaconsInRegion (beaconRegion); beaconManager.RangedBeacons += (sender, e) => { if(e.Beacons.Length == 0 ) return; zoneLabel.Text = TextForProximity(e.Beacons[0].Proximity); imageView.Image = ImageForProximity(e.Beacons[0].Proximity); }; }
public override void ViewDidLoad() { base.ViewDidLoad (); Title = "Notification Demo"; beaconManager = new BeaconManager (); beaconRegion = new BeaconRegion (Beacon.ProximityUUID, Beacon.Major, Beacon.Minor, "BeaconSample"); beaconRegion.NotifyOnEntry = enterSwitch.On; beaconRegion.NotifyOnExit = exitSwitch.On; enterSwitch.ValueChanged += HandleValueChanged; exitSwitch.ValueChanged += HandleValueChanged; beaconManager.StartMonitoring (beaconRegion); beaconManager.ExitedRegion += (sender, e) => { var notification = new UILocalNotification(); notification.AlertBody = "Exit region notification"; UIApplication.SharedApplication.PresentLocalNotificationNow(notification); }; beaconManager.EnteredRegion += (sender, e) => { var notification = new UILocalNotification(); notification.AlertBody = "Enter region notification"; UIApplication.SharedApplication.PresentLocalNotificationNow(notification); }; }
public override void ViewDidLoad() { base.ViewDidLoad (); Title = "Distance Demo"; backgroundImage = new UIImageView(UIImage.FromFile ("distance_bkg")); backgroundImage.Frame = UIScreen.MainScreen.Bounds; backgroundImage.ContentMode = UIViewContentMode.ScaleToFill; View.AddSubview (backgroundImage); View.BackgroundColor = UIColor.White; //var beaconImageView = new UIImageView (UIImage.FromFile ("beacon_linearnie")); //beaconImageView.Center = new CoreGraphics.CGPoint (View.Center.X, 100); //View.AddSubview (beaconImageView); positionDot = new UIImageView (UIImage.FromFile ("dot_image")); positionDot.Center = View.Center; View.AddSubview (positionDot); //Beacon manager setup. beaconManager = new BeaconManager (); beaconRegion = new CLBeaconRegion (beacon.ProximityUuid, ushort.Parse( beacon.Major.ToString()), ushort.Parse(beacon.Minor.ToString()), "BeaconSample"); beaconManager.StartRangingBeaconsInRegion(beaconRegion); }
public override void ViewDidLoad() { base.ViewDidLoad (); // setup Estimote beacon manager var myBeaconManager = new BeaconManager(distanceLabel); estBeaconManager = new ESTBeaconManager(); estBeaconManager.Delegate = myBeaconManager; estBeaconManager.AvoidUnknownStateBeacons = true; // create sample region object (you can additionaly pass major / minor values) ESTBeaconRegion region = new ESTBeaconRegion("EstimoteSampleRegion"); // start looking for estimote beacons in region // when beacon ranged beaconManager:didRangeBeacons:inRegion: invoked estBeaconManager.StartRangingBeaconsInRegion(region); // Perform any additional setup after loading the view, typically from a nib. NavigationItem.LeftBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Bookmarks, delegate { navigation.ToggleMenu(); }); }
private BeaconManager InitializeBeaconManager() { // Enable the BeaconManager BeaconManager bm = BeaconManager.GetInstanceForApplication(CurrentContext); #region Set up Beacon Simulator if testing without a BLE device // var beaconSimulator = new BeaconSimulator(); // beaconSimulator.CreateBasicSimulatedBeacons(); // // BeaconManager.BeaconSimulator = beaconSimulator; #endregion var iBeaconParser = new BeaconParser(); // iBeacon layout iBeaconParser.SetBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"); bm.BeaconParsers.Add(iBeaconParser); _monitorNotifier.EnterRegionComplete += EnteredRegion; _monitorNotifier.ExitRegionComplete += ExitedRegion; _monitorNotifier.DetermineStateForRegionComplete += DeterminedStateForRegionComplete; _rangeNotifier.DidRangeBeaconsInRegionComplete += RangingBeaconsInRegion; _tagRegion = new AltBeaconOrg.BoundBeacon.Region("com.example.myBeaconRegion", Identifier.Parse("39ED98FF-2900-441A-802F-9C398FC199D2"), null, null); bm.SetBackgroundMode(false); bm.Bind((IBeaconConsumer)CurrentContext); return(bm); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here beaconManager = new BeaconManager(this); beaconManager.Eddystone += (sender, e) => { if(e.Eddystones.Count == 0) return; RunOnUiThread(()=> { var items = e.Eddystones.Select(n => "Url: " + n.Url + "Proximity: " + Utils.ComputeProximity(n)); ListAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, Android.Resource.Id.Text1, items.ToArray()); ActionBar.Subtitle = string.Format("Found {0} eddystones.", items.Count()); }); }; }
private BeaconManager InitializeBeaconManager() { // Enable the BeaconManager BeaconManager bm = BeaconManager.GetInstanceForApplication(Xamarin.Forms.Forms.Context); #region Set up Beacon Simulator if testing without a BLE device // var beaconSimulator = new BeaconSimulator(); // beaconSimulator.CreateBasicSimulatedBeacons(); // // BeaconManager.BeaconSimulator = beaconSimulator; #endregion var iBeaconParser = new BeaconParser(); // Estimote > 2013 iBeaconParser.SetBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"); bm.BeaconParsers.Add(iBeaconParser); _monitorNotifier.EnterRegionComplete += EnteredRegion; _monitorNotifier.ExitRegionComplete += ExitedRegion; _monitorNotifier.DetermineStateForRegionComplete += DeterminedStateForRegionComplete; _rangeNotifier.DidRangeBeaconsInRegionComplete += RangingBeaconsInRegion; _tagRegion = new AltBeaconOrg.BoundBeacon.Region("myUniqueBeaconId", Identifier.Parse("E4C8A4FC-F68B-470D-959F-29382AF72CE7"), null, null); _tagRegion = new AltBeaconOrg.BoundBeacon.Region("myUniqueBeaconId", Identifier.Parse("B9407F30-F5F8-466E-AFF9-25556B57FE6D"), null, null); _emptyRegion = new AltBeaconOrg.BoundBeacon.Region("myEmptyBeaconId", null, null, null); bm.SetBackgroundMode(false); bm.Bind((IBeaconConsumer)Xamarin.Forms.Forms.Context); return(bm); }
public override void ViewDidLoad() { base.ViewDidLoad (); Title = "Distance Demo"; backgroundImage = new UIImageView(UIImage.FromFile ("distance_bkg")); backgroundImage.Frame = UIScreen.MainScreen.Bounds; backgroundImage.ContentMode = UIViewContentMode.ScaleToFill; View.AddSubview (backgroundImage); View.BackgroundColor = UIColor.White; //var beaconImageView = new UIImageView (UIImage.FromFile ("beacon_linearnie")); //beaconImageView.Center = new CoreGraphics.CGPoint (View.Center.X, 100); //View.AddSubview (beaconImageView); positionDot = new UIImageView (UIImage.FromFile ("dot_image")); positionDot.Center = View.Center; View.AddSubview (positionDot); //Beacon manager setup. beaconManager = new BeaconManager (); beaconRegion = new BeaconRegion (beacon.ProximityUUID, beacon.Major, beacon.Minor, "BeaconSample"); beaconManager.StartRangingBeacons(beaconRegion); beaconManager.RangedBeacons += (sender, e) => { if(e.Beacons.Length == 0) return; var first = e.Beacons[0]; UpdateDotPosition(first.Distance.FloatValue); }; }
public override void OnCreate() { base.OnCreate(); //string filebase = "/data/user/0/SHOPPERCOIN.SHOPPERCOIN/databases/SCDataBase"; //if (File.Exists(filebase)) //{ // File.Delete(filebase); //} notifManager = (NotificationManager)GetSystemService(Context.NotificationService); beaconManager = BeaconManager.GetInstanceForApplication(this); beaconManager.BeaconParsers.Add(new BeaconParser() .SetBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:25-25")); //writer = new DataBaseWriter(this); beaconManager.Bind(this); SetScanPeriods(200, 0, 2000, 0); bleManager = (BluetoothManager)GetSystemService(Context.BluetoothService); bleManager.Adapter.Enable(); //service = new DataBaseService(); }
private BeaconManager InitializeBeaconManager() { if (_isBinded) { return(_beaconManager); } // Enable the BeaconManager var bm = BeaconManager.GetInstanceForApplication(Forms.Context); // Estimote > 2013 //var iBeaconParser = new BeaconParser(); //iBeaconParser.SetBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"); //bm.BeaconParsers.Add(iBeaconParser); // events _monitorNotifier.EnterRegionComplete += EnteredRegion; _monitorNotifier.ExitRegionComplete += ExitedRegion; _monitorNotifier.DetermineStateForRegionComplete += DeterminedStateForRegionComplete; _rangeNotifier.DidRangeBeaconsInRegionComplete += RangingBeaconsInRegion; bm.BackgroundMode = false; //bm.SetEnableScheduledScanJobs(true); bm.Bind((IBeaconConsumer)Forms.Context); _isBinded = true; return(bm); }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.Main); progressBar = FindViewById<ProgressBar> (Resource.Id.progressBar); noBeacons = FindViewById<TextView> (Resource.Id.no_beacons); ListAdapter = new BeaconAdapter (this); //create a new beacon manager to handle starting and stopping ranging beaconManager = new BeaconManager (this); //manually check for BLE var ble = Android.Content.PM.PackageManager.FeatureBluetoothLe; if (PackageManager.HasSystemFeature(ble)) { Toast.MakeText(this, "BLE not supported", ToastLength.Short).Show(); } //Validation checks if (!beaconManager.HasBluetooth) { //no bluetooth :( DisplayMessage ("No bluetooth on your device.", ":("); beaconsEnabled = false; } else if (!beaconManager.IsBluetoothEnabled) { //bluetooth is not enabled DisplayMessage ("Please turn on bluetooth.", ":("); beaconsEnabled = false; } else if (!beaconManager.CheckPermissionsAndService ()) { //issues with permissions and service DisplayMessage ("Issues with service and persmissions.", ":("); beaconsEnabled = false; } //major and minor are optional, pass in null if you don't need them beaconRegion = new Region (beaconId, uuid, major, null); //Event for when ranging happens beaconManager.Ranging += (object sender, BeaconManager.RangingEventArgs e) => RunOnUiThread (() => { if (e.Beacons.Count == 0) noBeacons.Visibility = ViewStates.Visible; else if(noBeacons.Visibility == ViewStates.Visible) noBeacons.Visibility = ViewStates.Gone; if (progressBar.Visibility == ViewStates.Visible) progressBar.Visibility = ViewStates.Invisible; ((BeaconAdapter)ListAdapter).Beacons.Clear (); ((BeaconAdapter)ListAdapter).Beacons.AddRange (e.Beacons); ((BeaconAdapter)ListAdapter).NotifyDataSetChanged (); }); //estimote loggin, optional #if DEBUG EstimoteSdk.Utility.L.EnableDebugLogging (true); #endif }
public override void ViewDidAppear (bool animated) { base.ViewDidLoad (); this.Title = "Select Beacon"; beaconManager = new BeaconManager (); beaconManager.ReturnAllRangedBeaconsAtOnce = true; region = new CLBeaconRegion (AppDelegate.BeaconUUID, "BeaconSample"); }
public override void ViewDidAppear(bool animated) { base.ViewDidLoad(); this.Title = "Select Beacon"; beaconManager = new BeaconManager(); beaconManager.ReturnAllRangedBeaconsAtOnce = true; region = new CLBeaconRegion(AppDelegate.BeaconUUID, "BeaconSample"); }
public void FindBeacons() { if (!BeaconManager.IsBluetoothEnabled) { throw new Exception("Bluetooth is not enabled."); } BeaconManager.Connect(this); }
public async override void ViewDidLoad () { base.ViewDidLoad (); this.Title = "Select Beacon"; beaconManager = new BeaconManager (); utilityManager = new UtilityManager (); }
public BLE(IBluetoothPacketProvider provider) { if (provider != null) { manager = new BeaconManager(provider); manager.BeaconAdded += (s, b) => BeaconAdded.Invoke(s, b); provider.AdvertisementPacketReceived += (s, e) => AdvertisementPacketReceived.Invoke(s, e); } }
public void InitializeService() { if (isBinded) { return; } _beaconManager = InitializeBeaconManager(); }
public override void OnCreate() { base.OnCreate(); bMngr = BeaconManager.GetInstanceForApplication(this); bMngr.BeaconParsers.Add(new BeaconParser().SetBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24")); bMngr.Bind(this); _rangeNotify.DidRangeBeaconsInRegionComplete += RangingBeaconsInRegion; }
public override void ViewDidLoad() { base.ViewDidLoad(); //set up sqlite db var documents = Environment.GetFolderPath(Environment.SpecialFolder.Personal); _pathToDatabase = Path.Combine(documents, "db_sqlite-net.db"); TryToConnectToBridge(); utilityManager = new UtilityManager(); beaconManager = new BeaconManager(); locationManager = new CLLocationManager(); locationManager.RequestWhenInUseAuthorization(); beaconManager.AuthorizationStatusChanged += (sender, e) => { beaconManager.StartMonitoringForRegion(region); }; beaconManager.ExitedRegion += (sender, e) => { proximityValueLabel.Text = "You have EXITED the PooBerry region"; }; locationManager.DidDetermineState += (object sender, CLRegionStateDeterminedEventArgs e) => { switch (e.State) { case CLRegionState.Inside: OnAdd(); Console.WriteLine("region state inside"); break; case CLRegionState.Outside: Console.WriteLine("region state outside"); StartMonitoringBeacons(); break; case CLRegionState.Unknown: default: Console.WriteLine("region state unknown"); StartMonitoringBeacons(); break; } }; locationManager.RegionEntered += (object sender, CLRegionEventArgs e) => { Console.WriteLine("beacon region entered"); }; #region Hue UI connectBridge.TouchUpInside += ConnectBridgeClicked; onButton.TouchUpInside += OnButton_TouchUpInside; offButton.TouchUpInside += OffButton_TouchUpInside; #endregion Hue UI }
public BeaconManagerImpl() { this.rangeTimer = new Timer(500); // every second TODO: should coincide with foreground timer this.rangeTimer.Elapsed += (sender, args) => { this.rangeTimer.Stop(); lock (this.beaconsInRange) { var count = this.beaconsInRange.Count; for (var i = 0; i < count; i++) { var b = this.beaconsInRange[i]; var ts = b.LastPing.Subtract(DateTime.UtcNow); if (ts.TotalMilliseconds <= -2000) { this.beaconsInRange.RemoveAt(i); i--; count--; } } } this.rangeTimer.Start(); }; this.beaconManager = new BeaconManager(Application.Context); this.beaconManager.EnteredRegion += (sender, args) => { Log.Debug(DEBUG_TAG, "EnteredRegion Event"); var region = this.FromNative(args.Region); this.OnRegionStatusChanged(region, true); }; this.beaconManager.ExitedRegion += (sender, args) => { Log.Debug(DEBUG_TAG, "ExitedRegion Event"); var region = this.FromNative(args.Region); this.OnRegionStatusChanged(region, false); }; this.beaconManager.Ranging += (sender, args) => { Log.Debug(DEBUG_TAG, "Ranging Event"); var beacons = args.Beacons.Select(x => new Beacon(x)); lock (this.beaconsInRange) { foreach (var beacon in beacons) { var index = this.GetIndexOfBeacon(beacon); if (beacon.Proximity == Proximity.Unknown) { if (index > -1) this.beaconsInRange.RemoveAt(index); } else { beacon.LastPing = DateTime.UtcNow; if (index == -1) this.beaconsInRange.Add(beacon); else { var b = this.beaconsInRange[index]; b.Proximity = beacon.Proximity; b.LastPing = beacon.LastPing; } } } } this.OnRanged(this.beaconsInRange); }; }
protected override void OnStart() { base.OnStart(); _beaconManager = new BeaconManager(this); _beaconManager.Connect(this); _beaconManager.Nearable += _beaconManager_Nearable; _beaconManager.Nearable += UpdateBoardNames; myBeacons = new List <BeaconView>(); viewList.Adapter = new BeaconAdapter(this, myBeacons); }
protected virtual void HandleRanging(object sender, BeaconManager.RangingEventArgs e) { Log.Debug(TAG, "Found {0} beacons.", e.Beacons.Count); // IEnumerable<Beacon> beacons = from item in e.Beacons // let uuid = item.ProximityUUID // where uuid.Equals(EstimoteBeacons.EstimoteProximityUuid, StringComparison.OrdinalIgnoreCase) || // uuid.Equals(EstimoteBeacons.EstimoteIosProximityUuid, StringComparison.OrdinalIgnoreCase) // select item; BeaconsFound(this, new BeaconsFoundEventArgs(e.Beacons)); }
private void ExitRegionComplete(object sender, MonitorEventArgs e) { System.Diagnostics.Debug.WriteLine("ExitRegionComplete ---- StopRanging"); System.Diagnostics.Debug.WriteLine(e.ToString()); MainActivity activity = Xamarin.Forms.Forms.Context as MainActivity; _beaconManager = BeaconManager.GetInstanceForApplication(activity); //_beaconManager.StopRangingBeaconsInRegion(_fieldRegion); }
public void TestRecognizeBeacon() { var beaconManager = BeaconManager.GetInstanceForApplication(Android.App.Application.Context); var bytes = HexStringToByteArray("02011a1bff1801beac2f234454cf6d4a0fadf2f4911ba9ffa600010002c50900"); AltBeaconParser parser = new AltBeaconParser(); Beacon beacon = parser.FromScanData(bytes, -55, null, DateTime.UtcNow.Ticks); Assert.AreEqual(1, beacon.DataFields.Count, "Beacon should have one data field"); Assert.AreEqual(9, ((AltBeacon)beacon).MfgReserved, "manData should be parsed"); }
public override async Task <BeaconInitStatus> Initialize(bool backgroundMonitoring) { if (!UIDevice.CurrentDevice.CheckSystemVersion(7, 0)) { return(BeaconInitStatus.InvalidOperatingSystem); } if (!CLLocationManager.LocationServicesEnabled) { return(BeaconInitStatus.LocationServicesDisabled); } // if (UIApplication.SharedApplication.BackgroundRefreshStatus != UIBackgroundRefreshStatus.Denied) // return; //if (!CLLocationManager.IsMonitoringAvailable()) //CLLocationManager.IsRangingAvailable // var btstatus = this.GetBluetoothStatus(); // if (btstatus != BeaconInitStatus.Success) // return btstatus; var authStatus = BeaconManager.AuthorizationStatus(); var good = this.IsGoodStatus(authStatus, backgroundMonitoring); if (good) { return(BeaconInitStatus.Success); } var tcs = new TaskCompletionSource <BeaconInitStatus>(); var funcPnt = new EventHandler <AuthorizationStatusChangedArgsEventArgs>((sender, args) => { if (args.Status == CLAuthorizationStatus.NotDetermined) { return; // not done yet } var success = this.IsGoodStatus(args.Status, backgroundMonitoring); tcs.TrySetResult(success ? BeaconInitStatus.Success : BeaconInitStatus.PermissionDenied); }); this.beaconManager.AuthorizationStatusChanged += funcPnt; if (backgroundMonitoring) { this.beaconManager.RequestAlwaysAuthorization(); } else { this.beaconManager.RequestWhenInUseAuthorization(); } var status = await tcs.Task; this.beaconManager.AuthorizationStatusChanged -= funcPnt; return(status); }
public Resolver(bool synchron) { SynchronResolver = synchron; if (!SynchronResolver) { RequestQueue = new Queue<Request>(); } BeaconManager = new BeaconManager((long) Constants.DefaultBeaconExitTimeout); _exitTimer = new Timer(ExitTimerTick, null, 0, 1000); }
public Resolver(bool synchron) { SynchronResolver = synchron; if (!SynchronResolver) { RequestQueue = new Queue <Request>(); } BeaconManager = new BeaconManager((long)Constants.DefaultBeaconExitTimeout); _exitTimer = new Timer(ExitTimerTick, null, 0, 1000); }
bool VerifyBluetooth() { try { return(BeaconManager.GetInstanceForApplication(ApplicationContext).CheckAvailability()); } catch (BleNotAvailableException) { return(false); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); App.CurrentActivity = this; ActionBar.SetDisplayHomeAsUpEnabled(true); ActionBar.SetHomeButtonEnabled(true); viewModel = new GameCompleteViewModel(); SetContentView(Resource.Layout.game_complete); viewModel.PropertyChanged += HandlePropertyChanged; mainImage = FindViewById <ImageView>(Resource.Id.main_image); progressBar = FindViewById <ProgressBar>(Resource.Id.progressBar); beaconManager = new BeaconManager(this); scanner = new ZXing.Mobile.MobileBarcodeScanner(); var shareButton = FindViewById <Button>(Resource.Id.share_success); shareButton.Click += (sender, e) => { var intent = new Intent(Intent.ActionSend); intent.SetType("text/plain"); intent.PutExtra(Intent.ExtraText, Resources.GetString(Resource.String.success_tweet)); StartActivity(Intent.CreateChooser(intent, Resources.GetString(Resource.String.share_success))); }; beaconManager.Ranging += (sender, e) => { if (e.Beacons == null) { return; } foreach (var beacon in e.Beacons) { var proximity = Utils.ComputeProximity(beacon); if (proximity != Utils.Proximity.Immediate) { continue; } var accuracy = Utils.ComputeAccuracy(beacon); if (accuracy > .06) { continue; } viewModel.CheckBanana(beacon.Major, beacon.Minor); } }; viewModel.LoadGameCommand.Execute(null); }
public void FindBeacons(Context context) { //TODO: Properly detect BT Enabled var btEnabled = true; if (!btEnabled) { throw new Exception("Bluetooth is not enabled."); } BeaconManager.Connect(this); }
public override void Stop() { if (_isSearching) { BeaconManager.StopRanging(_region); base.Stop(); _region = null; _beacon = null; _isSearching = false; } }
public void testEddystoneScanFilterData() { BeaconParser parser = new BeaconParser(); parser.SetBeaconLayout(BeaconParser.EddystoneUidLayout); BeaconManager.SetsManifestCheckingDisabled(true); // no manifest available in robolectric var scanFilterDatas = new ScanFilterUtils().CreateScanFilterDataForBeaconParser(parser); AssertEx.AreEqual("scanFilters should be of correct size", 1, scanFilterDatas.Count); ScanFilterUtils.ScanFilterData sfd = scanFilterDatas[0]; AssertEx.AreEqual("serviceUuid should be right", new Java.Lang.Long(0xfeaa).LongValue(), sfd.ServiceUuid.LongValue()); }
public void StartMonitoring(IList <BeaconModel> beacons) { _beaconManager = BeaconManager.GetInstanceForApplication(this); _rangeNotifier = new RangeNotifier(); _listOfBeacons = beacons; //iBeacon _beaconManager.BeaconParsers.Add(new BeaconParser().SetBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24")); _beaconManager.Bind(this); }
public void Start() { // Construct the Universal Bluetooth Beacon manager _beaconManager = new BeaconManager(); // Create & start the Bluetooth LE watcher from the Windows 10 UWP _watcher = new BluetoothLEAdvertisementWatcher { ScanningMode = BluetoothLEScanningMode.Active }; _watcher.Received += WatcherOnReceived; _watcher.Start(); }
public async override void ViewDidLoad() { base.ViewDidLoad(); this.Title = "Select Beacon"; beaconManager = new BeaconManager(); beaconManager.ReturnAllRangedBeaconsAtOnce = true; region = new BeaconRegion(AppDelegate.BeaconUUID, "BeaconSample"); beaconManager.AuthorizationStatusChanged += (sender, e) => { StartRangingBeacons(); }; }
public BeaconService() { // get the platform-specific provider var provider = RootWorkItem.Services.Get <IBluetoothPacketProvider>(); // create a beacon manager, giving it an invoker to marshal collection changes to the UI thread _manager = new BeaconManager(provider, Device.BeginInvokeOnMainThread); //_manager = new BeaconManager(provider); _manager.Start(); }
public MainPage() { // Construct the Universal Bluetooth Beacon manager beaconManager = new BeaconManager(); // Create & start the Bluetooth LE watcher watcher = new BluetoothLEAdvertisementWatcher { ScanningMode = BluetoothLEScanningMode.Passive }; watcher.Received += WatcherOnReceived; watcher.Start(); }
private async void ExitTimerTick(object state) { List <Beacon> beaconExits = BeaconManager.ResolveBeaconExits(); foreach (Beacon beacon in beaconExits) { await CreateRequest(new BeaconEventArgs() { Beacon = beacon, EventType = BeaconEventType.Exit }); } }
public override void ViewDidLoad () { base.ViewDidLoad (); //set up sqlite db var documents = Environment.GetFolderPath (Environment.SpecialFolder.Personal); _pathToDatabase = Path.Combine (documents, "db_sqlite-net.db"); TryToConnectToBridge (); utilityManager = new UtilityManager (); beaconManager = new BeaconManager (); locationManager = new CLLocationManager (); locationManager.RequestWhenInUseAuthorization (); beaconManager.AuthorizationStatusChanged += (sender, e) => { beaconManager.StartMonitoringForRegion (region); }; beaconManager.ExitedRegion += (sender, e) => { proximityValueLabel.Text = "You have EXITED the PooBerry region"; }; locationManager.DidDetermineState += (object sender, CLRegionStateDeterminedEventArgs e) => { switch (e.State) { case CLRegionState.Inside: OnAdd (); Console.WriteLine ("region state inside"); break; case CLRegionState.Outside: Console.WriteLine ("region state outside"); StartMonitoringBeacons (); break; case CLRegionState.Unknown: default: Console.WriteLine ("region state unknown"); StartMonitoringBeacons (); break; } }; locationManager.RegionEntered += (object sender, CLRegionEventArgs e) => { Console.WriteLine ("beacon region entered"); }; #region Hue UI connectBridge.TouchUpInside += ConnectBridgeClicked; onButton.TouchUpInside += OnButton_TouchUpInside; offButton.TouchUpInside += OffButton_TouchUpInside; #endregion Hue UI }
public async override void ViewDidLoad () { base.ViewDidLoad (); this.Title = "Select Beacon"; beaconManager = new BeaconManager (); beaconManager.ReturnAllRangedBeaconsAtOnce = true; region = new BeaconRegion (AppDelegate.BeaconUUID, "BeaconSample"); beaconManager.AuthorizationStatusChanged += (sender, e) => { StartRangingBeacons(); }; }
protected FindBeacon(Context context) { #if DEBUG L.EnableDebugLogging(true); #endif Context = context; BeaconManager = new BeaconManager(context); if (!BeaconManager.HasBluetooth) { throw new Exception("The device does not have have Bluetooth!"); } }
private BeaconManager InitializeBeaconManager() { RequestPermission(); // Enable the BeaconManager _beaconManager = BeaconManager.GetInstanceForApplication(_mainActivity); /* #region Set up Beacon Simulator for TEST USE * // Beacon Simulator * var beaconSimulator = new BeaconSimulator(); * beaconSimulator.CreateBasicSimulatedBeacons(); * BeaconManager.BeaconSimulator = beaconSimulator; * // Beacon Simulator #endregion Set up Beacon Simulator for TEST USE */ _monitorNotifier = new MonitorNotifier(); _rangeNotifier = new RangeNotifier(); //iBeacon BeaconParser beaconParser = new BeaconParser().SetBeaconLayout(AppConstants.iBeaconFormat); _beaconManager.BeaconParsers.Add(beaconParser); // BeaconManager Setting // Check Touch おそらくmain activity beacon consumer側で設定 /* * _beaconManager.SetForegroundScanPeriod(AppConstants.BEACONS_UPDATES_IN_MILLISECONDS); * _beaconManager.SetForegroundBetweenScanPeriod(AppConstants.BEACONS_UPDATES_IN_MILLISECONDS); * _beaconManager.SetBackgroundScanPeriod(AppConstants.BEACONS_UPDATES_IN_MILLISECONDS); * _beaconManager.SetBackgroundBetweenScanPeriod(AppConstants.BEACONS_UPDATES_IN_MILLISECONDS); * _beaconManager.UpdateScanPeriods(); */ // MonitorNotifier _monitorNotifier.DetermineStateForRegionComplete += DetermineStateForRegionComplete; _monitorNotifier.EnterRegionComplete += EnterRegionComplete; _monitorNotifier.ExitRegionComplete += ExitRegionComplete; _beaconManager.AddMonitorNotifier(_monitorNotifier); // RangeNotifier _rangeNotifier.DidRangeBeaconsInRegionComplete += DidRangeBeaconsInRegionComplete; _beaconManager.AddRangeNotifier(_rangeNotifier); _fieldRegion = new AltBeaconOrg.BoundBeacon.Region("AppAppApp", Identifier.Parse(AppConstants.iBeaconAppUuid), null, null); _beaconManager.Bind(_mainActivity); return(_beaconManager); }
public override void ViewDidLoad() { base.ViewDidLoad(); TableView.ContentInset = new UIEdgeInsets(20.0f, 0.0f, 0.0f, 0.0f); TableView.SeparatorStyle = UITableViewCellSeparatorStyle.SingleLine; TableView.SeparatorInset = UIEdgeInsets.Zero; _beaconManager = new BeaconManager(); _beaconManager.ReturnAllRangedBeaconsAtOnce = true; _beaconManager.RangedBeacons += BeaconManagerRangedBeacons; _beaconManager.AuthorizationStatusChanged += BeaconManagerAuthorizationStatusChanged; _beaconManager.RequestWhenInUseAuthorization(); }
public async Task<bool> Init() { _beaconManager = new BeaconManager(Xamarin.Forms.Forms.Context as Activity); if (_beaconManager != null) { _beaconManager.SetBackgroundScanPeriod(TimeUnit.Seconds.ToMillis(1), 0); _itemsList = new List<Region>(); beaconsInRange = new List<Beacon>(); _beaconManager.Connect(this); return true; } return false; }
public async override void ViewDidLoad () { base.ViewDidLoad (); this.Title = "Cloud Beacons"; beaconManager = new BeaconManager (); try { beacons = await beaconManager.FetchEstimoteBeaconsAsync (); TableView.ReloadData(); } catch(Exception ex) { new UIAlertView ("Error", "Unable to fetch cloud beacons, ensure you have set Config in AppDelegate", null, "OK").Show (); } }
public override void ViewDidLoad() { base.ViewDidLoad (); Title = "Notification Demo"; beaconManager = new BeaconManager (); beaconRegion = new CLBeaconRegion (Beacon.ProximityUuid, ushort.Parse(Beacon.Major.ToString()), ushort.Parse(Beacon.Minor.ToString()), "BeaconSample"); beaconRegion.NotifyOnEntry = enterSwitch.On; beaconRegion.NotifyOnExit = exitSwitch.On; enterSwitch.ValueChanged += HandleValueChanged; exitSwitch.ValueChanged += HandleValueChanged; beaconManager.StartMonitoringForRegion (beaconRegion); }
protected BeaconFinder(Context context) { #if DEBUG //L.EnableDebugLogging(true); #endif Context = context; BeaconManager = new BeaconManager(context); BeaconManager.Error += BeaconManager_Error; if (!BeaconManager.HasBluetooth) { throw new Exception("The device does not have have Bluetooth!"); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); App.CurrentActivity = this; ActionBar.SetDisplayHomeAsUpEnabled(true); ActionBar.SetHomeButtonEnabled(true); viewModel = new GameCompleteViewModel(); SetContentView(Resource.Layout.game_complete); viewModel.PropertyChanged += HandlePropertyChanged; mainImage = FindViewById<ImageView>(Resource.Id.main_image); progressBar = FindViewById<ProgressBar>(Resource.Id.progressBar); beaconManager = new BeaconManager(this); scanner = new ZXing.Mobile.MobileBarcodeScanner(); var shareButton = FindViewById<Button>(Resource.Id.share_success); shareButton.Click += (sender, e) => { var intent = new Intent(Intent.ActionSend); intent.SetType("text/plain"); intent.PutExtra(Intent.ExtraText, Resources.GetString(Resource.String.success_tweet)); StartActivity(Intent.CreateChooser(intent, Resources.GetString(Resource.String.share_success))); }; beaconManager.Ranging += (sender, e) => { if (e.Beacons == null) return; foreach (var beacon in e.Beacons) { var proximity = Utils.ComputeProximity(beacon); if (proximity != Utils.Proximity.Immediate) continue; var accuracy = Utils.ComputeAccuracy(beacon); if (accuracy > .06) continue; viewModel.CheckBanana(beacon.Major, beacon.Minor); } }; viewModel.LoadGameCommand.Execute(null); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); _status = FindViewById<TextView>(Resource.Id.Status); _beaconManager = BeaconManager.GetInstanceForApplication(this); var iBeaconParser = new BeaconParser(); iBeaconParser.SetBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"); _beaconManager.BeaconParsers.Add(iBeaconParser); _beaconManager.SetRangeNotifier(this); _beaconManager.Bind(this); }
public BeaconManagerImpl() { this.beaconManager = new BeaconManager { ReturnAllRangedBeaconsAtOnce = true }; this.beaconManager.EnteredRegion += (sender, args) => { var region = this.FromNative(args.Region); this.OnRegionStatusChanged(region, true); }; this.beaconManager.ExitedRegion += (sender, args) => { var region = this.FromNative(args.Region); this.OnRegionStatusChanged(region, false); }; this.beaconManager.RangedBeacons += (sender, args) => { var beacons = args.Beacons.Select(x => new Beacon(x)); this.OnRanged(beacons); }; }
public override void ViewDidLoad () { base.ViewDidLoad (); this.Title = "Select Beacon"; utilityManager = new UtilityManager (); beaconManager = new BeaconManager (); beaconManager.ReturnAllRangedBeaconsAtOnce = true; region = new CLBeaconRegion (AppDelegate.BeaconUUID, "BeaconSample"); beaconManager.AuthorizationStatusChanged += (sender, e) => StartRangingBeacons (); beaconManager.RangedBeacons += (sender, e) => { beacons = e.Beacons; TableView.ReloadData(); }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); ActionBar.SetDisplayHomeAsUpEnabled(true); SetContentView(Resource.Layout.notify_demo); _region = this.GetBeaconAndRegion().Item2; _notificationManager = (NotificationManager)GetSystemService(NotificationService); _beaconManager = new BeaconManager(this); // Default values are 5s of scanning and 25s of waiting time to save CPU cycles. // In order for this demo to be more responsive and immediate we lower down those values. _beaconManager.SetBackgroundScanPeriod(TimeUnit.Seconds.ToMillis(1), 0); _beaconManager.EnteredRegion += (sender, e) => PostNotification("Entered region"); _beaconManager.ExitedRegion += (sender, e) => PostNotification("Exited region"); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); ActionBar.SetDisplayHomeAsUpEnabled(true); ActionBar.SetHomeButtonEnabled(true); App.CurrentActivity = this; ViewModel = new QuestViewModel(); SetContentView(Resource.Layout.quest); ViewModel.PropertyChanged += HandlePropertyChanged; imageLoader = new ImageLoader(this, 256, 5); beacon1 = FindViewById<ImageView>(Resource.Id.beacon1); beacon2 = FindViewById<ImageView>(Resource.Id.beacon2); beacon3 = FindViewById<ImageView>(Resource.Id.beacon3); beacons = new List<ImageView> { beacon1, beacon2, beacon3 }; mainImage = FindViewById<ImageView>(Resource.Id.main_image); mainText = FindViewById<TextView>(Resource.Id.main_text); beaconNearby = FindViewById<TextView>(Resource.Id.text_beacons); progressBar = FindViewById<ProgressBar>(Resource.Id.progressBar); buttonContinue = FindViewById<Button>(Resource.Id.button_continue); buttonContinue.Click += ButtonContinueClick; buttonContinue.Visibility = ViewStates.Gone; beaconManager = new BeaconManager(this); scanner = new ZXing.Mobile.MobileBarcodeScanner(); beaconManager.Ranging += BeaconManagerRanging; beaconManager.EnteredRegion += (sender, args) => SetBeaconText(true); beaconManager.ExitedRegion += (sender, args) => SetBeaconText(false); beacon1.Visibility = beacon2.Visibility = beacon3.Visibility = ViewStates.Invisible; options.PossibleFormats = new List<ZXing.BarcodeFormat>() { ZXing.BarcodeFormat.QR_CODE }; ViewModel.LoadQuestCommand.Execute(null); }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); //create a new beacon manager to handle starting and stopping ranging beaconManager = new BeaconManager (this); //major and minor are optional, pass in null if you don't need them beaconRegion = new EstimoteSdk.Region (beaconId, uuid, null, null); var v = FindViewById<WatchViewStub> (Resource.Id.watch_view_stub); v.LayoutInflated += delegate { // Get our button from the layout resource, // and attach an event to it background = FindViewById<View> (Resource.Id.main); count = FindViewById<TextView>(Resource.Id.text); }; beaconManager.Ranging += (object sender, BeaconManager.RangingEventArgs e) => RunOnUiThread (() => { background.SetBackgroundColor(Color.Black); count.Text = e.Beacons.Count.ToString(); if(e.Beacons.Count == 0) return; var prox = Utils.ComputeProximity(e.Beacons[0]); if(prox == Utils.Proximity.Far) background.SetBackgroundColor(Color.Blue); else if(prox == Utils.Proximity.Near) background.SetBackgroundColor(Color.Yellow); else if(prox == Utils.Proximity.Immediate) background.SetBackgroundColor(Color.Green); else background.SetBackgroundColor(Color.Black); }); }
public override void ViewDidLoad() { base.ViewDidLoad (); // setup Estimote beacon manager var myBeaconManager = new BeaconManager(distanceLabel); estBeaconManager = new ESTBeaconManager(); estBeaconManager.Delegate = myBeaconManager; estBeaconManager.AvoidUnknownStateBeacons = true; // create sample region object (you can additionaly pass major / minor values) ESTBeaconRegion region = new ESTBeaconRegion("EstimoteSampleRegion"); // start looking for estimote beacons in region // when beacon ranged beaconManager:didRangeBeacons:inRegion: invoked estBeaconManager.StartRangingBeacons(region); }
public override void OnCreate() { base.OnCreate(); _beaconManager = BeaconManager.GetInstanceForApplication(this); var iBeaconParser = new BeaconParser(); // Estimote > 2013 iBeaconParser.SetBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"); _beaconManager.BeaconParsers.Add(iBeaconParser); Log.Debug(TAG, "setting up background monitoring for beacons and power saving"); // wake up the app when a beacon is seen _backgroundRegion = new Region("backgroundRegion", null, null, null); regionBootstrap = new RegionBootstrap(this, _backgroundRegion); // simply constructing this class and holding a reference to it in your custom Application // class will automatically cause the BeaconLibrary to save battery whenever the application // is not visible. This reduces bluetooth power usage by about 60% backgroundPowerSaver = new BackgroundPowerSaver(this); }