The C Source, Patches and (shudder!) Bugs
Post Reply
macauxdragon
Posts: 2
Joined: 23 Jul 2011, 16:23
Location: Macau, China

Succeed to switch "Qisda H21 Flying beetle" on Ze

Post by macauxdragon » 23 Jul 2011, 16:57

I have got a Qisda H21 USB 3G Modem from my ISP. I tried to make it work on ZeroShell.

I have found a router (EDIMAX 3G-6200WG) which can work. Edimax has shared the firmware source.
http://www.edimax.com/tw/liunux.php?u=. ... 122010.zip

The folder has the source code:
3G6x00N_GPL_for_Edimax_08122010\3G6x00N\AP\3G\usb_modeswitch-0.9.7

I followed it to edit usb_modeswitch 1.1.8 and compile it on CentOS 5.3.
I saved it to usb disk and plug in a old pc with "ZeroShell-1.0.beta15-CompactFlash-IDE-USB-SATA-1GB.img.gz"(I used Winimage restore .img file to a harddisk.)


root@zeroshell root> cd /tmp
root@zeroshell tmp> cd /mnt
root@zeroshell mnt> mkdir usb1
root@zeroshell mnt> mount /dev/sda1 ./usb1
root@zeroshell mnt> cd usb1
root@zeroshell usb1> cd _usb_modeswitch
root@zeroshell _usb_modeswitch> ./usb_modeswitch -c ./usb_modeswitch.conf
root@zeroshell _usb_modeswitch> modprobe usbserial vendor=0x1da5 product=0x4512



I opened browser and changed setting in "ZeroShell-->SETUP-->NETWROK--> New 3G Modem"
In "2G/3G Mobile Connection" page,
"Modem connected to" choose "ttyUSB1"
"Dial string" type "*99#"

My "APN" is "ctm-mobile.t" (A ISP in Macao, China.)

Here is my code:
http://www.sendspace.com/file/399hed

rss
Posts: 7
Joined: 10 Aug 2011, 19:35
Location: Russia
Contact:

Post by rss » 17 Oct 2011, 19:47

Qisda modems support. Prepared patch from sources by macauxdragon.

Code: Select all

########################################################
# Qisda H21 Flying Beetle

DefaultVendor= 0x1da5
DefaultProduct=0xf000

TargetVendor=  0x1da5
TargetProduct= 0x4512

CheckSuccess=20

QisdaMode=1
 

Code: Select all

--- a/usb_modeswitch.c	2011-10-11 22:51:58.323482655 +0400
+++ b/usb_modeswitch.c	2011-10-11 22:51:09.400482654 +0400
@@ -207,6 +207,7 @@ int ret;
 
 char DetachStorageOnly=0, HuaweiMode=0, SierraMode=0, SonyMode=0, GCTMode=0, KobilMode=0;
 char SequansMode=0, MobileActionMode=0, CiscoMode=0;
+char QisdaMode=0;
 char verbose=0, show_progress=1, ResetUSB=0, CheckSuccess=0, config_read=0;
 char NeedResponse=0, NoDriverLoading=0, InquireDevice=1, sysmode=0;
 
@@ -241,6 +242,7 @@ static struct option long_options[] = {
 	{"huawei-mode",			no_argument, 0, 'H'},
 	{"sierra-mode",			no_argument, 0, 'S'},
 	{"sony-mode",			no_argument, 0, 'O'},
+	{"qisda-mode",			required_argument, 0, 'B'}, // tommy add for Qisda Flying Beetle
 	{"kobil-mode",			no_argument, 0, 'T'},
 	{"gct-mode",			no_argument, 0, 'G'},
 	{"sequans-mode",		no_argument, 0, 'N'},
@@ -274,6 +276,7 @@ void readConfigFile(const char *configFi
 	ParseParamBool(configFilename, HuaweiMode);
 	ParseParamBool(configFilename, SierraMode);
 	ParseParamBool(configFilename, SonyMode);
+	ParseParamBool(configFilename, QisdaMode);
 	ParseParamBool(configFilename, GCTMode);
 	ParseParamBool(configFilename, KobilMode);
 	ParseParamBool(configFilename, SequansMode);
@@ -331,6 +334,7 @@ void printConfig()
 	printf ("HuaweiMode=%i\n",			(int)HuaweiMode);
 	printf ("SierraMode=%i\n",			(int)SierraMode);
 	printf ("SonyMode=%i\n",			(int)SonyMode);
+	printf ("QisdaMode=%i\n",		(int)QisdaMode);
 	printf ("GCTMode=%i\n",			(int)GCTMode);
 	printf ("KobilMode=%i\n",		(int)KobilMode);
 	printf ("SequansMode=%i\n",		(int)SequansMode);
@@ -409,6 +413,7 @@ int readArguments(int argc, char **argv)
 			case 'H': HuaweiMode = 1; break;
 			case 'S': SierraMode = 1; break;
 			case 'O': SonyMode = 1; break;
+			case 'B': QisdaMode = 1; break;
 			case 'G': GCTMode = 1; break;
 			case 'T': KobilMode = 1; break;
 			case 'N': SequansMode = 1; break;
@@ -623,7 +628,7 @@ int main(int argc, char **argv)
 	}
 
 	/* Some scenarios are exclusive, so check for unwanted combinations */
- 	specialMode = DetachStorageOnly + HuaweiMode + SierraMode + SonyMode + KobilMode
+ 	specialMode = DetachStorageOnly + HuaweiMode + SierraMode + SonyMode + QisdaMode + KobilMode
 		+ SequansMode + MobileActionMode + CiscoMode;
 	if ( specialMode > 1 ) {
 		SHOW_PROGRESS("Invalid mode combination. Check your configuration. Aborting.\n\n");
@@ -663,6 +668,9 @@ int main(int argc, char **argv)
 		detachDriver();
 		switchGCTMode();
 	}
+	if (QisdaMode) {
+		switchQisdaMode();
+	}
 	if(KobilMode) {
 		detachDriver();
 		switchKobilMode();
@@ -1079,6 +1087,19 @@ int switchKobilMode() {
 	return 1;
 }
 
+int switchQisdaMode () {
+	int ret;
+
+	SHOW_PROGRESS("Trying to send Qisda control message\n");
+	memcpy(buffer, "\x05\x8c\x04\x08\xa0\xee\x20\x00\x5c\x01\x04\x08\x98\xcd\xea\xbf", 16);
+	ret = usb_control_msg(devh, 0x40, 0x04, 00000000, 0, buffer, 16, 100);
+	if (ret != 0) {
+		fprintf(stderr, "Error: sending Qisda control message failed (error %d). Aborting.\n\n", ret);
+		exit(1);
+	} else
+	SHOW_PROGRESS(" OK, Qisda control message sent\n");
+	return 1;
+}
 
 int switchSonyMode ()
 {
@@ -1863,6 +1884,7 @@ void printHelp()
 	        " -A, --mobileaction-mode       apply a special procedure\n"
 	        " -T, --kobil-mode              apply a special procedure\n"
 	        " -L, --cisco-mode              apply a special procedure\n"
+	        " -B, --qisda-mode              apply a special procedure\n"
 	        " -R, --reset-usb               reset the device after all other actions\n"
 	        " -Q, --quiet                   don't show progress or error messages\n"
 	        " -W, --verbose                 print all settings and debug output\n"

--- a/usb_modeswitch.h	2011-08-10 14:57:06.000000000 +0400
+++ b/usb_modeswitch.h	2011-10-11 22:50:46.237270752 +0400
@@ -35,6 +35,7 @@ void switchHuaweiMode();
 void switchSierraMode();
 void switchGCTMode();
 int switchKobilMode();
+int switchQisdaMode();
 int switchSequansMode();
 int switchActionMode();
 int switchSonyMode(); 
See:

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Post by Josh » 22 Oct 2011, 21:55

Sorry, this somehow stayed off my radar ... I only just discovered the patch ...

I'm in the process of preparing the next release. Of course I'll include the Qisda code!
Consequently, you should both be added to the code contributors list. Is that all right with you?

Thank you very much !!


macauxdragon
Posts: 2
Joined: 23 Jul 2011, 16:23
Location: Macau, China

Post by macauxdragon » 23 Oct 2011, 12:06

Josh. Thanks for your attention! I am pleasure of being one of contributors. It was a good experience of modding the code especially usb_modeswitch is a very famous program for Zero CD devices. Finally, with rss's help, I have made my router using the 3G modem now. Of course, it also need to thanks the open sources from Edimax. I just simply reference it's source and modify your source by my little programming knowledge. Thanks for your great usb_modeswitch!

rss, you have helped me so much, especially your changes for dial script. thank you!

rss said, he has forgotten to change this file.
http://wl500g.googlecode.com/svn/trunk/ ... itch.rules

40-usb_modeswitch.rules:
# Qisda H21 Flying Beetle
ATTRS{idVendor}=="1da5", ATTRS{idProduct}=="f000", RUN+="usb_modeswitch '%b/%k'"

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Post by Josh » 24 Oct 2011, 19:35

My "rules" file is generated automatically from the config files with the help of a script, and the config files are created from the file "device_reference.txt" by annother script, so there is almost no danger of forgetting an entry.

You can check out the new release of both program and data package. It's all in there.


Post Reply