# Strange 3G modem Huawei E3276 behavior



## kerlin (Oct 9, 2014)

Good day!

Can someone help me with my problem?

I have a system:
`uname -a`

```
FreeBSD home 10.0-STABLE FreeBSD 10.0-STABLE #0: Tue Aug 19 22:41:25 MSK 2014     kot@home:/usr/obj/usr/src/sys/BSDSERV  amd64
```
And for internet I use 3G USB stick:
`lsusb -v`

```
Bus /dev/usb Device /dev/ugen3.2: ID 12d1:1506 Huawei Technologies Co., Ltd. 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x12d1 Huawei Technologies Co., Ltd.
  idProduct          0x1506 
  bcdDevice            1.02
  iManufacturer           3       
  iProduct                2 Mobile Connect
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength          206
    bNumInterfaces          6
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      2 
      bInterfaceProtocol     97 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               5
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval              32
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval              32
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      2 
      bInterfaceProtocol    118 
      iInterface              0 
      ** UNRECOGNIZED:  05 24 00 10 01
      ** UNRECOGNIZED:  06 24 1a 00 01 1f
      ** UNRECOGNIZED:  0d 24 0f 01 05 00 00 00 ea 05 03 00 01
      ** UNRECOGNIZED:  05 24 06 01 01
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               5
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           3
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      2 
      bInterfaceProtocol    118 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               5
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval              32
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval              32
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      2 
      bInterfaceProtocol     99 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x85  EP 5 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval              32
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval              32
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      2 
      bInterfaceProtocol     98 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x86  EP 6 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval              32
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x04  EP 4 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval              32
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        4
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         8 Mass Storage
      bInterfaceSubClass      6 SCSI
      bInterfaceProtocol     80 Bulk (Zip)
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x05  EP 5 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x87  EP 7 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        5
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         8 Mass Storage
      bInterfaceSubClass      6 SCSI
      bInterfaceProtocol     80 Bulk (Zip)
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x06  EP 6 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x88  EP 8 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  bNumConfigurations      1
Device Status:     0x0000
  (Bus Powered)
```
But before connect to internet I need to use 
`/usr/local/sbin/usb_modeswitch -c /usr/local/etc/usb_modeswitch.conf`
/usr/local/etc/usb_modeswitch.conf

```
DisableSwitching=1
EnableLogging=0
DefaultVendor=0x12d1
DefaultProduct=0x155b
TargetVendor=0x12d1
TargetProduct=0x1506
MessageContent="55534243123456780000000000000011062000000100000000000000000000"
```
And after that it connects to the Internet using profile mts_x:
ppp.conf

```
default:
   set log Phase Chat LCP IPCP CCP tun command
   ident user-ppp VERSION

   set device /dev/cuaU0.0

   set speed 115200
   set dial "ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \
   \"\" AT OK-AT-OK ATE1Q0 OK \\dATDT\\T TIMEOUT 40 CONNECT"
   set timeout 5                        # 3 minute idle timer (the default)
   enable dns                             # request DNS info (for resolv.conf)

mts_x:
 set device /dev/cuaU0.0
 set speed 460800

 set dial "\"\" \
     AT OK \
     AT OK \
     ATS0=0 OK \
     AT OK \
     AT&FE0V1X1&D2&C1S0=0 OK \
     AT OK \
     AT+CGDCONT=1,\\\"IP\\\",\\\"internet.mts.ru\\\" OK \
     ATDT*99# CONNECT"

 set login
 set authname "mts"
 set authkey "mts"

 disable pap
 disable chap
 enable dns

 set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.0 0.0.0.0
 add default HISADDR
```
All works fine and it connects in 3G (or 4G) mode with a blue LED on the modem, but after some time (various, from five minutes to several hours) it switches to 2G mode with an orange LED and after that to reconnect on full speed I need do these actions:

`/etc/rc.d/ppp stop`
 Physically remove modem from usb port
 Plug-in modem to usb port
 Run again *usb_modeswitch*
`/etc/rc.d/ppp start`
So my question is: can I somehow emulate physical removing of modem with usbconfig or other utilities? Or maybe there are available some ppp.conf options to deny the switch to 2G mode?
I'm trying various actions to do:

`usbconfig -d 3.2 power_off` to powering off modem
`usbconfig -d 3.1 reset` to reset usb hub
`usbconfig -d 3.2 power_on` to power on usb modem again
But after that the modem connects only in 2G mode, until I physically remove them.

Log when modem inserts in USB port:
/var/log/messages

```
Oct  9 20:02:00 home kernel: ugen3.2: <vendor 0x12d1> at usbus3
Oct  9 20:02:00 home kernel: umass0: <vendor 0x12d1 Mobile Connect, class 0/0, rev 2.00/1.02, addr 2> on usbus3
Oct  9 20:02:00 home kernel: umass1: <vendor 0x12d1 Mobile Connect, class 0/0, rev 2.00/1.02, addr 2> on usbus3
Oct  9 20:02:00 home kernel: da0 at umass-sim1 bus 1 scbus3 target 0 lun 0
Oct  9 20:02:00 home kernel: da0: < SD Storage 2.31> Removable Direct Access SCSI-2 device 
Oct  9 20:02:00 home kernel: da0: 40.000MB/s transfers
Oct  9 20:02:00 home kernel: da0: Attempt to query device size failed: NOT READY, Medium not present
Oct  9 20:02:00 home kernel: da0: quirks=0x2<NO_6_BYTE>
```

Log when I run:
`usbconfig -d 3.2 power_off`

```
Oct  9 20:03:28 home kernel: umass0: at uhub3, port 4, addr 2 (disconnected)
Oct  9 20:03:28 home kernel: umass1: at uhub3, port 4, addr 2 (disconnected)
Oct  9 20:03:28 home kernel: da0 at umass-sim1 bus 1 scbus3 target 0 lun 0
Oct  9 20:03:28 home kernel: da0: < SD Storage 2.31> detached
Oct  9 20:03:28 home kernel: (da0:umass-sim1:1:0:0): Periph destroyed
Oct  9 20:03:28 home kernel: ugen3.2: <vendor 0x12d1> at usbus3 (disconnected)
Oct  9 20:03:37 home kernel: ugen3.2: <vendor 0x12d1> at usbus3
Oct  9 20:03:37 home kernel: umass0: <vendor 0x12d1 Mobile Connect, class 0/0, rev 2.00/1.02, addr 2> on usbus3
Oct  9 20:03:37 home kernel: umass1: <vendor 0x12d1 Mobile Connect, class 0/0, rev 2.00/1.02, addr 2> on usbus3
Oct  9 20:03:37 home kernel: da0 at umass-sim1 bus 1 scbus3 target 0 lun 0
Oct  9 20:03:37 home kernel: da0: < SD Storage 2.31> Removable Direct Access SCSI-2 device 
Oct  9 20:03:37 home kernel: da0: 40.000MB/s transfers
Oct  9 20:03:37 home kernel: da0: Attempt to query device size failed: NOT READY, Medium not present
Oct  9 20:03:37 home kernel: da0: quirks=0x2<NO_6_BYTE>
```

Is it possible?


----------

