Пример #1
0
        internal static BluesoleilDeviceInfo CreateFromHandleFromStored(uint hDev, BluesoleilFactory factory)
        {
            var result = new BluesoleilDeviceInfo(hDev, factory);

            result._remembered = true;
            return(result);
        }
Пример #2
0
 //----
 internal BluesoleilClient(BluesoleilFactory fcty)
 {
     if (fcty == null)
     {
         throw new ArgumentNullException("fcty");
     }
     _factory          = fcty;
     _beginConnectDlgt = new Action <BluetoothEndPoint>(Connect);
 }
 internal BlueSoleilSerialPortNetworkStream(ISerialPortWrapper port, UInt32 hConn,
                                            BluesoleilClient cli, BluesoleilFactory factory)
     : base(port, cli)
 {
     _hConn = hConn;
     // (Don't need Cli?)
     _factory = factory;
     //
     _state             = State.Connected;
     port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
 }
Пример #4
0
        internal static BluesoleilDeviceInfo CreateFromHandleFromInquiry(uint hDev, BluesoleilFactory factory)
        {
            var result = new BluesoleilDeviceInfo(hDev, factory);

            Debug.Assert(result._remembered == false, "NOT !_remembered, we don't set it, does the stack set it?");
            if (result.Authenticated)
            {
                result._remembered = true;
            }
            return(result);
        }
Пример #5
0
        internal BluesoleilRadio(BluesoleilFactory fcty)
        {
            _fcty = fcty;
            _fcty.SdkInit();
            BtSdkError retAddr, ret;

            byte[] bd_addr = new byte[StackConsts.BTSDK_BDADDR_LEN];
            ret = retAddr = _fcty.Api.Btsdk_GetLocalDeviceAddress(bd_addr);
            BluesoleilUtils.Assert(retAddr, "Btsdk_GetLocalDeviceAddress");
            if (ret == BtSdkError.OK)
            {
                _addr = BluesoleilUtils.ToBluetoothAddress(bd_addr);
            }
            else
            {
                _addr = BluetoothAddress.None;
            }
            //
            byte[] arr = new byte[500];
            UInt16 len = checked ((UInt16)arr.Length);

            ret = _fcty.Api.Btsdk_GetLocalName(arr, ref len);
            if (retAddr == BtSdkError.OK)
            {
                BluesoleilUtils.Assert(ret, "Btsdk_GetLocalName");
            }
            if (ret == BtSdkError.OK)
            {
                _name = BluesoleilUtils.FromNameString(arr, len);
            }
            else
            {
                _name = string.Empty;
            }
            //
            uint cod;

            ret = _fcty.Api.Btsdk_GetLocalDeviceClass(out cod);
            //BluesoleilUtils.CheckAndThrow(ret);
            if (retAddr == BtSdkError.OK)
            {
                Debug.Assert(ret == BtSdkError.OK, "Btsdk_GetLocalDeviceClass ret: " + ret);
            }
            _cod = new ClassOfDevice(cod);
            //
            _lmp = new Structs.BtSdkLocalLMPInfoStru(HciVersion.Unknown);
            ret  = _fcty.Api.Btsdk_GetLocalLMPInfo(ref _lmp);
            if (retAddr == BtSdkError.OK)
            {
                BluesoleilUtils.Assert(ret, "Btsdk_GetLocalLMPInfo");
            }
        }
Пример #6
0
        internal static void FreeComIndex(BluesoleilFactory factory, int comNum, uint comSerialNum)
        {
            Debug.WriteLine(string.Format(CultureInfo.InvariantCulture,
                                          "BluesoleilClient.FreeComIndex IN: comNum: {0}, comSerialNum: {1}",
                                          comNum, comSerialNum));
            BtSdkError ret;
            var        comNum8 = checked ((byte)comNum);

            ret = factory.Api.Btsdk_DeinitCommObj(comNum8);
            BluesoleilUtils.Assert(ret, "Btsdk_DeinitCommObj");
            factory.Api.Btsdk_PlugOutVComm(comSerialNum, StackConsts.COMM_SET.Record);
            Debug.WriteLine(string.Format(CultureInfo.InvariantCulture,
                                          "BluesoleilClient.FreeComIndex OUT: Btsdk_DeinitCommObj ret: {0}", ret));
        }
Пример #7
0
        private BluesoleilDeviceInfo(UInt32 hDev, BluesoleilFactory factory)
        {
            if (factory == null)
            {
                throw new ArgumentNullException("factory");
            }
            _factory = factory;
            BtSdkError ret;

            _hDev = hDev;
            //
            byte[] bd_addr = new byte[StackConsts.BTSDK_BDADDR_LEN];
            ret = factory.Api.Btsdk_GetRemoteDeviceAddress(_hDev, bd_addr);
            BluesoleilUtils.CheckAndThrow(ret, "Btsdk_GetRemoteDeviceAddress");
            if (ret != BtSdkError.OK)   // Not known/present(?).
            {
                return;
            }
            _addr = BluesoleilUtils.ToBluetoothAddress(bd_addr);
            //
            uint cod;

            ret = factory.Api.Btsdk_GetRemoteDeviceClass(_hDev, out cod);
            if (ret != BtSdkError.OK)   // Not known/present(?).
            {
                return;
            }
            _cod = new ClassOfDevice(cod);
            //
            ret = _factory.Api.Btsdk_IsDevicePaired(_hDev, out _paired);
            Debug.Assert(ret == BtSdkError.OK, "Btsdk_IsDevicePaired ret: " + ret);
            //
            _connected = _factory.Api.Btsdk_IsDeviceConnected(_hDev);
            //
            GetInfo(ref _addr);
        }
 internal BlueSoleilSerialPortNetworkStream(SerialPort port, UInt32 hConn,
                                            BluesoleilClient cli, BluesoleilFactory factory)
     : this(new SerialPortWrapper(port), hConn, cli, factory)
 {
 }
Пример #9
0
        internal static List <IBluetoothDeviceInfo> CreateFromInquiryHandles(List <uint> discoverableHandles, BluesoleilFactory factory)
        {
            List <IBluetoothDeviceInfo> result = new List <IBluetoothDeviceInfo>(discoverableHandles.Count);

            foreach (var hCur in discoverableHandles)
            {
                IBluetoothDeviceInfo bdi = CreateFromHandleFromInquiry(hCur, factory);
                result.Add(bdi);
            }
            return(result);
        }
Пример #10
0
        internal static BluesoleilDeviceInfo CreateFromHandleFromConnection(uint hDev, BluesoleilFactory factory)
        {
            var result = new BluesoleilDeviceInfo(hDev, factory);

            return(result);
        }
Пример #11
0
        //----
        internal static BluesoleilDeviceInfo CreateFromGivenAddress(BluetoothAddress addr, BluesoleilFactory factory)
        {
            UInt32 hDev;

            byte[] bd_addr = BluesoleilUtils.FromBluetoothAddress(addr);
            bool   remembered;

            hDev = factory.Api.Btsdk_GetRemoteDeviceHandle(bd_addr);
            if (hDev != StackConsts.BTSDK_INVALID_HANDLE)
            {
                remembered = true;
            }
            else
            {
                // Presumably this means that the device isn't known.
                // Does this add it forever? -- no???
                hDev = factory.Api.Btsdk_AddRemoteDevice(bd_addr);
                if (hDev == StackConsts.BTSDK_INVALID_HANDLE)
                {
                    BluesoleilUtils.CheckAndThrow(BtSdkError.SDK_UNINIT, "Btsdk_Get/AddRemoteDevice");
                }
                remembered = false;
            }
            var result = new BluesoleilDeviceInfo(hDev, factory);

            result._remembered = remembered;
            Debug.Assert(addr.Equals(result.DeviceAddress), "Address changed in create! was: "
                         + addr + ", now: " + result.DeviceAddress);
            return(result);
        }
Пример #12
0
 internal BluesoleilClient(BluesoleilFactory fcty, BluetoothEndPoint localEP)
     : this(fcty)
 {
     Debug.Fail("Ignoring localEP");
 }
Пример #13
0
 internal BluesoleilSecurity(BluesoleilFactory fcty)
 {
     _factory = fcty;
 }
Пример #14
0
 //----
 internal BluesoleilInquiry(BluesoleilFactory fcty)
 {
     _fcty = fcty;
 }