Esempio n. 1
0
        /// <summary>
        /// Wrapper around CBtIf::Bond().
        /// </summary>
        /// <param name="device"><see cref="BluetoothAddress"/></param>
        /// <param name="passcode"><see cref="T:System.String"/></param>
        /// <returns><see langword="true"/> if pairing was completed.
        /// <see langword="false"/> if were already paired, or pairing failed.
        /// </returns>
        private bool Bond(BluetoothAddress device, string passcode)
        {
            //bool pd = BluetoothSecurity.PairRequest(device, passcode);
            BOND_RETURN_CODE rc = ((WidcommBluetoothSecurity)m_factory.DoGetBluetoothSecurity()).Bond_(device, passcode);

            Log("Bond: " + rc);
            switch (rc)
            {
            case BOND_RETURN_CODE.SUCCESS:
                return(true);

            case BOND_RETURN_CODE.FAIL:
                // TODO ? BOND_RETURN_CODE.FAIL -> Report this in the exception?
                return(false);

            case BOND_RETURN_CODE.ALREADY_BONDED:
                // (BTW:"maintained for compatibility")
                return(false);

            case BOND_RETURN_CODE.REPEATED_ATTEMPTS:
                // What is this??
                return(false);

            case BOND_RETURN_CODE.BAD_PARAMETER:
                // TODO ? BOND_RETURN_CODE.BAD_PARAMETER -> Report this in the exception?
                return(false);

            case BOND_RETURN_CODE.NO_BT_SERVER:
            default:
                return(false);
            }
        }