lkutor
asked on
Bluetooth via Windows Sockets (Pocket PC)
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
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
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.