1 /* HUAWEI 3G modems activator
2 Copyright (C) 2006 bobovsky bobovsky@kanoistika.sk GPL
3 Copyright (C) 2009 Nuno Goncalves nunojpg@gmail.com GPL
4 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License2.
15 struct usb_dev_handle *devh;
17 void release_usb_device(int dummy) {
19 ret = usb_release_interface(devh, 0);
22 printf("failed to release interface: %d\n", ret);
27 printf("failed to close interface: %d\n", ret);
34 for (bus = usb_get_busses(); bus; bus = bus->next) {
35 struct usb_device *dev;
37 for (dev = bus->devices; dev; dev = dev->next)
38 printf("0x%04x 0x%04x\n", dev->descriptor.idVendor, dev->descriptor.idProduct);
42 struct usb_device *find_device() {
45 for (bus = usb_get_busses(); bus; bus = bus->next) {
46 struct usb_device *dev;
48 for (dev = bus->devices; dev; dev = dev->next) {
49 if (dev->descriptor.idVendor == 0x12d1 && dev->descriptor.idProduct == 0x1001 || //Huawei E169, Huawei E169G
50 dev->descriptor.idVendor == 0x12d1 && dev->descriptor.idProduct == 0x1003) //Huawei E220, Huawei E156G
57 int main(int argc, char **argv) {
58 int ret, vendor, product;
59 struct usb_device *dev;
60 char buf[65535], *endptr;
66 printf("Searching modem...");
70 printf("No supported modem found\n");
74 printf("found supported modem!\n");
80 signal(SIGTERM, release_usb_device);
82 ret = usb_get_descriptor(devh, 0x0000001, 0x0000000, buf, 0x0000012);
84 ret = usb_get_descriptor(devh, 0x0000002, 0x0000000, buf, 0x0000009);
86 ret = usb_get_descriptor(devh, 0x0000002, 0x0000000, buf, 0x0000020);
88 ret = usb_control_msg(devh, USB_TYPE_STANDARD + USB_RECIP_DEVICE, USB_REQ_SET_FEATURE, 00000001, 0, buf, 0, 1000);
90 ret = usb_close(devh);
93 printf("Modem poked!\n");