For debugging and testing an android device that connects to a custom USB peripheral, we'd like a software controlled way to unplug and replug the USB.
It looks like USB cables have 4 wires so I'm thinking if the specific device I need doesn't exist (I haven't found it) all I really need is a software controlled 4-channel switch so I can just cut the USB cable in half and plug the wires from each side into the switches, and open/close the switch using software.
Sane so far?
I looked around and found devices like this: https://www.amazon.com/SMAKN-Channel-Programmable-Computer-Control/dp/B01KWTL0BQ/.
Here is a diagram of how I imagine this would work:
A couple things I'm not clear about:
This will work (as with all things: if done correctly!).
The relay on that board is a hardware relay; when closed, it is electrically indistinguishable from a normal piece of wire. It's rated for 12 V which is fine for this application.
One precaution is that the USB connector is designed so that the different contacts meet in a specific order (e.g. ground first because it is the outer case, then the interior pins are different length so the power pins meet before the data pins) - your controller software should mimic this to avoid causing any potential issues if either device is unprepared for a different connection order.