I need to develop a C++ DLL in and for Windows 10, that is capable of scanning for, connecting to and exchanging data with a Bluetooth Low Energy (BLE) device.
Can someone please advise on an appropriate library, tutorial or relevant documentation that will enable me to develop a C++ DLL to implement BLE Central functionality.
You can use the WinRT BLE libraries for C++, which have the same API as if you would write in C#. You for example have https://github.com/urish/win-ble-cpp/tree/master/BLEScanner.
If you want to use the raw C libraries they work as well, but do not have all features: https://social.msdn.microsoft.com/Forums/en-US/bad452cb-4fc2-4a86-9b60-070b43577cc9/is-there-a-simple-example-desktop-programming-c-for-bluetooth-low-energy-devices?forum=wdk
Related
I'm trying to write a C++ command line program for peer-to-peer file transfer. My idea is to establish a connection with another machine, and send file data directly. My target platform is Windows, but interoperability with Linux and MacOS would be nice. I want this program to be standalone and not require a web browser.
I did some research and it seems that WebRTC would fit the bill, but I can't find much information on using it with C++.
Is it possible to build a standalone executable that utilizes WebRTC without requiring users to download any dependencies in order to use my program?
As the name suggests - to have the "RTC", it requires "Web" component, either in form of browser or a library.
The C++ library is quite huge and it's not a trivial task to understand and write it in a short period. Browser provides APIs in form of JavaScript calls, which are relatively easier to implement.
There might be commercial APIs in C++ available over internet.
I am still new to c++ and winsock stuff. I want to make a MFC application in c++ language with functionality of connecting to a mobile device and transfer data between the PC and mobile device. I cannot find much information on the internet regarding this topic, or maybe is because I am too new this c++ and MFC application, thus having trouble implementing these libraries. I want to start from scanning and discovering nearby Bluetooth devices in an empty c++ console application. Previously done it in c# using the 32Feet.Net library. Do suggest me on how I can perform such task by using c++. Thanks for viewing this topic.
I need to implement an application on Linux that drives a USB connected device (a medical instrument). The application will be written in C++ (2011 standard).
The current application is written for Windows 10 in C# and uses the standard Winusb driver enumerated for the device. I have a complete protocol specification for the commands and the events/interrupts coming back. Unfortunately, I'm not sure how I can pass these to the USB layer in Linux. If it was a simple serial device, there would be no problem but I'm guessing the command responses and the interrupt events are multiplexed by the driver using the functionality in the Winusb driver.
Where's the best place to start in terms of documentation? Alternatively, is there a Linux library (or driver) that provides more or less the same functionality as winusb for Linux?
Any help appreciated. Thanks
Alternatively, is there a Linux library (or driver) that provides more or less the same functionality as winusb for Linux?
One way is using directly the generic kernel API for USB (see the Asynchronous I/O parts to get the interrupts):
https://www.kernel.org/doc/html/v4.15/driver-api/usb/usb.html
This is the strict Linux equivalent of WinUSB.
The potentially less hard way is using libusb, which also get you cross-platform features.
(I am assuming your device is recognized correctly by the kernel, and doesn't need a custom driver)
Is there a Linux library (or driver) that provides more or less the same functionality as winusb for Linux?
Yes. libusb is a popular USB abstraction library that supports Linux, macOS, and Windows. I also wrote a similar library called libusbp with a different set of features that were more useful for my applications. These are C libraries so it will take some work to interoperate with them from C#, but once you do that, you can probably use the same code on either Windows or Linux (so you wouldn't have to maintain your code for calling WinUSB).
I am looking to communicate via RFCOMM to another Bluetooth device. I want to use C++ (VS2008) for the application. I already know of the 32feet library, but was unsure if it would work for C++. Does anyone know of a good starting point for this kind of project? Or possibly 32feet samples written in C++? I want a simple, easy to use API for Bluetooth using C++.
This question is rather old, I know.
Just wanted to update, that Qt Framework has now Qt Bluetooth for C++ that looks very promising -- http://doc.qt.io/qt-5/qtbluetooth-module.html
You can do Bluetooth programming using BT sockets into the OS Bluetooth stack. This page discusses socket usage:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa362928(v=vs.85).aspx
This page has links to download Bluetooth SDK from Microsoft:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363058(v=vs.85).aspx
Building apps using the Microsoft stack works fairly well (XP and Vista work great, trying to run the same apps under Windows 7-64bit does not work so well...)
The real advantage to 32feet.net is that the Bluetooth support on Windows is heavily Balkanized - you never know on a given machine whether it is using the Microsoft, Broadcom, Toshiba, BlueSolei, or some other stack. While these are all mostly compatible over-the-air, the APIs are completely different for each. Building with 32feet.net lets your application run on a larger subset of machines... That said, I have not tried building it into a C++ application - sorry.
The library should;
Be easy to use and few lines of client code should accomplish much
Be as platform independent as possible. (In case of future ports to other platforms)
Have C++ bindings.
Be mature and stable
I would also like to be notified of most HID events through callbacks.
I have considered the following alternatives:
libhid - (Unfortunately?) this is GPL and cannot be used in my application.
WDK - Seems to be a bit low-level for my use. I don’t need that kind of control.
atusbhid - This has an appropriate level of abstraction, but it is firmly tied to the Windows messaging loop
Are there other alternatives to offer?
Take a look at hidapi: it is C, which answers the C++ bindings question (effectively :)), is cross platform and has a very permissive license.
It doesn't appear to have the callbacks, but...
If libhid works for you, then perhaps the thing to do would be to write an application (which you would GPL), which uses libhid to talk to devices, then provides whatever you need via a TCP connection. Your real application would connect via TCP to do what it needs. This would obviously be a massive performance hit.
This application would effectively be a 'shim' between libhid and your application. In this case, the shim would exist for legal, not technical, reasons.
I'm not saying it's a good idea, just that it's an idea.
Consider rolling your own. You'll have total control over the interface, the level of platform independence, and such. Even though a project is GPL, you can use it as a recipe for your own, and as a testbed to find issues with your own.
There are several USB HID host drivers for Windows. An easy-to-use dynamic-link library is from http://embedded24.net.
There are also several example applications included for Visual Studio 2010 (C++, C#, and Visual Basic).
HIDmaker software suite from Trace systems is an option.
Pros:
Easy to use (excellent for learning how to program for USB HID)
Generates working applications source code in a various project formats (Visual Studio and Borland)
Generates stable example code for both host and device (stable in my experience)
High performance (if HID can even be said to have high performance in the first place)
Cons:
Only works on Microsoft Windows
Uses its own USB library I think (ActiveX)
Look at this code:
Read and use FM radio (or any other USB HID device) from C#
It gives you some simple classes to talk to a HID device. It boils down to getting the alias for the device (something like \?\HID#Vid_nnnn&Pid_nnn#...) and use CreateFile to open it. You can get the device's alias under HKML\SYSTEM\CCS\Control\DeviceClasses\{4d1e55...}\.
The Vid and Pid are the vendor ID and product ID of the device (check Device Manager).