Esempio n. 1
0
 //--------
 internal /*and protected*/ BluetoothWin32RadioEventArgs(BLUETOOTH_DEVICE_INFO bdi0)
 {
     _bdiWin = new WindowsBluetoothDeviceInfo(bdi0);
     _bdi    = new BluetoothDeviceInfo(_bdiWin);
 }
Esempio n. 2
0
        private void DoDevTypHandle(ref Message m, ref String text)
        {
#if DEBUG
            WindowsBluetoothDeviceInfo dev = null;
#endif
            DEV_BROADCAST_HANDLE hdrHandle = (DEV_BROADCAST_HANDLE)m.GetLParam(typeof(DEV_BROADCAST_HANDLE));
            var pData = Utils.Pointers.Add(m.LParam, _OffsetOfData);
            if (BluetoothDeviceNotificationEvent.BthPortDeviceInterface == hdrHandle.dbch_eventguid)
            {
                text += "GUID_BTHPORT_DEVICE_INTERFACE";
            }
            else if (BluetoothDeviceNotificationEvent.RadioInRange == hdrHandle.dbch_eventguid)
            {
                text += "GUID_BLUETOOTH_RADIO_IN_RANGE";
                BTH_RADIO_IN_RANGE inRange
                      = (BTH_RADIO_IN_RANGE)Marshal.PtrToStructure(pData, typeof(BTH_RADIO_IN_RANGE));
                text += String.Format(System.Globalization.CultureInfo.InvariantCulture,
                                      " 0x{0:X12}", inRange.deviceInfo.address);
                text += String.Format(System.Globalization.CultureInfo.InvariantCulture,
                                      " is ({0}) 0x{0:X}", inRange.deviceInfo.flags);
                text += String.Format(System.Globalization.CultureInfo.InvariantCulture,
                                      " was ({0}) 0x{0:X}", inRange.previousDeviceFlags);
                var bdi0 = BLUETOOTH_DEVICE_INFO.Create(inRange.deviceInfo);
                var e    = BluetoothWin32RadioInRangeEventArgs.Create(
                    inRange.previousDeviceFlags,
                    inRange.deviceInfo.flags, bdi0);
#if DEBUG
                dev = new WindowsBluetoothDeviceInfo(bdi0);
                Debug.WriteLine("InRange: " + dev.DeviceAddress);
#endif
                RaiseInRange(e);
            }
            else if (BluetoothDeviceNotificationEvent.RadioOutOfRange == hdrHandle.dbch_eventguid)
            {
                BTH_RADIO_OUT_OF_RANGE outOfRange
                      = (BTH_RADIO_OUT_OF_RANGE)Marshal.PtrToStructure(pData, typeof(BTH_RADIO_OUT_OF_RANGE));
                text += "GUID_BLUETOOTH_RADIO_OUT_OF_RANGE";
                text += String.Format(System.Globalization.CultureInfo.InvariantCulture,
                                      " 0x{0:X12}", outOfRange.deviceAddress);
                var e = BluetoothWin32RadioOutOfRangeEventArgs.Create(
                    outOfRange.deviceAddress);
                Debug.WriteLine("OutOfRange: " + outOfRange.deviceAddress);
                RaiseOutOfRange(e);
            }
            else if (BluetoothDeviceNotificationEvent.PinRequest == hdrHandle.dbch_eventguid)
            {
                text += "GUID_BLUETOOTH_PIN_REQUEST";
                // "This message should be ignored by the application.
                //  If the application must receive PIN requests, the
                //  BluetoothRegisterForAuthentication function should be used."
            }
            else if (BluetoothDeviceNotificationEvent.L2capEvent == hdrHandle.dbch_eventguid)
            {
                text += "GUID_BLUETOOTH_L2CAP_EVENT";
                // struct BTH_L2CAP_EVENT_INFO {
                //   BTH_ADDR bthAddress; USHORT psm; UCHAR connected; UCHAR initiated; }
#if DEBUG
                var l2capE = Marshal_PtrToStructure <BTH_L2CAP_EVENT_INFO>(pData);
                Debug.WriteLine(string.Format(CultureInfo.InvariantCulture,
                                              "L2CAP_EVENT: addr: {0:X}, psm: {1}, conn: {2}, init'd: {3}",
                                              l2capE.bthAddress, l2capE.psm, l2capE.connected, l2capE.initiated));
#endif
            }
            else if (BluetoothDeviceNotificationEvent.HciEvent == hdrHandle.dbch_eventguid)
            {
                text += "GUID_BLUETOOTH_HCI_EVENT";
                // struct BTH_HCI_EVENT_INFO {
                //   BTH_ADDR bthAddress; UCHAR connectionType; UCHAR connected; }
#if DEBUG
                var hciE = Marshal_PtrToStructure <BTH_HCI_EVENT_INFO>(pData);
                Debug.WriteLine(string.Format(CultureInfo.InvariantCulture,
                                              "HCI_EVENT: addr: {0:X}, type: {1}, conn: {2}",
                                              hciE.bthAddress, hciE.connectionType, hciE.connected));
#endif
            }
            // -- New somewhere after WinXP.
            else if (BluetoothDeviceNotificationEvent.AuthenticationRequestEvent == hdrHandle.dbch_eventguid)
            {
                text += "GUID_BLUETOOTH_AUTHENTICATION_REQUEST";
                // Same content as BluetoothRegisterForAuthenticationEx
            }
            else if (BluetoothDeviceNotificationEvent.KeyPressEvent == hdrHandle.dbch_eventguid)
            {
                text += "GUID_BLUETOOTH_KEYPRESS_EVENT";
                // struct BTH_HCI_KEYPRESS_INFO {
                //   BTH_ADDR  BTH_ADDR; UCHAR   NotificationType; // HCI_KEYPRESS_XXX value }
            }
            else if (BluetoothDeviceNotificationEvent.HciVendorEvent == hdrHandle.dbch_eventguid)
            {
                text += "GUID_BLUETOOTH_HCI_VENDOR_EVENT";
            }
            // -- Unknown
            else
            {
                text += "Unknown event: " + hdrHandle.dbch_eventguid;
            }
            Debug.WriteLine("Text: " + text);
        }