I am working with Bluetooth 4.0 LE Beacons and need to scan for Bluetooth LE devices from
within my C++ Application (based on OpenFrameworks). I couldn't find and API documentation for
C++ how to deal with Bluetooth LE yet.
Eventually, I could use also Objective-C code in the C++ project, but I am a C++ developer
and not used to Objective-C.
I would suggest using the Qt framework's Bluetooth module since you are familiar with C++ and need to work on OSX:
http://doc.qt.io/qt-5/qtbluetooth-lowenergyscanner-example.html
An example can be found here so it is easy to get something up and running:
http://doc.qt.io/qt-5/qtbluetooth-lowenergyscanner-example.html
Note if accessing the BLE's manufacturer specific data is important to you, you may have to wait until Qt gets those APIs added.
Related
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'm trying to search and connect to advertising Bluetooth Low Energy devices from C++ code.
I would like a piece of code to use laptop's wireless chip to discover and connect to BLE devices, regardless of their GATT Services.
I want in fine to use GATT properties (Services, Characteristics, Descriptors, Notification).
Programmatically
I have the BluetoothLEAdvertisementWatcher Class documentation from Windows API.
I tried to make working this example but without good results.
I also tried this example, but no success.
Manually
I figured out using Windows 10 Action Center, and use manual pairing to connect devices (because Windows con see and connect my device).
Then I could use directely the Windows.Devices.Bluetooth.GenericAttributeProfile Namespace
Is there a way to implement that automatically?
Hello Raphaƫl and welcome to stackoverflow. When you say "without good results" or "but no success", you should detail why (compilation error, runtime error...).
I used this piece of code:
Getting BLE Beacons in C++ Windows 10 Desktop Application
It compiles under Win10, so should the third link you posted (https://github.com/urish/win-ble-cpp) as it's very similar if you look at the includes here. Just note that this is not regular win32 projects: from Visual Studio you must create a new "Windows"/"Universal" C++ project, else they won't compile.
Alternatively, if you're OK with using a 3rd party library, you could simply use QtBluetooth, recent version supports windows 10. Then you can easily access BLE features from aregular win32 project.
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
I'm new to Arduino, and one thing I came across is this cool tool called Embedxcode, which basically allows you to compile and run sketches on the Arduino from Xcode instead of from the normal Arduino compiler.
The reason I'm using this is because I want the user to be able to do something on the Arduino (i.e. push a button) and the computer responds (i.e. call some function in Objective-C). Since as far as I know you can't do that from the Arduino compiler, I've decided to use Xcode because it can compile Objective-C and use the OSX SDK.
I got Embedxcode to work (the Arduino code compiles and uploads to the board fine), but I can't get Objective-C working. As in, I cannot create a new Objective-C class to pass data to without Xcode giving me errors (and no, renaming the C++ files to .mm did not work).
Does anybody know how to solve this? Or is there a better way to get Arduino to directly interact with OSX events?
embedXcode allows the use of the Xcode IDE for embedded development, but this doesn't include the OS X SDK or the OS X build toolchain. You are still using the AVR toolchain, but with Xcode in front to manage the project. That being said, you are limited to avr-gcc and avr-g++, no Objective-C. It is possible to pass data between C++ and Objective-C classes, but not in the context to which you are referring.
EDIT: If you really want to use Objective-C and Arduino, I suggest researching avr-gcc and Objective-C. According to the avr-gcc man page, Objective-C is supported. Although, getting this work will require meandering away from the cozy Arduino workspace.
It seems like you are misunderstanding the Arduino, and the microcontroller <-> PC relationship. The Arduino (and any microcontroller) is a small standalone computer running its own tiny operating system. So your question in light of that is: how do I get one computer to talk to another computer.
The IDE (XCode, the Arduino environment, etc.) has nothing to do with this. Those are just tools for writing and compiling code, and uploading it to the Arduino processor.
To connect any two computers, you have two options: through wires or through radio waves. The wired option is the easiest to implement and understand. You have two options here, direct USB connection and Ethernet. USB is the easiest to implement and understand and the barebones Arduino is capable of this. Ethernet would require addition hardware.
The wireless options would include Bluetooth, WiFi, XBee radio. These work well but are complicated to implement and require additional hardware.
So... I'd suggest you start with USB. There are many tutorials out there. On the OSX side you will need to write some software to communicate with the Arduino. This could be an app written in ObjectiveC or Java (e.g. using Processing) or Python, or any number of other programming languages. I'd suggest Processing as there are many Arduino <-> Processing tutorials on the web.
Key search terms for finding tutorials: Arduino serial port Processing
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.