Inheritance: Android.Bluetooth.BluetoothGattCallback, IGattCallback
示例#1
0
        public Adapter(BluetoothAdapter adapter)
        {
            _bluetoothAdapter       = adapter;
            DeviceOperationRegistry = new Dictionary <string, IDevice>();
            ConnectedDeviceRegistry = new Dictionary <string, IDevice>();

            // TODO: bonding
            //var bondStatusBroadcastReceiver = new BondStatusBroadcastReceiver();
            //Application.Context.RegisterReceiver(bondStatusBroadcastReceiver,
            //    new IntentFilter(BluetoothDevice.ActionBondStateChanged));

            ////forward events from broadcast receiver
            //bondStatusBroadcastReceiver.BondStateChanged += (s, args) =>
            //{
            //    //DeviceBondStateChanged(this, args);
            //};

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
            {
                _api21ScanCallback = new Api21BleScanCallback(this);
            }
            else
            {
                _api18ScanCallback = new Api18BleScanCallback(this);
            }

            _gattCallback = new GattCallback(this);
        }
示例#2
0
 public Device(Adapter adapter, BluetoothDevice nativeDevice, BluetoothGatt gatt, int rssi, byte[] advertisementData = null) : base(adapter)
 {
     Update(nativeDevice, gatt);
     Rssi = rssi;
     AdvertisementRecords = ParseScanRecord(advertisementData);
     _gattCallback        = new GattCallback(adapter, this);
 }