Exemplo n.º 1
0
        protected override async Task StartListeningAsync()
        {
            await base.StartListeningAsync();

            SensusContext.Current.MainThreadSynchronizer.ExecuteThreadSafe(() =>
            {
                if (Beacons.Count > 0)
                {
                    _proximityObserver = new ProximityObserver(new CloudCredentials(EstimoteCloudAppId, EstimoteCloudAppToken), error =>
                    {
                        SensusServiceHelper.Get().Logger.Log("Error while initializing proximity observer:  " + error, LoggingLevel.Normal, GetType());
                    });

                    List <ProximityZone> beaconZones = new List <ProximityZone>();

                    foreach (EstimoteBeacon beacon in Beacons)
                    {
                        ProximityZone beaconZone = new ProximityZone(beacon.Tag, new ProximityRange(beacon.ProximityMeters))
                        {
                            OnEnter = async(triggeringDeviceAttachment) =>
                            {
                                await StoreDatumAsync(new EstimoteBeaconDatum(DateTimeOffset.UtcNow, beacon, EstimoteBeaconProximityEvent.Entered));
                            },

                            OnExit = async(triggeringDeviceAttachment) =>
                            {
                                await StoreDatumAsync(new EstimoteBeaconDatum(DateTimeOffset.UtcNow, beacon, EstimoteBeaconProximityEvent.Exited));
                            }
                        };

                        beaconZones.Add(beaconZone);
                    }

                    _proximityObserver.StartObservingZones(beaconZones.ToArray());
                }

                if (Location != null)
                {
                    EILRequestFetchLocation locationFetchRequest = new EILRequestFetchLocation(Location.Identifier);

                    locationFetchRequest.SendRequest((fetchedLocation, error) =>
                    {
                        if (error == null)
                        {
                            _foregroundIndoorLocationManager.StartPositionUpdatesForLocation(fetchedLocation);
                            _backgroundIndoorLocationManager.StartPositionUpdatesForLocation(fetchedLocation);
                            _indoorLocation = fetchedLocation;
                        }
                        else
                        {
                            SensusServiceHelper.Get().Logger.Log("Failed to fetch Estimote indoor location:  " + error, LoggingLevel.Normal, GetType());
                        }
                    });
                }
            });
        }
Exemplo n.º 2
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // get your app ID and token on:
            // https://cloud.estimote.com/#/apps/add/your-own-app
            var creds = new CloudCredentials("app ID", "app token");

            observer = new ProximityObserver(creds, (error) =>
            {
                Debug.WriteLine($"error = {error}");
            });

            var range = new ProximityRange(1.0);

            var zone1 = new ProximityZone("lobby", range)
            {
                OnEnter = (context) =>
                {
                    Debug.WriteLine($"zone1 enter, context = {context}");
                },
                OnExit = (context) =>
                {
                    Debug.WriteLine($"zone1 exit, context = {context}");
                },
                OnContextChange = (contexts) =>
                {
                    Debug.WriteLine($"zone1 contextChange, contexts = {contexts}");
                }
            };

            var zone2 = new ProximityZone("conf-room", range)
            {
                OnEnter = (context) =>
                {
                    Debug.WriteLine($"zone2 enter, context = {context}");
                },
                OnExit = (context) =>
                {
                    Debug.WriteLine($"zone2 exit, context = {context}");
                },
                OnContextChange = (contexts) =>
                {
                    Debug.WriteLine($"zone2 contextChange, contexts = {contexts}");
                }
            };

            observer.StartObservingZones(new ProximityZone[] { zone1, zone2 });

            Debug.WriteLine("Proximity all ready to go!");

            return(true);
        }
Exemplo n.º 3
0
 public BeaconScanner(ProximityObserver estimoteProximityObserver, string tag, Sector sector) : base(estimoteProximityObserver, tag, sector.Id, sector.Zone.Distance)
 {
     this.sector = sector;
 }
Exemplo n.º 4
0
 public ImplementationScanner(ProximityObserver estimoteProximityObserver, string tag, double distance) : base(estimoteProximityObserver, tag, Guid.Empty, distance)
 {
     this.distance = distance;
 }
Exemplo n.º 5
0
    IObservable <ObjectDetected> CustomObservable; //crear un observable basado de un subject

    public EstimoteProximityScanner(ProximityObserver estimoteProximityObserver, string tag, Guid id, double distance) : base(id, distance)
    {
        this.estimoteProximityObserver = estimoteProximityObserver;
        this.tag = tag;
    }
Exemplo n.º 6
0
 public SectorScanner(ProximityObserver estimoteProximityObserver, Implementation implementation) : base(implementation.Id, 0)
 {
     this.implementation            = implementation;
     this.estimoteProximityObserver = estimoteProximityObserver;
 }