OpenWrt Forum Archive

Topic: Connecting to NSLU with openwrt using bluetooth

The content of this topic has been archived on 18 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I've been using this previously but I never made notes about it so on every new release of openwrt, I had to do it again.  I decided to take some time to write some stuff down, so I hope this will help some people who tries to do the same.
My goal is to be able to use my local network to connect my Sony Ericsson K660i to the internet using bluetooth NAP.  My bluetooth stick is on a Linksys NSLU with openwrt 10.03.

First I had to install the needed packages:

opkg install bluez-utils  kmod-bluetooth kmod-usb-ohci dbus-utils

Second there are some changes which has to be made to hcid.conf.  Mine currently looks like this:

#
# HCI daemon configuration file.
#

# HCId options
options {
    # Automatically initialize new devices
    autoinit yes;

    # Security Manager mode
    #   none - Security manager disabled
    #   auto - Use local PIN for incoming connections
    #   user - Always ask user for a PIN
    #
    security auto;

    # Pairing mode
    #   none  - Pairing disabled
    #   multi - Allow pairing with already paired devices
    #   once  - Pair once and deny successive attempts
    pairing multi;

    # Default PIN code for incoming connections
    # passkey "BlueZ";
    passkey "0000";
}

# Default settings for HCI devices
device {
    # Local device name
    #   %d - device id
    #   %h - host name
    name "%h";

    # Local device class
    class 0x020100;

    # Default packet type
    #pkt_type DH1,DM1,HV1;

    # Inquiry and Page scan
    iscan enable; pscan enable;

    # Default link mode
    #   none   - no specific policy 
    #   accept - always accept incoming connections
    #   master - become master on incoming connections,
    #            deny role switch on outgoing connections
    lm accept, master;

    # Default link policy
    #   none    - no specific policy
    #   rswitch - allow role switch
    #   hold    - allow hold mode
    #   sniff   - allow sniff mode
    #   park    - allow park mode
    lp rswitch,hold,sniff,park;
    
}

You need to enable dbus and bluetooth:

/etc/init.d/dbus enable
/etc/init.d/bluez-utils enable

I just add the new bnep interface to the br-lan.  To do this I created /etc/hotplug.d/net/20-bt with the next context:

case "$INTERFACE" in
    bnep*) ;;
    *) return 0;;
esac

case "$ACTION" in
    add|register)
        ifconfig $INTERFACE up
        brctl addif br-lan $INTERFACE
    ;;
    remove|unregister)
        brctl delif br-lan $INTERFACE
        ifconfig $INTERFACE down
    ;;
esac

At this point, you should be able to connect your mobile phone.  I used dbus and the info on http://wiki.bluez.org/wiki/FAQ was usefull:

dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez/hci0 org.bluez.Adapter.SetMode string:discoverable
dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez/hci0 org.bluez.Adapter.SetDiscoverableTimeout uint32:60

The first comment makes the NSLU discoverable, the next one sets the timeout to 60 seconds. If everything works as it should, you should now have a bnep0 added to your br-lan.

I hope this can help someone.

(Last edited by wimpunk on 10 May 2010, 15:32)

very good ,thx.

but , in my backfire  10.3 ,there is no "/etc/init.d/bluetooth", how can i enable it ?

by the way, i always get the message: "Can't create socket: Protocol not supported", whe i
exec l2ping command.

Sorry, I made a mistake.  It has to be "/etc/init.d/bluez-utils".  I corrected it in the post.
I never used the l2ping command, so I really have no idea what goes wrong.

(Last edited by wimpunk on 10 May 2010, 15:32)

longdanie,

If you look in dmesg are there any errors related to loading the bluetooth modules?

Paul

did everything as you said ....... on the phone after typing the pass key it connects and ten disconnects

drekthar: I think you are missing a dhcp server to provide an IP to your phone.  When writing the post, I had an linksys WRT as dhcp server and an NSLU to provide bluetooth access.
I've seen some problems with phones which even didn't accepted the IP addres provided and want to push their own IP.

wimpunk wrote:

drekthar: I think you are missing a dhcp server to provide an IP to your phone.  When writing the post, I had an linksys WRT as dhcp server and an NSLU to provide bluetooth access.
I've seen some problems with phones which even didn't accepted the IP addres provided and want to push their own IP.

first of thanks for your reply .... i am trying to connect my sony erisson phone to a x86 router with a bluetooth dongle in order to use internet via bluetooth i have dhcp running already on the lan ports already ....

i have no clue how to run it on the the bluetooth so far i have no interface that comes up related to bluetooth when i scan with my mobile i am able to find the router on authenticating with passkey it says connected for a short time and then disconnects rapidly .....

and help would be very appreciated

ps i still don't quite understand the process involved will a interface be created if a phone succesfully connects to the router and start a dhcp server.....

The discussion might have continued from here.