This is quite a general question I think but searching online I can't really find that much information. I have an embedded system with a Bluetooth chip that I often use to connect to another embedded device. This connection is very robust and never fails.
However the embedded system can also connect to windows via a virtual serial port. I've written a piece of software to handle the connection using the 32Foot inthehand bluetooth library. It works very consistently on some computers (including my own) but entirely fails or is very flakey on others. One of which is actually an identical system ( same hardware/ same version of windows)
Is there anything I should specifically be looking at in my software to improve reliability accross different computers/ versions of windows when it comes to bluetooth pairing, creation of virtual com ports etc.
Thanks
I write software that runs on Windows and connects to an embedded device via a virtual serial port using the 32Foot library. I've experienced similar issues to you, and from experience the main problems are:
Conflicts between Bluetooth radio on Windows:
Is more than one Bluetooth radio installed/attached? I find that if on a Windows machine there is both an external Bluetooth dongle plugged in, and the internal Bluetooth is switched on, it won't work.
Widcomm/Broadcom and BlueSoleil stacks:
These don't support authentication, and Widcomm/Broadcom don't support setting of a pin. You can check if BluetoothRadio.PrimaryRadio is not null, and if so find out the SoftwareManufacturer of the Bluetooth Radio. If the Manufacturer enum is Bluesoleil, Widcomm or Broadcom then just don't use authentication or SetPin when initializing the BluetoothClient.
Toshiba stack:
This isn't supported at all
Is a supported Bluetooth radio and stack even currently available?:
You can handle a PlatformNotSupportedException which will tell you if there is no currently available supported Bluetooth stack on the machine. This won't let you know if there is more than one radio attached however.
Finally, from experience, internal Bluetooth chips don't always have a good range and interference can really affect the connection. I have had better luck with an external Bluetooth dongle.
Related
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
And by this question I mean the user assigned names windows lets you type in like: "My home network" "Basement" "Garage" not the ssid (though I would also like to read that one for the wifi connections)
and I especially want to read the windows security levels that can be chosen for networks: Home/Office/Public
I want to use this information to switch programs on and off automatically when connecting to various networks.
Update:
Thanks to the answer of #Damien_The_Unbeliever I was able to solve my question and find the following information, I hope it will help others too:
Network awareness in windows 7 and vista (MSDN, Unmanaged)
Windows API Code Pack (Microsoft, managed wrapper for
NetworkListManager and others)
How to use the windows NLM API to get notified of new network
connectivity (Codeproject, Managed)
It sounds like you want to use the Network List Manager:
The Microsoft Windows networking environment allows multihomed computers to connect to several networks simultaneously. There may be multiple wireless networks available along with LAN and dial-up connections. Network List Manager identifies available networks and returns network attribute data to the application.
It's a COM API, I'm not aware of a managed equivalent.
I have a device and the drivers for this device. What I would like to do is build an application that mocks a USB device to communicate with a third party application.
More specifically, I am attempting to build an application that can mock a USB device that mimics a Microsoft Zune. I want to make it so my application can register as a zune device and then communicate with the client. I have added several DLL's to my application in order to attempt to determine the calls that tell the software a connected device is a legitimate zune, but so far I haven't had much luck.
I'm new to this type of development - that is mimicking hardware devices, and I'm not very experienced in importing dll's that were written in C/C++. I am using Visual Studio 2010 (.net 4.0) to develop my app, and I would appreciate any help anyone can offer me towards mimicking the hardware. I do have the device drivers, which Visual studio refuses to reference directly. I also have an actual physical device, so I can see what the drivers are that it uses in Device Manager.
The goal is as follows
Application registers itself as a usb device, mimicking a Microsoft Zune in a similar fashion to how Virtual Clone Drive mimics a DVD player.
Application is recognized by zune client as a valid microsoft zune.
Zune Software works with application as it does the hardware device (syncing, etc)
I just found something called the Device Simulation Framework, which might be exactly what you need. It will still require significant research into how USB works to finish your solution, though. And probably still typically done using C or C++.
The Zune uses a modified version of the MTP protocol called MTPZ, but I found this sample using the Device Simulation Framework to simulate a regular MTP device. It's called The MTP Device Simulator. I can't tell if source code is available.
Are you able to replace the DLLs used by the zune client software with your own DLLs? In that case, you could wrap the original DLLs with your DLLs and intercept the operations.
Update: To find out the signatures of the functions in the DLL, take a look at the Dependency Walker tool, which will list the exported functions (and lots of other information). I'm guessing you will want to write your replacement DLL in C.
Otherwise, you'll have to write drivers that register a USB device with the proper endpoints. I'm not sure how to do this on Windows - I've only done USB coding on the firmware side, not the driver side. You should be able to use any tutorial for creating a Windows USB driver, like Getting Started with USB Driver Development
Zune specifics information might also be useful. Perhaps this blog post and its sequels could help: Inside the Zune/USB Protocol: Part 1
I need to connect and disconnect USB devices, such as flash drives, in a programmatical manner, without unplugging and re-plugging the device.
Is there any way to do it in a C# Windows application?
You might want to look at some related questions:
Safe remove USB-Drive using Win32 API?
Windows - Power off an usb device in software
Both of the approaches mentioned in the answers are readily translatable to C#.