Beispiel #1
0
        public CentralContext(IServiceProvider services, BleCentralConfiguration config)
        {
            this.services = services;

            var opts = new CBCentralInitOptions
            {
                ShowPowerAlert = config.iOSShowPowerAlert
            };

            if (!config.iOSRestoreIdentifier.IsEmpty())
            {
                opts.RestoreIdentifier = config.iOSRestoreIdentifier;
            }

            if (!PlatformExtensions.HasPlistValue("NSBluetoothPeripheralUsageDescription"))
            {
                Console.WriteLine("NSBluetoothPeripheralUsageDescription needs to be set - you will likely experience a native crash after this log");
            }

            if (!PlatformExtensions.HasPlistValue("NSBluetoothAlwaysUsageDescription", 13))
            {
                Console.WriteLine("NSBluetoothAlwaysUsageDescription needs to be set - you will likely experience a native crash after this log");
            }

            this.Manager = new CBCentralManager(this, null, opts);
        }
Beispiel #2
0
        public ManagerContext(IServiceProvider services,
                              BleConfiguration config,
                              ILogger <IBleManager> logger)
        {
            this.Services = services;
            this.logger   = logger;

            this.managerLazy = new Lazy <CBCentralManager>(() =>
            {
                if (!AppleExtensions.HasPlistValue("NSBluetoothPeripheralUsageDescription"))
                {
                    this.logger.LogCritical("NSBluetoothPeripheralUsageDescription needs to be set - you will likely experience a native crash after this log");
                }

                var background = services.GetService(typeof(IBleDelegate)) != null;
                if (!background)
                {
                    return(new CBCentralManager(this, null));
                }

                if (!AppleExtensions.HasPlistValue("NSBluetoothAlwaysUsageDescription", 13))
                {
                    this.logger.LogCritical("NSBluetoothAlwaysUsageDescription needs to be set - you will likely experience a native crash after this log");
                }

                var opts = new CBCentralInitOptions
                {
                    ShowPowerAlert    = config.iOSShowPowerAlert,
                    RestoreIdentifier = config.iOSRestoreIdentifier ?? "shinyble"
                };

                return(new CBCentralManager(this, null, opts));
            });
        }
        public IonCBCentralManagerDelegate(IION ion)
        {
            this.ion = ion;
            var options = new CBCentralInitOptions();

            options.ShowPowerAlert = false;

            centralManager = new CBCentralManager(this, new DispatchQueue("ION Bluetooth", true), options);
        }
        // Create Bluetooth Low Energy central object
        public void IntializeBluetoothCentralService()
        {
            // prepare init options
            CBCentralInitOptions initOptions = CreateInitOptions();

            //centralManagerDelegate = new BleCentralManagerDelegate();

            // create ble central object
            centralManager = new CBCentralManager(this, DispatchQueue.CurrentQueue, initOptions);
        }
Beispiel #5
0
        public IOSBluetooth(BTCallback btCallback)
        {
            cmDelegate         = new MyCentralmanagerDelegate(this);
            peripheralDelegate = new MyCBPeripheralDelegate(this);
            callback           = btCallback;
            CBCentralInitOptions opts = new CBCentralInitOptions();

            opts.ShowPowerAlert = false;
            centralManager      = new CBCentralManager(cmDelegate, null, opts);
        }
Beispiel #6
0
        static Bluetooth()
        {
            Debug.WriteLine("Bluetooth_ctor");
            CBCentralInitOptions options = new CBCentralInitOptions {
                ShowPowerAlert = true
#if __IOS__
//                ,  RestoreIdentifier = NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleName")?.ToString()
#endif
            };

            _manager = new CBCentralManager(_delegate, new DispatchQueue("com.inthehand.Bluetooth"), options);
        }
Beispiel #7
0
        public AdapterContext(BleAdapterConfiguration config)
        {
            var opts = new CBCentralInitOptions
            {
                ShowPowerAlert = config?.ShowPowerAlert ?? false,
#if __IOS__
                RestoreIdentifier = config?.RestoreIdentifier ?? "pluginbluetoothle"
#endif
            };

            this.Manager = new CBCentralManager(this, config?.DispatchQueue, opts);
        }
        public AdapterContext(BleAdapterConfiguration config)
        {
            config = config ?? new BleAdapterConfiguration();
            var opts = new CBCentralInitOptions
            {
                ShowPowerAlert = config.ShowPowerAlert
            };

            if (!config.RestoreIdentifier.IsEmpty())
            {
                opts.RestoreIdentifier = config.RestoreIdentifier;
            }

            this.Manager = new CBCentralManager(this, config.DispatchQueue, opts);
        }
Beispiel #9
0
        public AdapterContext(BleAdapterConfiguration config)
        {
            var opts = new CBCentralInitOptions
            {
                ShowPowerAlert = config.ShowPowerAlert
            };

#if __IOS__
            if (!config.RestoreIdentifier.IsEmpty())
            {
                opts.RestoreIdentifier = config?.RestoreIdentifier;
            }
#endif
            this.Manager = new CBCentralManager(this, config?.DispatchQueue, opts);
        }
Beispiel #10
0
        public AdapterContext(BleAdapterConfiguration config)
        {
            this.PeripheralManager = new CBPeripheralManager();
            var queue = config?.DispatchQueue ?? DispatchQueue.CurrentQueue;

            var opts = new CBCentralInitOptions
            {
                ShowPowerAlert = config?.ShowPowerAlert ?? false,
#if __IOS__
                RestoreIdentifier = config?.RestoreIdentifier ?? "acrble"
#endif
            };

            this.Manager = new CBCentralManager(this, queue, opts);
        }
Beispiel #11
0
        public CentralContext(IServiceProvider services, BleCentralConfiguration config)
        {
            this.services = services;

            var opts = new CBCentralInitOptions
            {
                ShowPowerAlert = config.iOSShowPowerAlert
            };

            if (!config.iOSRestoreIdentifier.IsEmpty())
            {
                opts.RestoreIdentifier = config.iOSRestoreIdentifier;
            }

            this.Manager = new CBCentralManager(this, null, opts);
        }
Beispiel #12
0
        static Bluetooth()
        {
            Debug.WriteLine("Bluetooth_ctor");
            CBCentralInitOptions options = new CBCentralInitOptions {
                ShowPowerAlert = true
#if __IOS__
//                ,  RestoreIdentifier = NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleName")?.ToString()
#endif
            };

            _manager = new CBCentralManager(_delegate, DispatchQueue.MainQueue, options);
            //_manager.UpdatedState += _manager_UpdatedState;
#if __IOS__
            //_manager.DiscoveredPeripheral += _manager_DiscoveredPeripheral;
            //_manager.RetrievedConnectedPeripherals += _manager_RetrievedConnectedPeripherals;
#endif
        }