Huawei E220

From ArchWiki
Revision as of 11:17, 10 July 2007 by Raca (talk | contribs)
Jump to: navigation, search

Huawei E220 it's a 3G HSDPA modem.

Make it work

When you plug the modem to the computer you should see 3 usb serials ports of it, normally, /dev/ttyUSB0, /dev/ttyUSB1 and /dev/ttyUSB2.

If when you connect the modem only one usbserial port shows up (i.e. ttyUSB0) you should run the program below.

/* Huawei E220 3G HSDPA modem mode activator
 * Copyright (C) 2006 bobovsky  GPL 
 * This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License 2.
 * Changes from the original at:
 * by raca,
 * Compile:
 * gcc -lusb h_e220_mma.c -o h_e220_mma

#include <stdio.h>
#include <usb.h> //libusb 

//Find a specific usb device and return its usb_device
struct usb_device *find_device(int vendor, int product) {
	struct usb_bus *bus;
	struct usb_device *dev; 

	for (bus = usb_get_busses(); bus; bus = bus->next) {		
		for (dev = bus->devices; dev; dev = dev->next) {
			if (dev->descriptor.idVendor == vendor
					&& dev->descriptor.idProduct == product)
				return dev;
	return NULL;

int main(int argc, char **argv){
	int ret, vendor, product;
	struct usb_device *usbdev;
	struct usb_dev_handle *usbdev_h;
	char *data;

	usb_init(); //init de libusb library 
	usb_find_busses(); // fill the busses info for the library
	usb_find_devices(); // fill the devices info for the library

	vendor = 0x12d1; //Huawei
	product = 0x1003; //E220
	usbdev = find_device(vendor, product);
		fprintf(stderr, "Couldn't find the device, terminating.\n");
		return 0;

	usbdev_h = usb_open(usbdev);
		fprintf(stderr, "Couldn't open the device, terminating.\n");
		return 0;

	ret=usb_control_msg(usbdev_h, USB_TYPE_STANDARD + USB_RECIP_DEVICE, USB_REQ_SET_FEATURE, 1, 0, data, 0, 1000);
		fprintf(stdout, "Message to activate modem mode send successfully.\n");
	} else {
		fprintf(stdout, "Message to activate modem mode send unsuccessfully, terminating.\n");
		return 0;

	fprintf(stdout, "Everything done. You can use the usbtty now.\n");
	return 0;

Compile with gcc -lusb h_e220_mma.c -o h_e220_mma
And run as root the program.

The usb serial ports:

  • ttyUSB0 - Don't know what's for.
  • ttyUSB1 - Used for modem communication.
  • ttyUSB2 - Should even show up, isn't used. It has some to do with the emulated scsi cdrom of the modem.

To check if everything is running ok, use minicom. (If you don't have it just to the usal pacman -Sy minicom)

$ minicom -s

Change the serial port to /dev/ttyUSB1 and exit (not exit from minicom), this will open minicom.
If minicom initialize the modem and when you send the command 'AT' the answer is 'OK', the modem is working well on that port.

Using it

Now you just have to configure it according to you network provider and set up the scripts do connect. Here, , you can find a program do check the modem status and a package which has the wvdial scripts. I haven't been able to make the program to work.