Пример #1
0
        public void StartRagingBeacons()
        {
            MvxTrace.TaggedTrace(TAG, "StartRagingBeacons");

            if (_rangeNotifier != null)
            {
                return;
            }

            BEACONS_REGION_HEADER = $"beacons_{Context.PackageName}";

            _beaconManager = BeaconManager.GetInstanceForApplication(this);

            _regionBootstrap = new RegionBootstrap(this, new AltBeaconOrg.BoundBeacon.Region(BEACONS_REGION_HEADER, null, null, null));
            _powerSaver      = new BackgroundPowerSaver(this);

            RegisterActivityLifecycleCallbacks(this);

            _rangeNotifier = new RangeNotifier();

            //iBeacon
            _beaconManager.BeaconParsers.Add(new BeaconParser().SetBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));

            //Estimote
            _beaconManager.BeaconParsers.Add(new BeaconParser().SetBeaconLayout(BeaconParser.EddystoneUidLayout));
            _beaconManager.BeaconParsers.Add(new BeaconParser().SetBeaconLayout(BeaconParser.EddystoneTlmLayout));

            _beaconManager.BeaconParsers.Add(new BeaconParser().SetBeaconLayout(BeaconParser.EddystoneUrlLayout));

            _beaconManager.Bind(this);
        }
        /// <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 override void OnCreate()
        {
            base.OnCreate();

            var beaconManager = BeaconManager.GetInstanceForApplication(this);

            // By default the AndroidBeaconLibrary will only find AltBeacons.  If you wish to make it
            // find a different type of beacon, you must specify the byte layout for that beacon's
            // advertisement with a line like below.  The example shows how to find a beacon with the
            // same byte layout as AltBeacon but with a beaconTypeCode of 0xaabb.  To find the proper
            // layout expression for other beacon types, do a web search for "setBeaconLayout"
            // including the quotes.
            //
            //beaconManager.getBeaconParsers().clear();
            //beaconManager.getBeaconParsers().add(new BeaconParser().
            //        setBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
            //
            // Estimote
            // iBeacons
            //beaconManager.getBeaconParsers().add(new BeaconParser().
            //	      setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));

            var altBeaconParser = new BeaconParser();

            altBeaconParser.SetBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25");
            beaconManager.BeaconParsers.Add(altBeaconParser);

            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);

            Debug.WriteLine("setting up background monitoring for beacons and power saving", TAG);

            // wake up the app when a beacon is seen
            var region = new Region("backgroundRegion", null, null, null);

            regionBootstrap = new RegionBootstrap(this, region);

            // 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);

            // If you wish to test beacon detection in the Android Emulator, you can use code like this:
            //BeaconManager.BeaconSimulator = new TimedBeaconSimulator();
            //if (BeaconManager.BeaconSimulator is TimedBeaconSimulator simulator) {
            //	//simulator.CreateTimedSimulatedBeacons();
            //	simulator.CreateBasicSimulatedBeacons();
            //}
        }
Пример #4
0
        public override void OnCreate()
        {
            base.OnCreate();
            Log.Debug(TAG, "App started up");
            InitialiseBeacons();


            // wake up the app when any beacon is seen (you can specify specific id filers in the parameters below)
            var region = new Region("com.wws.boostrapRegion", null, null, null);

            regionBootstrap = new RegionBootstrap(this, region);


            Log.Debug(TAG, "finished OnCreate");
        }
		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);
		}
        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);
        }