I never expected the Bluetooth sockets entry to be so popular ... From the comments on that entry it seems a lot of people are having trouble with getting devices to work with XP's bluetooth support. To help out a little here's my proof of concept test project.
The TDK dongle may come with the MS stack, if not you can get it from TDK for around 10 GBP.
Posted by: Len at August 13, 2004 06:33 AMJim
In general, it's easier to decode the error numbers into the messages and report those, sometimes the messages may help... 10049 is WSAEADDRNOTAVAIL; ie the address is not available. Looking at my complete code example that works, here, http://www.lenholgate.com/archives/000102.html and comparing it to the code you show here that fails, I'm guessing you might not be zeroing out the address structure correctly and leaving random rubbish in there? It's hard to tell since the code you've posted isnt a stand alone compilable example...
I'd suggest that you take the example in the page I refer to, build that, see if that works and if it does adjust it incrementally to get to where you want to be; when it breaks, back up and work out what you did wrong.
Posted by: Len at August 15, 2004 10:26 PMJim
Zip up your source and email it to me and I'll take a quick look.
Posted by: Len at August 18, 2004 09:14 PMHi Len,
Is there a C# (.net framework - desktop) sample for OBEX file transfer through Microsoft BT SDK?
Thanks,
B Vidyadhar Joshi
Posted by: B Vidyadhar Joshi at November 5, 2004 01:31 PMNot that I've seen. There's some COM OBEX stuff on www.codeproject.com I think.
Posted by: Len Holgate at November 5, 2004 01:32 PMIs it not possible to write a C# wrapper class around the MS Bluetooth stack? Just curious because if it was possible, someone would have made an attempt. :-)
Posted by: B Vidyadhar Joshi at November 9, 2004 02:27 PMNothing's impossible; there just doesn't seem to be a great deal of code out there that uses the MS stack...
Posted by: Len at November 9, 2004 07:54 PMlen
I use your above code for communicate my Nokia 6600 with PC server by BT. After I succeed in creating a BT socket, I bind the socket and start to listen. Also, WSASetService is invoked here. Next, when I attemp to send file from my 6600 to PC by BT, I can not find the PC server on my 6600 so that file sending can not be accomplished.
Len
I use your above code for communicate my Nokia 6600 with PC server by BT. After I succeed in creating a BT socket, I bind the socket and start to listen. Also, WSASetService is invoked here. Next, when I attemp to send file from my 6600 to PC by BT, I can not find the PC server on my 6600 so that file sending can not be accomplished.
Sorry, I just found that the option "Turn discovery on" of my PC BT Device is off, thus I modified the option and can find PC BT from my 6600 now.
To continue testing your sample code, when I attempt to send file from my 6600 to PC by BT, an error "Unable to Connect" always returned on my 6600. Could you tell me why?
That is because your Bluetooth Server is not advertising the service. Even I have the same problem. Can't figure out what is wrong with WSASetService. :-(
Posted by: B Vidyadhar Joshi at January 17, 2005 06:42 AMI am trying to write a client for xp, Thanks for your code it looks like it will be a great help in understanding Bluetooth sockets in XP. I have a D-Link DBT-120 dongle, I was reading above that people couldn't get it to work. Got it working with your program, and it seems to work great so far. Heres how I got it to work. I have Xp Pro SP2. I just installed SDK (http://www.microsoft.com/msdownload/platformsdk/sdkupdate/XPSP2FULLInstall.htm) After installing SDK I changed the driver for the dongle. Let XP do a search for a driver and it should choose to use the generic one with the emulator. Then the program works great and I can recieve stuff from a linux client over bluetooth.
Posted by: muldr2 at February 24, 2005 12:12 AMwhen i build ur test project above, "error LNK2001: unresolved external symbol _OBEXFileTransferServiceClass_UUID" came out. I know someone have post abt this before and sometime wrong related with uuid.lib. However, where could i get the correct uuid.lib? can u send me by email?
anyway, i can successfully build and run your another example at Bluetooth sockets post.
Thank you for your kindly help! :)
Posted by: CS at March 4, 2005 07:27 AMThanks len,
this is a great code sample.
I've qustion:
How can I use your code to send a file?!
what function?
and how to work with BT protocols?
thx
hi,
i'm working on a similar piece of code. i'm trying to connect with my nokia 6230 to my win32 application.
my problem is that the phone cannot discover the service running on the PC. I'm not sure if it is a problem on the phone or on the pc. at the moment i think the WSASetService ist not working but i'm using it in the exact same way than you are.
it could also be that the java app on the phone i've also written myself is not working.
do you know any good way to debug such a problem? is there a tool for windows which lists all registered services?
thanks
ttest
Posted by: peter mueller at March 19, 2005 11:58 PMwell i should have looked around on your site first and than i should have posted a comment...
my socket address was not initialized correct i tried your snippet:
address.addressFamily = AF_BTH;
address.btAddr = 0;
address.serviceClassId = GUID_NULL;
address.port = BT_PORT_ANY;
and now it works.
Posted by: peter mueller at March 20, 2005 12:27 AMLen,
Your code has been a great help. It is really very helpful. However I am "stuck" on the following problem.
blue.obj : error LNK2001: unresolved external symbol _OBEXFileTransferServiceClass_UUID
Debug/blue.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
I know that some other people have the same problem using the uuid.lib, but where can I find a new uuid.leb that it will correct this problem.
Thanks a priori.
manny
Which version of the platform SDK are you using? I assume the correct uuid.lib file is in all versions from the one that first targetted XP SP1 onwards. I'm using the Feb 2003 one at present.
Posted by: Len at August 16, 2005 01:48 PMLen,
Thanks for your help. Actually I found out (as you suggested) that my library path was not properly set-up in order to access the proper uuid.lib
Thanks again.
Manny
When i execute the code and try to send a file from my 6600 to PC, in 6600 it is showing 'Unable to connect'.
Can anyone suggests me the solution?
Thanks
Posted by: Manu at February 8, 2006 03:22 PMSounds like you expect the simple example code to be able to do far more than it can...
It's a simple example! Use it to learn about the API and then write some code that does what you want...
Posted by: Len at February 8, 2006 03:28 PM