# Bluetooth with GNOME overview

## Devport

A bluetooth guide with a focus on GNOME integration

Possibilities :

send / receive files ( gnome-bluetooth )

browse phone filesystem ( gnome-vfs-obexftp )

use mobile phone as remote to control desktop / mouse pointer ( bluez-gnome )

browse the web on your phone using your computer`s broadband connection ( bluez-utils )

sync evolution to mobile phone ( opensync )

Implementation ( other ways possible ) :

send / receive files

- emerge gnome-bluetooth ( tested with version 0.9.1 )

- run gnome-obex-server to be able to receive files via bluetooth

- use gnome-obex-send to send files via bluetooth via command line

- emerge nautilus-actions ( ebuild available via sunrise overlay ) and add an action :

        - command "gnome-obex-send -d 00:00:00:00:00:00" ( change MAC address to address of mobile phone )

        - parameter "%M"

( alternativly emerge nautilus-sendto with USEFLAG bluetooth - which doesnt work sometimes )

browse phone filesystem

- emerge gnome-vfs-obexftp ( tested with version 0.4 )

- browse "obex:///" with nautilus

use mobile phone as remote to control desktop / mouse pointer

- edit /etc/conf.d/bluetooth ( change ) :

```

HIDD_ENABLE=true

```

```

HIDD_OPTIONS="--connect 00:00:00:00:00:00"

```

( change MAC address to address of mobile phone )

- Restart bluetooth service

```

/etc/init.d/bluetooth restart

```

( thx to gerardo ) 

browse the web on your phone using your computer`s broadband connection

WARNING : During setting this up it may be that you start a data connection on your phone by accident which will cost quite some money. To avoid this delete all internet / data profiles on the phone / disable all other ways to surf the web than bluetooth - see https://forums.gentoo.org/viewtopic-p-5152045.html#5152045 for details

- For this guide I will use some easy defaults ( e.g. auto-authorisation ) which can be changed by advanced users

- First of all we enable NAT - kernel 2.6.x has this built in AFAIK

- This guide assumes that you dont use a firewall yet and that the device which connects to the internet is eth0

```
emerge iptables

rc-update add iptables default

/etc/init.d/iptables start

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

/etc/init.d/iptables save

echo 1 > /proc/sys/net/ipv4/ip_forward

```

- /etc/sysctl.conf ( change ) :

```
# Disables packet forwarding

net.ipv4.ip_forward = 1

```

- emerge bluez-utils ( tested with version 2.25-r1 - newer versions dont work ! )

- /etc/bluetooth/pin ( create ) :

```
1234
```

- /etc/bluetooth/hcid.conf ( change ) :

```
security auto;
```

- /etc/conf.d/bluetooth ( change ) :

```
# Start pand (allowed values are "true" and "false")

PAND_ENABLE=true

# Arguments to pand

PAND_OPTIONS="--listen --role NAP /etc/bluetooth/pan/dev-up"

```

- /etc/bluetooth/pan/dev-up ( create ) :

```
#!/bin/sh

ifconfig bnep0 10.0.0.1

/etc/init.d/dhcpd restart

```

- 

```
chmod 755 /etc/bluetooth/pan/dev-up
```

- Restart bluetooth service

```
/etc/init.d/bluetooth restart
```

- emerge dhcp

- /etc/conf.d/dhcpd ( change ) :

```
DHCPD_IFACE="bnep0"
```

- /etc/dhcp/dhcpd.conf ( create - change your-routers-ip-or-name to the ip / name of your router / cable modem or use an ip of /etc/resolv.conf )

```
# dhcpd.conf

#

# option definitions common to all supported networks...

option domain-name-servers your-routers-ip-or-name;

# Use this to enble / disable dynamic dns updates globally.

ddns-update-style interim;

subnet 10.0.0.0 netmask 255.255.255.0 {

   range 10.0.0.10 10.0.0.20;

   option routers 10.0.0.1;

}

```

- Add the computer to your mobile phones bluetooth devices ( using above pin [1234] ).

- Now you should be able to browse the web on the phone over bluetooth connection

If it doesnt work you can check that

when you connect the phone over bluetooth a bnep0 interface should turn up ( ifconfig bnep0 )

when you connect the phone over bluetooth the bnep0 interface should have the correct ip ( ifconfig bnep0 -> 10.0.0.1 )

when you connect the phone over bluetooth the dhcp server should be running ( /etc/init.d/dhcpd status )

NAT should be enabled :

```
> cat /proc/sys/net/ipv4/ip_forward

1

> iptables -t nat -L | grep MASQUERADE

MASQUERADE  all  --  anywhere             anywhere   

```

sync evolution to mobile phone

WARNING : Synchronisation will change data in evolution and on your mobile phone. To avoid data loss backup any important data ( ~/.evolution and data on the mobile phone ). On my phone synchronisation lead to duplicate entries in the phone so be cautios.

- Unmask opensync

```
<app-pda/msynctool-9999

<app-pda/libopensync-9999

<app-pda/libopensync-plugin-evolution2-9999

<app-pda/libopensync-plugin-file-9999

<app-pda/libopensync-plugin-syncml-9999

<app-pda/libopensync-plugin-vformat-9999

```

- Keyword opensync ( replace ~amd64 with ~yourarch, e.g. ~x86 )

```
app-pda/msynctool ~amd64

app-pda/libopensync ~amd64

app-pda/libopensync-plugin-evolution2 ~amd64

app-pda/libopensync-plugin-file ~amd64

app-pda/libopensync-plugin-syncml ~amd64

app-pda/libopensync-plugin-vformat ~amd64

 dev-util/cmake ~amd64

  dev-libs/xmlrpc-c ~amd64

app-pda/libsyncml ~amd64

```

- emerge opensync ( tested with version 0.36 )

```
emerge -av msynctool libopensync-plugin-syncml
```

- setup opensync

```
msynctool --addgroup evolution-mobilephone

msynctool --addmember evolution-mobilephone evo2-sync

msynctool --addmember evolution-mobilephone syncml-obex-client

```

- The following actions have to be done by the evolution user

- configure evolution sync target

```
msynctool --configure evolution-mobilephone 1
```

( Generally nothing has to be changed here )

- configure syncml sync target

```
msynctool --configure evolution-mobilephone 2
```

change it to look like this

```
<?xml version="1.0"?>

<config>

  <!-- sets the connection type to use. -->

  <!-- please note that actually OBEX over network is not supported -->

  <!-- 1 means obex over serial cable -->

  <!-- 2 means obex over bluetooth    -->

  <!-- 3 means obex over IRDA         -->

  <!-- 4 means obex over network      -->

  <!-- 5 means obex over usb          -->

  <type>2</type>

  

  <!-- (Only for bluetooth) The bluetooth address if the bluetooth mode is selected.

       `hciconfig scan` to search bluetooth devices.  -->

  <bluetooth_address>00:00:00:00:00:00</bluetooth_address>

  

  <!-- (Only for bluetooth) The bluetooth channel to use.

       `sdptool browse $MAC` to search for the correct channel -->

  <bluetooth_channel>1</bluetooth_channel>

  

  <!-- (Only for USB) The usb interface number of the SYNCML-SYNC target. use syncml-obex-client -u (you will need access to the USB raw device) to find it. -->

  <interface>0</interface>

  

  <!-- The string that the plugin will use to identify itself. Some devices need a special string here. -->

  <identifier></identifier>

  

  <!-- The syncml version to use: 0 for 1.0, 1 for 1.1 and 2 for 1.2 -->

  <version>1</version>

  

  <!-- if the plugin should use wbxml -->

  <wbxml>1</wbxml>

  

  <!-- The username to use. Leave empty to not require a username -->

  <username></username>

  

  <!-- the password for the username -->

  <password></password>

 

  <!-- If wbxml is enabled, defines wether the wbxml should use string tables -->

  <usestringtable>0</usestringtable>

  

  <!-- Never send ADD command, but send REPLACE (not needed normally) -->

  <onlyreplace>0</onlyreplace>

  <!-- Workaround around for mobile phones which only use local timestamps and _no_ UTC timestamps! -->

  <onlyLocaltime>0</onlyLocaltime>

  

  <!-- Sets the maximum allowed size in bytes of incoming messages (some device need this option set). Example: 10000 -->

  <recvLimit>0</recvLimit>

  

  <maxObjSize>0</maxObjSize>

  <!-- XXX: Currently you need to write this by your own.

       Later it's planned to create such entries on the fly during

       the discovery() call. Example database field:

  -->

   <database>

     <name>contacts</name>

     <objtype>contact</objtype>

     <objformat>vcard21</objformat>

  </database>

<!--

   <database>

     <name>agenda</name>

     <objtype>event</objtype>

     <objformat>vevent10</objformat>

  </database>

-->

<!--

   <database>

     <name>notes</name>

     <objtype>note</objtype>

     <objformat>vjournal</objformat>

  </database>

-->

<!--

   <database>

     <name>tasks</name>

     <objtype>todo</objtype>

     <objformat>vtodo10</objformat>

  </database>

-->

</config>

```

Note : There are many details that have to be correct here. Make sure to use the right MAC address and channel. The database names vary among different mobile phones, see http://en.opensuse.org/OpenSync/SyncML-OBEX-Client to get an idea. Its also important to use the correct objformat versions - e.g. on my mobile phone ( SE K800i ) vevent20 fails but vevent10 works. You may want to try out which databases work for you and which not by uncommenting / changing the respictive database entries.

- let opensync detect the data to be synced ( do this whenever you change the database entries )

```
msynctool --discover evolution-mobilephone
```

- sync data

```
mysynctool --sync evolution-mobilephone
```

Planned sections :

Sync mobile phone data, e.g a music library

Use mobile phone as remote control to specfic apps ( lirc replacement ) - anyremote

Use bluetooth headphones ( http://bluetooth-alsa.sourceforge.net/ - not in portage )

....

Changelog

27.04.2008

- Removed bluez-utils-3.x sections since it doesn`t support PAN

- Added gerardo`s guide to enable HID

- Added section to sync evolution to mobile phoneLast edited by Devport on Tue Jul 15, 2008 12:46 pm; edited 86 times in total

----------

## muczy

Remote control:

anyremote (nokias doesn't have remote control function like sony ericsson)

File transfer:

I would like to know how can i set up a constant obextftp daemon? I don't like gnome-obex-server...

----------

## zietbukuel

I'd really liked to know how to do this:

Connect the mobile phone to the web over bluetooth 

Anybody can tell me? thanks.

----------

## Devport

 *zietbukuel wrote:*   

> I'd really liked to know how to do this:
> 
> Connect the mobile phone to the web over bluetooth 
> 
> Anybody can tell me? thanks.

 

I am currently working on this one. Right now I got it working by bridging the interface but this means you only have internet either on the phone or on your computer. I will change my webconfiguration to be able to provide ip_forwarding. If this works ill post a howto till tomorrow hopefully. A clean solution with networkmanager is planned ( by bluez team ) but not possible yet. If you try by yourself make sure to use the non-masked version of bluez-utils because documenation for newer ( masked ) versions is rare and it does not bring up a network interface.

----------

## Devport

I think it will take some days till I write the ip_forwarding howto. Until then you can use ethernet bridging.

Please refer to

http://www.gentoo.org/doc/en/bluetooth-guide.xml -> for general setup

http://bluez.sourceforge.net/contrib/HOWTO-PAN -> for ethernet bridging ( skip the other sections )

Make sure you use bluez-utils-2.25-r1 - newer versions work different and arent ready yet as it seems.

----------

## Devport

 :Cool:   I got it working and I`ll post an updated howto in a few days ( need to figure out the best / nicest way and will try to get it to work with a more recent ~arch version of bluez-utils ). Dont start to struggle with bridging now as ip_forwarding is way easier.

In the meantime anyone who wants to get it working may want to look here :

http://www.hackenberger.at/blog/gentoo-guides/how-to-set-up-a-linux-box-as-a-bluetooth-server/

----------

## zietbukuel

Thanks a lot Devport!!!! This is what I've been looking for AGES without a easy way to do!! thanks again, I'll be waiting for your HOWTO  :Smile: 

ps. I'm following this thread...

----------

## Devport

The step by step guide is ready now and I hope that it helps someone despite all the pitfalls.

----------

## zietbukuel

 *Devport wrote:*   

> The step by step guide is ready now and I hope that it helps someone despite all the pitfalls.

 

Thanks, but I'm using as an internal IP 10.0.0.1 and my routers IP is 10.0.0.138 what should I put in the configuration? I can't assign bnep0 the IP 10.0.0.1 as it is already assigned to eth0, thanks.   :Very Happy: 

[EDIT]

I've soled the problem using the 192.168.0.0 subnet instead if 10.0.0.0 so people with my type of IP addresses can use this:

in dhcpd.conf:

```
# dhcpd.conf

#

# option definitions common to all supported networks...

option domain-name-servers 208.67.222.222;

# Use this to enble / disable dynamic dns updates globally.

ddns-update-style interim;

subnet 192.168.0.0 netmask 255.255.255.0 {

   range 192.168.0.10 192.168.0.20;

   option routers 192.168.0.1;

}
```

in dev-up:

```
#!/bin/sh

ifconfig bnep0 192.168.0.1

/etc/init.d/dhcpd restart
```

This should start working now  :Smile: 

[/EDIT]

----------

## Devport

Then replace all 10.0.0.x numbers in the howto with 192.168.0.x numbers. Dont forget to set the routers ip in dhcp configuration.

Yeah - as I see you did it right ( but dont forget 208.67.222.222 should be the router`s IP 10.0.0.138 ).

----------

## zietbukuel

You forgot something:

```

chmod 755 /etc/bluetooth/pan/dev-up

```

So it can be executed  :Smile: 

----------

## zietbukuel

 *Devport wrote:*   

> Then replace all 10.0.0.x numbers in the howto with 192.168.0.x numbers. Dont forget to set the routers ip in dhcp configuration.
> 
> Yeah - as I see you did it right ( but dont forget 208.67.222.222 should be the router`s IP 10.0.0.138 ).

 

My router has the DNS server down, I prefere to use OpenDNS DNS servers, thanks.

----------

## Devport

 *zietbukuel wrote:*   

> You forgot something:
> 
> ```
> 
> chmod 755 /etc/bluetooth/pan/dev-up
> ...

 

Added. Thx. And does it work for you ?

----------

## zietbukuel

Yes it does work with my SonyEricsson W610. Thank you very much for the howto.

----------

## zietbukuel

To use your cellphone or mouse or whatever to control your desktop or app, do this:

Edit /etc/conf.d/bluetooth and change:

```

HIDD_ENABLE=false

```

to

```

HIDD_ENABLE=true

```

Then change

```

HIDD_OPTIONS=""

```

to

```

HIDD_OPTIONS="--connect 00:11:22:33:44:55"

```

Where 00:11:22:33:44:55 is the device you want to connect, you can know this by using

```

hcitool scan

```

Then execute this command:

```

/etc/init.d/bluetooth restart

```

I've tested this simple setup with OpenOffice to control presentations, controling Rhythmbox, Totem and my mouse using my W610i.

This is only tested with net-wireless/bluez-utils-2.25-r1 and net-wireless/bluez-libs-2.25.

I think this can be added to the howto  :Smile: 

Note:

If you need more than one device to be connected as a "remote control" just change "--connect <mac>" to "--server" (without quotes).Last edited by zietbukuel on Sun Feb 03, 2008 3:52 am; edited 1 time in total

----------

## Devport

Nice howto - my small remote control passage is related to ~arch bluez-utils, but due to PAN only being possible with the old bluez-utils your way fits better.

If you agree I will add your part / replace my part in the guide and add an author list with your name.

----------

## zietbukuel

 *Devport wrote:*   

> Nice howto - my small remote control passage is related to ~arch bluez-utils, but due to PAN only being possible with the old bluez-utils your way fits better.
> 
> If you agree I will add your part / replace my part in the guide and add an author list with your name.

 

Yes I agree buddy, do it  :Smile: 

----------

## PaulW21781

I have one problem with nautilus-sendto...

I've merged it in with the bluetooth flag set, yet when I right-click files and select Send To, all thats listed is Evolution...

Everything else works fine, and I can manually send stuff using the console, its just the send to option which is missing...

any ideas??  I'm on ~amd64

----------

## zietbukuel

 *PaulW21781 wrote:*   

> 
> 
> PostPosted: Wed Jan 30, 2008 6:13 pm    Post subject:
> 
> I have one problem with nautilus-sendto...
> ...

 

 *Devport wrote:*   

> # send / receive files
> 
> - emerge gnome-bluetooth ( tested with version 0.9.1 )
> 
> - run gnome-obex-server to be able to receive files via bluetooth
> ...

 

I use this method, it is way better and stable than nautilus-sendto, which send files with '%20' instead of a space...  :Smile: 

----------

## Devport

Added a section about how to sync evolution to a mobile phone - this is very rough so please report any bugs back.

----------

## Anon5710

I am trying to get pan networking enabled. Internet on my phone trough laptops broad band !

But for some reeson dhcp fails to restart

the error log

```

laptop kevin # tail /var/log/messages 

Apr 27 20:06:46 localhost dhcpd: 

Apr 27 20:06:46 localhost dhcpd: No subnet declaration for eth0 (192.168.2.100).

Apr 27 20:06:46 localhost dhcpd: ** Ignoring requests on eth0.  If this is not what

Apr 27 20:06:46 localhost dhcpd:    you want, please write a subnet declaration

Apr 27 20:06:46 localhost dhcpd:    in your dhcpd.conf file for the network segment

Apr 27 20:06:46 localhost dhcpd:    to which interface eth0 is attached. **

Apr 27 20:06:46 localhost dhcpd: 

Apr 27 20:06:46 localhost dhcpd: 

Apr 27 20:06:46 localhost dhcpd: Not configured to listen on any interfaces!

Apr 27 20:06:46 localhost dhcpd: exiting.

```

Any help ?

----------

## Devport

Did you do the step :

- /etc/conf.d/dhcpd ( change ) :

Code:

DHCPD_IFACE="bnep0"

?

----------

## Anon5710

alright, by redoing everything again.

I am fasing an other error at this moment.

```

Apr 28 00:39:05 localhost dhcpd: 

Apr 28 00:39:05 localhost dhcpd: No subnet declaration for bnep0 (0.0.0.0).

Apr 28 00:39:05 localhost dhcpd: ** Ignoring requests on bnep0.  If this is not what

Apr 28 00:39:05 localhost dhcpd:    you want, please write a subnet declaration

Apr 28 00:39:05 localhost dhcpd:    in your dhcpd.conf file for the network segment

Apr 28 00:39:05 localhost dhcpd:    to which interface bnep0 is attached. **

Apr 28 00:39:05 localhost dhcpd: 

Apr 28 00:39:05 localhost dhcpd: 

Apr 28 00:39:05 localhost dhcpd: Not configured to listen on any interfaces!

Apr 28 00:39:05 localhost dhcpd: exiting.

```

Problem is i have a subnet declaration in for bnep0 in dhcpd.cond

```

GNU nano 2.0.7                                 File: /etc/dhcp/dhcpd.conf                                                                        

option domain-name-servers 192.168.2.1;

ddns-update-style interim;

subnet 10.0.0.0 netmask 255.255.255.0 {

        range 10.0.0.10 10.0.0.20;

        option routers 10.0.0.1;

        }

```

and yes i've changed DHCPD_IFACE="bnep0"  correct.

Greetings Anon5710

----------

## Devport

Now you have defined the correct interface. What you are doing now is you try to start the dhcp server without the interface being up. dhcpd will start correctly only when there is an active connection ...

Check what the guide says (!) :

when you connect the phone over bluetooth a bnep0 interface should turn up ( ifconfig bnep0 )

when you connect the phone over bluetooth the bnep0 interface should have the correct ip ( ifconfig bnep0 -> 10.0.0.1 )

If both is the case the dhcp server will startup just fine. Otherwise you first need to fix your bluetooth connection to get the bnep0 interface.

----------

## Peach

did anyone tried devel version of gnome-bluetooth? am I the only that can't find gnome-obex-send in this version???

----------

## Devport

I am sorry - I will switch to the more recent versions ( and update the guide ) when bluez-utils-3.x will support PAN again which is not the case yet. This is the feature I use most so newer versions are absolutly useless for me.

Check these for pointers to solve your problem :

http://www.nabble.com/gnome-obex-send-obsolecence-td14955324.html

http://tadas.dailyda.com/blog/

----------

## zietbukuel

Hi, devport, do you know how to configure a SE K850 to automatically use bluetooth for internet connection (go to browser and start using internet) instead of 1)active bluetooth, 2)connect device 3)go to browser and open webpage?? my old W610 could do that, but I don't know how to do this with my new K850. Thank you!

----------

## Devport

 *zietbukuel wrote:*   

> Hi, devport, do you know how to configure a SE K850 to automatically use bluetooth for internet connection (go to browser and start using internet) instead of 1)active bluetooth, 2)connect device 3)go to browser and open webpage?? my old W610 could do that, but I don't know how to do this with my new K850. Thank you!

 

On my K800i this works - it automatically connects via bluetooth when I start an app which is allowed to access the web ( which is very useful since it saves much power ). I dont know what exactly is neccessary to achieve this - I did several things so that the bluetooth connection is the only possible way to get internet access ( since I never use the expensive mobile phone internet service ) :

- In data transfer settings I removed all accounts but the bluetooth connection

- In data transfer settings I set preferred service to GSM only so that it wont use GPRS for internet

- In internet profiles I removed all accounts but the bluetooth connection

As far as I remember all these steps were neccessary on my phone to prevent it to find another way to connect to the internet.

Generally you can get the internet / data profiles back by phone manufacturer ( e.g. SE ) or your mobile phone service provider when you need them again later. Probably there is even a way to store such a data profile SMS and keep it on your phone so you can choose at any time which one should be the prefered way to connect by removing / adding the data profile.

Hopefully this helps.

----------

## CosminG

I use the 0.36 versions and I can not sync with syncml

```
msynctool --discover evolution-mobilephone

ERROR: discover failed: no objtypes returned

```

I have a bug here: http://www.opensync.org/ticket/830#

----------

## Khumarahn

Hi there!

Does anybody know how we can receive files over OBEX in Gnome now? It would be cool to have a kind of GUI  :Smile: 

By now I tried to figure that out without success.

----------

