WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Problems setting up bluetooth  (Read 8020 times)

Offline Stratofortress

  • Newbie
  • *
  • Posts: 15
Problems setting up bluetooth
« on: May 04, 2009, 10:57:38 AM »
I have major problems setting up bluetooth on TC 2.x. My goal is to setup a file transfer listener on my laptop which listens for incoming file transfers from any device. Files need to be copied to a folder.

I have loaded these extensions:
- atk.tcel
- bluez_gnome.tcel
- bluez.tcel
- bt-2.6.29.1-tinycore.tcem
- cairo.tcel
- dbus_glib.tcel
- expat2.tcel
- fontconfig.tcel
- glib2.tcel
- gtk2.tcel
- libxml2.tcel
- obex.tcel
- pango.tcel
- pixman.tcel
- ttf-bitstream-vera.tce
- usb-utils.cel

I have modprobed the modules
modprobe bluetooth
modprobe btusb
modprobe l2cap
modprobe rfcomm
modprobe bnep
modprobe sco

$ sudo mkdir -p /var/lib/dbus
$ sudo dbus-uuidgen --ensure
$ sudo mkdir /var/run/dbus
$ sudo dbus-daemon --system
$ sudo mkdir /etc/dbus-1/session.d
$ sudo bluetoothd

The adapter is recognized by the command #lsusb, but the adapter isn't shown in bluez_gnome. #hcitool scan finds other BT devices.

When I want to set the discoverable mode through dbus-send I get an UnknownMethod "org.bluez.Adapter" doesn't exist.
/etc/bluetooth/hcid.conf isn't available as is hcid.

Can someone please halp me?
« Last Edit: May 04, 2009, 11:00:14 AM by Stratofortress »

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14817
Re: Problems setting up bluetooth
« Reply #1 on: May 04, 2009, 11:04:53 AM »
Once you've loaded all those extensions (or let appbrowser do it for you), you should have two bluetooth icons and several menu items for bluetooth.

One of the icons should say "bt-start" - if you click on this, it will start the dbus and bluetooth daemons. Once these have started, clicking on the other bluetooth icon "bt-pair" should bring up the bluez-gnome pairing wizard and should show any available bluetooth devices inthe vicinity.

One easy way to tell if the dbus daemon has started is to look for the file in /var/run/dbus.

If you don't see anything, re-boot your machine, load the bluetooth modules and then run "sudo /etc/init.d/bluez start" from a terminal window to look for error messages.

I used bluetooth with tinycore_2.x yesterday to transfer files backwards and forwards using emelfm without problems.

BTW - depending on how you want to do the file transfer, you might need the fuse module

Offline Stratofortress

  • Newbie
  • *
  • Posts: 15
Re: Problems setting up bluetooth
« Reply #2 on: May 04, 2009, 02:28:41 PM »
Thank you for your help Juanito. I am able to view the bluetooth devices in close vicinity in the bluez_gnome app. I do not know really what went wrong. Probably a typing error. But I still can't change the discoverable setting through dbus-send. Where can I view/change the pin/pass code? I can't pair because I do not know the pin-code.

I am getting a bit confused now. I have read some information about hciconfig and hcitools to setup a bluetooth link. Doesn't bluez use these programs? Is there a manual for setting up bluez with a OBEX file transfer protocol.

What I am trying to install is a program which is always discoverable and accepts any bluetooth filetransfer from any device without authentication (PIN/PAIRING). Just accept the transfer and move the file to a folder. Do you have any suggestions? I am getting a bit confusd here. I almost haven't got any experience with linux. Is OpenObex usable, is doesn't seem to include a OBEX daemon? :)

Also I can't load #modprobe hci_usb?

http://ftp.nluug.nl/os/Linux/distr/tinycorelinux/2.x/tce/bt-2.6.29.1-tinycore.tcem.list

hci_usb isn't available also.

--------------------------

I have build this tool, but can't poceed because I do not know pass codes. Can I just add hcid.conf?

http://oss.bdit.de/opd.html

« Last Edit: May 04, 2009, 07:14:10 PM by Stratofortress »

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14817
Re: Problems setting up bluetooth
« Reply #3 on: May 05, 2009, 12:23:04 PM »
Unfortunately, there seems to be a lot of confusion in the bluetooth documentation between bluez-3.x and bluez-4.x plus there have been a lot of changes in the move from 3.x to 4.x  - possibly the biggest change being the need to use dbus.

In 3.x it was a minor hack to set the PIN for a bluetooth device, now in 4.x I do not know how it is done - I did ask on the bluez lists and was told that it was relatively easy to write something in python... This is the reason I built the bluez-gnome extension, which seems to be using some kind of random number generation to pass a PIN via dbus to the remote device to pair.

I have not used the obex daemon available on the bluez site for file transfer - it seems to be some kind of client/server based tool? The obex extension is a combination of the openobex lib, obexftp and obexfs, but perhaps obexd might be a solution to your needs? In using obex to transfer files, I am not modifying any conf files.

Note that the hci-usb module is now depreciated in favour of the btusb module, you should not need hci-usb.

Offline Stratofortress

  • Newbie
  • *
  • Posts: 15
Re: Problems setting up bluetooth
« Reply #4 on: May 06, 2009, 11:43:23 AM »
Thanks. I have moved from Bluez-4.x to Bluez-utils-3.36 and Bluez-libs-3.36. The programs are compiled and I have made a tce which loads in /usr/local. I remeber from a DSL installation that I had a /etc/init.d/bluetooth script for restarting and starting the bluetooth programs. I can't find it in this release. Also after compiling the Bluez-utils-3.36 doesn't put out a /tmp/package/etc directory. Has this also changed in Bluez-3.xx?

My connection is up and I can setup stuff. Remarkably my /usr/local/etc/bluetooth/hcid.conf isn't read, so hciconfig is initialized as default. Quite strange.

I am now struggeling setting up the service classes for my device. hciconfig -a show "Service classes: Unspecified".



Offline Stratofortress

  • Newbie
  • *
  • Posts: 15
Re: Problems setting up bluetooth
« Reply #5 on: May 07, 2009, 05:51:55 PM »
I have got a clue why my service classes aren't viewable. I seems my BT dongle isn't recognized properly, so software can't read the classes. Adding service classes is BS, obviously. ;) This causes the pairing problem I think.

I will buy a CSR dongle tomorrow. I think this will solve many problems. :)

Offline Stratofortress

  • Newbie
  • *
  • Posts: 15
Re: Problems setting up bluetooth
« Reply #6 on: May 08, 2009, 05:54:47 AM »
bluez4: Nice, new dongle installed and new errors pop up. Failed to access HAL, pffffffff.

The hcid daemon in Bluez3 is working without error. But after a hcitool cc <bt adress of my phone> nothing happens.
« Last Edit: May 08, 2009, 08:42:15 AM by Stratofortress »

Offline Stratofortress

  • Newbie
  • *
  • Posts: 15
Re: Problems setting up bluetooth
« Reply #7 on: May 08, 2009, 11:28:41 AM »
Well, I can't get bluez-utils to pair properly. But OBEX software on top of bluez works.

Does someone have the passkey_agent binary? I can't get it to compile.

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14817
Re: Problems setting up bluetooth
« Reply #8 on: May 08, 2009, 11:32:57 AM »
Are you speaking of bluez-4.x or bluez-3.x?

I don't think passkey_agent is intended for use in 4.x (at least not in later versions)

Offline Stratofortress

  • Newbie
  • *
  • Posts: 15
Re: Problems setting up bluetooth
« Reply #9 on: May 08, 2009, 11:36:08 AM »
I am using 3.36. :)

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14817
Re: Problems setting up bluetooth
« Reply #10 on: May 08, 2009, 12:50:10 PM »
If you have a look at the bluez-utils extension I made for dsl (in the testing section) - there's a pin work-around that might be useful?

Offline Stratofortress

  • Newbie
  • *
  • Posts: 15
Re: Problems setting up bluetooth
« Reply #11 on: May 08, 2009, 02:28:23 PM »
It verks! I have compiled the passkey-agent and activated it.

Only my blackberry INSISTS on pairing before sending. My Sony ericcsson does not. Just search bluetooth device name and send stuff! Thanks for your time and effort Juanito!

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14817
Re: Problems setting up bluetooth
« Reply #12 on: May 14, 2009, 02:55:56 AM »
I didn't try it, but this modified simple-agent(?) may work with bluez-4.x, replacing 5555 with your PIN:
Code: [Select]
#!/usr/bin/python

import gobject

import sys
import dbus
import dbus.service
import dbus.mainloop.glib

class Rejected(dbus.DBu.ception):
        _dbus_error_name = "org.bluez.Error.Rejected"

class Agent(dbus.service.Object):
        exit_on_release = True

        def set_exit_on_release(self, exit_on_release):
                self.exit_on_release = exit_on_release

        @dbus.service.method("org.bluez.Agent",
                                        in_signature="", out_signature="")
        def Release(self):
                print "Release"
                if self.exit_on_release:
                        mainloop.quit()

        @dbus.service.method("org.bluez.Agent",
                                        in_signature="os", out_signature="")
        def Authorize(self, device, uuid):
                print "Authorize (%s, %s)" % (device, uuid)

        @dbus.service.method("org.bluez.Agent",
                                        in_signature="o", out_signature="s")
        def RequestPinCode(self, device):
                print "RequestPinCode (%s)" % (device)
                return "5555"

        @dbus.service.method("org.bluez.Agent",
                                        in_signature="o", out_signature="u")
        def RequestPasskey(self, device):
                print "RequestPasskey (%s)" % (device)
                passkey = raw_input("Enter passkey: ")
                return dbus.UInt32(passkey)

        @dbus.service.method("org.bluez.Agent",
                                        in_signature="ou", out_signature="")
        def DisplayPasskey(self, device, passkey):
                print "DisplayPasskey (%s, %d)" % (device, passkey)

        @dbus.service.method("org.bluez.Agent",
                                        in_signature="ou", out_signature="")
        def RequestConfirmation(self, device, passkey):
                print "RequestConfirmation (%s, %d)" % (device, passkey)
                confirm = raw_input("Confirm passkey (yes/no): ")
                if (confirm == "yes"):
                        return
                raise Rejected("Passkey doesn't match")

        @dbus.service.method("org.bluez.Agent",
                                        in_signature="s", out_signature="")
        def ConfirmModeChange(self, mode):
                print "ConfirmModeChange (%s)" % (mode)

        @dbus.service.method("org.bluez.Agent",
                                        in_signature="", out_signature="")
        def Cancel(self):
                print "Cancel"

def create_device_reply(device):
        print "New device (%s)" % (device)
        mainloop.quit()

def create_device_error(error):
        print "Creating device failed: %s" % (error)
        mainloop.quit()

if __name__ == '__main__':
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

        bus = dbus.SystemBus()
        manager = dbus.Interface(bus.get_object("org.bluez", "/"),
                                                        "org.bluez.Manager")

        if len(sys.argv) > 1:
                path = manager.FindAdapter(sys.argv[1])
        else:
                path = manager.DefaultAdapter()

        adapter = dbus.Interface(bus.get_object("org.bluez", path),
                                                        "org.bluez.Adapter")

        path = "/test/agent"
        agent = Agent(bus, path)

        mainloop = gobject.MainLoop()

        if len(sys.argv) > 2:
                if len(sys.argv) > 3:
                        device = adapter.FindDevice(sys.argv[2])
                        adapter.RemoveDevice(device)

                agent.set_exit_on_release(False)
                adapter.CreatePairedDevice(sys.argv[2], path, "DisplayYesNo",
                                        reply_handler=create_device_reply,
                                        error_handler=create_device_error)
        else:
                adapter.RegisterAgent(path, "DisplayYesNo")
                print "Agent registered"

        mainloop.run()

        #adapter.UnregisterAgent(path)
        #print "Agent unregistered"


Offline daemonjax

  • Newbie
  • *
  • Posts: 18
Re: Problems setting up bluetooth
« Reply #13 on: June 26, 2009, 11:28:16 PM »
It verks! I have compiled the passkey-agent and activated it.

Only my blackberry INSISTS on pairing before sending. My Sony ericcsson does not. Just search bluetooth device name and send stuff! Thanks for your time and effort Juanito!

When you compiled nluez 3.x, did you manage to get pand to compile?  It keeps skipping over the source dierctory for me... make is saying there's nothing to be for 'all'... I know you weren't using pand, but this relates to something I'm working on.

Thanks in advance for any advice...