Windows: Disable / Enable USB Hub WITHOUT reboot - windows

I would like to be able to programmatically disable or enable a USB hub in order to make the USB devices connected to it unavailable or available, respectively. I did some testing using device manager and then using Devcon, and found that when certain devices are connected to the hub (specifically some Android phones), it cannot be disabled right away, and it is marked for disabling after reboot instead.
I tried to get over this problem by trying to also disable problematic devices connected to the hub, but this also failed.
I also tried using the SetupDixxx API directly, and even some USB IOCTLs, but I did not manage to get this task done.
I believe there ought to be a way of forcing immediate disable of a hub without reboot. I would appreciate it if anyone could point me to the right way.
Thanks in advance,
Ziv

Related

How do you disconnect a Bluetooth device in a Windows driver so that Windows doesn't lose it's pairing?

I'm currently working on a Windows driver for Nintendo Wii remotes and I want the PC to be able to disconnect the device without removing it's pairing. I know this behavior exists since my mouse is capable of doing it. What I want it to do is, when looking in Devices and Printers, the device should show as grayed out when off/out of range. Unfortunately I can't find any documentation on how to do this, either because I don't know what this exact behavior is called or because it's never clearly stated in the documentation. Does anyone have any idea how this is implemented?
EDIT: Realized this was probably not a Bluetooth specific feature since printers also make use of this and removed the Bluetooth tag.

Programmatically restarting a driver windows

I'm working on a KMDF pcie driver. Currently if I disconnect/reconnect the device, windows does not recognize that the device was disconnected, does not re-enumerate the node, and does not release the driver.
Currently the best way is to disable/enable the driver manually through device manager, which causes a reload. When I try to do this manually through SetupAPI.h, by using SetupDiSetClassInstallParams and SetupDiCallClassInstaller, I get an 0xe0000219 error on SetupDiCallClassInstaller, which corresponds to NO_ASSOCIATED_SERVICE, and I have no idea how to deal with this. Is there a better way to programmatically force a restart?
Alternatively, is there a way to get the translated resource list WDFCMRESLIST, normally provided by the plug-n-play EvtDevicePrepareHardware callback? This way I could reconfigure my driver.

Windows Phone - Application crashes when disconnected from PC

Whenever I disconnect my Windows Phone from PC (connected through USB) and if my application is running, my application hangs for sometime and then application crashes.
Does anyone experienced same behavior? I guess switching for PC connection to Wi-Fi/GPRS is causing the issue.
the windows Phone Requires that you Safely Remove hardware first, after a few times when i started Development on the windows phone i did the same and Ended up getting a new Phone. So plainly put, try to Safely Remove and Make sure it is installing the app to the Device.
Meaning if you Remove the phone, the App is still able to be ran just like a normal downloaded App form the Market place.
if you want more in depth information, i would suggest Reading the WP7 Everything Programming ebook lol
its filled with good information, and Definitely Helped me along my road to Love DEV for WP7.
As gamernb says, if you disconnect the USB from a properly tethered Windows Phone (i.e. connected to Zune, or using the WPConnect utility), the phone's network connection will be reset and your app's connections will be terminated. The phone will then start trying to connect using WiFi or cellular data (if they are on), but this can take quite a while.
You will have to handle this network disconnection in your app - I've found that pulling the USB cable in this way is a good ad-hoc test for WP7 apps: do an action which you know will use the network connection. Then watch if the app crashes, or handles this gracefully.
Actually you aren't guaranteed to always use the PC data connection: if you make sure that the computer has no data connection (i.e. pull the Ethernet cable, turn off WiFi etc ), the WP7 app can then use cellular data or WiFi on the phone instead.
Alas-
you could set perimeters in your application to Check what the connection type is, then Make changes accordingly.
You May have a slight freeze, but that's better then a crash....mainly when the phone switches from PC to WWAN, their would be a slight Pause.
use the Reachability Class and NSLog to Figure out whats going on exactly.
I really hope that helps!

How do I debug wireless problems on a mobile app when it has to be wired to run in debug mode?

I'm trying to track down some bugs on a Windows Mobile 5.0 app. The testers can reproduce these bugs no problem, but I can't. They are using the devices across a wireless network, but I'm always running the app in an emulator, or on the actual device while it's in its cradle. In other words I always have a hard-wired connection.
I'm not sure how to approach this. Boatloads of logging? Is there some way to get Visual Studio to "Start Debugging" across the wireless connection? How does one effectively debug wireless connection issues on a mobile device?
You can get the debugger working over the wireless by manually running conmanclietn2.exe and cmaccept.exe, but the fact that the debugger is then using the connection may well affect your testing (depends on what the issues you're trying to find are). Your best bet is to use logging.
Another option to try is to enable the WLAN connection when you're device is in the cradle (I assume it now switches off the WLAN connection when you cradle it, which is the WM5 default).
If you're using Vista, go to the Windows Mobile Device Center and under Mobile Device Settings go to Connection Settings. Make sure the Allow Data Connections On Device When Connected To A PC option is ticked (I think the option is called the same in ActiveSync in case you're using XP). That way you will have an active WLAN connection when trying to debug through the cradle.

Windows Mobile Device Emulator - how to save config permanently?

I am working at a client site where there is a proxy server (HTTP) in place. If I do a hard reset of the emulator it forgets network connection settings for the emulator and settings in the hosted Windows Mobile OS. If I 'save state and exit' it will lose all of these settings. I need to do hard resets regularly which means that I lose this information and spend a lot of time setting:
The emulators associated network card
DNS servers for network card in the WM OS.
Proxy servers in connection settings of WM OS.
How can I make my life easier? Can I save this as defaults in the emulator, or create an installer easily?
There is a way you can programmatically provision your devices. If you're using managed code, you can use Microsoft.WindowsMobile.Configuration.dll to do most of the work for you. If you're using unmanaged code, you have to use DMProcessConfigXML native function.
There's more details in this blog post by Andrew Arnott.
The problem with these devices is everything is stored in the RAM and ROM. So you need a second alternate device storage for these settings, just like a real device. So that when a real device, or your device is reset, it has a statically stored configuration file outside of the RAM that can be loaded on start up. The alternative is to do soft-resets if possible.

Resources