Do not use on any
shared computer
August 29, 2008 06:01pm pdt
 
[x]
Attachment Details

Bluetooth via Windows Sockets (Pocket PC)

Zone: Bluetooth
Tags: bluetooth, wsaaddresstostring, pc, pocket, sockets
Hello!
My goal is to realize an application which can discover Bluetooth devices and services, and send a simple file on my Pocket PC. I managed to discover device names and addresses with WSALookupServiceBegin and WSALookupServiceNext (with LUP_RETURN_NAME | LUP_RETURN_ADDR flags), and print the names, but I can't step any further.
1. First I can't print out the address, becouse I don't really understand how the WSAAddressToString works. But it doesn't really necessery becouse it is just to write the addresses to the screen, so let's see the real problem of mine:
2. Second question: how can I use received address (as far as I know it is in the lpcsaBuffer) to connect to the found device?

I tried t use the connect function with the following code, but I get an error about types.:

SOCKADDR_BTH address;
memset (&address, 0, sizeof(address));
address.addressFamily = AF_BTH;
address.serviceClassId = GUID_NULL;
address.port = BT_PORT_ANY;

if (0 != connect(s, &address, sizeof(address)))
{
MessageBox(hDlg, _T("Sikertelen connect függvény"), _T("Connection failed"), MB_OK);
}

ERROR MESSAGE: "error C2664: 'connect': cannot convert parameter 2 from 'struct _SOCKADDR_BTH *' to 'const struct sockaddr *'
(I know that the connect function waiting for a const struct type variable, but in every sample (they say: working codes) connect function is used like this).

3.: It is possible that I can't use this function on Pocket PC? Maybe it is impossible to realize my Bluetooth application on Pocket PC with Windows Sockets?

4. I also had problem with the s socket in the connect function (I have WSAstartup, and s socket definded before). I solve the problem that I make the s socket global variable. I fear that this isn't the correct way to solve the problem, becouse I think I can define the s socket everywhere in my program, it won't be a local variable, becouse the closesocket(s) is needed to close a socket. Or I'm wrong and the "ok, make it global variable" solved the problem?

5.: This last question is about an another concepcion (my originally) that I tried. I start to realize a similar application to my laptop, but I noticed, that it is impossible, to find the working hardware configurations. I mean that if I had an SDK or a sample from the net which may work, than I don't have the proper Bluetooth dongle for it (for example there is an example code on the web: http://www.lenholgate.com/archives/000102.html which is really great, but it need MS compatible Blueooth dongle (TDK Bluetooth adaptor, that I can't have), or Avelink has a great SDK but that work only with Braniboxes H4 PCMCIA Bluetooth adapter, which I can't have, as well). Can you advice me something about which Bluetooth dongle should I use, with which SDK?
Or the best would be, if you can tell me: how can I run the sample code found here: http://www.lenholgate.com/archives/000102.html (I've the latest Platform SDK installed with VS .NET)

I'm sorry about the size of this question.
Thanks a lot in advance:

AndreW
Start your free trial to view this solution
[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!

Question Stats
Zone: Networking
Question Asked By: lkutor
Solution Provided By: DanRollins
Participating Experts: 1
Solution Grade: A
Views: 0
Translate:
Loading Advertisement...
 
[+][-]Accepted Solution by DanRollins
Accepted Solution by DanRollins:

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.

 
 
[+][-]Administrative Comment by Venabili
Administrative Comment by Venabili:

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.

 
 
[+][-]Administrative Comment by modulo
Administrative Comment by modulo:

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...
20080723-EE-VQP-34