The Microsoft Bluetooth stack on both desktop Windows and WM/CE uses sockets for RFCOMM communications, and they use socket options for both setting parameters and getting information. We use two of the options to implement the BluetoothClient and BluetoothListener Authenticate and Encrypt properties, and another on WM/CE for the SetPin method.
As these options are present only on the Microsoft platforms and even vary between the two platforms they aren’t very useful for production use, but they can be useful for diagnostics etc. We recently had a question in the forums and I knocked up a bit of code to run through all the options we’ve seen in MSDN and see what values they return. The code to run through all the known option is in our code repository at codeplex in the XxxMenuTesting suite of apps (Forms-/Device-/ConsoleMenuTesting) and uses reflection to get the list of options. I won’t reproduce that here due to its complexity, but a sample simple(!) call would be:
System.Net.Sockets.Socket sock = ... ...; System.Net.Sockets.SocketOptionName option; #if NETCF option = BluetoothSocketOptionName.GetMtu; #else option = BluetoothSocketOptionName.XPMtu; #endif var v = sock.GetSocketOption(BluetoothSocketOptionLevel.RFComm, option); var i = (int)v; console.WriteLine("Option MTU value: {0}=0x{0:X}", i);
Firstly the result from a WM device, when connected to Widcomm on Windows XP. We get fifteen successes there.
---- TryAllMsftSocketOptions ---- Option: Authenticate 1 : error: (10042) Option: XPAuthenticate 0x80000001 : error: (10042) Option: Encrypt 2 : error: (10042) Option: SetPin 3 : error: (10042) Option: SetLink 4 : error: (10042) Option: GetLink 5 : error: (10022) Option: XPMtu 0x80000007 : error: (10042) Option: SetMtu 6 : error: (10042) Option: GetMtu 7 : value: 127=0x7F Option: XPMtuMaximum 0x80000008 : error: (10042) Option: SetMtuMaximum 8 : error: (10042) Option: GetMtuMaximum 9 : value: 32767=0x7FFF Option: XPMtuMinimum 0x8000000A : error: (10042) Option: SetMtuMinimum 10 : error: (10042) Option: GetMtuMinimum 11 : value: 23=0x17 Option: SetXOnLimit 12 : error: (10042) Option: GetXOnLimit 13 : value: 800=0x320 Option: SetXOffLimit 14 : error: (10042) Option: GetXOffLimit 15 : value: 200=0xC8 Option: SetSendBuffer 16 : error: (10042) Option: GetSendBuffer 17 : value: 7168=0x1C00 Option: SetReceiveBuffer 18 : error: (10042) Option: GetReceiveBuffer 19 : value: 7168=0x1C00 Option: GetV24Break 20 : error: (10022) Option: GetRls 21 : value: 0=0x0 Option: SendMsc 22 : error: (10042) Option: SendRls 23 : error: (10042) Option: GetFlowType 24 : value: 1=0x1 Option: SetPageTimeout 25 : error: (10042) Option: GetPageTimeout 26 : value: 9472=0x2500 Option: SetScan 27 : error: (10042) Option: GetScan 28 : value: 3=0x3 Option: SetCod 29 : error: (10042) Option: GetCod 30 : value: 5898764=0x5A020C Option: GetLocalVersion 31 : error: (10022) Option: GetRemoteVersion 32 : error: (10022) Option: GetAuthenticationEnabled 33 : value: 0=0x0 Option: SetAuthenticationEnabled 34 : error: (10042) Option: ReadRemoteName 35 : error: (10042) Option: GetLinkPolicy 36 : value: 15=0xF Option: SetLinkPolicy 37 : error: (10042) Option: EnterHoldMode 38 : error: (10042) Option: EnterSniffMode 39 : error: (10042) Option: ExitSniffMode 40 : error: (10042) Option: EnterParkMode 41 : error: (10042) Option: ExitParkMode 42 : error: (10042) Option: GetMode 43 : value: 0=0x0 ---- CLEAN EXIT ----
Secondly on Windows XP, when connected to a MSFT+WM6, we only get one successful on XP.
---- TryAllMsftSocketOptions ---- Option: Authenticate 1 : error: (10042 ProtocolOption) Option: XPAuthenticate 0x80000001 : error: (10042 ProtocolOption) Option: Encrypt 2 : error: (10042 ProtocolOption) Option: SetPin 3 : error: (10042 ProtocolOption) Option: SetLink 4 : error: (10042 ProtocolOption) Option: GetLink 5 : error: (10042 ProtocolOption) Option: XPMtu 0x80000007 : value: 666=0x29A Option: SetMtu 6 : error: (10042 ProtocolOption) Option: GetMtu 7 : error: (10042 ProtocolOption) Option: XPMtuMaximum 0x80000008 : error: (10042 ProtocolOption) Option: SetMtuMaximum 8 : error: (10042 ProtocolOption) Option: GetMtuMaximum 9 : error: (10042 ProtocolOption) Option: XPMtuMinimum 0x8000000A : error: (10042 ProtocolOption) Option: SetMtuMinimum 10 : error: (10042 ProtocolOption) Option: GetMtuMinimum 11 : error: (10042 ProtocolOption) Option: SetXOnLimit 12 : error: (10042 ProtocolOption) Option: GetXOnLimit 13 : error: (10042 ProtocolOption) Option: SetXOffLimit 14 : error: (10042 ProtocolOption) Option: GetXOffLimit 15 : error: (10042 ProtocolOption) Option: SetSendBuffer 16 : error: (10042 ProtocolOption) Option: GetSendBuffer 17 : error: (10042 ProtocolOption) Option: SetReceiveBuffer 18 : error: (10042 ProtocolOption) Option: GetReceiveBuffer 19 : error: (10042 ProtocolOption) Option: GetV24Break 20 : error: (10042 ProtocolOption) Option: GetRls 21 : error: (10042 ProtocolOption) Option: SendMsc 22 : error: (10042 ProtocolOption) Option: SendRls 23 : error: (10042 ProtocolOption) Option: GetFlowType 24 : error: (10042 ProtocolOption) Option: SetPageTimeout 25 : error: (10042 ProtocolOption) Option: GetPageTimeout 26 : error: (10042 ProtocolOption) Option: SetScan 27 : error: (10042 ProtocolOption) Option: GetScan 28 : error: (10042 ProtocolOption) Option: SetCod 29 : error: (10042 ProtocolOption) Option: GetCod 30 : error: (10042 ProtocolOption) Option: GetLocalVersion 31 : error: (10042 ProtocolOption) Option: GetRemoteVersion 32 : error: (10042 ProtocolOption) Option: GetAuthenticationEnabled 33 : error: (10042 ProtocolOption) Option: SetAuthenticationEnabled 34 : error: (10042 ProtocolOption) Option: ReadRemoteName 35 : error: (10042 ProtocolOption) Option: GetLinkPolicy 36 : error: (10042 ProtocolOption) Option: SetLinkPolicy 37 : error: (10042 ProtocolOption) Option: EnterHoldMode 38 : error: (10042 ProtocolOption) Option: EnterSniffMode 39 : error: (10042 ProtocolOption) Option: ExitSniffMode 40 : error: (10042 ProtocolOption) Option: EnterParkMode 41 : error: (10042 ProtocolOption) Option: ExitParkMode 42 : error: (10042 ProtocolOption) Option: GetMode 43 : error: (10042 ProtocolOption) ---- CLEAN EXIT ----
* WM
“setsockopt (Bluetooth)” http://msdn.microsoft.com/en-us/library/aa915899.aspx
“getsockopt (Bluetooth)” http://msdn.microsoft.com/en-us/library/aa916547.aspx
* Win32
“Bluetooth and Socket Options” http://msdn.microsoft.com/en-us/library/aa362911(VS.85).aspx