private void AttachDevice() { // Lets get the primary Plantronics device (if any) and then register // for the device event handlers try { _device = _session.GetActiveDevice(); if (_device != null) { // display device information: OnSDKInfo(new SDKInfoArgs(SDKInfoType.sdk_device_attached, "Device attached: " + _device.ProductName + ", Product ID = " + _device.ProductId.ToString("X"))); _deviceListenerEvents = (ICOMDeviceListenerEvents_Event)_device.DeviceListener; if (_deviceListenerEvents != null) { _deviceListenerEvents.onHeadsetStateChanged += _deviceListenerEvents_onHeadsetStateChanged; _deviceListenerEvents.onATDStateChanged += _deviceListenerEvents_onATDStateChanged; OnSDKInfo(new SDKInfoArgs(SDKInfoType.sdk_notification, "Successfully hooked to device listener events")); } else { OnSDKInfo(new SDKInfoArgs(SDKInfoType.sdk_notification, "Unable to hook to device listener events")); } _deviceListener = _device.DeviceListener; // Obtain a DeviceListener object for later use _deviceComEvents = _device as ICOMDeviceEvents_Event; if (_deviceComEvents != null) { // Attach to device events _deviceComEvents.onButtonPressed += _deviceComEvents_onButtonPressed; _deviceComEvents.onMuteStateChanged += _deviceComEvents_onMuteStateChanged; _deviceComEvents.onDataReceived += _deviceComEvents_onDataReceived; _deviceComEvents.onAudioStateChanged += _deviceComEvents_onAudioStateChanged; OnSDKInfo(new SDKInfoArgs(SDKInfoType.sdk_notification, "AttachedEventHandler to device events")); } else { OnSDKInfo(new SDKInfoArgs(SDKInfoType.sdk_notification, "Error: unable to attach to device events")); } OnSDKInfo(new SDKInfoArgs(SDKInfoType.sdk_notification, "Device mute state: muted = " + _deviceListener.mute)); // Obtain initial device microphone mute state } else { OnSDKInfo(new SDKInfoArgs(SDKInfoType.sdk_notification, "Unable to retrieve active device")); } } catch (Exception) { OnSDKInfo(new SDKInfoArgs(SDKInfoType.sdk_notification, "Unable to retrieve/hook to active device")); } }
private static void AttachDevice() { // Lets get the primary Plantronics device (if any) and then register // for the device event handlers try { _device = _session.GetActiveDevice(); if (_device != null) { // display device information: Console.WriteLine("Device attached: " + _device.ProductName + ", Product ID = " + _device.ProductId.ToString("X")); _deviceListenerEvents = (ICOMDeviceListenerEvents_Event)_device.DeviceListener; if (_deviceListenerEvents != null) { _deviceListenerEvents.onHeadsetStateChanged += _deviceListenerEvents_onHeadsetStateChanged; Console.WriteLine("Successfully hooked to device listener events"); // Mobile Caller ID: onDataReceived event handler to receive BT600 mobile caller id _deviceComEvents = (ICOMDeviceEvents_Event)_session.GetActiveDevice(); if (_deviceComEvents != null) { _deviceComEvents.onDataReceived += _deviceComEvents_onDataReceived; } } else { Console.WriteLine("Unable to hook to device listener events"); } _deviceListener = _device.DeviceListener; // Obtain a DeviceListener object for later use Console.WriteLine("Device mute state: muted = " + _deviceListener.mute); // Obtain initial device microphone mute state } else { Console.WriteLine("Unable to retrieve active device"); } } catch (Exception) { Console.WriteLine("Unable to retrieve/hook to active device"); } }