From: florian Date: Sun, 20 Jan 2008 21:35:50 +0000 (+0000) Subject: Add huawei e220 user space configuration tool X-Git-Url: http://207.154.207.93/?a=commitdiff_plain;h=f25b3d8d7c0e69c0620b69b2386ac8f1fdeba5a1;p=packages.git Add huawei e220 user space configuration tool git-svn-id: svn://svn.openwrt.org/openwrt/packages@10226 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- diff --git a/utils/huaweiaktbbo/Makefile b/utils/huaweiaktbbo/Makefile new file mode 100644 index 000000000..ce68cb611 --- /dev/null +++ b/utils/huaweiaktbbo/Makefile @@ -0,0 +1,42 @@ +# +# Copyright (C) 2008 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +# $Id: $ + +include $(TOPDIR)/rules.mk + +PKG_NAME:=huaweiaktbbo +PKG_RELEASE:=1 + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) + +include $(INCLUDE_DIR)/package.mk + +define Package/huaweiaktbbo + SECTION:=utils + CATEGORY:=Utilities + DEPENDS:=+libusb + TITLE:=Huawei e220 configuration tool +endef + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) + $(CP) ./src/* $(PKG_BUILD_DIR) +endef + +define Build/Compile + $(TARGET_CC) $(TARGET_CFLAGS) -I $(STAGING_DIR)/usr/include \ + -lusb -L$(STAGING_DIR)/usr/lib/ \ + -o $(PKG_BUILD_DIR)/huaweiAktBbo \ + $(PKG_BUILD_DIR)/huaweiAktBbo.c +endef + +define Package/huaweiaktbbo/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/huaweiAktBbo $(1)/usr/bin/ +endef + +$(eval $(call BuildPackage,huaweiaktbbo)) diff --git a/utils/huaweiaktbbo/src/huaweiAktBbo.c b/utils/huaweiaktbbo/src/huaweiAktBbo.c new file mode 100644 index 000000000..f7679a59d --- /dev/null +++ b/utils/huaweiaktbbo/src/huaweiAktBbo.c @@ -0,0 +1,180 @@ +/* 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 + 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 +#include +#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); +} + +void list_devices() { + 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); + } +} + +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) + return dev; + } + } + 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"); + return 0; +}