Starting a C# BLE project

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I am working on a windows service in C# that uses a Broadcomm radio.

I am attempting to convert over the necessary C++ code needed to get this project going.

When I attempted to reference btwleapi.dll in my project I pickedup the following error:

A reference to 'C:\...\Btwleapi.dll' could not be added.  Please make sure that the file is accessible, and that that it is a valid assembly or COM component.

I am working with version 6.5.1.2700 of the .dll

My primary question is, what is the right way to reference this DLL?

Is this only done with  DllImport attributes for each method?

It looks like btwleapi.dll is the main file that my software will need to interface with.

Is this correct?

If no, does anyone know what .dlls we need to focus on?

What kind of .dll is btwleapi?
(win32, MFC, CRL)?

By chance, does anyone have a C# version of btwleapis.h?

My thanks in advance.

When I tried to reference
btwleapi.dll in my C# project I picked up the error below:

Could not be added.  Please
make sure that the file is accessible, and that it is a valid assembly or COM
component.

Have you seen this kind of error
before?

0 Likes
1 Solution

Got it.  The only DLL that you need is BtwLeApi which comes with Broadcom's profile pack for Windows 7 (BTW 6.5.1).  The btwleapis.h header file which is included in Windows WICED Smart samples should have a reasonable description of the functionality.  Unfortunately WICED Smart SDK only includes C++ and does not include C#, VB, or Java script samples.  On Windows 8/8.1 this DLL is not required because all required functionality is included in standard Microsoft DLLs.

View solution in original post

8 Replies
VikramR_26
Employee
Employee
25 sign-ins 10 sign-ins 10 comments on KBA

Could you provide more details on this, to understand better did you go ahead and generate the btwleapi.dll ?

If yes could you tell us the procedure just to understand better.

Secondly for the error

Btwleapi.file is a native DLL which means you can't add it to a .NET project via Add Reference...

you can use it via DllImport (see http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.aspx)

[sdavid471]My primary question is, what is the right way to reference this DLL?

Is this only done with  DllImport attributes for each method?

It looks like btwleapi.dll is the main file that my software will need to interface with.

Is this correct?

[vik86]Could you give more details on what is the purpose of the DLL you are trying to generate and end goal.


IHave you seen this kind of error
before?

[vik86] We have never done this before.

Thanks

vik86

BTWLEAPI is a C DLL with a standard WINAPI interface.  I do not think this forum is an appropriate place for the discussion how to interface C DLLs from C#. 

0 Likes
Anonymous
Not applicable

As we are developing a windows application in C#, where would the appropriate place be?

Thanks.

David Sheh

Senior Staff Software Engineer

Platforms & Services

T 602-643-7430 | F 602-643-7698

david.sheh@baesystems.com<mailto:david.sheh@baesystems.com> / www.baesystems.com<http://www.baesystems.com/>

BAE Systems; 7822 S. 46st Street Phoenix AZ 85044 USA

0 Likes

I would start with MSDN.  But Google search for how to access C DLL from C# produced about 2,720,000 results.

Anonymous
Not applicable

Of course I have been looking at MSDN, however that will not provide vendor specific information from Broadcom.

I was not asking about the C# language in particular, rather how can we find what Broadcom BLE .dlls. we need and which functions go with .dll.

0 Likes

Got it.  The only DLL that you need is BtwLeApi which comes with Broadcom's profile pack for Windows 7 (BTW 6.5.1).  The btwleapis.h header file which is included in Windows WICED Smart samples should have a reasonable description of the functionality.  Unfortunately WICED Smart SDK only includes C++ and does not include C#, VB, or Java script samples.  On Windows 8/8.1 this DLL is not required because all required functionality is included in standard Microsoft DLLs.

lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

As you might has surmised by now, we are starting a new project using BLE and the Broadcom drivers and hardware.

I feel I have reached a roadblock and I think a 15 minute conversation with the right person would make a big difference in this project.

Would you be willing to assist me in setting up such a conversation with a Windows Software BLE engineer at Broadcom?

Someone familiar with C++, C#, the software examples and accessing the necessary structures and driver calls?

For the specific question please see my post of Aug 29th.

Thanks.

David Sheh

Senior Staff Software Engineer

Platforms & Services

T 602-643-7430 | F 602-643-7698

david.sheh@baesystems.com<mailto:david.sheh@baesystems.com> / www.baesystems.com<http://www.baesystems.com/>

BAE Systems; 7822 S. 46st Street Phoenix AZ 85044 USA

0 Likes
Anonymous
Not applicable

You might want to look through these C# namespaces..

Windows.Devices.Bluetooth

Windows.Devices.Bluetooth.GenericAttributeProfile

Windows.Devices.Bluetooth.Rfcomm

Windows.Devices.Bluetooth.Background

Windows.Devices.Bluetooth.Advertisement


Those namespaces provide some key functionalities that might be enough for your application.

Most of them works on Windows 8.1 except the Advertisement that I am testing on Windows 10 Insider Preview.


0 Likes