Router - TG582N - Adding support for a 3G dongle

From AAISP Support Site
Jump to navigation Jump to search

It is possible to add support to the TG582n for a 3G dongle which isn't in the list of supported dongles (this list can be viewed by

:mobile device list

). Possible to add support, not necessarily easily.

Data required for a new 3G dongle

If one looks at the list of supported dongles, one will observe that there are 7 items of data for each entry. These are:

  • Name
  • Storage id
  • Modem id
  • modeswitch
  • AT interface
  • Data interface
  • Force USB 1.1

So adding support for a new dongle requires that appropriate values are added to the list of supported dongles. Finding these values is the main task.

Every USB device has a USB ID allocated to it by the manufacturer, for example '19d2:0016'. The USB ID has two halves - the vendor ID ('19d2' in the example), and the product ID ('0016' in the example). All the dongles made by one manufacturer will have the same vendor ID (in the example. '19d2' is ZTE), but different dongle models by the manufacturer will have different product IDs.

Mode switching

Some 3G dongles have an 'interesting' way of working. They power-up as a USB storage device, which presents a filesystem containing a Windows executable file which can be autorun to install drivers and provide an application for the desktop to allow the user to connect to the mobile network. When a connection is required, the USB dongle is switched from being a USB storage device to being a USB 3G modem (which changes the USB ID). But how can this work when the system the dongle is connected to doesn't run Windows ?

Well, the options are to disable mode switching, or to provide data on how to mode switch.

Disabling mode switching

ZTE dongles, at least, have means to disable mode switching and make the dongle power-up as a USB 3G modem. There are two possible commands to use, depending on the age of the dongle: use 'AT+ZCDRUN=E', or if that isn't supported use 'AT+ZCDRUN=8' to force the dongle into modem mode.

To reconfigure the dongle, one needs a computer which supports 3G dongles and which can do mode switching in order to present an interface which accepts AT commands.

For example, a Linux computer with the usb-modeswitch and usb-modeswitch-data packages can be used. Plugging in a ZTE MF112 dongle results in 'dmesg' reporting:

option 1-1:1.0: GSM modem (1-port) converter detected
usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0
option 1-1:1.1: GSM modem (1-port) converter detected
usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1
option 1-1:1.2: GSM modem (1-port) converter detected
usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2

Trying 'screen /dev/ttyUSB0' shows this port doesn't respond to 'AT' commands (use ^Ak to kill the session), but 'screen /dev/ttyUSB1' does respond to 'AT' commands.

Out of the box:
AT+ZCDRUN=4 reports 1
AT+ZCDRUN=G reports 0 (Memory device)

AT+ZCDRUN=4 queries "autorun"
AT+ZCDRUN=8 disables autorun
AT+ZCDRUN=9 enables autorun

AT+ZCDRUN=G queries "download"
AT+ZCDRUN=E hides memory device, enables 3G modem
AT+ZCDRUN=F reveals memory device, disables 3G modem

Note that disabling mode switching may compromise use of the dongle under Windows.

Provide the data to mode switch

Dongles which mode switch send a long magic string to the dongle to switch the dongle to modem mode. It's impractical to guess this value for this string, so one needs to find the value. Often a manufacturer uses the same modeswitch string for a range of their models.

Fortunately various OSes have already addressed the mode switch problem. For example, Linux has the usb-modeswitch package to handle mode switching, and the usb-modeswitch-data package is a very useful source of config data for 3G dongles.

AT and data interfaces

The dongle needs to provide 2 interfaces to the TG582n - a raw data interface for the network traffic, and an 'AT' interface for control commands (just like an old dial-up modem from the 1990s) and signal information back from the modem.

Finding the data for a new dongle

The first step is to find the USB ID(s) for the dongle. This is best achieved by using a computer which supports the dongle. Linux users can use 'lsusb' to list the attached USB devices. Run 'lsusb', then plug the dongle in and rerun 'lsusb'. Then wait for 30 seconds or so, and run 'lsusb' again - this may show mode switching having taken place.

For example, with a ZTE MF112 lsusb initially reports

ID 19d2:0103 ZTE WCDMA Technologies MSM MF112

and then mode switches and lsusb reports

ID 19d2:0031 ZTE WCDMA Technologies MSM MF110/MF627/MF636

Strangely, with mode switching disabled the USB ID may be different from either of the previous USB IDs. The ZTE MF112 with mode switching disabled reports

ID 19d2:0016 ZTE WCDMA Technologies MSM

Armed with the USB ID(s) it's time to hope that someone else has already found the remaining data. Let's go searching.


We've just been lucky with the ZTE MF112 - its 'storage ID' of 19d2:0103 isn't in the list of supported dongles, but with mode switching disabled the 'modem ID' of 19d2:0016 is in that list (appearing as the ZTE_MF110). Plugging the ZTE MF112 in, having first disabled mode switching, results in

:mobile device list

reporting at the end

Detected device: ZTE_MF110
# interfaces  : 3
AT interface  : 1
Data interface: 2

Copying from a similar entry

It may be the case that a new dongle has similar USB ID(s) to a supported dongle from the same manufacturer. If so it would be worthwhile trying most of the data from the supported dongle, but with the new USB ID(s). For example, the supported ZTE dongles all use the same modeswitch string, and the ZTE MF100 and MF110 entries only differ in the USB IDs. So for the MF112 it's worth trying to copy those entries but modifying the USB IDs.

[ In fact, the modem USB ID for the ZTE MF112 is the same (19d2:0031) as for the already supported ZTE_MF627 - so once the TG582n detects the MF112 in storage mode and mode switches the device, then the TG582n detects the dongle as a ZTE MF627 ].

Finding the config from the Internet

There are several external sites to consult in case someone else has already worked out the data for the new dongle:

Adding a new dongle

Once one has the (candidate) data for a new dongle the TG582n can be configured. This might be a trial-and-error process and need a few attempts to find settings that work.

In the command which follows 'storagevid' is the USB vendor ID for the dongle in storage mode, 'storagepid' the corresponding product ID. Similarly 'modemvid' is the USB vendor ID for the device in modem mode, and 'modempid' the corresponding product ID.

The command required is of the form below. If the dongle doesn't mode switch, or mode switching has been disabled, then the 'storagevid', 'storagepid', and 'modeswitchparam' parameters can be ignored.

:mobile device add name=Maker_model storagevid=xxxx storagepid=yyyy modemvid=pppp modempid=qqqq modeswitchparam=hideously_long_string atinterface=1 datainterface=0 forceusb11=0

and to delete it because it doesn't work:

:mobile device delete name=Maker_model

Testing the new dongle

The first check to be made is whether the TG582n successfully sees the dongle. Plug the dongle in, wait a minute or so, and then issue the command

:mobile device list

If the output ends with

No device detected

then the dongle hasn't been recognised. What to look for is the output ending with something like

Detected device: ZTE_MF627
# interfaces  : 4
AT interface  : 1
Data interface: 3

If the 'AT interface' or 'Data interface' lines report 'invalid' rather than a number, then the config is wrong - it's worth trying again with different numbers.

Once the dongle is recognised, the next step is to configure the 3G service (3G) and then see if mobile broadband works. On the web interface 'Broadband Connection' should show the mobile broadband connection, and 'View More' should show operator and signal strength info - if the signal strength info is missing, the 'AT interface' might be wrongly configured.