Hello All,
I'm trying to connect a USB Dongle to Arduino Mega, everything okay but there is a little problem.
My USB Modem Huawei k3770 has 2 modes Mass storage mode that's the initial and modem mode
when I plug it to my PC it's shown as Mass storage to get driver and the dashboard .. etc after installing it the modem mode will be shown to get connection.
to connect it to my usb host shield I need firstly to do mode switch
By examine the usbmodeswitch debug log in a linux system I found the required details
DefaultVendor= 0x12d1
DefaultProduct= 0x14d1
TargetVendor= 0x12d1
TargetProduct= 0x14c9
TargetClass= not set
TargetProductList=""
DetachStorageOnly=0
HuaweiMode=0
SierraMode=0
SonyMode=0
QisdaMode=0
GCTMode=0
KobilMode=0
SequansMode=0
MobileActionMode=0
CiscoMode=0
MessageEndpoint= not set
MessageContent="55534243123456780000000000000011062000000100000000000000000000"
so I think the important details is DefaultVendor= 0x12d1 DefaultProduct= 0x14d1 TargetVendor= 0x12d1 TargetProduct= 0x14c9 MessageContent="55534243123456780000000000000011062000000100000000000000000000"
but unfortunately I don't know how I can use these details with my software
Could anyone tell me how I can make some coding in my software to switch Huawei k3770 to modem mode firstly before I sent AT Commands?
Sorry I forgot to tell you that I'm using USB Host shield (which depend on MAX3421E).
and I'm knowing about the USB stick it's a combo device contain Modem & CD & Card Reader devices
I have found that AT^U2DIAG=0 runs the USB Stick in the Modem Mode only
I used putty(an app like Hyperterminal) and sent AT^U2DIAG=0 so the USB Stick runs now in the Modem Mode only
As I explained earlier, I'm using Arduino Mega and trying to modify this example to get my modem work
/* Arduino terminal for PL2303 USB to serial converter and DealeXtreme GPRS modem. */
/* USB support */
#include <avrpins.h>
#include <max3421e.h>
#include <usbhost.h>
#include <usb_ch9.h>
#include <Usb.h>
#include <usbhub.h>
#include <avr/pgmspace.h>
#include <address.h>
/* CDC support */
#include <cdcacm.h>
#include <cdcprolific.h>
/* Debug support */
#include <printhex.h>
#include <message.h>
#include <hexdump.h>
#include <parsetools.h>
class PLAsyncOper : public CDCAsyncOper
{
public:
virtual uint8_t OnInit(ACM *pacm);
};
uint8_t PLAsyncOper::OnInit(ACM *pacm)
{
uint8_t rcode;
// Set DTR = 1
rcode = pacm->SetControlLineState(1);
if (rcode)
{
ErrorMessage<uint8_t>(PSTR("SetControlLineState"), rcode);
return rcode;
}
LINE_CODING lc;
//lc.dwDTERate = 9600;
lc.dwDTERate = 115200;
lc.bCharFormat = 0;
lc.bParityType = 0;
lc.bDataBits = 8;
rcode = pacm->SetLineCoding(&lc);
if (rcode)
ErrorMessage<uint8_t>(PSTR("SetLineCoding"), rcode);
return rcode;
}
USB Usb;
//USBHub Hub(&Usb);
PLAsyncOper AsyncOper;
PL2303 Pl(&Usb, &AsyncOper);
void setup()
{
Serial.begin( 115200 );
Serial.println("Start");
if (Usb.Init() == -1)
Serial.println("OSCOKIRQ failed to assert");
delay( 200 );
}
void loop()
{
Usb.Task();
if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
{
uint8_t rcode;
/* reading the keyboard */
if(Serial.available()) {
uint8_t data= Serial.read();
/* sending to the phone */
rcode = Pl.SndData(1, &data);
if (rcode)
ErrorMessage<uint8_t>(PSTR("SndData"), rcode);
}//if(Serial.available()...
/* reading the converter */
/* buffer size must be greater or equal to max.packet size */
/* it it set to 64 (largest possible max.packet size) here, can be tuned down
for particular endpoint */
uint8_t buf[64];
uint16_t rcvd = 64;
rcode = Pl.RcvData(&rcvd, buf);
if (rcode && rcode != hrNAK)
ErrorMessage<uint8_t>(PSTR("Ret"), rcode);
if( rcvd ) { //more than zero bytes received
for(uint16_t i=0; i < rcvd; i++ ) {
Serial.print((char)buf[i]); //printing on the screen
}
}//if( rcvd ...
}//if( Usb.getUsbTaskState() == USB_STATE_RUNNING..
}
I tried this code with these USB Modems list :
ZTE MF180
Huawei E303
Huawei E220
Huawei k3565
Huawei k3765
Huawei K3770