CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1

    Angry WIDCOMM and VC++ 6.0

    Code:
    class WIDCOMMStack : public CBtIf 
    {
    public:
    		BLUETOOTH_DEVICE_INFO	btDevInfo;
    		bool Stop;
    
    		//virtual void OnInquiryComplete(BOOL bSuccess, short nResponses); 
    		//virtual void OnDeviceResponded (BD_ADDR bda, DEV_CLASS devClass, BD_NAME bdName, BOOL bConnected);
    
    		WIDCOMMStack::WIDCOMMStack()
    		{
    			OutputDebugString("Starting To Inquiry\r\n");
    			StartInquiry();
    			Sleep(5000);
    			StopInquiry();
    		}
    
    		WIDCOMMStack::~WIDCOMMStack()
    		{
    		}
    
    		
    		void WIDCOMMStack::OnDeviceResponded(BD_ADDR bda,DEV_CLASS devClass,BD_NAME bdName,BOOL bConnected)
    		{
    			if (Stop == true) { return; } else { Stop=true; }
    			//BLUETOOTH_DEVICE_INFO    btDevInfo; 
    			//
    			// Prepare the device information structure
    			//
    			memset(&btDevInfo, 0, sizeof(btDevInfo));
    			btDevInfo.dwSize     = sizeof(BLUETOOTH_DEVICE_INFO);
    			btDevInfo.fConnected = bConnected; 
    			memcpy(btDevInfo.Address.rgBytes, bda, BD_ADDR_LEN);
    			// Set the device class
    			btDevInfo.ulClassofDevice = ((ULONG)devClass[0] << 16) + ((ULONG)devClass[1] <<  8) + devClass[2]; 
    
    			MultiByteToWideChar(CP_ACP, 0, (const char*)bdName,BD_NAME_LEN,btDevInfo.szName, BD_NAME_LEN); 
    
    			OutputDebugString("OnDeviceResponded\r\n");
    			OutputDebugString("Connected: ");
    			if (bConnected == true) {OutputDebugString("True\r\n");} else {OutputDebugString("False\r\n");}
    			
    			OutputDebugString("Device Name: ");
    			OutputDebugString((LPCSTR)bdName);
    			OutputDebugString("\r\n");
    
    			CString strDevClass;
                CString strAddress; 
    
    			strDevClass.Format("%X", btDevInfo.ulClassofDevice);
    
    			OutputDebugString("Class Of Device: ");
    			OutputDebugString(strDevClass);
    			OutputDebugString("\r\n");
    
    			strAddress.Format("%02X:%02X:%02X:%02X:%02X:%02X",
                                  btDevInfo.Address.rgBytes[0],
                                  btDevInfo.Address.rgBytes[1],
                                  btDevInfo.Address.rgBytes[2],
                                  btDevInfo.Address.rgBytes[3],
                                  btDevInfo.Address.rgBytes[4],
                                  btDevInfo.Address.rgBytes[5]); 
    
    			OutputDebugString("BTAddr: ");
    			OutputDebugString(strAddress);
    			OutputDebugString("\r\n");
    
    			StartDiscovery(btDevInfo.Address.rgBytes, NULL); 
    		} 
    
    		void WIDCOMMStack::OnInquiryComplete(BOOL bSuccess, short nResponses)
    		{
    			OutputDebugString("OnInquiryComplete\r\n");
    		}
    
    		void WIDCOMMStack::OnDiscoveryComplete()
    		{
    
    			
    
    			int    i, nRecs;
    
    			CSdpDiscoveryRec		m_sdpRecs[16];
    			nRecs = ReadDiscoveryRecords(btDevInfo.Address.rgBytes,16, m_sdpRecs, NULL);
    
    			OutputDebugString("----Service Names----\r\n");
    
    			for(i = 0; i < nRecs; ++i)
    			{
    				CString strGuid;
    				GUID    guid    = m_sdpRecs[i].m_service_guid;
    				UINT8   channel;
    
    				
    				OutputDebugString(m_sdpRecs[i].m_service_name);
    				OutputDebugString("\r\n");
    
    				strGuid.Format("%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
    					guid.Data1, guid.Data2, guid.Data3,
    					guid.Data4[0],
    					guid.Data4[1],
    					guid.Data4[2],
    					guid.Data4[3],
    					guid.Data4[4],
    					guid.Data4[5],
    					guid.Data4[6],
    					guid.Data4[7]);
    
    				OutputDebugString("GUID: ");
    				OutputDebugString(strGuid);
    				OutputDebugString("\r\n");
    
    				UINT16 PSM;
    
    				
    
    				if(m_sdpRecs[i].FindL2CapPsm(&PSM))
    				{
    					CString strPSM;
    
    					strPSM.Format("%d", PSM);
    					OutputDebugString("strPSM: ");
    					OutputDebugString(strPSM);
    					OutputDebugString("\r\n\r\n");
    				}
    
    				if(m_sdpRecs[i].FindRFCommScn(&channel))
    				{
    					CString strChannel;
    
    					strChannel.Format("%d", channel);
    					OutputDebugString("strChannel: ");
    					OutputDebugString(strChannel);
    					OutputDebugString("\r\n\r\n");
    				}
    
    				if (channel==5 && false)
    				{
    			
    					//CRfCommConn MyRFControl;
    					CRfCommIf MyRF;
    
    					unsigned char uSCN = 0;
    					if (! MyRF.AssignScnValue(&m_sdpRecs[i].m_service_guid, uSCN, (LPCSTR)m_sdpRecs[i].m_service_name)) return;
    
    					CRfCommPort ComPort;
    					if (! ComPort.OpenClient(uSCN, btDevInfo.Address.rgBytes)) { OutputDebugString("Failed To Connect RFCOMM"); WIDCOMMSDK_ShutDown(); return;}
    					
    					tBT_CONN_STATS *Stats = new tBT_CONN_STATS;
    					GetConnectionStats(btDevInfo.Address.rgBytes, Stats);
    					
    				}
    
    				if (PSM==25 && false)
    				{
    					CL2CapIf *MyCap = new CL2CapIf;
    					int asnpsm = MyCap->AssignPsmValue(&m_sdpRecs[i].m_service_guid, PSM);
    					int registered = MyCap->Register();
    
    					CL2CapConn *MyCapCONN = new CL2CapConn;
    					int connected = MyCapCONN->Connect(MyCap, btDevInfo.Address.rgBytes);
    
    					tBT_CONN_STATS *Stats = new tBT_CONN_STATS;
    					GetConnectionStats(btDevInfo.Address.rgBytes, Stats);
    					if (!connected) { OutputDebugString("BAD!"); }
    				}
    
    				
    			}
    			
    			//AfxMessageBox("Test", 0, 0);
    			OutputDebugString("----END OF Service Names----\r\n\r\n");
    
    			
    
    			return; 
    		}
    
    };
    alright so far this is pretty good, I cant ever get the connetion to work with this output

    Code:
    OnDeviceResponded
    Connected: False
    Device Name: The kool kids phone
    Class Of Device: 7A0204
    BTAddr: 00:1D:F6:6F:87:6E
    ----Service Names----
    Voice Gateway
    GUID: 0000111F-0000-1000-8000-00805F9B34FB
    strChannel: 1
    
    AUDIO Gateway
    GUID: 00001112-0000-1000-8000-00805F9B34FB
    strChannel: 2
    
    OBEX Object Push
    GUID: 00001105-0000-1000-8000-00805F9B34FB
    strChannel: 3
    
    Advanced Audio
    GUID: 0000110A-0000-1000-8000-00805F9B34FB
    strPSM: 25
    
    
    GUID: 0000110C-0000-1000-8000-00805F9B34FB
    strPSM: 23
    
    Phonebook Access PSE
    GUID: 0000112F-0000-1000-8000-00805F9B34FB
    strChannel: 4
    
    Serial Port
    GUID: 00001101-0000-1000-8000-00805F9B34FB
    strChannel: 5
    Im running Vista, All I want is to be able to get a RSSI from the device, From what I know a l2cap connection has to be created first, Anyone can point me in the right direction as to were I should ask this, Finding Widcomm Support is impossible... =)

    THANKS!

    -Agent
    Http://ControllingTheInter.Net
    My General Computer Forum, From Security To Programming And Back To Troubleshooting.

  2. #2
    Join Date
    Oct 2009
    Posts
    12

    Re: WIDCOMM and VC++ 6.0

    Hello, Smith

    Would Smith please tell Bather about the library Smith is using ?

    Thank you Smith

  3. #3

    Re: WIDCOMM and VC++ 6.0

    Yes, Its WIDCOMM's

    Say do Headsets Accept connections from L2CAP from a Laptop class bluetooth connection?
    or does it only accept class 0x50204 Cellphone?
    Http://ControllingTheInter.Net
    My General Computer Forum, From Security To Programming And Back To Troubleshooting.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured