Cannot change bluetooth Radio Mode after manuall setting

Topics: Bluetooth - Microsoft, Samples
Feb 13, 2012 at 11:20 AM

Hello,

I am writing a windows service code in c# that will prevent from a user to set the "Turn discovery on" and "Allow Bluetooth devices to connect to this computer" in the Bluetooth Devices options window on windows XP/windows 7 OS. However, when the "Turn discovery on" is set from this Bluetooth Devices window I cannot change the radio mode from my service (or any application I've wrote) using the InTheHand library.

it stays always on "Discoverable" mode no matter what I do, unless I unchecked it in the Bluetooth Devices window.

If the "Turn discovery on" is not checked everything is working well PowerOff/Connectable/Discoverable are set properly.

I assume that the Bluetooth stack is somehow holding this state.

My simple code is:

if (InTheHand.Net.Bluetooth.BluetoothRadio.IsSupported == true)
            {
           
                InTheHand.Net.Bluetooth.BluetoothRadio.PrimaryRadio.Mode = InTheHand.Net.Bluetooth.RadioMode.PowerOff;
            
            }

 

What can I do to force this radio mode change.

Thanks in advance,

Developer
Feb 13, 2012 at 8:19 PM

Huhhh & Woww.  I just tested and saw the same!  I've never seen that before.  I wonder if its new behaviour in Windows 7 (or Vista).

I note also text in MSDN I've never seen/noticed before: "When BluetoothEnableDiscovery changes the discovery state, the new state is valid for the lifetime of the calling application. Additionally ... ..." http://msdn.microsoft.com/en-us/library/windows/desktop/aa362776(v=vs.85).aspx

I can't find a direct workaround so far.  For your situation I'd suggest looking at the device/hardware control APIs to disable the Bluetooth device instead of just setting the 'incoming' and 'discoverable' flags.  Note that our 'PowerOff' is a bit of a misnomer in desktop Windows case it really mean: { incoming=false, discoveravble=false, powerOn=true } (it is largely correct on WinCE).

Developer
Feb 13, 2012 at 8:20 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Developer
Feb 13, 2012 at 8:22 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.