Sunday, June 3, 2012

BlueVPN+, connect your Android device to internet with a GPRS modem phone

In the previous post we saw how to pair two Android devices and share the internet connection between them with BlueDUN installed on the master and BlueVPN installed on the slave.   In particular we described how install and configure the BlueVPN:  this app implements a bluetooth dial up client, also called reverse DUN feature.  
However, there are situations where you need to connect an Android device, for example a tablet, and you don't own a second Android device (generally a phone), but you have only a GPRS [General Packet Radio Service] phone (like many common BlackBerry, Nokia, Samsung ...phones) with tethered modem capability.
Till now, you has been able to use this phone as an external modem to connect a laptop computer to the Internet but not to connect the Android device.
The last release of BlueVPN for Android ICS (4.0.x) enables the internet connection of Android devices through dial up modem phones and so bypasses this limitation.

To setup the connection you may follow the same steps described before:  enable the bluetooth on both Android and no-Android device and create the BT pairing.    For an unknown Android limitation it is strongly recomended to remove any space in the Bluetooth device names before the pairing ( for example:  rename "Nokia E65" to "NokiaE65" )

The main differences are in the setting parameters:

Modem compatibility:    some modems don't allow multiple lines for AT commands; if you enable this option the AT commands are not prefixed with <cr><lf> ("carriage return" and "line feed")
For example:    compatibility disabled:  <cr><lf>AT<cr><lf>  ;  compatibility enabled:   AT\<cr><lf>

Modem line feed:    if you disable this option the AT commands will use only the "carriage return" character (<cr>) otherwise thery will use both the "carriage return" and "line feed" (<cr><lf>)
For example:    compatibility disabled:    <cr>AT<cr>  ;     compatibility enabled:   AT<cr>

AT Initialization:  it is the modem initialization string, the default is E0V1&C1&D2  but you can change it according to your modem specifications

Connection Timeout:  is the time after which the app will resend the same data if it doesn't receive the replay for the first AT command or first LCP / NCP initialization packet.

Inter-character delay:   some devices are slow in processing characters so we need to wait some milliseconds between each of them (e.g. sending AT is equal to send 'A', wait few milliseconds, send 'T', wait few milliseconds, etc.)

LCP compatibility:  it is an option to force the PPP-LCP negotiation,  you need to enable this option only in extremely rare cases

Blackberry compatibility:  enable this option if you are connecting a Blackberry phone as modem

Bluetooth Insecure Socket:  enable this option only if you get issues with the bluetooth connection

DUN service channel:  represents the channel for the bluetooth DUN profile;  change the value and set a number like 2, 3 , 4 or 6 if the connection doesn't work with the default value 0 (auto-assigned)

Access Point:   while BlueDUN doesn't need any particular configuration because it routes the data packets to/from the Mobile 3G or Wi-Fi existing connections, for your phone to connect over GPRS, you'll need to tell the phone which APN (Access Point Name) to use.  
GPRS is a service supplied by mobile phone network operators and the APN is used to work out where to route data requests.  Most operators have different access points for different services, and you'll need to pick the right one, or things won't work; generally the Internet Access point is used for web browsing, email and instant messaging, etc.    Here is the World's GPRS APN list.
For CDMA (Code Division Multiple Access) connections keep the Access Point value blank.

Phone Number:   GPRS doesn't use a dial-up number (as GSM data calls do), but a conventional dial up Phone Number (*99# , *99***1# or something similar) should be set for the modem negotiation.
For CDMA usually the number is #777.

Authentication:   the authentication step is generally required even if the username and password are not defined, so you may select the authentication type = PAP (default) or CHAP.   UserName and Password are sometimes required by certain mobile operators and you have to insert the right ones for the user authentication (otherwise leave them blank).

DNS:  finally, you may need to set the Primary and alternative (Secondary) DNS addresses; they are used to resolve the domain names and are generally assigned automatically during the connection setup when equal to  If you force these parameters it is possible that the service provider cannot resolve the internet URLs and the connection doesn't work.

Note:  dialing and connection is supported by the wireless service provider and extra fees or additional charges might apply as this is going through the carrier's network.

BlueVPN has been tested with BlackBerry 9300, Nokia phones (E65, E66, N8-00 Belle, C60-01), Samsung SGH-L760.

Log reports:

You can help the app development in these way:
1. Open the BlueVPN settings and activate the options "Enable Logger" + "Log To File"
2. Go back and tap the GPRS phone name on the paired device list (start new connection)
3. If connection fails or after some time, open the BlueVPN settings again and click the last item [Send Files for Debug] for sending all the generated log files ( named application.log ) by email

Known issues:

A) The BlueVPN app seems locked on Modem or LCP negotiation messages

1. Pair the GPRS phone with a Windows PC and create a bluetooth modem connection
2. Open a command prompt on Window PC (cmd) and type in the order the following commands:
  • netsh
  • ras
  • set tracing PPP enable
3. Connect to internet the PC with your GPRS phone
4. Send by mail the file  /Windows/tracing/PPP.log  and the application.log (generated as described above)

B) The BlueVPN app shows the connected message (and the stop button) but suddently goes back to the paired device list

Some Android device manufacturers (Sony  for example) do not include the
VPN TUN module in the Android 4.0.x version that is installed on the device. This module is similar to a device driver. Without the module installed, a VPN tunnel cannot be established from the device.
To check if your device supports the VPN you can install the CatLog - Logcat Reader! app;
In case of unsupported VPN, an error message that appears similar to the following example is written to the catlog report when you tap the connection button on BlueVPN app:

E/VpnJni  (  189): Cannot allocate TUN: Bad file number
E/F5EdgeClient( 1391): Failed to establish VPN
E/F5EdgeClient( 1391): java.lang.IllegalStateException: Cannot create interface

You can install the TUN module by installing the "TUN.ko Installer" app:

Please contact the manufacturer's support for more information.

Best Practices:  Use only letters and numbers for Bluetooth device names (no special chars or spaces)

C) After the upgrade to Android 4.1 or 4.2 (Jelly Bean), BlueVPN doesn't connect when click on remote device name

  - remove the pairing with the remote device on Android settings and create it again.
  - click over the icon on the right of paired device name
  - enable the option "Use for internet access" (don't worry if the it remains unchecked )