public void StartMonitoring(string uuid, double major, double minor, string identifier)
        {
            if (IsMonitoringBeacons)
            {
                return;
            }

            // save region details
            this.uuid       = uuid;
            this.major      = major;
            this.minor      = minor;
            this.identifier = identifier;

            // initiate service
            if (!isBinded)
            {
                InitializeService();
            }

            if (!isServiceBound)
            {
                // service not bound.
                // this happened because we just started the service. Wait for OnBeaconServiceConnect event on MainActivity
                isStartMonitoringRequested = true;
                return;
            }

            // check bluetooh
            CheckBluetoothEnabled();

            // start monitoring
            if (major == 0 && minor == 0)
            {
                _tagRegion = new Region(identifier, Identifier.Parse(uuid), null, null);
            }
            else
            {
                _tagRegion = new Region(identifier, Identifier.Parse(uuid), Identifier.FromInt((int)major),
                                        Identifier.FromInt((int)minor));
            }

            BeaconManagerImpl.ForegroundBetweenScanPeriod = 1000;

            BeaconManagerImpl.AddMonitorNotifier(_monitorNotifier);
            _beaconManager.StartMonitoringBeaconsInRegion(_tagRegion);

            _beaconManager.StartMonitoringBeaconsInRegion(_tagRegion);

            BeaconManagerImpl.AddRangeNotifier(_rangeNotifier);
            _beaconManager.StartRangingBeaconsInRegion(_tagRegion);

            IsMonitoringBeacons = true;

            Log.Debug("FLBEACON", "StartMonitoring");

            logService.WriteToLog(LOG_FILENAME, "StartMonitoring");
        }
Exemplo n.º 2
0
        public void StartMonitoring(string uuid, double major, double minor, string identifier)
        {
            if (IsMonitoringBeacons)
            {
                return;
            }

            // save region details
            this._uuid       = uuid;
            this._major      = major;
            this._minor      = minor;
            this._identifier = identifier;

            // initiate service
            if (!_isBinded)
            {
                InitializeService();
            }

            //if (!_isServiceBound)
            //{
            //    // service not bound.
            //    // this happened because we just started the service. Wait for OnBeaconServiceConnect event on MainActivity
            //    _isStartMonitoringRequested = true;
            //    return;
            //}


            // start monitoring
            if (major == 0 && minor == 0)
            {
                _tagRegion = new Region(identifier, Identifier.Parse(uuid), null, null);
            }
            else
            {
                _tagRegion = new Region(identifier, Identifier.Parse(uuid), Identifier.FromInt((int)major),
                                        Identifier.FromInt((int)minor));
            }

            BeaconManagerImpl.ForegroundBetweenScanPeriod = 1000;

            BeaconManagerImpl.AddMonitorNotifier(_monitorNotifier);
            _beaconManager.StartMonitoringBeaconsInRegion(_tagRegion);

            BeaconManagerImpl.AddRangeNotifier(_rangeNotifier);
            _beaconManager.StartRangingBeaconsInRegion(_tagRegion);

            IsMonitoringBeacons = true;
        }