Example #1
0
        internal static AndroidBthDeviceInfo CreateFromBondedList(AndroidBthFactoryBase fcty, BluetoothDevice dev)
        {
            var bdi = new AndroidBthDeviceInfo(fcty, dev);

            bdi._rmbd = bdi._authd = true;
            return(bdi);
        }
Example #2
0
        internal static AndroidBthDeviceInfo CreateFromInquiry(
            AndroidBthFactoryBase fcty, BluetoothDevice dev,
            BluetoothClass cod, string nameOpt, short rssiOpt)
        {
            var bdi = new AndroidBthDeviceInfo(fcty, dev);

            bdi._discoTime   = DateTime.UtcNow;
            bdi._cod         = AndroidBthUtils.ConvertCoDs(cod);
            bdi._rssiAtDisco = rssiOpt;
            Debug.Assert(bdi._dev.Name == nameOpt);
            return(bdi);
        }
        protected override List <IBluetoothDeviceInfo> GetKnownRemoteDeviceEntries()
        {
            // "If Bluetooth state is not STATE_ON, this API will return an empty set."
            // "Returns: unmodifiable set of BluetoothDevice, or null on error"
            var knownDevs = _fcty.GetAdapter().BondedDevices;

            if (knownDevs == null)
            {
                throw new InvalidOperationException("Failed to get the known devices.");
            }
            var known = from x in knownDevs
                        select(IBluetoothDeviceInfo)
                        AndroidBthDeviceInfo.CreateFromBondedList(_fcty, x);

            return(known.ToList());
        }
Example #4
0
        internal static AndroidBthDeviceInfo CreateFromGivenAddress(
            AndroidBthFactoryBase fcty, BluetoothAddress address,
            bool queryOrInternalOnly)
        {
            BluetoothAdapter a = fcty.GetAdapter();
            var dev            = a.GetRemoteDevice(AndroidBthUtils.FromBluetoothAddress(address));
            var bdi            = new AndroidBthDeviceInfo(fcty, dev);

            //
            if (queryOrInternalOnly)
            {
                bdi._rmbd = bdi._authd = (dev.BondState == Bond.Bonded);
                var cod = dev.BluetoothClass;
                if (cod != null)
                {
                    bdi._cod = AndroidBthUtils.ConvertCoDs(cod);
                }
            }
            return(bdi);
        }
Example #5
0
 //
 public override void OnReceive(Context context, Intent intent)
 {
     //Toast.MakeText (context, "Received intent: '"
     //  + intent.Action + "'",
     //  ToastLength.Long).Show ();
     if (intent.Action == BluetoothAdapter.ActionDiscoveryStarted)
     {
         //
     }
     else if (intent.Action == MyFakeActionFound ||
              intent.Action == BluetoothDevice.ActionFound)
     {
         var objD = intent.GetParcelableExtra(BluetoothDevice.ExtraDevice);
         var dev  = (BluetoothDevice)objD;
         if (!_parent._handlerActive)
         {
             // ActionFound occurs if any installed app/system runs inquiry.
         }
         else
         {
             var    objC              = intent.GetParcelableExtra(BluetoothDevice.ExtraClass);
             var    cod               = (BluetoothClass)objC;
             var    foo               = intent.GetStringExtra("foo");
             string optName           = intent.GetStringExtra(BluetoothDevice.ExtraName);
             short  optRssi           = intent.GetShortExtra(BluetoothDevice.ExtraRssi, Int16.MinValue);
             AndroidBthDeviceInfo bdi = AndroidBthDeviceInfo.CreateFromInquiry(
                 _parent._fcty,
                 dev, cod, optName, optRssi);
             _parent.HandleInquiryResultInd(bdi);
         }
     }
     else if (intent.Action == BluetoothAdapter.ActionDiscoveryFinished)
     {
         int?numResponses = null;
         _parent._handlerActive = false;
         _parent.HandleInquiryComplete(numResponses);
     }
 }
 internal AndroidBthDeviceInfo DoGetBluetoothDeviceInfoInternalOnly(BluetoothAddress address)
 {
     return(AndroidBthDeviceInfo.CreateFromGivenAddress(this, address, false));
 }
 //--
 protected override IBluetoothDeviceInfo GetBluetoothDeviceInfo(BluetoothAddress address)
 {
     return(AndroidBthDeviceInfo.CreateFromGivenAddress(this, address, true));
 }