source: src/router/libutils/lib3g.c @ 15805

Last change on this file since 15805 was 15805, checked in by BrainSlayer, 2 years ago

typo

File size: 24.2 KB
Line 
1/*
2 * lib3g.c
3 *
4 * Copyright (C) 2009 Sebastian Gottschall <gottschall@dd-wrt.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 *
20 * $Id:
21 * this module detects various special 3G/CDMA USB Devices which is required to handle them correct, since some devices
22 * are using non standard tty interfaces. everything which is not handled here in this list, is supported by the default tty handling which means dialin on tty0
23 */
24
25#include <stdio.h>
26#include <stdlib.h>
27#include <shutils.h>
28#include <bcmnvram.h>
29
30static int scanFor(int Vendor, int Product)
31{
32#if defined(ARCH_broadcom) && !defined(HAVE_BCMMODERN)
33        char grepstr[128];
34        sprintf(grepstr, "grep Vendor=%x ProdID=%x /tmp/usb/devices|wc -l",
35                Vendor, Product);
36        FILE *check = popen(grepstr, "rb");
37        if (check) {
38                int count = 0;
39                fscanf(check, "%d", &count);
40                fclose(check);
41                if (count > 0) {
42                        eval("umount /tmp/usb");
43                        return 1;
44                }
45        }
46        return 0;
47#else
48        int count = 1;
49        int hub = 1;
50        while (hub < 5) {
51                char sysfs[64];
52                sprintf(sysfs, "/sys/bus/usb/devices/%d-0:1.0/bInterfaceNumber",
53                        count);
54                FILE *probe = fopen(sysfs, "rb");
55                if (!probe) {
56                        count = 1;
57                        hub++;
58                        continue;
59                }
60                fclose(probe);
61
62                sprintf(sysfs, "/sys/bus/usb/devices/%d-%d/idProduct", count,
63                        hub);
64                FILE *modem = fopen(sysfs, "rb");
65                if (!modem) {
66                        count++;
67                        continue;
68                }
69                int idProduct;
70                int idVendor;
71                fscanf(modem, "%X", &idProduct);
72                fclose(modem);
73                sprintf(sysfs, "/sys/bus/usb/devices/%d-%d/idVendor", count,
74                        hub);
75                modem = fopen(sysfs, "rb");
76                if (!modem) {
77                        count++;
78                        continue;
79                }
80                fscanf(modem, "%X", &idVendor);
81                fclose(modem);
82                if (idVendor == Vendor && idProduct == Product)
83                        return 1;
84
85                count++;
86        }
87        return 0;
88#endif
89}
90
91void checkreset(char *tty)
92{
93#ifdef HAVE_CAMBRIA
94        eval("comgt", "-d", tty, "-s", "/etc/comgt/reset.comgt");
95        FILE *check = NULL;
96        int count = 0;
97        sleep(1);
98        while (!(check = fopen(tty, "rb")) && count < 10) {
99                sleep(1);
100                count++;
101        }
102        if (check)
103                fclose(check);
104        else
105                fprintf(stderr, "reset error\n");
106        fprintf(stderr, "wakeup card\n");
107        eval("comgt", "-d", tty, "-s", "/etc/comgt/wakeup.comgt");
108        sleep(5);               //give extra delay for registering
109#endif
110}
111
112static void reset_mc(int needreset, char *controldev)
113{
114        if (needreset)
115                checkreset(controldev);
116}
117
118static void modeswitch_usb760(int needreset, char *controldev)
119{
120        system
121            ("usb_modeswitch -v 0x1410 -p 0x5010 -M 5553424312345678000000000000061b000000020000000000000000000000");
122        system
123            ("usb_modeswitch -v 0x1410 -p 0x5020 -M 5553424312345678000000000000061b000000020000000000000000000000");
124        system
125            ("usb_modeswitch -v 0x1410 -p 0x5030 -M 5553424312345678000000000000061b000000020000000000000000000000");
126        system
127            ("usb_modeswitch -v 0x1410 -p 0x5031 -M 5553424312345678000000000000061b000000020000000000000000000000");
128        system
129            ("usb_modeswitch -v 0x1410 -p 0x5041 -M 5553424312345678000000000000061b000000020000000000000000000000");
130        sleep(2);
131}
132
133static void modeswitch_onda(int needreset, char *controldev)
134{
135        FILE *out = fopen("/tmp/usb_modeswitch.conf", "wb");
136
137        fprintf(out, "DefaultVendor=0x19d2\n"
138                "DefaultProduct=0x2000\n"
139                "TargetVendor=0x19d2\n"
140                "TargetProductList=\"0001,0002,0015,0016,0017,0031,0037,0052,0055,0063,0064,0108,0128\"\n"
141                "MessageContent=\"5553424312345678000000000000061e000000000000000000000000000000\"\n"
142                "MessageContent2=\"5553424312345679000000000000061b000000020000000000000000000000\"\n"
143                "MessageContent3=\"55534243123456702000000080000c85010101180101010101000000000000\"\n"
144                "NeedResponse=1\n" "CheckSuccess=20\n");
145        fclose(out);
146        system("usb_modeswitch -c /tmp/usb_modeswitch.conf");
147        sleep(2);
148}
149
150static void modeswitch_onda2(int needreset, char *controldev)
151{
152        system
153            ("usb_modeswitch -v 0x19d2 -p 0x0003 -M 5553424312345678000000000000061e000000000000000000000000000000 -2 5553424312345679000000000000061b000000020000000000000000000000");
154        system
155            ("usb_modeswitch -v 0x19d2 -p 0x0026 -n -M 5553424312345678000000000000061b000000020000000000000000000000");
156        system
157            ("usb_modeswitch -v 0x19d2 -p 0x0040 -n -M 5553424312345678000000000000061e000000000000000000000000000000 -2 5553424312345679000000000000061b000000020000000000000000000000");
158        system
159            ("usb_modeswitch -v 0x19d2 -p 0x0053 -n -M 5553424312345678000000000000061e000000000000000000000000000000 -2 5553424312345679000000000000061b000000020000000000000000000000");
160        system
161            ("usb_modeswitch -v 0x19d2 -p 0x0083 -n -M 5553424312345678000000000000061b000000020000000000000000000000");
162        system
163            ("usb_modeswitch -v 0x19d2 -p 0x0101 -n -M 5553424312345678000000000000061b000000020000000000000000000000");
164        system
165            ("usb_modeswitch -v 0x19d2 -p 0x0103 -n -M 5553424312345678000000000000061e000000000000000000000000000000 -2 5553424312345679000000000000061b000000020000000000000000000000");
166        system
167            ("usb_modeswitch -v 0x19d2 -p 0x0115 -n -M 5553424312345678000000000000061b000000020000000000000000000000");
168        system
169            ("usb_modeswitch -v 0x19d2 -p 0x1001 -n -M 5553424312345678000000000000061b000000020000000000000000000000");
170        system
171            ("usb_modeswitch -v 0x19d2 -p 0x1007 -n -M 5553424312345678000000000000061b000000020000000000000000000000");
172        system
173            ("usb_modeswitch -v 0x19d2 -p 0x1009 -n -M 5553424312345678000000000000061b000000020000000000000000000000");
174        system
175            ("usb_modeswitch -v 0x19d2 -p 0x1013 -n -M 5553424312345678000000000000061b000000020000000000000000000000");
176        system
177            ("usb_modeswitch -v 0x19d2 -p 0xfff5 -M 5553424312345678c00000008000069f030000000000000000000000000000");
178        system
179            ("usb_modeswitch -v 0x19d2 -p 0xfff6 -M 5553424312345678c00000008000069f030000000000000000000000000000");
180        sleep(2);
181}
182
183static void modeswitch_sierra(int needreset, char *controldev)
184{
185        FILE *out = fopen("/tmp/usb_modeswitch.conf", "wb");
186
187        fprintf(out, "DefaultVendor=0x1199\n"
188                "DefaultProduct=0x0fff\n"
189                "TargetVendor=0x1199\n"
190                "TargetProductList=\"0017,0018,0019,0020,0021,0022,0024,0026,0027,0028,0029,0112,0120,0218,0220,0224,6802,6803,6804,6805,6808,6809,6812,6813,6815,6816,6820,6821,6822,6832,6833,6834,6835,6838,6839,683a,683b,683c,683d,683e,6850,6851,6852,6853,6855,6856,6859,685a\"\n"
191                "SierraMode=1\n" "CheckSuccess=10\n");
192        fclose(out);
193        system("usb_modeswitch -c /tmp/usb_modeswitch.conf");
194        sleep(2);
195}
196
197static void modeswitch_huawei(int needreset, char *controldev)
198{
199        system("usb_modeswitch -v 0x12d1 -p 0x1001 -H");
200        system("usb_modeswitch -v 0x12d1 -p 0x1003 -H");
201        system("usb_modeswitch -v 0x12d1 -p 0x1414 -H");
202        system
203            ("usb_modeswitch -v 0x12d1 -p 0x101e -M 55534243123456780600000080000601000000000000000000000000000000");
204        system
205            ("usb_modeswitch -v 0x12d1 -p 0x1031 -M 55534243123456780600000080010a11060000000000000000000000000000");
206        system
207            ("usb_modeswitch -v 0x12d1 -p 0x1446 -M 55534243123456780000000000000011060000000000000000000000000000");
208        system
209            ("usb_modeswitch -v 0x12d1 -p 0x14ad -M 55534243123456780000000000000011060000000000000000000000000000");
210        system
211            ("usb_modeswitch -v 0x12d1 -p 0x14c6 -M 55534243123456780000000000000011060000000000000000000000000000");
212        system
213            ("usb_modeswitch -v 0x12d1 -p 0x1520 -M 55534243123456780000000000000011060000000000000000000000000000");
214        system
215            ("usb_modeswitch -v 0x12d1 -p 0x1521 -M 55534243123456780000000000000011060000000000000000000000000000");
216        system
217            ("usb_modeswitch -v 0x12d1 -p 0x1523 -M 55534243123456780000000000000011060000000000000000000000000000");
218        system
219            ("usb_modeswitch -v 0x12d1 -p 0x1557 -M 55534243123456780000000000000011060000000000000000000000000000");
220        sleep(2);
221}
222
223static void modeswitch_icon210(int needreset, char *controldev)
224{
225        FILE *out = fopen("/tmp/usb_modeswitch.conf", "wb");
226        fprintf(out, "DefaultVendor=0x1e0e\n");
227        fprintf(out, "DefaultProduct=0xf000\n");
228        fprintf(out, "TargetVendor=0x1e0e\n");
229        fprintf(out, "TargetProductList=\"9200,9000\"\n");
230        fprintf(out,
231                "MessageContent=\"555342431234567800000000000006bd000000020000000000000000000000\"\n");
232        fprintf(out, "NeedResponse=1\n");
233        fclose(out);
234        system("usb_modeswitch -c /tmp/usb_modeswitch.conf");
235        sleep(2);
236}
237
238static void hsoinit_icon225(int needreset, char *controldev)
239{
240        system("ozerocdoff -wi 0x6971");
241        sleep(10);
242        system("insmod hso");
243        FILE *out = fopen("/tmp/conninfo.ini", "wb");
244        fprintf(out, "APN=%s\n", nvram_safe_get("wan_apn"));
245        fprintf(out, "USER=%s\n", nvram_safe_get("ppp_username"));
246        fprintf(out, "PASS=%s\n", nvram_safe_get("ppp_passwd"));
247        fprintf(out, "PIN=%s\n", nvram_safe_get("wan_pin"));
248        fclose(out);
249        nvram_set("3gdata", "hso");
250        system("/etc/hso/hso_connect.sh restart");
251}
252
253struct DEVICES {
254        int vendor;
255        int product;
256        char *driver;
257        char *controldevice;
258        char *datadevice;
259        int modeswitch;
260        void (*customsetup) (int needreset, char *controldev);
261        char *name;
262};
263
264static struct DEVICES devicelist[] = {
265//sierra wireless cards
266        {0x1199, 0x0fff, "sierra", "3", "4", 1, &modeswitch_sierra, "Sierra Device CDROM Mode"},        //
267        {0x1199, 0x0017, "sierra", "3", "4", 1, NULL, "Sierra Wireless Modem Mode"},    //
268        {0x1199, 0x0018, "sierra", "3", "4", 1, NULL, "Sierra Wireless Modem Mode"},    //
269        {0x1199, 0x0019, "sierra", "3", "4", 1, NULL, "Sierra Wireless AC595U Modem Mode"},     //
270        {0x1199, 0x0020, "sierra", "3", "4", 1, NULL, "Sierra Wireless Modem Mode"},    //
271        {0x1199, 0x0021, "sierra", "3", "4", 1, NULL, "Sierra Wireless AC597E Modem Mode"},     //
272        {0x1199, 0x0022, "sierra", "3", "4", 1, NULL, "Sierra Wireless Modem Mode"},    //
273        {0x1199, 0x0024, "sierra", "3", "4", 1, NULL, "Sierra Wireless MC5727 CDMA Modem Mode"},        //
274        {0x1199, 0x0026, "sierra", "3", "4", 1, NULL, "Sierra Wireless Modem Mode"},    //
275        {0x1199, 0x0027, "sierra", "3", "4", 1, NULL, "Sierra Wireless Modem Mode"},    //
276        {0x1199, 0x0028, "sierra", "3", "4", 1, NULL, "Sierra Wireless Modem Mode"},    //
277        {0x1199, 0x0029, "sierra", "3", "4", 1, NULL, "Sierra Wireless Modem Mode"},    //
278        {0x1199, 0x0112, "sierra", "3", "4", 1, NULL, "Sierra Wireless CDMA 1xEVDO PC Card, Aircard 580 Modem Mode"},   //
279        {0x1199, 0x0120, "sierra", "3", "4", 1, NULL, "Sierra Wireless AC595U Modem Mode"},     //
280        {0x1199, 0x0218, "sierra", "3", "4", 1, NULL, "Sierra Wireless MC5720 Wireless Modem"}, //
281        {0x1199, 0x0220, "sierra", "3", "4", 1, NULL, "Sierra Wireless Modem Mode"},    //
282        {0x1199, 0x0224, "sierra", "3", "4", 1, NULL, "Sierra Wireless Modem Mode"},    //
283        {0x1199, 0x6802, "sierra", "0", "2", 1, NULL, "Sierra Wireless MC8755 Modem Mode"},     //
284        {0x1199, 0x6803, "sierra", "0", "2", 1, NULL, "Sierra Wireless MC8765 Modem Mode"},     //
285        {0x1199, 0x6804, "sierra", "0", "2", 1, NULL, "Sierra Wireless MC8755 Modem Mode"},     //
286        {0x1199, 0x6805, "sierra", "0", "2", 1, NULL, "Sierra Wireless MC8765 Modem Mode"},     //
287        {0x1199, 0x6808, "sierra", "0", "2", 1, NULL, "Sierra Wireless MC8755 Modem Mode"},     //
288        {0x1199, 0x6809, "sierra", "0", "2", 1, NULL, "Sierra Wireless MC8755 Modem Mode"},     //
289        {0x1199, 0x6812, "sierra", "0", "2", 1, &reset_mc, "Sierra Wireless MC8775V"},  //
290        {0x1199, 0x6813, "sierra", "0", "2", 1, NULL, "Sierra Wireless MC8775 Modem Mode"},     //
291        {0x1199, 0x6815, "sierra", "0", "2", 1, NULL, "Sierra Wireless MC8775 Modem Mode"},     //
292        {0x1199, 0x6816, "sierra", "0", "2", 1, NULL, "Sierra Wireless MC8775 Modem Mode"},     //
293        {0x1199, 0x6820, "sierra", "0", "2", 1, NULL, "Sierra Wireless AC875 Modem Mode"},      //
294        {0x1199, 0x6821, "sierra", "2", "0", 1, NULL, "Sierra Wireless AC875U Modem Mode"},     //
295        {0x1199, 0x6822, "sierra", "3", "4", 1, NULL, "Sierra Wireless Modem Mode"},    //
296        {0x1199, 0x6832, "sierra", "2", "0", 1, &reset_mc, "Sierra Wireless MC8780 Modem Mode"},        //
297        {0x1199, 0x6833, "sierra", "3", "4", 1, NULL, "Sierra Wireless MC8781 Modem Mode"},     //
298        {0x1199, 0x6834, "sierra", "3", "4", 1, NULL, "Sierra Wireless Modem Mode"},    //
299        {0x1199, 0x6835, "sierra", "3", "4", 1, NULL, "Sierra Wireless Modem Mode"},    //
300        {0x1199, 0x6838, "sierra", "3", "4", 1, NULL, "Sierra Wireless Modem Mode"},    //
301        {0x1199, 0x6839, "sierra", "3", "4", 1, NULL, "Sierra Wireless Modem Mode"},    //
302        {0x1199, 0x683a, "sierra", "3", "4", 1, NULL, "Sierra Wireless MC8785 Modem Mode"},     //
303        {0x1199, 0x683b, "sierra", "3", "4", 1, NULL, "Sierra Wireless MC8785 Composite Modem Mode"},   //
304        {0x1199, 0x683c, "sierra", "3", "4", 1, &reset_mc, "Sierra Wireless MC8790"},   //
305        {0x1199, 0x683d, "sierra", "3", "4", 1, &reset_mc, "Sierra Wireless MC8791 Composite"}, //
306        {0x1199, 0x683e, "sierra", "3", "4", 1, &reset_mc, "Sierra Wireless MC8790"},   //
307        {0x1199, 0x6850, "sierra", "2", "0", 1, NULL, "Sierra Wireless AirCard 880 Modem Mode"},        //
308        {0x1199, 0x6851, "sierra", "2", "0", 1, NULL, "Sierra Wireless AirCard 881 Modem Mode"},        //
309        {0x1199, 0x6852, "sierra", "2", "0", 1, NULL, "Sierra Wireless AirCard 880E Modem Mode"},       //
310        {0x1199, 0x6853, "sierra", "2", "0", 1, NULL, "Sierra Wireless AirCard 881E Modem Mode"},       //
311        {0x1199, 0x6855, "sierra", "2", "0", 1, NULL, "Sierra Wireless Modem Mode"},    //
312        {0x1199, 0x6856, "sierra", "2", "0", 1, NULL, "Sierra Wireless ATT USB Connect 881 Modem Mode"},        //
313        {0x1199, 0x6859, "sierra", "2", "0", 1, NULL, "Sierra Wireless Modem Mode"},    //
314        {0x1199, 0x685a, "sierra", "2", "0", 1, NULL, "Sierra Wireless Modem Mode"},    //
315        {0x1199, 0x6880, "sierra", "3", "3", 1, NULL, "Sierra Wireless Compass 885"},   //
316        {0x1199, 0x6890, "sierra", "3", "3", 1, NULL, "Sierra Wireless Compass 888"},   //
317        {0x1199, 0x6893, "sierra", "3", "3", 1, NULL, "Sierra Wireless Compass 889"},   //
318//      {0x1199, 0x68a3, "sierra", "3", "4", 1, NULL, "Sierra Wireless Compass 889"},   //alternate variant
319        {0x1199, 0x68a3, "sierra", "2", "2", 1, &reset_mc, "Sierra Wireless MC8700/Compass Direct IP"}, //
320//option/huawei
321        {0x12d1, 0x1001, "option", "0", "0", 2, &modeswitch_huawei, "HUAWEI/Option E600/E620 or generic"},      //
322        {0x12d1, 0x1003, "option", "0", "0", 2, &modeswitch_huawei, "HUAWEI/Option E172/EC27/E220/E230/E270 HSDPA/HSUPA Model"},        //
323        {0x12d1, 0x1009, "option", "0", "0", 2, &modeswitch_huawei, "HUAWEI/Option U120"},      //
324        {0x12d1, 0x101e, "option", "0", "0", 2, &modeswitch_huawei, "HUAWEI U7510 / U7517"},    //
325        {0x12d1, 0x1031, "option", "0", "0", 2, &modeswitch_huawei, "HUAWEI U8110 (Android smartphone)"},       //
326        {0x12d1, 0x1035, "option", "0", "0", 2, NULL, "HUAWEI U8110 (Android smartphone)"},     //
327        {0x12d1, 0x1414, "option", "0", "0", 2, &modeswitch_huawei, "HUAWEI/Option E180"},      //
328        {0x12d1, 0x1406, "option", "0", "0", 2, NULL, "HUAWEI/Option newer modems"},    //
329        {0x12d1, 0x140b, "option", "0", "0", 2, NULL, "HUAWEI/Option EC1260 Wireless Data Modem HSD USB Card"}, //
330        {0x12d1, 0x140c, "option", "0", "0", 2, NULL, "HUAWEI/Option newer modems"},    //
331        {0x12d1, 0x1412, "option", "0", "0", 2, NULL, "HUAWEI/Option EC168"},   //
332        {0x12d1, 0x141b, "option", "0", "0", 2, NULL, "HUAWEI/Option newer modems"},    //
333        {0x12d1, 0x14ac, "option", "0", "0", 2, NULL, "HUAWEI/Option newer modems"},    //
334        {0x12d1, 0x14ae, "option", "0", "0", 2, NULL, "Vodafone (Huawei) K3806"},       //
335        {0x12d1, 0x1446, "option", "0", "0", 2, &modeswitch_huawei, "HUAWEI/Option E1552 HSPA Modem"},  //
336        {0x12d1, 0x14ad, "option", "0", "0", 2, &modeswitch_huawei, "Vodafone (Huawei) K3806"}, //
337        {0x12d1, 0x14c1, "option", "0", "0", 2, &modeswitch_huawei, "Vodafone (Huawei) K4605"}, //
338        {0x12d1, 0x14c6, "option", "0", "0", 2, NULL, "Vodafone (Huawei) K4605"},       //
339        {0x12d1, 0x1520, "option", "0", "0", 2, &modeswitch_huawei, "Huawei K3765"},    //
340        {0x12d1, 0x1465, "option", "0", "0", 2, NULL, "Huawei K3765"},  //
341        {0x12d1, 0x1521, "option", "0", "0", 2, &modeswitch_huawei, "Huawei K4505"},    //
342        {0x12d1, 0x1464, "option", "0", "0", 2, NULL, "Huawei K4505"},  //
343        {0x12d1, 0x1521, "option", "0", "0", 2, &modeswitch_huawei, "Huawei R201"},     //
344        {0x12d1, 0x1491, "option", "0", "0", 2, NULL, "Huawei R201"},   //
345        {0x12d1, 0x1557, "option", "0", "0", 2, &modeswitch_huawei, "Huawei E173"},     //
346        {0x12d1, 0x14a5, "option", "0", "0", 2, NULL, "Huawei E173"},   //
347
348        {0x0af0, 0x7011, "option", "0", "0", 2, NULL, "HUAWEI/Option E301 HSUPA"},      //
349
350        {0x1410, 0x5010, "option", "0", "0", 2, &modeswitch_usb760, "Novatel CDROM Mode"},      //
351        {0x1410, 0x5020, "option", "0", "0", 2, &modeswitch_usb760, "Novatel MC990D CDROM Mode"},       //
352        {0x1410, 0x5030, "option", "0", "0", 2, &modeswitch_usb760, "Novatel USB760 CDROM Mode"},       //
353        {0x1410, 0x5031, "option", "0", "0", 2, &modeswitch_usb760, "Novatel USB760 3G CDROM Mode"},    //
354        {0x1410, 0x5041, "option", "0", "0", 2, &modeswitch_usb760, "Novatel Generic MiFi 2352 / Vodafone MiFi 2352 CDROM Mode"},       //
355        {0x1410, 0x4100, "option", "0", "0", 2, NULL, "Novatel U727 Modem Mode"},       //
356        {0x1410, 0x4400, "option", "0", "0", 2, NULL, "Novatel Ovation MC930D/MC950D Modem Mode"},      //
357
358        {0x1410, 0x7001, "option", "0", "0", 2, NULL, "Novatel Generic MiFi 2352 / Vodafone MiFi 2352 Modem Mode"},     //
359        {0x1410, 0x7003, "option", "0", "0", 2, NULL, "Novatel Generic MiFi 2352 / Vodafone MiFi 2352 Modem Mode"},     //
360
361        {0x1410, 0x6000, "option", "0", "0", 2, NULL, "Novatel USB760 Modem Mode"},     //
362        {0x1410, 0x6002, "option", "0", "0", 2, NULL, "Novatel USB760 3G Modem Mode"},  //
363//qualcomm
364        {0x1e0e, 0x9000, "option", "2", "2", 3, NULL, "Option iCON 210, PROLiNK PHS100, Hyundai MB-810, A-Link 3GU Modem Mode"},        //
365        {0x1e0e, 0x9200, "option", "2", "2", 3, NULL, "Option iCON 210, PROLiNK PHS100, Hyundai MB-810, A-Link 3GU Modem Mode"},        //
366        {0x1e0e, 0xf000, "option", "2", "2", 3, &modeswitch_icon210, "Option iCON 210, PROLiNK PHS100, Hyundai MB-810, A-Link 3GU CDROM Mode"}, //
367        {0x0af0, 0x6971, NULL, "hso", "hso", 0, &hsoinit_icon225, "Qualcomm ICON 225"}, //
368//ericsson
369        {0x0bdb, 0x1900, "option", "4", "4", 0, NULL, "Ericsson F3507g"},       //
370        {0x0bdb, 0x1902, "option", "4", "4", 0, NULL, "Ericsson F3507g"},       //
371//ONDA
372        {0x19d2, 0x2000, "option", "1", "1", 2, &modeswitch_onda, "ONDA/ZTE (cdrom mode)"},     //
373        {0x19d2, 0x0001, "option", "1", "3", 2, NULL, "ONDA MT505UP/ZTE (modem mode)"}, //
374        {0x19d2, 0x0002, "option", "1", "3", 2, NULL, "ZTE ET502HS/MT505UP/MF632"},     //
375        {0x19d2, 0x0003, "option", "1", "3", 2, &modeswitch_onda2, "ZTE MU351 (cdrom mode)"},   //
376        {0x19d2, 0x0015, "option", "1", "3", 2, NULL, "ONDA MT505UP/ZTE (modem mode)"}, //
377        {0x19d2, 0x0016, "option", "1", "3", 2, NULL, "ONDA MT505UP/ZTE (modem mode)"}, //
378        {0x19d2, 0x0017, "option", "1", "3", 2, NULL, "ONDA MT505UP/ZTE (modem mode)"}, //
379        {0x19d2, 0x0022, "option", "1", "3", 2, NULL, "Vodafone (ZTE) K2525 (modem mode)"},     //
380        {0x19d2, 0x0026, "option", "1", "3", 2, &modeswitch_onda2, "ZTE AC581 (cdrom mode)"},   //
381        {0x19d2, 0x0031, "option", "1", "2", 2, NULL, "ZTE MF110/MF112/MF626 (Variant) (modem mode)"},  //tested on MF626
382        {0x19d2, 0x0037, "option", "1", "3", 2, NULL, "ONDA MT505UP/ZTE (modem mode)"}, //
383        {0x19d2, 0x0040, "option", "1", "3", 2, &modeswitch_onda2, "Vodafone (ZTE) K2525 (cdrom mode)"},        //
384        {0x19d2, 0x0052, "option", "1", "3", 2, NULL, "ONDA MT505UP/ZTE (modem mode)"}, //
385        {0x19d2, 0x0053, "option", "1", "3", 2, &modeswitch_onda2, "ZTE MF110 (Variant) (modem mode)"}, //
386        {0x19d2, 0x0055, "option", "1", "3", 2, NULL, "ONDA MT505UP/ZTE (modem mode)"}, //
387        {0x19d2, 0x0063, "option", "1", "3", 2, NULL, "Vodafone K3565-Z HSDPA (modem mode)"},   // tested, working. i hope the other ZDA devices are working in the same way
388        {0x19d2, 0x0064, "option", "1", "3", 2, NULL, "ZTE MF627 AU (modem mode)"},     //
389        {0x19d2, 0x0083, "option", "1", "3", 2, &modeswitch_onda2, "ZTE MF110 (Variant) (cdrom mode)"}, //
390        {0x19d2, 0x0094, "option", "1", "3", 2, NULL, "ZTE AC581 (modem mode)"},        //
391        {0x19d2, 0x0101, "option", "1", "3", 2, &modeswitch_onda2, "Vodafone (ZTE) K4505-Z (cdrom mode)"},      //
392        {0x19d2, 0x0103, "option", "1", "3", 2, &modeswitch_onda2, "ZTE MF112 (cdrom mode)"},   //
393        {0x19d2, 0x0104, "option", "1", "3", 2, NULL, "Vodafone (ZTE) K4505-Z (modem mode)"},   //
394        {0x19d2, 0x0108, "option", "1", "3", 2, NULL, "ONDA MT505UP/ZTE (modem mode)"}, //
395        {0x19d2, 0x0115, "option", "1", "3", 2, &modeswitch_onda2, "ONDA MT505UP/ZTE (modem mode)"},    //
396        {0x19d2, 0x0116, "option", "1", "3", 2, NULL, "ZTE MF651 (cdrom mode)"},        //
397        {0x19d2, 0x0117, "option", "1", "2", 2, NULL, "ZTE MF112 (modem mode)"},        // tested, works
398        {0x19d2, 0x0128, "option", "1", "3", 2, NULL, "ZTE MF651 (modem mode)"},        //
399        {0x19d2, 0x0124, "option", "1", "3", 2, NULL, "ZTE MF110 (Variant) (modem mode)"},      //
400        {0x19d2, 0x1001, "option", "1", "3", 2, &modeswitch_onda2, "Vodafone (ZTE) K3805-Z (cdrom mode)"},      //
401        {0x19d2, 0x1003, "option", "1", "3", 2, NULL, "Vodafone (ZTE) K3805-Z (modem mode)"},   //
402        {0x19d2, 0x1007, "option", "1", "3", 2, &modeswitch_onda2, "Vodafone (ZTE) K3570-Z (cdrom mode)"},      //
403        {0x19d2, 0x1008, "option", "1", "3", 2, NULL, "Vodafone (ZTE) K3570-Z (modem mode)"},   //
404        {0x19d2, 0x1009, "option", "1", "3", 2, &modeswitch_onda2, "Vodafone (ZTE) K3571-Z (cdrom mode)"},      //
405        {0x19d2, 0x1010, "option", "1", "3", 2, NULL, "Vodafone (ZTE) K3571-Z (modem mode)"},   //
406        {0x19d2, 0x1013, "option", "1", "3", 2, &modeswitch_onda2, "Vodafone (ZTE) K3806-Z (cdrom mode)"},      //
407        {0x19d2, 0x1015, "option", "1", "3", 2, NULL, "Vodafone (ZTE) K3806-Z (modem mode)"},   //
408        {0x19d2, 0xfff5, "option", "1", "3", 2, &modeswitch_onda2, "ZTE generic (cdrom mode)"}, //
409        {0x19d2, 0xfff6, "option", "1", "3", 2, &modeswitch_onda2, "ZTE generic (cdrom mode)"}, //
410        {0x19d2, 0xfff1, "option", "1", "3", 2, NULL, "ZTE generic (modem mode)"},      //
411        {0x19d2, 0xffff, "option", "1", "3", 2, NULL, "ZTE generic (modem mode)"},      //
412
413        {0xffff, 0xffff, NULL, NULL, NULL, 0, NULL, NULL}       //
414};
415
416char *get3GControlDevice(void)
417{
418#if defined(ARCH_broadcom) && !defined(HAVE_BCMMODERN)
419        mkdir("/tmp/usb");
420        eval("mount", "-t", "usbfs", "usb", "/tmp/usb");
421//insmod("sierra");  //further investigation required (compass problem)
422#endif
423        int needreset = 1;
424        char *ttsdevice = "/dev/usb/tts/0";
425#ifdef HAVE_CAMBRIA
426        int gpio1 = atoi(nvram_safe_get("gpio26"));
427        int gpio2 = atoi(nvram_safe_get("gpio27"));
428        int select = atoi(nvram_safe_get("wan_select"));
429        switch (select) {
430        case 1:
431                if (gpio1 == 1 || gpio2 == 0)
432                        needreset = 0;
433                else {
434                        gpio1 = 1;
435                        gpio2 = 0;
436                }
437                break;
438        case 2:
439                if (gpio1 == 0 || gpio2 == 1)
440                        needreset = 0;
441                else {
442                        gpio1 = 0;
443                        gpio2 = 1;
444                }
445                break;
446        case 3:
447                if (gpio1 == 1 || gpio2 == 1)
448                        needreset = 0;
449                else {
450                        gpio1 = 1;
451                        gpio2 = 1;
452                }
453                break;
454        default:
455                if (gpio1 == 0 && gpio2 == 0) {
456                        gpio1 = 1;
457                        gpio2 = 0;
458                } else
459                        needreset = 0;
460                break;
461        }
462        if (gpio1) {
463                nvram_set("gpio26", "1");
464                set_gpio(26, 1);
465        } else {
466                nvram_set("gpio26", "0");
467                set_gpio(26, 0);
468        }
469        if (gpio2) {
470                nvram_set("gpio27", "1");
471                set_gpio(27, 1);
472        } else {
473                nvram_set("gpio27", "0");
474                set_gpio(27, 0);
475        }
476#endif
477        nvram_unset("3gnmvariant");
478        nvram_set("3gdata", "/dev/usb/tts/0");
479
480        int devicecount = 0;
481        while (devicelist[devicecount].vendor != 0xffff) {
482                if (scanFor
483                    (devicelist[devicecount].vendor,
484                     devicelist[devicecount].product)) {
485                        fprintf(stderr, "%s detected\n",
486                                devicelist[devicecount].name);
487                        if (devicelist[devicecount].driver) {
488                                insmod("usbserial");
489                                insmod(devicelist[devicecount].driver);
490                        }
491                        if (devicelist[devicecount].datadevice) {
492                                static char data[32];
493                                if (!strcmp
494                                    (devicelist[devicecount].datadevice, "hso"))
495                                        sprintf(data, "hso");
496                                else
497                                        sprintf(data, "/dev/usb/tts/%s",
498                                                devicelist[devicecount].
499                                                datadevice);
500                                nvram_set("3gdata", data);
501                        }
502                        if (devicelist[devicecount].modeswitch) {
503                                char variant[32];
504                                sprintf(variant, "%d",
505                                        devicelist[devicecount].modeswitch);
506                                nvram_set("3gnmvariant", variant);
507                        }
508                        //start custom setup, if defined
509                        if (devicelist[devicecount].customsetup)
510                                devicelist[devicecount].customsetup(needreset,
511                                                                    devicelist
512                                                                    [devicecount].controldevice);
513                        static char control[32];
514                        if (!strcmp
515                            (devicelist[devicecount].controldevice, "hso"))
516                                sprintf(control, "hso");
517                        else
518                                sprintf(control, "/dev/usb/tts/%s",
519                                        devicelist[devicecount].controldevice);
520                        return control;
521                }
522                devicecount++;
523        }
524        //not found, use generic implementation (tts0, all drivers)
525
526        insmod("usbserial");
527        insmod("sierra");
528        insmod("option");
529        return ttsdevice;
530}
531
532/*
533//future
534typedef struct {
535char *devicename;
536int vendorid;
537int productid;
538char *drivers;
539char *3gdata;
540char *controldevice;
541int iconswitch;
542}3GDEVICE;
543*/
Note: See TracBrowser for help on using the repository browser.