For the last few years, one of the tool I have greatly used is a Huawei E587 modem. It’s a great little device which gave me a lot of freedom. Even if it is quite old, it outperforms, even without an external antenna any smartphone I used for tethering and especially my new Samsung Galaxy S5 Neo which, as a parenthesis, has one of the poorest software I have ever seen, reminds me of a circa 2000 windows pre-installed on a laptop and filled with junkware.

However, as many other devices, the reporting of signal strength is very simplistic. My goal was to be able to identify the best spot for the external antenna defined by the best signal strength.

Using my smartphone

The first idea was to use my smartphone as a signal detector. There are a few applications which show the signal strength in dbm such as Network Signal Info. However this is just a basic information since each device antenna influences a lot the signal. This is probably why my S5 Neo cannot maintain tethering with less -85dbm while the E587 has no problem.

Using Speedtest

Unless having an unlimited amount of time and bandwidth using Speedtest to detect the best antenna position is not feasible. I think it’s more a tool to validate the last few candidates.

Going deeper

The modem has a web interface which if you start looking at the traffic with something like firebug you realize it is calling some xml api. One example is: /api/monitoring/status

<pre lang="xml"><response>
<connectionstatus>901</connectionstatus>
<signalstrength>99</signalstrength>
<currentnetworktype>46</currentnetworktype>
...
</response>

This link seems to work even if you are not logged in. This is due to a vulnerability in the modem. And even so the SignalStrength information is incomplete. Everything > 99 is considered good strength and is used to show the 5 bars signal indicator in the interface.

Even deeper

It is possible to get access to the modem via telnet but my hope was:

  • to be able to run something like: dumpsys telephony.registry | grep -i signalstrength however the dumpsys command is not installed.
  • find the modem, /dev/smd0 and run AT commands directly but this did not worked either

The last attempt was to upgrade the firmware using the one which fixes the above discussed vulnerability in the hope it will also add some new functionality but this was not the case.

Bump

At this point I had spend a lot of time and got nowhere.

The solution

The solution came when after running my firmware upgrade in virtualbox I had seen this in the host dmesg:

<pre lang="bash">[ 1241.809822] usb 3-1: Product: HUAWEI Mobile
[ 1241.809826] usb 3-1: Manufacturer: HUAWEI Technology
[ 1241.816136] option 3-1:1.0: GSM modem (1-port) converter detected
[ 1241.816392] usb 3-1: GSM modem (1-port) converter now attached to ttyUSB0

can it be this simple? Not quite since if I plugged the modem I just got this:

<pre lang="bash">[ 6455.018544] usb 3-1: new high-speed USB device number 11 using xhci_hcd
[ 6455.049652] usb 3-1: New USB device found, idVendor=12d1, idProduct=14fe
[ 6455.049665] usb 3-1: New USB device strings: Mfr=2, Product=1, SerialNumber=3
[ 6455.049672] usb 3-1: Product: HUAWEI Mobile
[ 6455.049678] usb 3-1: Manufacturer: HUAWEI Technology
[ 6455.054041] usb-storage 3-1:1.0: USB Mass Storage device detected

Hopefully the information was easy to find:

<pre lang="bash">/lib/udev/usb_modeswitch --vendor 0x12d1 --product 0x14fe --type option-zerocd

this forced the device to be seen as a modem /dev/ttyUSB0. I quickly fired minicom (yes, I remember connecting to the internet via a phone line modem):

<pre lang="bash">minicom -D /dev/ttyUSB0

Welcome to minicom 2.7

OPTIONS: I18n
Compiled on Jan 1 2014, 17:13:19.
Port /dev/ttyUSB0, 00:00:59

Press CTRL-A Z for help on special keys

AT+CSQ
+CSQ: 14,99

OK

This is the rssi value for the signal strength: (14.99*2) – 113 = -83.02 dbm. Hurray, I got my signal strength value.

Automate

It is possible to automate this using atinout from a shell script:

<pre lang="bash">echo "AT+CSQ" | atinout - /dev/ttyUSB0 -
AT+CSQ
+CSQ: 13,99

OK

As far as it gets 13.99 is only a good value, not even excellent yet I have 5/5 bars on my interface.