[packages] huaweiaktbbo: add support for the E156 and E169 (#6396)
git-svn-id: svn://svn.openwrt.org/openwrt/packages@18898 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
da197f6286
commit
797c9991ec
@ -18,7 +18,7 @@ define Package/huaweiaktbbo
|
|||||||
SECTION:=utils
|
SECTION:=utils
|
||||||
CATEGORY:=Utilities
|
CATEGORY:=Utilities
|
||||||
DEPENDS:=+libusb
|
DEPENDS:=+libusb
|
||||||
TITLE:=Huawei e220 configuration tool
|
TITLE:=Huawei E156/E169/E220 activation tool
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Build/Prepare
|
define Build/Prepare
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
/* HUAWEI E220 3G HSDPA modem - Aktivator modemu = aktivuje ttyUSB0 tty USB1
|
/* HUAWEI 3G modems activator
|
||||||
bobovsky 11.12.2006
|
Copyright (C) 2006 bobovsky bobovsky@kanoistika.sk GPL
|
||||||
dalej sa uz pouzije usbserial a usb-storage
|
Copyright (C) 2009 Nuno Goncalves nunojpg@gmail.com GPL
|
||||||
cc huaweiAktBbo.c -lusb (resp -I. -L.)
|
|
||||||
armeb-linux-gcc huaweiAktBbo.c -L. -I. -lusb
|
|
||||||
Copyright (C) 2006 bobovsky bobovsky@kanoistika.sk GPL
|
|
||||||
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License2.
|
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License2.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -13,168 +11,85 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <usb.h>
|
#include <usb.h>
|
||||||
#if 0
|
|
||||||
#include <linux/usbdevice_fs.h>
|
|
||||||
#define LIBUSB_AUGMENT
|
|
||||||
#include "libusb_augment.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct usb_dev_handle *devh;
|
struct usb_dev_handle *devh;
|
||||||
|
|
||||||
void release_usb_device(int dummy) {
|
void release_usb_device(int dummy) {
|
||||||
int ret;
|
int ret;
|
||||||
ret = usb_release_interface(devh, 0);
|
ret = usb_release_interface(devh, 0);
|
||||||
if (!ret)
|
|
||||||
printf("failed to release interface: %d\n", ret);
|
if (!ret)
|
||||||
usb_close(devh);
|
printf("failed to release interface: %d\n", ret);
|
||||||
if (!ret)
|
|
||||||
printf("failed to close interface: %d\n", ret);
|
usb_close(devh);
|
||||||
exit(1);
|
|
||||||
|
if (!ret)
|
||||||
|
printf("failed to close interface: %d\n", ret);
|
||||||
|
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void list_devices() {
|
void list_devices() {
|
||||||
struct usb_bus *bus;
|
struct usb_bus *bus;
|
||||||
for (bus = usb_get_busses(); bus; bus = bus->next) {
|
for (bus = usb_get_busses(); bus; bus = bus->next) {
|
||||||
struct usb_device *dev;
|
struct usb_device *dev;
|
||||||
|
|
||||||
for (dev = bus->devices; dev; dev = dev->next)
|
for (dev = bus->devices; dev; dev = dev->next)
|
||||||
printf("0x%04x 0x%04x\n",
|
printf("0x%04x 0x%04x\n", dev->descriptor.idVendor, dev->descriptor.idProduct);
|
||||||
dev->descriptor.idVendor,
|
|
||||||
dev->descriptor.idProduct);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct usb_device *find_device(int vendor, int product) {
|
struct usb_device *find_device() {
|
||||||
struct usb_bus *bus;
|
struct usb_bus *bus;
|
||||||
|
|
||||||
for (bus = usb_get_busses(); bus; bus = bus->next) {
|
for (bus = usb_get_busses(); bus; bus = bus->next) {
|
||||||
struct usb_device *dev;
|
struct usb_device *dev;
|
||||||
|
|
||||||
for (dev = bus->devices; dev; dev = dev->next) {
|
for (dev = bus->devices; dev; dev = dev->next) {
|
||||||
if (dev->descriptor.idVendor == vendor
|
if (dev->descriptor.idVendor == 0x12d1 && dev->descriptor.idProduct == 0x1001 || //Huawei E169, Huawei E169G
|
||||||
&& dev->descriptor.idProduct == product)
|
dev->descriptor.idVendor == 0x12d1 && dev->descriptor.idProduct == 0x1003) //Huawei E220, Huawei E156G
|
||||||
return dev;
|
return dev;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
return NULL;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_bytes(char *bytes, int len) {
|
|
||||||
int i;
|
|
||||||
if (len > 0) {
|
|
||||||
for (i=0; i<len; i++) {
|
|
||||||
printf("%02x ", (int)((unsigned char)bytes[i]));
|
|
||||||
}
|
|
||||||
printf("\"");
|
|
||||||
for (i=0; i<len; i++) {
|
|
||||||
printf("%c", isprint(bytes[i]) ? bytes[i] : '.');
|
|
||||||
}
|
|
||||||
printf("\"");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
int ret, vendor, product;
|
int ret, vendor, product;
|
||||||
struct usb_device *dev;
|
struct usb_device *dev;
|
||||||
char buf[65535], *endptr;
|
char buf[65535], *endptr;
|
||||||
#if 0
|
|
||||||
usb_urb *isourb;
|
|
||||||
struct timeval isotv;
|
|
||||||
char isobuf[32768];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
usb_init();
|
usb_init();
|
||||||
// usb_set_debug(255);
|
usb_find_busses();
|
||||||
usb_find_busses();
|
usb_find_devices();
|
||||||
usb_find_devices();
|
|
||||||
/*
|
|
||||||
if (argc!=3) {
|
|
||||||
printf("usage: %s vendorID productID\n", argv[0]);
|
|
||||||
printf("ID numbers of currently attached devices:\n");
|
|
||||||
list_devices();
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
vendor = strtol(argv[1], &endptr, 16);
|
|
||||||
if (*endptr != '\0') {
|
|
||||||
printf("invalid vendor id\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
product = strtol(argv[2], &endptr, 16);
|
|
||||||
if (*endptr != '\0') {
|
|
||||||
printf("invalid product id\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
printf("Hladam HUAWEI E220 a prepnem na modem - bbo 06\n");
|
|
||||||
vendor = 0x12d1;
|
|
||||||
product = 0x1003;
|
|
||||||
dev = find_device(vendor, product);
|
|
||||||
assert(dev);
|
|
||||||
|
|
||||||
devh = usb_open(dev);
|
printf("Searching modem...");
|
||||||
assert(devh);
|
dev = find_device();
|
||||||
|
|
||||||
signal(SIGTERM, release_usb_device);
|
if(dev == NULL){
|
||||||
|
printf("No supported modem found\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("found supported modem!\n");
|
||||||
|
|
||||||
|
assert(dev);
|
||||||
|
devh = usb_open(dev);
|
||||||
|
assert(devh);
|
||||||
|
|
||||||
|
signal(SIGTERM, release_usb_device);
|
||||||
|
|
||||||
|
ret = usb_get_descriptor(devh, 0x0000001, 0x0000000, buf, 0x0000012);
|
||||||
|
usleep(1*1000);
|
||||||
|
ret = usb_get_descriptor(devh, 0x0000002, 0x0000000, buf, 0x0000009);
|
||||||
|
usleep(1*1000);
|
||||||
|
ret = usb_get_descriptor(devh, 0x0000002, 0x0000000, buf, 0x0000020);
|
||||||
|
usleep(1*1000);
|
||||||
|
ret = usb_control_msg(devh, USB_TYPE_STANDARD + USB_RECIP_DEVICE, USB_REQ_SET_FEATURE, 00000001, 0, buf, 0, 1000);
|
||||||
|
|
||||||
/*
|
|
||||||
ret = usb_get_driver_np(devh, 0, buf, sizeof(buf));
|
|
||||||
printf("usb_get_driver_np returned %d\n", ret);
|
|
||||||
if (ret == 0) {
|
|
||||||
printf("interface 0 already claimed by driver \"%s\", attempting to detach it\n", buf);
|
|
||||||
ret = usb_detach_kernel_driver_np(devh, 0);
|
|
||||||
printf("usb_detach_kernel_driver_np returned %d\n", ret);
|
|
||||||
}
|
|
||||||
ret = usb_claim_interface(devh, 0);
|
|
||||||
if (ret != 0) {
|
|
||||||
printf("claim failed with error %d\n", ret);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = usb_set_altinterface(devh, 0);
|
|
||||||
assert(ret >= 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);
|
ret = usb_close(devh);
|
||||||
assert(ret == 0);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user