I think this question has been asked in different forms but there is no clear answer.
I want to be able to discover all available BLE device and connect to any of them. My peripheral device advertises a certain service. I read about 32feet.NET library and tried to use it but apparently it does not support BLE, and the only way I can scan my device through this library is to connect to windows first and then do the discovery.
I also went through this article: Acuire data by C# from BLE but it didn't work for my device and I couldn't do any scanning. I even bought TI BLE dongle and tried their sample app: TI sample app but it didn't work with my peripheral device.
Then I tried to use Windows 8 sample code for BLE Heart-rate app it worked fine with a heart rate BLE sensor, but still I couldn't get it to work with my peripheral device.
I thought there is a problem with my device but there is an app in iPhone called LightBlue which discovers BLE devices and can act as a peripheral device too, I even used that app but couldn't get it to work with Windows.
So my question is, is there any way or library or anything for C# that I can use to scan BLE devices and connect to them and send/received date?
Thanks
I wasn't able to find a library for Windows Form styled programs, however, Universal Windows Apps have the Windows.Devices.Bluetooth namespace which will allow you to do everything you described (it's a little rough around the edges, though).
Related
I wonder if it is possible to discover unpaired Bluetooth devices programmatically within a Windows 10 tablet application.
I really don't want to pair by Settings -> Devices -> Bluetooth.
Unfortunately I couldn't find any documentation/example that would have helped.
I tried to search for Bluetooth devices by using the BluetoothLEAdvertisementWatcher but I wasn't able to find any. Probably because these devices were no BluetoothLE devices. Thought these were compatible.
Also I thought it would be possible to create a CLI/C++ wrapper that I could reuse in my UWP application but I feel very uncertain about that as not the whole (especially the interfacing part of the) Win32 API is re-usable in UWP environment.
At a last option I thought there must be a way to just get the list of devices that Windows generates when entering Settings -> Devices -> Bluetooth and I tried to achieve that by using a DeviceWachter but without success.
Now I am very desperate. For my application it would be horrible to manually pair each and every device before using it. I cannot understand why Microsoft cuts the developers so enormous.
Thanks in advance for your help.
Grace's answer is correct. I tried this sample before but stopped working on it as it expected a Windows Phone instead of a Windows 10 tablet.
Now I extracted the DeviceWatcher part but created the DeviceWatcher with the selector BluetoothDevice.GetDeviceSelectorFromPairingState(false). Only with this selecter the watcher was able to finde unpaired Bluetooth devices.
It also works with:
DeviceInformation.FindAllAsync(BluetoothDevice.GetDeviceSelectorFromPairingState(false))
I wonder if it is possible to discover unpaired Bluetooth devices programmatically within a Windows 10 tablet application.
Yes, it's possible.
I tried to search for Bluetooth devices by using the BluetoothLEAdvertisementWatcher but I wasn't able to find any. Probably because these devices were no BluetoothLE devices.
You used a wrong watcher. What you need is DeviceWatcher, not BluetoothLEAdvertisementWatcher. The difference between them is that the DeviceWatcher is for enumerating devices dynamically, while the BluetoothLEAdvertisementWatcher is for receiving Bluetooth Low Energy (LE) advertisements.
There is an official Device enumeration and pairing sample, you can refer to scenario 8 of this sample, this sample is absolutely what you need.
apologies if the question is quite basic, I am inexperienced in USB programming and I might be missing some conceptual detail here.
For our industrial solution we are supposed to provide communication between our PC wpf application and windows embedded HH 8.1 application. Ideally we would like this to be over USB.
I see a lot of sample code to connect directly to USB devices from host role.
However in our case the Windows Embedded HH device (Panasonic FZ-E1) will have the device role listening. I could not find any way to register to raw data sent from our PC application via USB events. I examined UMDF (user mode driver framework) which has examples about writing drivers for usb devices, yet it seems like it is for device manufacturers and us not being the manufacturer for Panasonic HH we should not/cannot use our own driver and we have to use the WinUSB driver it already has in place.
Windows Embedded 8.1 HH has some USB apis unlike windows phone, yet all the functionality provided in the API seems like connecting to external USB devices with the host role. When we use USBlyzer I see that there is some USB traffic towards the device from the PC so it looks it should be possible for the HH to have the listening device role. What am I missing here, any ideas?
Any help/direction is greatly appreciated.
P.S: I also tried windows connectivity api examining the source code of windows phone power tools yet it seems like the the dlls for addon packages here to handle transfer via agents is not there for newer versions of windows phone anymore.
I am writing a BT app on an android to connect to a lab device/hardware. At the present time I have a device on loan. However it is not possible for me to always have one while I am developing for it, (commuting, out of town, etc) Therefore I am creating an emulator for it and will run that emulator on my Windows desktop so that my Android client code can make connections to it.
The android code is built with .NET/xamarin and works fine connecting to the real device.
I am comfortable with C++ or C# on the desktop.
I have found this code http://www.codeproject.com/Articles/252882/Bluetooth-Server-Programming-on-Windows online to create and accept BT connections. it looks like a very good start for what I wish to do - which is build a state machine/emulator to mimic the real device. However I have been unable to connect my android device to it.
Note - the connection is a serial port connection. (the UUI coming from the android device is the "well known" serial port connection ("00001101-0000-1000-8000-00805F9B34FB")
I am not sure how to configure the windows 7 desktop and bluetooth services to allow this server/emulator program to accept connections.
I have paired the devices, but unable to connect.
How can I accept incoming Bluetooth serial connections in the C++ or C# code running on Win7 desktop?
If you want to do low level stuff like establish a connection via bluetooth through a C# app then you will need to access the bluetooth stack via its API. If your device is running the Microsofts Bluetooth Stack then you can look at 32feet.net's managed wrapper for Microsofts Bluetooth API. If you have the Widcomm stack then you will have to locate Widcomm's API for it.
To access the microsoft bluetooth stack, you can use the BthUtil.dll.
BthUtil.dll is an unmanaged dll which is part of the Microsoft Bluetooth stack. It's typically utilised for tasks such as turning the bluetooth radio on or off via a function called BthSetMode
(see MSDN for documentation - http://msdn2.microsoft.com/EN-US/library/aa456007.aspx)
You can check the following links:-
http://www.youtube.com/watch?v=Jn05CU3mxzo
Also, check the 32feet.Net
A Brief description of 32feet.Net
32feet.NET is a shared-source project to make personal area networking technologies such as Bluetooth, Infrared (IrDA) and more, easily accessible from .NET code.
Supports desktop, mobile or embedded systems.
32feet.NET is free for commercial or non-commercial use.
If you use the binaries you can just use the library as-is, if you make modifications to the source you need to include the 32feet.NET License.txt document and ensure the file headers are not modified/removed. The project currently consists of the following libraries:-
Bluetooth
IrDA
Object Exchange
Bluetooth support requires a device with either the Microsoft, Widcomm, BlueSoleil, or Stonestreet One Bluetopia Bluetooth stack. Requires .NET Compact Framework v3.5 or above and Windows CE.NET 4.2 or above, or .NET Framework v3.5 for desktop Windows XP, Vista, 7 and 8.
Link
http://32feet.codeplex.com/
Feature link for 32feet.Net
http://32feet.codeplex.com/wikipage?title=Feature%20support%20table&referringTitle=Documentation
Does anyone know if it's possible to use Bluetooth to connect to multiple phones using C# Monotouch/Xamarin iOS?
Update
I'd preferably like to connect multiple phones to one main phone
host, all via Bluetooth (1 host and 3 or 4 clients).
I don't know a
great deal about bluetooth and the various profiles, so I'd be
looking for guidance on this aspect also.
Yes, you can.
iOS 7.0 introduced the Multipeer Connectivity framework. It can work with both bluetooth and/or wifi (and can even bridge between them, pretty neat).
You can find sample code (e.g. chat, mixed with iBeacons) by googling around for Multipeer Connectivity, iOS and monotouch.
I am trying to find a sample that connect a Win RT app with other Bluetooth devices for example a PC. It is a basic thing but seems like it is not supported in WinRT.
In one thread a Microsoft employee says
.... Other than the call control sample, there is no Bluetooth stack
available for Store apps...
After reading other similar threads it seems to me that this is not possible at the moment. Am I right or is there any way to connect a Win RT app with some other device like a desktop app on PC via Bluetooth?
After reading many questions and articles (some links are below) on different forums I have reached to conclusion that communication between a Metro Style App and a PC is not possible via Bluetooth. One option is to go with is WiFi.
Some useful links which supports this conclusion are below
http://social.msdn.microsoft.com/Forums/en-US/tailoringappsfordevices/thread/6634240b-c042-4e76-a3b0-1f1103ea0ddf
http://social.msdn.microsoft.com/Forums/en-US/tailoringappsfordevices/thread/0cb2a6c1-d1f1-4872-aa32-709acd90b94d
http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/9db327e1-afe4-443b-8856-343492645083/
http://social.msdn.microsoft.com/Forums/en-US/tailoringappsfordevices/thread/172061f4-56ff-4fd2-987d-687d4703506d
The WinRT 8.1 Bluetooth stack provides the requisite services for ad hoc Bluetooth communications with similarly capable devices. More specifically, peer discovery and peer to peer communications is supported.