I have a USB 3G modem which does the “flip flop” - without drivers, it acts as a USB mass storage device until it’s sent the “mode switch” request, after which it shows up as a virtual COM/serial device.
It successfully initializes as a Mass Storage device via USBHostController, but I’m not sure how I can send it the “mode switch” command. I tried casting the mode switch class as a generic device, but I get an invalid cast exception.
The usb_modeswitch.c (from Linux) data is as follows:
MessageEndpoint = 0x05
MessageContent = “55534243904ed68a24000000800008ff024445564348470000000000000000”
Here’s my test code:
// perform mode switch
if (device.TYPE == USBH_DeviceType.MassStorage)
{
Debug.Print("Setting up modem...");
USBH_Descriptors.Configuration cd = ((USBH_RawDevice)device).GetConfigurationDescriptors(0);
byte[] init_string = { 85, 83, 66, 67, 144, 78, 214, 138, 36, 0, 0, 0, 128, 0, 8, 255, 2, 68, 69, 86, 67, 72, 71, 0, 0, 0, 0, 0, 0, 0, 0 };
((USBH_RawDevice)device).SendSetupTransfer(0x00, 0x05, cd.bConfigurationValue, 0x00, init_string, 0, init_string.Length);
Any thoughts on how to make this work?