From af76f5a4d8da86442011e519a5d668f6d273a22c Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 22 Dec 2009 22:58:59 +0000 Subject: [PATCH] huaweiaktbbo: add support for the E156 and E169 (#6396) SVN-Revision: 18898 --- utils/huaweiaktbbo/Makefile | 2 +- utils/huaweiaktbbo/src/huaweiAktBbo.c | 211 ++++++++------------------ 2 files changed, 64 insertions(+), 149 deletions(-) diff --git a/utils/huaweiaktbbo/Makefile b/utils/huaweiaktbbo/Makefile index 3d07a65c4..bb9b3c341 100644 --- a/utils/huaweiaktbbo/Makefile +++ b/utils/huaweiaktbbo/Makefile @@ -18,7 +18,7 @@ define Package/huaweiaktbbo SECTION:=utils CATEGORY:=Utilities DEPENDS:=+libusb - TITLE:=Huawei e220 configuration tool + TITLE:=Huawei E156/E169/E220 activation tool endef define Build/Prepare diff --git a/utils/huaweiaktbbo/src/huaweiAktBbo.c b/utils/huaweiaktbbo/src/huaweiAktBbo.c index f7679a59d..09c905085 100644 --- a/utils/huaweiaktbbo/src/huaweiAktBbo.c +++ b/utils/huaweiaktbbo/src/huaweiAktBbo.c @@ -1,11 +1,9 @@ -/* HUAWEI E220 3G HSDPA modem - Aktivator modemu = aktivuje ttyUSB0 tty USB1 - bobovsky 11.12.2006 - dalej sa uz pouzije usbserial a usb-storage - cc huaweiAktBbo.c -lusb (resp -I. -L.) - armeb-linux-gcc huaweiAktBbo.c -L. -I. -lusb - Copyright (C) 2006 bobovsky bobovsky@kanoistika.sk GPL +/* HUAWEI 3G modems activator + Copyright (C) 2006 bobovsky bobovsky@kanoistika.sk GPL + Copyright (C) 2009 Nuno Goncalves nunojpg@gmail.com GPL This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License2. */ + #include #include #include @@ -13,168 +11,85 @@ #include #include #include -#if 0 - #include - #define LIBUSB_AUGMENT - #include "libusb_augment.h" -#endif struct usb_dev_handle *devh; void release_usb_device(int dummy) { - int ret; - ret = usb_release_interface(devh, 0); - if (!ret) - printf("failed to release interface: %d\n", ret); - usb_close(devh); - if (!ret) - printf("failed to close interface: %d\n", ret); - exit(1); + int ret; + ret = usb_release_interface(devh, 0); + + if (!ret) + printf("failed to release interface: %d\n", ret); + + usb_close(devh); + + if (!ret) + printf("failed to close interface: %d\n", ret); + + exit(1); } void list_devices() { - struct usb_bus *bus; - for (bus = usb_get_busses(); bus; bus = bus->next) { + struct usb_bus *bus; + for (bus = usb_get_busses(); bus; bus = bus->next) { struct usb_device *dev; - + for (dev = bus->devices; dev; dev = dev->next) - printf("0x%04x 0x%04x\n", - dev->descriptor.idVendor, - dev->descriptor.idProduct); + printf("0x%04x 0x%04x\n", dev->descriptor.idVendor, dev->descriptor.idProduct); } } -struct usb_device *find_device(int vendor, int product) { - struct usb_bus *bus; - - for (bus = usb_get_busses(); bus; bus = bus->next) { - struct usb_device *dev; - - for (dev = bus->devices; dev; dev = dev->next) { - if (dev->descriptor.idVendor == vendor - && dev->descriptor.idProduct == product) +struct usb_device *find_device() { + struct usb_bus *bus; + + for (bus = usb_get_busses(); bus; bus = bus->next) { + struct usb_device *dev; + + for (dev = bus->devices; dev; dev = dev->next) { + if (dev->descriptor.idVendor == 0x12d1 && dev->descriptor.idProduct == 0x1001 || //Huawei E169, Huawei E169G + dev->descriptor.idVendor == 0x12d1 && dev->descriptor.idProduct == 0x1003) //Huawei E220, Huawei E156G return dev; + } } - } - return NULL; + return NULL; } -void print_bytes(char *bytes, int len) { - int i; - if (len > 0) { - for (i=0; i= 0); -*/ -// BBO typ 1 = DEVICE -ret = usb_get_descriptor(devh, 0x0000001, 0x0000000, buf, 0x0000012); -//printf("1 get descriptor returned %d, bytes: ", ret); -//print_bytes(buf, ret); -//printf("\n"); -usleep(1*1000); -// BBO typ 2 = CONFIGURATION -ret = usb_get_descriptor(devh, 0x0000002, 0x0000000, buf, 0x0000009); -//printf("2 get descriptor returned %d, bytes: ", ret); -//print_bytes(buf, ret); -//printf("\n"); -usleep(1*1000); -// BBO typ 2 = CONFIGURATION -ret = usb_get_descriptor(devh, 0x0000002, 0x0000000, buf, 0x0000020); -//printf("3 get descriptor returned %d, bytes: ", ret); -//print_bytes(buf, ret); -//printf("\n"); -usleep(1*1000); -/* -ret = usb_release_interface(devh, 0); -if (ret != 0) printf("failed to release interface before set_configuration: %d\n", ret); -ret = usb_set_configuration(devh, 0x0000001); -printf("4 set configuration returned %d\n", ret); -ret = usb_claim_interface(devh, 0); -if (ret != 0) printf("claim after set_configuration failed with error %d\n", ret); -ret = usb_set_altinterface(devh, 0); -printf("4 set alternate setting returned %d\n", ret); -usleep(50*1000); -ret = usb_set_altinterface(devh, 0); -printf("5 set alternate setting returned %d\n", ret); -usleep(62*1000); -*/ -ret = usb_control_msg(devh, USB_TYPE_STANDARD + USB_RECIP_DEVICE, USB_REQ_SET_FEATURE, 00000001, 0, buf, 0, 1000); -printf("4 set feature request returned %d\n", ret); -/* - ret = usb_release_interface(devh, 0); - assert(ret == 0); -*/ ret = usb_close(devh); assert(ret == 0); - printf("Prepnute-OK, Mas ttyUSB0 ttyUSB1 (cez usbserial vendor=0x12d1 product=0x1003)\n"); - printf("pozri /proc/bus/usb/devices\n"); + + printf("Modem poked!\n"); return 0; } -- 2.30.2