private static void OnGetPositionComplete(IAsyncResult result)
        {
            // Get the radiomapContext back from the stored state.
            snifferContext = result.AsyncState as SnifferModel;
            try
            {
                WifiSnifferPositioningService.PositionEstimate newPos = snifferContext.EndExecute <WifiSnifferPositioningService.PositionEstimate>(result).FirstOrDefault();
                PreviousPositionEstimate = CurrentPositionEstimate;
                CurrentPositionEstimate  = newPos;
                if (CurrentPositionEstimate != null)
                {
                    //We notify about a new building in any of these two scenarios:
                    //1) This is the first estimate after starting positioning.
                    //2) The building id of the current estimate differs from the previous
                    bool arrivedAtNewBuilding = PreviousPositionEstimate != null && CurrentPositionEstimate != null && CurrentPositionEstimate.Building_ID != PreviousPositionEstimate.Building_ID;
                    if (!_hasReceivedWifiPosition || arrivedAtNewBuilding)
                    {
                        _hasReceivedWifiPosition = true;
                        OnBuildingIdentificationStatusChanged(null, new BuildingIdentificationEventArgs(true, CurrentPositionEstimate.Building_ID));
                    }

                    OnPositionEstimateChanged(null, new PositionEstimateEventArgs(CurrentPositionEstimate));

                    if (AllowTracking)
                    {
                        AddToTrackedPositions(newPos);
                    }
                }
            }
            catch (DataServiceQueryException) { }
        }
Beispiel #2
0
        public WifiScanForm()
        {
            InitializeComponent();
            InitializeMenu();
            InitializeUploadDialog();

            _macAddress = LocationService.MacAddress;
            context     = new SnifferModel(snifferUri);
            SetState(MeasurementState.NotStarted);
        }
 public static void initializeSniffer()
 {
     snifferContext = new SnifferModel(snifferUri);
 }