Sunday, February 25, 2007

The Bluetooth sources

When I wrote my first article on the Widcomm Bluetooth stack, I promised to publish a .NET CF 2.0 library that would abstract the enumeration features of the Widcomm and Microsoft stacks under a unique API. My life became very busy since then, especially when I got a contract for integrating the new version of a mobile GPS application on the Windows Mobile environment. This has been a very interesting challenge that has put all my knowledge through its paces and made me learn a lot: powering off the device, integrating DirectDraw with screen rotations, popping up the phone when a call comes through and the screen is in DirectDraw mode, handling bizzare GPS behaviors, exotic device keys (think HTC 3300)... The works!

Requests for the Bluetooth code and article have not stopped, though so I decided to post links to the unedited versions of the C++ and C# sources. Before I get to fully comment the code and write a proper article, what you see is what you get. The sources are divided into 3 ZIP files:

Bluetooth.zip - Contains a sample C# WM5 application that enumerates devices and services. Also contains the Primeworks.Bluetooth class library.
msbts.zip - The low-level Microsoft Bluetooth stack wrapper.
wcbts.zip - The low-level Widcomm Bluetooth stack wrapper.

Now, I can take my time and write the full length article. All your comments and suggestions are welcome.

37 comments:

Giorgio said...

You are the man! The community loves you...

THANK YOU!!! :D

Eric said...

Joao,

You have done a lot of work on this - good work.

I'm an experienced software engineer but I have never worked with C/C++. As a result I'm stumbling around a bit with setting this up.

As a start I opened the Widcomm Stack wrapper project, wcbs, in Visual Studio 2005. To make life easier in terms of paths etc I copied the header, library and DLL files from the WIDCOMM BTW-CE SDK directory.

On compiling I receive an "unresolved external symbol" error as follows. Can you advise what I am doing wrong? The files that I added are all in the base project directory.

Thanks,

Eric

Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: enum CSppServer::SPP_SERVER_RETURN_CODE __cdecl CSppServer::CreateConnection(wchar_t *)" (__imp_?CreateConnection@CSppServer@@QAA?AW4SPP_SERVER_RETURN_CODE@1@PA_W@Z) referenced in function SppServerStart wcbts.obj

João Paulo Figueira said...

You must install the Widcomm SDK for your particular platform. Also, these projects were compiled with eVC4 (free download from Microsoft), not VS 2005.

Jesus said...

Hello Joao, and thank you very much for your work.

I am trying to test your code samples but I haven´t been able to run the Enumerate sample because I obtain an exception because It can´t find the wcbts.dll library in execution time.

I have installed WIDCOMM SDK and I have converted and compiled your projects to Visual Studio 2005, however, I dont know why I obtain that error because I have included in the debug(bin) folder that dll. I´ve tried putting in the system32 folder but it doesn´t run either.

The exception is launchd in the WidcommAPI.WidcommStackPresent()method. I have revised that method and modified using a .lib instead of a .dll (because I only have a lib version of the library) but I have the same result.

Do you know what I am doing wrong?

Thanyou in advance :D
Jesus

Sergio said...

Hello,

Thanks for this amazing code, its really usefull. I have two small questions:

1- I try to compile both wrappers in VS2005 but i cant. Is it possible? or you do it in eVC4 because VS2005 can create this type of library?

2- When think you can have the final release of the article? :)

thanks a lot.

João Paulo Figueira said...

You should be able to compile the eVC4 project under VS 2005. My advice is to create a new project with the same properties.

Sergio said...

Hello Joao,

i try to create a new project and i have the same problem like eric post. I not have enought knowledge in compilation options and i dont know what to do. I read an article with a problem similar but the compilation options are distinc.

Article ->http://www.codeguru.com/Cpp/Cpp/cpp_managed/interop/article.php/c6867/

Solution to compile in VS->http://www.codeguru.com/cpp/cpp/cpp_managed/interop/comments.php/c6867/?thread=10025

Maybe any can help with this problem

Sergio said...

Sorry link not post correctly

Article:
http://www.codeguru.com/Cpp/
Cpp/cpp_managed/interop/
article.php/c6867/

Solution to compile in VS:
http://www.codeguru.com/cpp/
cpp/cpp_managed/interop/
comments.php/c6867/?thread=10025

rbergo said...

Hello

I got a look to widcomm wrapper... it seems a good work.
I need to reset the bluetooth radio.
Is it possible or does it will be possible to switch off-on the bluetoot radio?

Thank you
Roberto

Zdeněk Němec said...


Eric said...
Joao,

On compiling I receive an "unresolved external symbol" error as follows. Can you advise what I am doing wrong? The files that I added are all in the base project directory.

----------

Hello, did you checked the wchar_t consistency?

see
http://nativespeech.blogspot.com/2007/06/inconsistent-wchart-representation.html

regards

- z

aana said...

A lot of bluetooth sources are there. Infact a great blog on revolutionising wireless technology- Bluetooth. Those were of a great help.
Thanks!!

Bao Ho said...

Hello Joao,

First, I apologize for revising this topic.

I'd like to ask if anyone has played with CL2CapConn::OnCongestionStatus() on WidComm SDK 5.1.0, which vanishes in version 6.1.0? If so, what is your experience with that API? I am currently receiving only one congestion=TRUE notification, but nothing else after that.
Also, CBtIf::SwitchRole() is also gone in 6.1.0? Any work-around?

I'm using VC2005, Widcomm 5.1.0 on XP.

Thank you for any comment.

Patrick said...

João,

This is an incredible piece of work. I was easily able to port and compile your wrappers from eVC4 projects to VS2005, and to compile for both Pocket PC 2003 and WM5.

I was also able to easily compile your C# library and run your sample.

I just want to say - you've saved me a ton of work. This is absolutely incredible - thank you!

I did have a question - there's some interest in having this work incorporated into the 32Feet.Net Compact Framework Bluetooth library. Would you be interested in allowing your work to be so incorporated?

João Paulo Figueira said...

I would be delighted to add this code to 32feet, but it is still mising lots of stuff. Time keeps slipping through my fingers like sand and this code is shamefully (for me) abandoned... So please take it and do whatever you need to do with it!

Patrick said...

João,

That's great to hear - It's something I'd love to work on in my spare time (not that there's much of it, but.. I need interesting projects to keep me sane).

I'll keep you updated!

Murat Topçu said...
This comment has been removed by the author.
Murat Topçu said...

Thanks for all ;)

I want see rssi value. How i see it ?

rano said...

Hi,
I will programm a bluetooth communication with the microcontroller (with bleutoth module)and a PDA.
is this DLL for free use. how can I use it. what is primworks DLL? is it free for use too?

its my first application with bluetooth and Framework. (VS 2005) windows Mobile 6
Thanks

Célio said...

Olá João,
Pelo que entendi esse código localiza todas as conexões ativas de bluetooth não ?
Pos bem, eu compilei o código com o VS 2005 e instalei no pocket-pc da Hp IPAQ hw6945 e ao selecionar a opção "Enumerate Devices", liguei o bluetooth do meu celular ("telemovel" ) para verificar se o programa o localizaria mas isso não aconteceu.

Tú tens alguma idéia do ocorrido ?

Abraços.

rano said...

I hav the some Problem As jesus but with other line MicrosoftAPI.CreateStack:
namespace Primeworks.Bluetooth.Microsoft
{......
m_pStack = MicrosoftAPI.CreateStack();
.......

this is rhe error:
Der Einstiegspunkt 'CreateStack' in der PInvoke-DLL 'msbts.dll' wurde nicht gefunden.

'CreateStack' in PInvoke-DLL msbts.dll not found!!!!!!

João Paulo Figueira said...

I would be delighted to add this code to 32feet, but it is still mising lots of stuff. Time keeps slipping through my fingers like sand and this code is shamefully (for me) abandoned... So please take it and do whatever you need to do with it!

João Paulo Figueira said...

Make sure the msbts.dll is on the DLL search path.

rano said...

Thanks for the Answer. Itry to build the msbts with VS2005 I receive linker extern errors:

Fehler 8 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "WSALookupServiceEnd" in Funktion ""protected: unsigned long __cdecl CMicrosoftStack::DiscoverServices(unsigned __int64,struct _GUID *)" (?DiscoverServices@CMicrosoftStack@@IAAK_KPAU_GUID@@@Z)". MicrosoftStack.obj

Fehler 9 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "WSALookupServiceNextW" in Funktion ""protected: unsigned long __cdecl CMicrosoftStack::DiscoverServices(unsigned __int64,struct _GUID *)" (?DiscoverServices@CMicrosoftStack@@IAAK_KPAU_GUID@@@Z)". MicrosoftStack.obj

Fehler 10 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "WSAGetLastError" in Funktion ""protected: unsigned long __cdecl CMicrosoftStack::DiscoverServices(unsigned __int64,struct _GUID *)" (?DiscoverServices@CMicrosoftStack@@IAAK_KPAU_GUID@@@Z)". MicrosoftStack.obj

Fehler 11 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "WSALookupServiceBeginW" in Funktion ""protected: unsigned long __cdecl CMicrosoftStack::DiscoverServices(unsigned __int64,struct _GUID *)" (?DiscoverServices@CMicrosoftStack@@IAAK_KPAU_GUID@@@Z)". MicrosoftStack.obj

Fehler 12 error LNK2001: Nicht aufgelöstes externes Symbol "RFCOMM_PROTOCOL_UUID". NodeData.obj

any Idee. Itested some things from Internet but no result?
Eric how are you solved your Problem.

Eduardo Castro said...

I am getting the following error
Can't find PInvoke DLL 'wcbts.dll' but I have already copied the file the directory where the .exe is stored.

Dante R. Otero said...

Is there a way to get local device address with this wrapper?? If not, how can I do that?

buy wow gold said...

When Wow Gold wolf finally found the wow gold cheap hole in the chimney he crawled cheap wow gold down and KERSPLASH right into that kettle of water and that was cheapest wow gold the end of his troubles with the big bad wolf.
game4power.
The next day the Buy Wow Goldlittle pig invited hisbuy gold wow mother over . She said "You see it is just as mygamegoldI told you. The way to get along in the world is to do world of warcraft gold things as well as you can." Fortunately for that little pig, he buy cheap wow gold learned that lesson. And he just k4gold lived happily ever after!.

belrion said...

buy wow goldAsesor ProfessionalUruguayProfessionalbuy wow goldOfficeLinksNotice

梦中林 said...

A slim, wide-eyed mygamegoldwoman almost human in virbanksfeatures eyed agamegold the pair. Her nose was sharp, but very elegant. She had tbcgold a pale, trade4gamebeautiful face the color of ivory, and veryge for hair she wore a wondrous mane of downy feathers. Her gown fluttered as she walked—on two delicate worldofgolds but still sharply-taloned feet. “Awake, awake you are,” she said with a pvp365 slight frown. “You should rest, rest.” Krasus bowed to her. “I am ezmmorpg grateful for your ighey hospitality, mistress, but I am well enough to continue on9a9z now.” She cocked her head as a bird might, giving the mageltk365 a reproving look. “No, no…too soon, toogold4guild soon. Please, sit.” The duo looked around u4game and discovered that two chairs, made in the same ready4game fashion as the nest, waited behind happygolds them. Malfurion waited for Krasus, who finally nodded and sat.

肖小非 said...

When the Wow Gold wolf finally found the Buy Wow Goldhole in the chimney he crawled wow gold cheap down and KERSPLASH right into that kettle of water and that was cheapest wow gold the end of his troubles with the big bad wolf.

game4power,buy cheap wow goldThe next day the cheap wow gold buy gold wow little pig invited his mother over . She said "You see it is just as I told you. The way to wow goldget along in the world is to do world of warcraft gold things as well as you can." Fortunately for that little pig, he cheapest wow gold learned that lesson. And he just lived happily ever after!

梦中林 said...

A slim, wide-eyed mygamegoldwoman almost human in virbanksfeatures eyed agamegold the pair. Her nose was sharp, but very elegant. She had tbcgold a pale, trade4gamebeautiful face the color of ivory, and veryge for hair she wore a wondrous mane of downy feathers. Her gown fluttered as she walked—on two delicate worldofgolds but still sharply-taloned feet. “Awake, awake you are,” she said with a pvp365 slight frown. “You should rest, rest.” Krasus bowed to her. “I am ezmmorpg grateful for your ighey hospitality, mistress, but I am well enough to continue on9a9z now.” She cocked her head as a bird might, giving the mageltk365 a reproving look. “No, no…too soon, toogold4guild soon. Please, sit.” The duo looked around u4game and discovered that two chairs, made in the same ready4game fashion as the nest, waited behind happygolds them. Malfurion waited for Krasus, who finally nodded and sat.
brogameswagvaultgoldsoonoforuigxethsale

Boris Torrado said...

Hi guys...

I don't know, if is too late for help, but, I had the same error Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: enum CSppServer::SPP_SERVER_RETURN_CODE __cdecl CSppServer::CreateConnection(wchar_t *)" (__imp_?CreateConnection@CSppServer@@QAA?AW4SPP_SERVER_RETURN_CODE@1@PA_W@Z) referenced in function SppServerStart wcbts.obj

And I solved the problem including in The Properties Project, Configuration Properties, Linker, Input, in the Additional Dependencies: Bthguid.lib

then I get compiled the Joao's Dll.
hope was helpful...

cjaopd said...

http://clipboarded.blogspot.com/2007/10/vim-as-ide.html

venn99 said...

http://www.moneytoyourdoor.net
mortgage
credit
mortgage interest rates
current mortgage interest rates
mortgage payments
monthly payment
mortgages
rates
interest
amortization
mortgage rates
refinance news and calculator
mortgage lender directory
mortgage loan payment calculators
refinance
mortgage rate
refinance news and calculator
calculator
tax
insurance
home loans
home loan
loan information
va
fha
apr


http://www.top98freeonlinegames.info
top free online games
online games
free online games
games

venn99 said...

http://www.youronlinetipsource.com
finance tips
car tips
travel tips
shopping tips
computer tips
search the internet
search the internet online
free search the internet
search the net
search the net online
free search the net
quality search the net
best search the net
internet tips
internet tips online
free internet tips
free internet tips online
quality internet tips
quality internet tips online
best internet tips
best internet tips online
shopping tips online
free shopping tips
free shopping tips online
quality shopping tips
best internet tips
best shopping tips online
finance tips online
shopping tips free
free finance tips
free finance tips online
quality finance tips
quality finance tips online
best finance tips
best finance tips online
car info
car info online
free car info
car internet search
car internet search online
shopping internet search
free internet car search

happyhope said...

Articles are meaningful, and your blog is nice!
polo jacket
polo shirt
ralp lauren jacket
cheap polo shirts
spyder jackets
discount polo shirts
ralph lauren shirt
columbia jacket
north face jacket
cheap ralph lauren shirts
women's columbia jackets
polo t shirts
polo men's shirt
ralph lauren men's shirt
polo mens shirt
cheap polo jackets
ralph lauren mens shirt
wholesale polo jacket
ralp lauren polo shirts
short sleeve polo shirt
men polo shirt
lacoste polo shirts
wholesale polo shirts
men's polo shirts
cheap polo ralph lauren
cheap polo t-shirts
cheap polo clothes
custom polo shirts
discount north face jackets
ladies spyder jacket
tennis rackets
tennis racket
tennis racquet
tennis racquets
wilson tennis rackets
prince tennis rackets
head tennis rackets
babolat tennis rackets
best tennis racket
cheap tennis rackets
wilson tennis racquets
head tennis racquets
babolat tennis racquets
cheap tennis rackets

GiGi said...

Your blog is wonderful, I like it very much, thank you!
By the way, do you like polo shirts, which are very chic, especially the polo t shirts, I love them very much. I also like playing tennis rackets, it can keep healthy, what do you like to do?
We are the outlet of polo t shirts women, polo t shirts on sale, polo t shirts for women, polo shirts on sale, these products are best-seller in our store online.besides we also sell polo shirts men, men's polo shirt, men polo shirt, mens polo shirts, mens polo shirt and cheap polo shirts, discount polo shirts, men's polo shirts, women's polo shirts We are also the outlet of cheap tennis racket, discount tennis racket, and the main product is prince tennis racquet, head tennis rackets, wilson tennis racket, babolat tennis racquet.You are warmly welcomed to my store online!

dreaz said...

araç sorgulama
sorgulama
ehliyet
açıköğretim
bağkur sorgulama
ssk sorgulama
emekli sandığı
cinsel bilgiler
radyo dinle
korku
evlilik
ssk hizmet dökümü
ssk emeklilik sorgulama
hikaye
bağkur hizmet dökümü
gazeteler
ilan
ssk
evlilik sitesi
ehliyet sınav sonuçları
iş ilanları
bağkur
gazete oku