Sunday, October 11, 2015

BlueDUN & BlueVPN - What do you need to connect?

BlueDUN+ / BlueDUN emulate the hardware modem on your Android phone. They allow your phone to share wifi or mobile connection over the bluetooth channel with other devices like PCs,tablets or navigation systems.  The bluetooth DUN (dial-up network) service is turned on, in order to enable the external device to access the Internet.
Android 2.3.* / 3.* :
Android >= 4.*  :

BlueVPN+ / BlueVPN  open a VPN connection through the bluetooth or USB channel and allow to navigate the internet without a WiFi or a built-in 3G module.
They requires one of:
 - Android smartphone/tablet with BlueDUN installed and running
 - GPRS phone with Dial-Up Networking (DUN) support
 - USB Stick with 3G or PSTN Modem [BlueVPN+]
Android 2.3.* / 3.* :
                            Android >= 4.*  :

1. TABLET (USB host port) & 3G STICK or PSTN (Line) Modem






BlueDUN(+): Connect Windows 10 PCs to internet via bluetooth through Android phones

This post shows how to install and configure Bluetooth and pair your computer with an Android mobile phone to enable the internet connection.

Prerequisites are that you have already installed the bluetooth adapter on your windows 10 computer and turned on the bluetooth interface.

The pairing process can be started both from computer and phone. If you choose to start from phone you need also to enable in the Bluetooth Settings  the option: "Allow Bluetooth devices to find this computer".
In this example, I will choose to start the pairing from the computer.

In Windows search bar type "devices" and select "Device and Printers - Control Panel"

Now you can see the list of the previously paired devices, but, before clicking "Add a device" to create a new pairing with your phone it is necessary to turn on the BlueDUN+ service on phone.

Open the BlueDUN+ app and enable the "Discoverable" option on preference panel (click the menu button to access to the preferences); now when you start the service you should get the message "Bluetooth permission request" asking you to enable the bluetooth visibility status for a limited time. 

If the BlueDUN+ service is running on the phone, you can click the "Add a device" button on PC; this starts the "Add a Device" wizard, which automatically scans for new devices, including Bluetooth ones.
After a few seconds, your phone should show up in the list of available devices. If it doesn’t, then you need to make sure Bluetooth is enabled on the phone and the phone is set as discoverable.

Select your phone and click Next.

The wizard displays a code that you need to type on your mobile phone, so that the pairing is completed.

On your mobile phone, you are notified that your computer wants to connect via Bluetooth. Press OK to confirm the passcode.

After the confirmation, the pairing will be created and Windows automatically searches for drivers for all Bluetooth profiles available on your mobile phone, then installs them.

To check the discovered and installed BT profiles, you can right-click the phone you’ve just added and choose Properties:

Note:  the "Dial Up Network (
DUN)" profile will be available on phone only when the BlueDUN+ service is running; if you pair the devices in a different condition, you will not be able the create a new internet connection on PC.   In this case, remove the old pairing and create a new one following the above steps.

Make sure the DUN profile is also selected and click OK to confirm.
Now it is the time to create a new internet connection to access the internet through the  bluetooth phone tethering:  right-click again your phone and then choose "Dial-Up Networking" > "Create a dial-up connection…"

after clicking that, it will ask for what Modem device to use in your dial-up choose the last one, if it doesn’t work, try the others...

now enter the mandatory dial-up number ( for example  *99***1#  is the mostly used ), and enter a name for your dial-up connection… no need for username and password with the BlueDUN+ app …

after entering the details, click Connect, it will try to dial the number in your phone and registering your connection to networks server, and after that it will test your connection…

On the BlueDUN+ app you should see the "Modem negotiating.." message and soon after the panel with connection statistics indicating the connection was established with success.

Now your done! Click close button to close the window, and Open your browser to start surfing the web, Enjoy!

If you need to use the dial-up connection in the future, you have just to click the "Network settings" icon on notification area:

select the connection with proper name

click the "Connect" button and finally click the "Dial" button:

Saturday, October 10, 2015

BlueDUN+: Connect custom application to external device with TCP/IP over bluetooth

External app running a TCP server

The external application runs a TCP server on a specified port and acts as normal application server:   when the bluetooth client requests a connection with a special IP, the BlueDUN service redirects the data packets to the local port on localhost (    

Application settings -  “Extensions” category:
Client application = unchecked
Redirect IP = the special IP associated to the external application [ default: ]
Local port = the port number on localhost related to the TCP server running inside the external app [ default: 8001 ]

Actions to be performed in the external application:

1. Start the BlueDUN service [if not automatically started on device boot]:

   Intent intent = new Intent();
   intent.setComponent(new ComponentName("com.bluedunx","com.bluedunx.BlueDUNService"));

2. Start up the TCP server for a given local port number

External app connecting as a TCP client

The external application connects to a TCP server running inside BlueDUN;  the BlueDUN module redirects the data packets to the TCP socket created with the external device over the bluetooth channel, matching the port numbers.
The TCP server starts as soon as you start up the BlueDUN service on localhost ( and opens the specified port.  

Application settings -  “Extensions” category:
Client application = checked
Redirect IP = the special IP associated to the external application [ default: ]
Local port = the port number on localhost related to the TCP server running inside BlueDUN [default: 8001] and equivalent to the port number on the external device

Actions to be performed in the external application:

1. Start the BlueDUN service  [if not automatically started on device boot]:

   Intent intent = new Intent();
   intent.setComponent(new ComponentName("com.bluedunx","com.bluedunx.BlueDUNService"));

2. Connect to the TCP server for the given port number

Note:  this configuration needs the external app to be reconnected if the external device closes a connection created before.

Sunday, May 5, 2013

BlueVPN+, connect your Tablet to internet with a USB modem (3G or PSTN)

The BlueVPN+ app allows the use of 3G or PSTN modems attached to USB host port.  Not all tablets have the USB or microUSB port but they are provided only with a proprietary connector;  in these cases you need a OTG cable or adaptor from the special connector to USB female connector.


A) Make sure your USB device is switched to modem feature only and the auto running is disabled:

The following procedure must be executed before using the USB stick with BlueVPN

1) Connect the modem to a PC running Windows and make sure it works.

2) Download the  Hyper Terminal  application, extract the zip file and run  hypertrm.exe

[ for Windows XP  you can find HyperTerminal under  Star t>Programs>Accessories>Communications>HyperTerminal ]

3) In the "Connection Description" write any Name, say "Huawei" for example, and click OK. 

4)  Wait for the appearance of the window "Connect To" and in the "Connect using:" option select the name of your USB modem ( for example:  "HUAWEI Mobile Connect - 3G Modem" ) ;  click OK.

5)  Close the next window by pressing the "Cancel" button.

6)  On the toolbar of the program, press the last icon "Properties";  that opens the "Properties" window.
Select the  "Settings" tab and click the "ASCII Setup" button;  put a tick in the checkbox "Echo typed characters locally"
Click OK two times for closing the ASCII setup window and the Properties window.

7) In the main window you should see a flashing cursor:   turn on the CAPS LOCK,  type the command "AT" and press ENTER.  If comes the answer  "OK"  means the terminal is connected to the modem. 

8) Introduce one of the following 

For Huawey modems:

  AT^U2DIAG=0      (device-only modem)
  AT^U2DIAG=1       (the device as a modem + CD-ROM)
  AT^U2DIAG=255   (the device as a modem + CD-ROM + Card Reader)
  AT^U2DIAG=256   (the device as a modem + Card Reader).

For using the modem with a tablet the USB stick has to be configured as "device only modem"
Type the command  AT^U2DIAG=0 and press ENTER.

For ZTE modems:

   AT+ZCDRUN=8   (disable flash cd-drive)
   AT+ZCDRUN=9   (enable flash cd-drive)

9) After the response "OK" from the modem, close the window Hyper Terminal, answering "Yes" to the proposal to interrupt a session and refusing to stay connected.

10) Make sure that CD-ROM emulation is disabled.   To do this, disconnect the modem from the USB port and then reconnect it in the same port.   In "My Computer" should not appear a drive for the USB stick.

If you need to recover the modem to its original state, you have to repeat the whole procedure, but using the command AT^U2DIAG=255 (the device as a modem + CD-ROM + Card Reader).

All these actions are no more required since BlueVPN+ version 1.5:
The new versions include a file with parameters  for  most popular devices and sends the code for switching automatically the USB stick to the modem feature.   Probably you will need to confirm twice the USB exclusive access message because after the switch the device is disconnected and immediately reconnected with a different ID.

B) You need a powered USB hub if your Android device supplies low USB power

On some tablets there is often not enough power available for attached USB devices.
Wireless modems are among the devices with the highest power demand (500 mA straight).  Usually, only some larger tablets can provide that much power on their host ports (with Samsung, even the 10.1" devices are reportedly power-limited).  Smaller ones often have their limit at 100 mA which rules out using a large array of devices. One notable exception is the Nexus 7 which works fine with many 3G sticks attached directly.  To bypass the problem you can use a (self-)powered hub:

or alternatively a mobile power battery charger like that (Tekkeon TekCharge MP1820) showed in this video:

NOTE:  some USB devices require some time after the modem switch before accepting AT commands; in this case it is possible to increase the Connection Timeout parameter.

BlueVPN+  common configurations:

a) Phone with Bluetooth Modem:  [ also valid for BlueVPN ]

Modem compatibility:   generally OFF        ( if enabled removes the <cr><lf> before AT commands )
Modem Line Feed:    generally ON              ( if disabled removes the <lf> in AT commands )
AT Initialization:  E0V1&C1&D2
Connection Timeout:   3000 ms                    ( repeat the AT initialization if not received a reply after some ms )
Inter-character delay:   0 ms                         ( increase the value only for very slow devices )
Modem speed:    [not important]
LCP Compatibility:   generally OFF
BlackBerry Compatibility:  generally OFF  (ON for Blackberry phones and if you get issues during negotiation )
Phone Number:    *99***1#  or  *99#   (  #777 for CDMA )
Access Point:   service provider  APN  ( <empty> for CDMA 
Authentication Type:  Password Authentication  ( or Challenge-Handshake )
UserName:  account for the service provider (generally the email) / <empty>
Password:   password for the account / <empty>
Primary / Secondary DNS:  (automatically assigned) 
Bluetooth Insecure Socket:   OFF  (ON if you get issues with bluetooth channel) 
DUN service channel:    0  (number >0  if you get issues with bluetooth channel) 

b) Android Smartphone with BlueDUN:  [ also valid for BlueVPN ]

Modem compatibility:   generally OFF        ( if enabled removes the <cr><lf> before AT commands )
Modem Line Feed:    generally ON              ( if disabled removes the <lf> in AT commands )
AT Initialization:  [not important]
Connection Timeout:   3000 ms                    ( repeat the AT initialization if not received a reply after some ms )
Inter-character delay:   0 ms                         ( increase the value only with very slow devices )
Modem speed:    [not important]
LCP Compatibility:  OFF
BlackBerry Compatibility:  OFF
Phone Number:   [not important]  
Access Point:   [not important]
Authentication Type:  None
UserName:   <empty>
Password:    <empty>
Primary / Secondary DNS:  (automatically assigned) 
Bluetooth Insecure Socket:   OFF  (ON if you get issues with bluetooth channel) 
DUN service channel:    0  (number >0  if you get issues with bluetooth channel) 

c) PSTN Modem:

Modem compatibility:   generally OFF        ( if enabled removes the <cr><lf> before AT commands )
Modem Line Feed:    generally ON              ( if disabled removes the <lf> in AT commands )
AT Initialization:  E0V1&C1&D2
Connection Timeout:   3000 ms                    ( repeat the AT initialization if not received a reply after some ms )
Inter-character delay:   0 ms                         ( increase the value only for very slow devices )
Modem speed:   less or equal to 115200 bauds
LCP Compatibility:  OFF
BlackBerry Compatibility: OFF
Phone Number:   number of service provider
Access Point:  <empty>
Authentication Type:  Password Authentication
UserName:  account for the service provider (generally the email) / <empty>
Password:   password for the account / <empty>
Primary / Secondary DNS:  (automatically assigned)

d) USB Stick Modem:

Modem compatibility:   generally ON         ( if enabled removes the <cr><lf> before AT commands )
Modem Line Feed:    generally ON              ( if disabled removes the <lf> in AT commands )
AT Initialization:  E0V1&C1&D2
Connection Timeout:   3000 ms                    ( repeat the AT initialization if not received a reply after some ms )
Inter-character delay:   0 ms                         ( increase the value only for very slow devices )
Modem speed:   460800 or  921600 bauds
LCP Compatibility:  OFF
BlackBerry Compatibility: OFF
Phone Number:   *99***1#  or  *99#   
Access Point:  service provider  APN
Authentication Type:  Password Authentication
UserName:   <empty>
Password:    <empty>
Primary / Secondary DNS:  (automatically assigned)
Modem switch code:   required only if the device is not included inside the internal list; the text is similar to the following 


The message content strictly depends on the device brand and modem:  you can find some examples here:

For the APN list please refer to the following document:

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 )

Sunday, May 20, 2012

Bluetooth tethering for Android devices: making BlueVPN and BlueDUN work together

The BlueVPN application for Android acts like a "reverse bluetooth DUN" feature, or in other terms it is able to open a dial up connection on a bluetooth-enabled cell phone and use it as modem.  This function is natively supported for many operating systems (Windows, Mac OS, Linux ...) but not for Android:  the previous post showed how to create a modem internet connection on Windows 7.    At the current state, the only way to route all network traffic to a custom channel for a "not rooted" Android device is to open a VPN connection.  This is the reason for the application name.

What does mean "tethering"?

For people that are not familiar with the tethering concept, I quote here a definition taken from wikipedia:

"Tethering means sharing the Internet connection of an Internet-capable mobile phone or internet tablet with other devices. This sharing can be offered over a wireless LAN (Wi-Fi), over Bluetooth, or by a physical connection using a (USB) cable . In the case of tethering over wireless LAN, the feature may be branded as a mobile hotspot. The Internet-connected mobile phone acts as a portable router when providing tethering services to others."

While the Wi-Fi and USB tethering has been disabled on some Android devices the Bluetooth tethering is not supported in any case.  These features can be reenabled only by a device 'rooting' (hack the firmware to attain the superuser access) and there are several applications that work fine for rooted devices.
Anyway not all users are willing to alter the original manufacturer firmware because this operation does come with some risks.   The most notable risk is that you will void any warranty that you have on your device and you may have difficulty to find the original ROM for your device.
In addition, some users can run into problems, for example rendering the phone completely non-functional, having problems with reboots (endless boot cycles) or making the device more vulnerably respect to virus attacks.
The main benefit of using Bluetooth or Wi-Fi instead of a USB cable for tethering is that you can keep your cell phone in your bag or pocket and still make the connection.   Moreover, Bluetooth uses less energy respect to Wi-Fi and it is better suited for use in small portable electronics that rely on battery power.
This is because a Wi-Fi device is constantly transmitting data back and forth between connections, and it needs a lot of energy to transmit large amounts of data. Bluetooth, on the other hand, keeps a connection with very little energy being spent, about one-fifth that of a Wi-Fi connection.

The BlueVPN, app works also for "not rooted" devices ad allows to connect on-line an Android device without an Internet-access capability, sharing the connection available on another phone or tablet.

A said before, this application, routes the network traffic to a VPN connection and finally it exchanges the data packets throught the bluetooth channel.    VPN connections are fully supported  on the latest Android versions Ice Cream Sandwich 4.0.x but limited for previuos releases (Girgerbread 2.x and Honeycomb 3.x)

BlueVPN for Android 2.x and 3.x is quite unstable and difficult to set-up

while the version for Android 4.0.x (BlueVPN ics) is more simple and reliable

In this post we will see how to pair two Android devices for bluetooth tethering:  on the second device (host-router) we install the BlueDUN app to enable the bluetooth DUN profile [generally not natively supported].

1. Create the BT pairing between the client device (with BlueVPN installed) and the host device

Settings / Wireless and Network / Bluetooth settings / Turn on bluetooth if off and make the device visible on both / Scan for devices;  when the name of the other device appears in the bottom list, click on it ( maybe you need to insert a paring code, for example 1234 ) and confirm.   Insert the same code, if necessary, on the host device and confirm.

2. Make sure you have a valid internet connection and the BT-DUN profile on host; if necessary install the BlueDUN app.

[ 3. Create a new VPN L2TP connection on client device - only for Android 2.x and 3.x ]

Settings Wireless and Network / VPN settings / Add VPN / Add L2TP VPN  

set VPN name = BlueVPN   and the VPN server = ; disable the L2TP secret and leave empty the DNS search domains parameter.

Normal use:
[ 0. Enable the wifi/mobile data connection on client (required only to allow the VPN connection opening, but not used for data transfers) - only for Android 2.x and 3.x ]

This is a limitation of Android 2.x and 3.x: even if the VPN is enabled, the traffic is not routed toward it if the wireless connectivity is down.

1. Activate the bluetooth interface [if BT DUN profile is natively supported] or open the BlueDUN app on host device and start the service.

2. Open the BlueVPN app on client, click the host name in the BT device list

On Android ICS devices, the first time you click a button in the list, you may get a message that asks to confirm the VPN connection creation.   Check "I trust this application" and confirm; that click again the host device name on the device list. 

at  this point, the application tries to open the bluetooth connection with the host device and open the VPN  called "BlueVPN" to route the network traffic.

if everything goes right, you should see the stop button and the message "BlueVPN connected with ...."; otherwise, click on the animated central image to go back to the main menu. 

The VPN is really connected only if you can see on the notification panel a "key" icon and the traffic statistics by clicking on it (please dont disconnect the VPN direclty from here, but click the stop button when you have finished).

If BlueVPN does not connect automatically (Honeycomb), start it manually from the system settings (set any username and password):

Settings Wireless and Network / VPN settings / BlueVPN

While BlueVPN is connected you can open a browser and navigate the internet throught the bluetooth tethering.