Exemple #1
0
        //--------
#if !NETCF
        public static BLUETOOTH_DEVICE_INFO Create(BTH_DEVICE_INFO deviceInfo)
        {
            Debug.Assert(0 != (deviceInfo.flags & BluetoothDeviceInfoProperties.Address),
                         "BTH_DEVICE_INFO Address field flagged as empty!: " + deviceInfo.address.ToString("X12"));
            BLUETOOTH_DEVICE_INFO bdi0 = new BLUETOOTH_DEVICE_INFO(deviceInfo.address);

            //
            if (0 != (deviceInfo.flags & BluetoothDeviceInfoProperties.Cod))
            {
                bdi0.ulClassofDevice = deviceInfo.classOfDevice;
            }
            byte[] nameUtf8 = deviceInfo.name;
            if (0 != (deviceInfo.flags & BluetoothDeviceInfoProperties.Name))
            {
                int end = Array.IndexOf <byte>(nameUtf8, 0);
                if (end != -1)
                {
                    string name = Encoding.UTF8.GetString(nameUtf8, 0, end);
                    bdi0.szName = name;
                }
            }
            bdi0.fAuthenticated = 0 != (deviceInfo.flags & BluetoothDeviceInfoProperties.Paired);
            bdi0.fConnected     = 0 != (deviceInfo.flags & BluetoothDeviceInfoProperties.Connected);
            bdi0.fRemembered    = 0 != (deviceInfo.flags & BluetoothDeviceInfoProperties.Personal);
            //
            return(bdi0);
        }
Exemple #2
0
        private void ReadBlobBTH_DEVICE_INFO(byte[] buffer, IBluetoothDeviceInfo dev)
        {
            // XXXX - Testing only, at least delete the "Console.WriteLine" before use. - XXXX
            IntPtr pBlob = Marshal32.ReadIntPtr(buffer, WqsOffset.lpBlob_56);

            if (pBlob != IntPtr.Zero)
            {
                BLOB blob = (BLOB)Marshal.PtrToStructure(pBlob, typeof(BLOB));
                if (blob.pBlobData != IntPtr.Zero)
                {
                    BTH_DEVICE_INFO bdi = (BTH_DEVICE_INFO)Marshal.PtrToStructure(blob.pBlobData, typeof(BTH_DEVICE_INFO));
                    BluetoothDeviceInfoProperties flags = bdi.flags;
                    Debug.WriteLine(String.Format(CultureInfo.InvariantCulture, "[BTH_DEVICE_INFO: {0:X12}, '{1}' = 0x{2:X4}]", bdi.address, flags, bdi.flags));
                    Trace.Assert((flags & ~BDIFMasks.AllOrig) == 0, "*Are* new flags there!");
                }
            }
        }