Wednesday, June 27, 2012 2:51 PM
I'm checking out the new Bluetooth LE APIs for Windows 8. I've made a small Win32 console application to test them, but I'm struggling with the compiling.
I'm getting (only) these errors:
1>c:\program files (x86)\windows kits\8.0\include\um\bthledef.h(421): warning C4068: unknown pragma 1>c:\program files (x86)\windows kits\8.0\include\um\bluetoothleapis.h(658): error C2373: 'PFNBLUETOOTH_GATT_EVENT_CALLBACK' : redefinition; different type modifiers 1> c:\program files (x86)\windows kits\8.0\include\um\bthledef.h(349) : see declaration of 'PFNBLUETOOTH_GATT_EVENT_CALLBACK'
To me it looks like an error in the library files. Am I missing something?
I'm including (only) stdafx.h in my code, then in stdafx.h I'm including these:
#include <stdio.h> #include <tchar.h> #include <windows.h> #include <setupapi.h> #include <BluetoothLEApis.h>
c:\program files (x86)\windows kits\8.0\include\um\bthledef.h(421) has:
#ifdef _MSC_VER #pragma pop #endif //_MSC_VER
c:\program files (x86)\windows kits\8.0\include\um\bluetoothleapis.h(658) has:
// // Callback function signature for Bluetooth GATT events. // typedef VOID (CALLBACK *PFNBLUETOOTH_GATT_EVENT_CALLBACK)( _In_ BTH_LE_GATT_EVENT_TYPE EventType, _In_ PVOID EventOutParameter, _In_opt_ PVOID Context );
And c:\program files (x86)\windows kits\8.0\include\um\bthledef.h(349) has:
typedef VOID (*PFNBLUETOOTH_GATT_EVENT_CALLBACK)( _In_ BTH_LE_GATT_EVENT_TYPE EventType, _In_ PVOID EventOutParameter, _In_opt_ PVOID Context );
I'm using Visual Studio 2012 Pro RC, and compiling as 'Default', with calling convention '__cdecl (/Gd)'.
- Edited by ronningstad Wednesday, June 27, 2012 2:53 PM
Wednesday, June 27, 2012 9:44 PM
Thanks for reporting this issue. You should be able to work around this problem by adding BthLEdef.h before including BluetoothLEApis.h. So your list of includes would look like this:
I can also encourage you to look at the available samples that make use of these apis:
- Marked As Answer by Doron Holan [MSFT]Microsoft Community Contributor, Owner Thursday, June 28, 2012 3:44 AM
- Unmarked As Answer by ronningstad Thursday, June 28, 2012 7:28 AM
Thursday, June 28, 2012 8:36 AM
Thanks for replying!
Unfortunately I get the exact same error. I have actually been looking at the sample, and I originally included those extra declarations you propose because I found them in the sample, but removed them because they did not seem to have an effect.
Also, the sample doesn't work for me. It compiles, and I can update the appropriate GATT service driver, but it doesn't work in the metro app. I made this forum thread, in short, I get an 80070005 error in the metro app sample, and a 'Type mismatch' error in my own app.
On a side note, since you're Alain Michaud :)... (I recognize you from the build 2011 videos):
Will you be including service drivers for all standard services in-box?
Also, the GATT framework isn't all that complicated. Why should one need to make a Win32 driver for every service? Why not give access to a more general API in the metro app? Making a metro style app, including using devices, is super-super-easy, great job! But it doesn't matter if making an app is super easy if making a driver is, at best, daunting.
Thursday, June 28, 2012 2:44 PM
Your last post contained several questions, so let me try to answer them individually:
Could you please past the complete compilation/build log after applying the suggestion above? I'll look further into the problem. I'm especially curious about the unknown pragma error that's reported above.
Access Denied trying to access the device from your metro app:
This error is actually a result of a Windows policy change that took place after our Customer Preview release. Only privileged applications will be allowed to access the WPD services exposed by the driver. What this means is that you will need to post a device metadata package to declare your application as being allowed to access the device in question. I know this is a very short answer for something that requires more explanation, and for this purpose, we are working on a whitepaper to address the specifics of this. I encourage you to stay posted to the following link where more details will be available shortly about the Metro Style Device apps for "Other" devices:
Will we include service drivers for all standard services in-box?
Windows 8 will ship with in-box support for the HID over GATT profile only. While we do provide samples for a good set of standard health profiles, these will not be available in-box.
Why isn't our GATT Apis available directly in WinRT?
Our first release of WinRT focuses on well defined verticals when it comes to giving custom device access to Metro Style applications. This is especially important when it comes to ensuring the proper level of protection is provided by the system for devices which can expose sensitive information to applications. This includes location, health data etc. For this reason, our initial release will allow scenarios to be built using Bluetooth LE on Windows 8, but will be isolated to the implementation of a Metro Style Device Apps which limits the number of applications that can use any given devices thus reducing the foot print of this risk. We certainly understand that requiring a driver is less than compelling and hopefully our samples will help a great deal in getting device manufacturers and enthusiasts started.
- Proposed As Answer by Alain Michaud [MSFT] Thursday, June 28, 2012 2:45 PM
- Marked As Answer by Doron Holan [MSFT]Microsoft Community Contributor, Owner Thursday, June 28, 2012 5:42 PM
Monday, July 02, 2012 12:48 PM
Thanks for the thorough answer.
This is the complete build log, unless there is some kind of verbose log I can access somewhere:
1>------ Build started: Project: BleTest CppDesktopBlank, Configuration: Debug Win32 ------ 1> stdafx.cpp 1>c:\program files (x86)\windows kits\8.0\include\um\bthledef.h(421): warning C4068: unknown pragma 1>c:\program files (x86)\windows kits\8.0\include\um\bluetoothleapis.h(658): error C2373: 'PFNBLUETOOTH_GATT_EVENT_CALLBACK' : redefinition; different type modifiers 1> c:\program files (x86)\windows kits\8.0\include\um\bthledef.h(349) : see declaration of 'PFNBLUETOOTH_GATT_EVENT_CALLBACK' ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== ========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========
Friday, August 03, 2012 3:53 PM
AM> Build Problems:
AM> Could you please past the complete compilation/build log after applying the suggestion above? I'll look further into the problem.
did you get a chance to look into this issue? Well, I'm able to replace #pragma pop with #pragma warning(pop) etc. on my own, manually, but it doesn't seem to be an ideal solution :-)
Thursday, August 23, 2012 11:33 AM
AM>Could you please past the complete compilation/build log after applying the suggestion above?
AM>I'll look further into the problem. I'm especially curious about the unknown pragma error that's reported above.
With VS 2012, when you create a new UMDF project, calling convention is set to _stdcall by default, and warning.h header (which, among other, disables "C4068: unknown pragma" warning) is forcible included. So, both problems go away.
Looks like nobody at Microsoft tryed to use Bluetooth LE APIs from regular application. And that's the problem.
BTW, that means that if you include BthDef.h (or BluetoothLEApis.h, if your app's calling convention is _stdcall) into regular app's, you will not know, what warnings are actually disabled. A disaster, isn't it?
Thursday, November 08, 2012 6:04 PM
First thank you as well for the informative discussion. It's been a few months and I just had a few quick questions:
1. If we wish to interact with a Bluetooth LE device (other than HID) in WinRT, we need to write a WPD driver?
2. If we wish to interact with it in a desktop app (x86, not ARM), then we can either make a driver and use the WPD framework like in #1, or we can call the GATT API directly?
3. In the case of #2, is there sample code for, say, simple getting and setting of a characteristic (NOT in the overall WPD driver framework, but something like a simple Win32 utility..)? Functions like "BluetoothGATTGetServices()" etc. seem to be simple enough to call, just need a basic example. For example, the first argument is hDevice--how do we get this device handle? (obviously I'm new to this..). CreateFile()?
4. What's the story with Windows Phone 8 and BLE? Similar to #1 I'm assuming..?
- Edited by mozziyar Thursday, November 08, 2012 6:07 PM
Tuesday, November 27, 2012 3:20 AMAFAIK windows phone 8 only supports BT3.X, not BT4. So there's no BTLE support on Windows Phone yet.
- Edited by ukdiveboy Tuesday, November 27, 2012 3:20 AM
Tuesday, March 26, 2013 11:09 AM
Did you find a solution to your error??
Sunday, March 31, 2013 6:19 AMI am also looking for an answer to question 2 and 3. It would be redicoulus to write a whole driver just for doing simple things like accessing a few values of a BLE device. Have you got an answer somewhere else for them?