Qt Pairing Blutooth Device Ubuntu - c++

I am building an application in which I would like to pair a bluetooth low energy device and connect to it.
What should be the typical workflow for this
if the device bluetooth address is known
if the device bluetooth address is not known
Is QBluetoothDeviceDiscoveryAgent the class to do all this? If so, do you need to pair in the OS level (for instance using bluetooth icon in task bar) first or can it be done programmatically?
Thanks!

I believe that ble devices cannot be paired via settings in OS, because they can discover only bt classic devices. In ble devices bonding is not necessary, but sometimes is done for security reasons.
QBluetoothDeviceDiscoveryAgent class is only for discovering devices. For connecting to device is used QLowEnergyController class. For more info I would refer to Qt quides as I have only experience with Qt only with bluetooth classic devices

Related

Using usb to connect Android to Pixhawk

I am looking for a way to connect my pixhawk to an android device using the USB(OTG) cable.
After doing some research i figured there is two possible ways to do that. Either using the micro usb port on the pixhawk or just using a USB FTDI cable to use the telemetry port.
What i am asking if it would be possible to use dronekit android with either of those options ?
If yes which one would you recommend.
Thanks
I consider you wanna make a "flying Android"?
Android device is not a good onboard device because of its poor IO ports.But Android is a good device to be a ground station.
You can only use a USB FTDI to connect each other.The micro-usb on pixhawk is used to debug,your vehicle while not fly if pixhawk's micro-usb is in use.

Windows form application for USB port

Previously I have work with Windows Form application to establish some RS232 connection. I used the already provided serial port component (SerialPort), and I was able to establish RS232 communication relatively easy.
Now, I was wondering if there will be something similar in Winodows Form application to establish a USB communication ?
It seems there is this WinUSB API that provides a very low level interfacing with the device.
However, I am not sure how easy will that be? Also, not sure how easy will it be to integrate into Windows Form application ?!
Will there be a simpler version of such USB interface API?
I don't have to stick to Visual Studio. Is there other c++ USB API, besides WinUSB, that is more standard that people use? I would like to develop a GUI API that does some communication over USB. If need be, I can use Python or some other tools if it facilitates the process?
Thanks in advance.
Although USB is a serial protocol, you can't treat USB like a serial port:
It's dependant on what the actual device is. For example a mobile phone, may provide several "endpoints" for USB, one being a serial port to use the phone as a modem, one as a storage device allowing you to transfer photos and music files to/from the phones storage, and as a camera device that you can take photos with. All of these have different behaviour and need a USB driver-plugin to make it behave correctly - these are typically shipped with Windows, and your phone will appear as COM5:, the E: or "Samsung Galaxy S3 Mini" drives and as a camera under the "cameras and scanners".
Of course, you can programmatically open all these devices, but it is done as the device-type that they present as on the inside of windows (so you use serial port functions or file functions or camera functions).
You CAN also write a device driver for a device, if you have sufficient details of how it works.
But there's no real way to "open the port". The USB API is a driver API, not a user-mode API. Here's a page to start from to understand USB drivers:
http://msdn.microsoft.com/en-gb/library/windows/hardware/ff540215%28v=vs.85%29.aspx
There is a WinUSB driver, which allows a single application to access a single device, assuming you know how to operate that device.

How to check network interface type is Ethernet or Wireless on Windows using Qt?

I need to find out the network interface type is Wired or Wireless on PC.
I have tried using QNetworkInterface class which provides Adapter Name. But adapter name can be changed by user on Windows. On Mac, I can check for interface type as eth0 or eth1 since it is same for all users.
I also tried QNetworkConfiguration::bearerType, But I am getting configuration as Ethernet i.e. BearerEthernet for both wired and wireless configuration.
Is there any other way to find out network interface type in Qt or using Windows platform specific APIs?
This Native Wifi API example can help: http://msdn.microsoft.com/en-us/library/ms706749%28v=VS.85%29.aspx

What usb device is connected to a usb port

I'll try to keep this simple.
I have a hub connected to my PC. This hub has several USB interfaces. I'm listening to WM_DEVICECHANGE event and I get the USB interface path. How can I know what port it was connected to? Looking for a non-WMI solution in c++ or c# for a windows environment.
I tried using IOCTL_USB_GET_NODE_CONNECTION_NAME with USB_NODE_CONNECTION_NAME (where USB_NODE_CONNECTION_NAME.NodeName will hold the path to the device) but this only works if the device connected to the port is a hub as well.
Any help will be much appreciated.
The primary issue in C++ is that there is no standard functions for detecting USB ports.
USB Port identification and implementation is a platform specific issue. For example, Linux handles USB ports quite differently than Windows and many embedded systems don't have USB ports.
So you'll have to look for a 3rd party library or find some OS API to use for your platform.

Trigger an exe once My device is connected via USB

Once my embedded device is connected to USB port of my PC, it should trigger an exe as an event. How can I achieve this??
Should I create a service to keep monitoring the USB connector bus or is there any default API's available in Windows to achieve this??
thanks.
A simple exe which is started on connect is not possible. But you can write a service or user mode application which listens for device arrival events. WM_DEVICECHANGE is sent to all (registered) applications with a device interface guid which represents which device is plugged in. You can then use this id with the setupapi to see if its your device.
On receiving that event, you can then start your executable.
Depending on your version of Windows it might be possible with a workaround using a AutoRun.inf file in the root folder of a USB drive. For security reasons this is by default turned off, and in Windows 7 not allowed at all.
To achieve the same effect in a more robust way, you need to create a service that monitors whether your device is connected or not (e.g. iTunesHelper that monitors for connected Apple devices).
The easiest solution is probably a trivial UMDF driver. That's basically a small COM component called when your device is connected.