Пример #1
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");
            }
        }
Пример #2
0
        void GetInfo(ref BluetoothAddress addr)
        {
            BtSdkError ret;
            var        props = new Structs.BtSdkRemoteDevicePropertyStru();

            ret = _factory.Api.Btsdk_GetRemoteDeviceProperty(_hDev, out props);
            BluesoleilUtils.CheckAndThrow(ret, "Btsdk_GetRemoteDeviceProperty");
            //
            if ((props.mask & Structs.BtSdkRemoteDevicePropertyStru.Mask.Handle) != 0)
            {
                Debug.Assert(_hDev == props.dev_hdl, "hDev");
            }
            else
            {
                Debug.Fail("Handle unknown?!?");
            }
            if ((props.mask & Structs.BtSdkRemoteDevicePropertyStru.Mask.Address) != 0)
            {
                addr = BluesoleilUtils.ToBluetoothAddress(props.bd_addr);
            }
            if ((props.mask & Structs.BtSdkRemoteDevicePropertyStru.Mask.Class) != 0)
            {
                _cod = new ClassOfDevice(props.dev_class);
            }
            if ((props.mask & Structs.BtSdkRemoteDevicePropertyStru.Mask.Name) != 0)
            {
                Debug.Assert(props.name.Length == StackConsts.BTSDK_DEVNAME_LEN,
                             "props.name.Length: " + props.name.Length + ", BTSDK_DEVNAME_LEN: " + StackConsts.BTSDK_DEVNAME_LEN);
                string name = BluesoleilUtils.FromNameString(props.name);
                _cachedName = name;
            }
            if ((props.mask & Structs.BtSdkRemoteDevicePropertyStru.Mask.LmpInfo) != 0)
            {
                var fs = (LmpFeatures)BitConverter.ToInt64(props.lmp_info.lmp_feature, 0);
                var v  = new RadioVersions(props.lmp_info.lmp_version, props.lmp_info.lmp_subversion,
                                           fs, props.lmp_info.manuf_name);
                _versions = v;
            }
            //props.
        }
Пример #3
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);
        }