Saturday, May 5, 2012

BlueDUN: Connect Windows 7 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 7 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 your computer.


In the notification area, click on the small arrow to reveal a whole set of additional icons. Then, right click on the Bluetooth icon and click on "Show Bluetooth Devices"


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, then type the code.   Once the code is entered, the pairing is 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 throught 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!




Reference:  http://www.7tutorials.com/transfer-files-between-devices-your-windows-7-pc-bluetooth

Saturday, April 7, 2012

BlueDUN+: MB Comand OnLine and Android phones


The bluetooth pairing between Android phones and the MB comand online allows the users to share phone contacts and perform telephone calls.  In addition to Navi(gation), Audio, Tel(ephone), Video and System menu-options, you can see another icon:  the web navigation.  
Selecting this menu option, the user can open a web browser and insert URL for web navigation, or access the Comand OnLine functions including weather forecast, facebook, point of interest and more... 



The comand online needs a bluetooth DUN (dial up network) service but Android phones don't support it natively (because it is an old technology), so you have to install an app to activate this service.


The BlueDUN app for Android enables the bluetooth DUN service on your phones; this short guide shows how it is possible to open the web access for MB Comand OnLine:

1. Remove the old pairing between the Navi and the phone
If you have not recently purchased your car, it is quite possible that you have already paired the phone with the Comand to make phone calls.  When you create the Bluetooth 
connection between two devices, each of them searches and stores all the services available on the other device, then when you try to open a web link you may get the message  "Connected phone does not support data communication".   



No problem, it is normal, you have just to return to the initial situation, like if the two devices had never met themselves.  In other words, you have to remove the pairing:   select the Tel menu option / Telephone item on the bottom sub-menu / Bluetooth telephones / scroll the phone list and select the phone to remove / click the white icon on the right / De-authorise option and finally confirm.






2. Open BlueDUN,  Start the DUN Service and create a new pairing

After removing the pairing you'll need to create a new connection between the phone and Comand: normally you should activate the bluetooth interface on your phone and make it discoverable by other devices.  The BlueDUN app automatically enables the bluetooth, but you must check the "Discoverable" option in the properties panel (click the menu/left hard-button to show it):




BlueDUN requires a valid internet connection to start, so, when you click the "Start Service" button, the first message you can see is "Testing Internet connection...".   The app emulates a modem features but it doesn't perform a true dial up call, when the device client requests information, BlueDUN forwards these messages to the wifi or mobile (HSDPA/EDGE/GPRS) data connection and it forwards back to the client all replies.


If the BlueDUN screen shows the status "Waiting Bt Client.."  you are ready to pair again the Comand and the phone following the same steps:   select the Tel menu option / Telephone item on the bottom sub-menu / Bluetooth telephones / search for discoverable devices.

3. Select a Provider and setup the connection parameters
Once the Comand has stored the phone BT services, including the DUN, you don't need to pair them again, but the first time you try to open a web link you will get this message:  "No provider selected or provider data is incorrect. Please check settings".      You need to assign a Provider for the web connection and you can choose one from provider list of your country.


Connection parameters (Phone number, access point, used ID and Password) are not important, so don't care about them.  The only parameter that has effect is the DNS address:  if you enter a wrong IP you may not be able to access the MB server, so it is better to leave them as automatic assigned.  In this case BlueDUN will use the Google's default primary DNS IP (8:8:8:8) and secondary DNS IP (8:8:4:4).




4. Access to Comand OnLine Apps or to a web page
Previous steps should be executed only the first time, in normal usage you can select the web navigation icon and open an URL or the Mercedes Benz Apps menu.


It is important to notice that Comand OnLine doesn't access directly to internet web pages but downloads them from the Mercedes Berz VPN server, this means that download speed is considerably slower respect to the phone browser because it depends on MB server congestion.



I suggest to use the phone connected to a Wi-fi network (such as the home or office wifi access point) when you use the Comand Online the first time for accessing the on-line services:   the navigator gets from the server many data for configuring the menu and the apps and the phone must have a stable connection otherwise you need to restart the process again if the connection drops.

Moreover, you have to remember to start the BlueDUN service on the phone before opening a www link, otherwise you will get the message "Function not possible at the moment".   For this reason, you may activate the "Auto-Start" (and "Auto-Resume") option on BlueDUN property panel;  in this manner the DUN service will be always on while the app is running.




If after several attempts, you can not connect, always getting the message "Connection failed" message, it means that bluetooth channel cannot be reused. 
Try closing the connection by clicking the disconnect icon at the bottom right on the Comand, turn off the bluetooth interface on the phone and finally restart the BlueDUN service.




In the preference panel you may also change the Bluetooth Channel:   the default is number 0 [auto-assigned], but if it seems that you cannot start the bluetooth DUN service, enter a value in the range 1-30.  Generally this has not effect for new version of Android because the DUN channel is always auto-assigned.

Another parameter very important for the connection success is the UDP packet delay;  this parameter represents the time delay between each packet sent to the UDP server.  Its default value is 50ms but you can increment it (for example set 100ms or 150ms) if the phone has connection issues.   [Deprecated on new versions]

If none of the previous actions has success, please enable the "UDP Compatibility" option in the property panel, this option increases the connetion timeout and reduces the download speed, but allows the Comand to connect online.  [Deprecated on new versions]

Thursday, March 1, 2012

BlueDUN issue: why the "Start Service" button has no effect?


Symptoms: when click the "Start Service" button, the status comes back to the green color immediately.

The BlueDUN application allows to enable the bluetooth DUN profile for Android phones;  this profile is not officially supported by Google and you need an app to turn on this feature.   
Some firmwares (in particular the Motorola, and some HTC / Sony firmwares) don't allow the registration of DUN profile because it seems already registered even if not available.   

To check if the DUN profile is available or not for your device/firmware you can trace the systems logs with the Catlog app  (download it from Google Play, it is free):
- download and install the Catlog app, open it
- open BluDUN and click the "Start Service" button
- go back to Catlog and filter by BluetoothService

If you find this message:

W/BluetoothService( 448): Attempted to register a reserved UUID: 00001103-0000-1000-8000-00805f9b34fb

you will not able to use the BludDUN app.


The Catlog app requires a rooted firmware for Jelly Bean;  alternatively you can get the same report connecting the phone to a Windows / Mac or Linux PC:

1. Download the latest Android SDK (SDK Tools Only) for your SO from Google: Android SDK
2. Extract the ZIP file to your desired location
3. To get ADB, you need to install the SDK: Installing the SDK
    ( execute the SDK Manager and install the "Android SDK Platform Tools" )


Make sure in your phone the option Settings” -> “Developer Options” -> “Debugging” ->”USB debugging" is enabled;   open a terminal (cmd) and execute the command in the folder  .../android-sdk/platform-tools:

adb logcat 

   starts dumping debugging information from your handset to the console 

adb logcat -f <logfilename> 

   starts dumping debugging information from your handset to the file <logfilename>

##############################################################################

The Android source code is open, so we can discover where is the problem:

If you want enable a profile, you need to call the listenUsingRfcommWithServiceRecord method of BluetoothAdapter class:

925   public BluetoothServerSocket listenUsingRfcommWithServiceRecord(String name, UUID uuid) throws IOException {
927       return createNewRfcommSocketAndRecord(name, uuid, true, true);
928  }


There are 2 parameters:  the first one is the name assigned to the new profile (you can see this name from Windows when you list the available BT services), the other is the Universally Unique Identifier (UUID) that identifies uniquely the profile type:

The base UUID is 00000000-0000-1000-8000-00805F9B34FB
The DUN profile code is 1103;  
The complete UUID for DUN profile is :  00001103-0000-1000-8000-00805F9B34FB

The listenUsingRfcommWithServiceRecord method calls the createNewRfcommSocketAndRecord method inside:

999  private BluetoothServerSocket createNewRfcommSocketAndRecord(String name, UUID uuid,
                  boolean auth, boolean encrypt) throws IOException 

and createNewRfcommSocketAndRecord calls:

1035    handle = mService.addRfcommServiceRecord(name, new ParcelUuid(uuid), channel, new Binder());

for registering the service record related to the UUID for a specific bluetooth channel.

The mService object is declared as an interface (IBluetooth); the implementation is the BluetoothService class:


public synchronized int addRfcommServiceRecord(String serviceName, ParcelUuid uuid,
            int channel, IBinder b) {
        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        if (!isEnabledInternal()) return -1;

        if (serviceName == null || uuid == null || channel < 1 ||
                channel > BluetoothSocket.MAX_RFCOMM_CHANNEL) {
            return -1;
        }
        if (BluetoothUuid.isUuidPresent(BluetoothUuid.RESERVED_UUIDS, uuid)) {
            Log.w(TAG, "Attempted to register a reserved UUID: " + uuid);
            return -1;
        }
        int handle = addRfcommServiceRecordNative(serviceName,
                uuid.getUuid().getMostSignificantBits(), uuid.getUuid().getLeastSignificantBits(),
                (short)channel);
        if (DBG) log("new handle " + Integer.toHexString(handle));
        if (handle == -1) {
            return -1;
        }

        int pid = Binder.getCallingPid();
        mServiceRecordToPid.put(new Integer(handle), new Integer(pid));
        try {
            b.linkToDeath(new Reaper(handle, pid), 0);
        } catch (RemoteException e) {}
        return handle;
    }

Inside this method you can see the call: BluetoothUuid.isUuidPresent(BluetoothUuid.RESERVED_UUIDS, uuid)
and if it fails, returns the message showed in the system log: 

Attempted to register a reserved UUID: 00001103-0000-1000-8000-00805F9B34FB

        

The isUuidPresent method of BluetoothUuid class checks if the UUID you want to register is free; in other words, the firmware defines a list of taken UUID and the method checks if your UUID is included or not in this list.   If included, you cannot register the new profile.
  
The list is fixed and it is given by the  RESERVED_UUIDS constant:

RESERVED_UUIDS = { AudioSink, AudioSource, AdvAudioDist, HSP, Handsfree, AvrcpController, AvrcpTarget, ObexObjectPush, PANU, NAP }

Usually the list doesn't include the DUN profile:

AudioSink ="0000110B-0000-1000-8000-00805F9B34FB"
AudioSource ="0000110A-0000-1000-8000-00805F9B34FB"
AdvAudioDist ="0000110D-0000-1000-8000-00805F9B34FB"
HSP ="00001108-0000-1000-8000-00805F9B34FB"
HSP_AG ="00001112-0000-1000-8000-00805F9B34FB"
Handsfree ="0000111E-0000-1000-8000-00805F9B34FB"
Handsfree_AG ="0000111F-0000-1000-8000-00805F9B34FB"
AvrcpController ="0000110E-0000-1000-8000-00805F9B34FB"
AvrcpTarget ="0000110C-0000-1000-8000-00805F9B34FB"
ObexObjectPush ="00001105-0000-1000-8000-00805f9b34fb"
Hid ="00001124-0000-1000-8000-00805f9b34fb"
PANU ="00001115-0000-1000-8000-00805F9B34FB"
NAP ="00001116-0000-1000-8000-00805F9B34FB"
BNEP ="0000000f-0000-1000-8000-00805F9B34FB"
PBAP_PSE ="0000112f-0000-1000-8000-00805F9B34FB"

On the other hand, if the DUN profile was added in this list the BluetoothUuid.isUuidPresent returns true;  you get the message "Attempted to register a reserved UUID: "  the app will not able to register the new profile!


The question is:   why is the DUN profile is included inside this list if the DUN profile is not implemented?

Probably the reason is that the manufacturer doesn't want the DUN profile is enabled at the application level in their devices; maybe for security issues.