The main interface of Sensorberg SDK.
Пример #1
0
 /// <summary>
 /// Returns the singleton instance of this class.
 /// </summary>
 /// <returns>The singleton instance of this class.</returns>
 public static SDKManager Instance()
 {
     _logger.Debug("Instance");
     if (_instance == null)
     {
         _instance = new SDKManager();
     }
     if (_instance.Configuration == null)
     {
         _instance.Configuration = new SdkConfiguration();
     }
     return(_instance);
 }
Пример #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public MainPage()
        {
            this.InitializeComponent();

            LogEntryItemCollection = new ObservableCollection<LogEntryItem>();

            _sdkManager = SDKManager.Instance();
            _sdkManager.ScannerStatusChanged += OnScannerStatusChangedAsync;
            _sdkManager.BeaconActionResolved += OnBeaconActionResolvedAsync;

            // Listening to the following events is not necessary, but provides interesting data for our log
            _sdkManager.Scanner.BeaconEvent += OnBeaconEventAsync;
            _sdkManager.FailedToResolveBeaconAction += OnFailedToResolveBeaconActionAsync;

            Window.Current.VisibilityChanged += _sdkManager.OnApplicationVisibilityChanged;
        }
Пример #3
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("MainPage.OnNavigatedTo()");
            base.OnNavigatedTo(e);

            if (_sdkManager == null)
            {
                _sdkManager = SDKManager.Instance(ManufacturerId, BeaconCode);
                _sdkManager.ScannerStatusChanged += OnScannerStatusChangedAsync;
                _sdkManager.LayoutValidityChanged += OnBeaconLayoutValidityChanged;
                _sdkManager.BackgroundFiltersUpdated += OnBackgroundFiltersUpdatedAsync;
            }

            BeaconAction pendingBeaconAction = BeaconAction.FromNavigationEventArgs(e);

            if (pendingBeaconAction != null)
            {
                _sdkManager.ClearPendingActions();

                if (await pendingBeaconAction.LaunchWebBrowserAsync())
                {
                    Application.Current.Exit();
                }
                else
                {
                    OnBeaconActionResolvedAsync(this, pendingBeaconAction);
                }
            }

            LoadApplicationSettings();
            ValidateApiKeyAsync();

            if (_advertiser == null)
            {
                _advertiser = new Advertiser();
                _advertiser.ManufacturerId = ManufacturerId;
                _advertiser.BeaconCode = BeaconCode;
            }

            toggleScanButton.IsEnabled = false;
            HookScannerEvents();
            _sdkManager.StartScanner();

            Window.Current.VisibilityChanged += OnVisibilityChanged;
        }
Пример #4
0
        /// <summary>
        /// Returns the singleton instance of this class.
        /// </summary>
        /// <param name="manufacturerId">The manufacturer ID of beacons to watch.</param>
        /// <param name="beaconCode">The beacon code of beacons to watch.</param>
        /// <returns>The singleton instance of this class.</returns>
		public static SDKManager Instance(UInt16 manufacturerId, UInt16 beaconCode)
        {
            if (_instance == null)
            {
                _instance = new SDKManager();
            }

            _instance.ManufacturerId = manufacturerId;
            _instance.BeaconCode = beaconCode;

            return _instance;
        }
Пример #5
0
 /// <summary>
 /// Returns the singleton instance of this class.
 /// </summary>
 /// <returns>The singleton instance of this class.</returns>
 public static SDKManager Instance()
 {
     _logger.Debug("Instance");
     if (_instance == null)
     {
         _instance = new SDKManager();
     }
     if (_instance.Configuration == null)
     {
         _instance.Configuration = new SdkConfiguration();
     }
     return _instance;
 }