Router - TG582N - Adding support for a 3G dongle: Difference between revisions

From AAISP Support Site
m (Mention 'usb-modeswitch' package)
(Describe how to reconfigure a dongle using AT commands)
Line 34: Line 34:
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
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 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:
Out of the box:

Revision as of 17:41, 23 January 2015

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

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

Coming soon...

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