private BeaconManager InitializeBeaconManager()
        {
            // Enable the BeaconManager
            BeaconManager bm = BeaconManager.GetInstanceForApplication(Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity);

            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 Org.Altbeacon.Beacon.Region/* AltBeaconOrg.BoundBeacon.Region*/ ("Beacon 2", Identifier.Parse("8E6DBFBB-489D-418A-9560-1BA1CE6301AA"), null, null);
            _tagRegion   = new Org.Altbeacon.Beacon.Region/* AltBeaconOrg.BoundBeacon.Region*/ ("myUniqueBeaconId", Identifier.Parse("B9407F30-F5F8-466E-AFF9-25556B57FE6D"), null, null);
            _emptyRegion = new Org.Altbeacon.Beacon.Region/* AltBeaconOrg.BoundBeacon.Region*/ ("myEmptyBeaconId", null, null, null);

            //bm.SetBackgroundMode(false);

            bm.BackgroundMode = false;
            bm.Bind((IBeaconConsumer)Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity);

            return(bm);
        }
        /// <summary>
        /// Beacon領域の初期化処理
        /// </summary>
        private void InitBeaconRegion()
        {
            var uuid   = Identifier.Parse(Regions.RegionList.研究室.Uuid);
            var major  = Identifier.Parse(Regions.RegionList.研究室.Major.ToString());
            var minor  = Identifier.Parse(Regions.RegionList.研究室.Minor.ToString());
            var region = new Org.Altbeacon.Beacon.Region(Regions.RegionList.研究室.Identifier, uuid, major, minor);

            _regionBootstrap = new RegionBootstrap(this, region);
        }
        public void OnBeaconServiceConnect()
        {
            _beaconManager.AddMonitorNotifier(this);

            var uuid   = Identifier.Parse(Regions.RegionList.研究室.Uuid);
            var major  = Identifier.Parse(Regions.RegionList.研究室.Major.ToString());
            var minor  = Identifier.Parse(Regions.RegionList.研究室.Minor.ToString());
            var region = new Org.Altbeacon.Beacon.Region(Regions.RegionList.研究室.Identifier, uuid, major, minor);

            _beaconManager.StartMonitoringBeaconsInRegion(region);
        }
        /// <summary>
        /// ビーコン領域から退出した際のコールバック
        /// </summary>
        /// <param name="p0"></param>
        public void DidExitRegion(Org.Altbeacon.Beacon.Region p0)
        {
            Log.Info(TAG, "Exit [{0}] Region", p0.UniqueId);
            var adapter = new DbAdapter_Droid();

            adapter.AddDeviceLog("ビーコンから退出:在室状況を[学内]に更新", p0.UniqueId);

            if (p0.UniqueId.Equals(Regions.RegionList.研究室.Identifier))
            {
                //研究室から退出
                var dbAdapter = new DbAdapter_Droid();
                dbAdapter.UpdateStatus(UserDataModel.Instance.MemberId, Status.学内.GetStatusId(), true);
            }
        }
        public void DidExitRegion(Org.Altbeacon.Beacon.Region p0)
        {
            Log.Info(TAG, "Exit [{0}] Region", p0.UniqueId);

            if (p0.UniqueId.Equals(Regions.RegionList.研究室.Identifier))
            {
                //研究室から退出
                var dbAdapter = new DbAdapter_Droid();
                dbAdapter.UpdateStatus(UserDataModel.Instance.MemberId, Status.学内.GetStatusId(), true);

                _beaconManager.Unbind(this);
                StopForeground(true);
            }
        }
        /// <summary>
        /// ビーコン領域に侵入した際のコールバック
        /// </summary>
        /// <param name="p0"></param>
        public void DidEnterRegion(Org.Altbeacon.Beacon.Region p0)
        {
            Log.Info(TAG, "Enter [{0}] Region", p0.UniqueId);
            Firebase.FirebaseApp.InitializeApp(this.ApplicationContext);
            var adapter = new DbAdapter_Droid();

            adapter.AddDeviceLog("ビーコンに侵入:在室状況を[在室]に更新", p0.UniqueId);

            if (p0.UniqueId.Equals(Regions.RegionList.研究室.Identifier))
            {
                //研究室に侵入
                var dbAdapter = new DbAdapter_Droid();
                dbAdapter.UpdateStatus(UserDataModel.Instance.MemberId, Status.在室.GetStatusId(), true);

                //var intent = new Intent(this, typeof(Beacons.BeaconMonitoringService));
                //StartForegroundService(intent);
            }
        }
Пример #7
0
 public void OnBeaconServiceConnect()
 {
     try
     {
         var region = new Region("SarayMuhallebicisi", new List <Identifier>
         {
             Identifier.FromUuid(UUID.FromString("adc2050d-3dce-4700-adf9-f42c8f70e5a4"))
         });
         //beaconManager.ForegroundScanPeriod = 1;
         //beaconManager.ForegroundBetweenScanPeriod = 1;
         //beaconManager.BackgroundBetweenScanPeriod= 1;
         //beaconManager.BackgroundScanPeriod = 1;
         beaconManager.StartRangingBeaconsInRegion(region);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
Пример #8
0
        public void DidRangeBeaconsInRegion(ICollection <Beacon> p0, Region p1)
        {
            if (!p0.Any())
            {
                return;
            }
            var beacons = p0.ToList().OrderBy(p => p.Distance).ToList();

            var first = beacons.First();

            if (_selectedBeacon == null)
            {
                _selectedBeacon = first;
            }

            var updateBeacon = beacons.FirstOrDefault(p => p.BluetoothAddress == _selectedBeacon.BluetoothAddress);

            if (updateBeacon != null)
            {
                _selectedBeacon = updateBeacon;
            }
            else
            {
                if (first.Distance < _selectedBeacon.Distance)
                {
                    _selectedBeacon = first;
                }
            }

            if (_selectedBeacon.BluetoothAddress != first.BluetoothAddress)
            {
                if (first.Distance < _selectedBeacon.Distance)
                {
                    _selectedBeacon = first;
                }
            }

            beaconIds.Text = BeaconList[_selectedBeacon.BluetoothAddress];
        }
 /// <summary>
 /// ビーコンのステータス更新時のコールバック
 /// </summary>
 /// <param name="p0"></param>
 /// <param name="p1"></param>
 public void DidDetermineStateForRegion(int p0, Org.Altbeacon.Beacon.Region p1)
 {
 }
 public void DidEnterRegion(Org.Altbeacon.Beacon.Region p0)
 {
     throw new NotImplementedException();
 }