Advertisement

11.04.2003 at 06:51AM PST, ID: 20787399
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

RFCOMM: Windows Mobile 2003 - Virtual COM Port - ERROR_DEVICE_IN_USE

Zone: Bluetooth
Tags: bluetooth, windows, mobile, port
I'm developing an application (Pocket PC 2003 / Windows Mobile 2003) which should establish a RFCOMM Bluetooth connection to a bluetooth-server-device. ( A serial interface for an older non-bluetooth version of this device already exists. PPC is the T-Mobile MDA )

So i checked the scanty microsoft documentation and found out, that it is possible to create a virtual com port with
RegisterDevice(L"COM", index, L"btd.dll", (DWORD)&pp).

With WSALookupServiceBegin(...) and WSALookupServiceNext(...) it was possible to detect the BT_ADDR needed for the PORTEMUPortParams (see above -> pp ) device parameter.

But RegisterDevice always fails with SystemError:ERROR_DEVICE_IN_USE (The device is in use by an active process and cannot be disconnected.) - Then i checked the "HKLM\drivers\Active" Key in my PPC registry and found out, that there is no service using COM 4, 5 or 6. But this Ports also generate this error message.

Interestingly enough the "btd.dll" is not yet loaded. So i guess my PORTEMUPortParams structure isn't the error source.

The sample source code supplied with Windows CE Evaluation Edition seems to do exactly the same.

Maybe I could have forgotten to implement several important gimmicks. Or maybe there is another way to connect with a RFCOMM bluetooth device.

Thanks in advance.

Here is the source (without catching any errors :)

/*+++++++++++Startup WSA+++++++++++++++++*/
WORD wVersionRequested;
WSADATA wsaData;
wVersionRequested = MAKEWORD( 2, 2 );
WSAStartup( wVersionRequested, &wsaData );

/*+++++++++++++Search for my device++++++++++++++++*/
INT iResult = 0;
LPWSAQUERYSET pwsaResults;
DWORD dwSize = 0;
WSAQUERYSET wsaq;
HANDLE hLookup = 0;
memset (&wsaq, 0, sizeof(wsaq));
wsaq.dwSize = sizeof(wsaq);
wsaq.dwNameSpace = NS_BTH;
wsaq.lpcsaBuffer = NULL;

WSALookupServiceBegin(&wsaq, LUP_CONTAINERS, &hLookup);

union {
CHAR buf[5000];
SOCKADDR_BTH      __unused;
};
pwsaResults = (LPWSAQUERYSET) buf;
dwSize  = sizeof(buf);            
memset(pwsaResults,0,sizeof(WSAQUERYSET));
pwsaResults->dwSize      = sizeof(WSAQUERYSET);
pwsaResults->dwNameSpace = NS_BTH;
pwsaResults->lpBlob      = NULL;

WSALookupServiceNext (hLookup, LUP_RETURN_NAME | LUP_RETURN_ADDR, &dwSize, pwsaResults);
// Real device name is found ... pwsaResults->lpszServiceInstanceName;

/*+++++++++Now trying to register the virtual COM Port+++++++++++++++*/
PORTEMUPortParams pp;
memset (&pp, 0, sizeof(pp));
pp.channel = 0;
pp.flocal = false;
pp.device = reinterpret_cast<_SOCKADDR_BTH*>(pwsaResults->lpcsaBuffer->LocalAddr.lpSockaddr)->btAddr;
//the detected BT_ADDR
memcpy(&pp.uuidService, &CLSID_NULL, sizeof(GUID));
pp.uiportflags = RFCOMM_PORT_FLAGS_REMOTE_DCB;
int port = 4; //or anything else like 1..4,5 or 6..9 | Limit is 9 i think
HANDLE bth = RegisterDevice  (L"COM", port, L"btd.dll", (DWORD)&pp));

/*++++++++the result+++++++++++++++++++*/
//bth == 0
//GetLastError () == ERROR_DEVICE_IN_USE :(
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: tstwk
Solution Provided By: cindy_k
Participating Experts: 4
Solution Grade: A
Views: 118
Translate:
Loading Advertisement...
11.04.2003 at 10:57AM PST, ID: 9680833

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.05.2003 at 12:34AM PST, ID: 9685144

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.05.2003 at 07:37AM PST, ID: 9687490

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.06.2003 at 12:20AM PST, ID: 9692644

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.06.2003 at 10:21AM PST, ID: 9695700

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.07.2003 at 05:45AM PST, ID: 9701029

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.07.2003 at 12:41PM PST, ID: 9703896

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.01.2004 at 09:00PM PST, ID: 10492484

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
06.03.2004 at 01:52AM PDT, ID: 11220254

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
06.03.2004 at 02:22AM PDT, ID: 11220417

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
06.13.2004 at 02:57AM PDT, ID: 11299287

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080236-EE-VQP-29