Exemplo n.º 1
0
 internal BOND_RETURN_CODE Bond_(BluetoothAddress device, string pin)
 {
     Utils.MiscUtils.Trace_WriteLine("Calling CBtIf:Bond...");
     BOND_RETURN_CODE ret = _factory.GetWidcommBtInterface().Bond(device, pin);
     Utils.MiscUtils.Trace_WriteLine("Bond returned: {0} = 0x{1:X}", ret, (int)ret);
     return ret;
 }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
 public bool PairRequest(BluetoothAddress device, string pin)
 {
     // Win32+MSFT supports pin=null to show the UI, Widcomm has no 
     // support for that, so copy what we do in CE/WM and fail here.
     if (pin == null) {
         throw new ArgumentNullException("pin");
     }
     BOND_RETURN_CODE ret = Bond_(device, pin);
     Debug.Assert((ret == BOND_RETURN_CODE.SUCCESS)
             || (ret == BOND_RETURN_CODE.ALREADY_BONDED)
             || (ret == BOND_RETURN_CODE.FAIL),
         "Unexpected Bond result: " + ret);
     return (ret == BOND_RETURN_CODE.SUCCESS)
             || (ret == BOND_RETURN_CODE.ALREADY_BONDED);
 }