Bluetooth and headless Linux

January 11th, 2009 | by RoarinPenguin |

Ever wondered how to connect your linux box via bluetooth, for instance to allow file transfer with your phone?

I found some cool and working hints on the Net, reporting here below what worked for me.

  1. Connect your USB dongle
  2. Install what you need:
    apt-get install obexftp bluetooth
  3. Then you need to set the system to use a predefined PIN, since you have no console and very probably you would like to digit only from phone side to connect with this box.
    To do this, you need to edit file /etc/bluetooth/hcid.conf to change the following defaults:
    # Security Manager mode
    #   none – Security manager disabled
    #   auto – Use local PIN for incoming connections
    #   user – Always ask user for a PIN
    #
    security auto; <== this is set by default to user

    and
            # Default PIN code for incoming connections
            passkey "58336342"; <== this is set by default to 1234, not enough secure IMHO…

Now, back to cellular connections:

  1. Scan for cellular address:
    hcitool scan
    this will return the address of your device, like:
    magicbox:~# hcitool scan
    Scanning …
            00:17:E4:82:F4:64       RoarinPenguin
  2. Now we need to search the channel for file tranfers
    magicbox:~# sdptool browse 00:17:E4:82:F4:64      
    This will return all details about services provided by the phone:
    magicbox:~# sdptool browse 00:17:E4:82:F4:64
    Browsing 00:17:E4:82:F4:64 …
    Service Name: AVRCP Target
    Service Description: Audio Video Remote Control
    Service Provider: Symbian Software Ltd.
    Service RecHandle: 0×10000
    Service Class ID List:
      "AV Remote Target" (0×110c)
    Protocol Descriptor List:
      "L2CAP" (0×0100)
        PSM: 23
      "AVCTP" (0×0017)
        uint16: 0×100
    Profile Descriptor List:
      "AV Remote" (0×110e)
        Version: 0×0100
  3. Service RecHandle: 0×10001
    Protocol Descriptor List:
      "L2CAP" (0×0100)
      "RFCOMM" (0×0003)
        Channel: 1

    Service Name: Dial-Up Networking
    Service RecHandle: 0×10002
    Service Class ID List:
      "Dialup Networking" (0×1103)
    Protocol Descriptor List:
      "L2CAP" (0×0100)
      "RFCOMM" (0×0003)
        Channel: 2
    Language Base Attr List:
      code_ISO639: 0×454e
      encoding:    0×6a
      base_offset: 0×100
    Profile Descriptor List:
      "Dialup Networking" (0×1103)
        Version: 0×0100

    Service Name: OBEX Object Push
    Service RecHandle: 0×10003
    Service Class ID List:
      "OBEX Object Push" (0×1105)
    Protocol Descriptor List:
      "L2CAP" (0×0100)
      "RFCOMM" (0×0003)
        Channel: 9
      "OBEX" (0×0008)
    Language Base Attr List:
      code_ISO639: 0×454e
      encoding:    0×6a
      base_offset: 0×100
    Profile Descriptor List:
      "OBEX Object Push" (0×1105)
        Version: 0×0100

    Service Name: Hands-Free Audio Gateway
    Service RecHandle: 0×10004
    Service Class ID List:
      "Handfree Audio Gateway" (0×111f)
      "Generic Audio" (0×1203)
    Protocol Descriptor List:
      "L2CAP" (0×0100)
      "RFCOMM" (0×0003)
        Channel: 28
    Language Base Attr List:
      code_ISO639: 0×454e
      encoding:    0×6a
      base_offset: 0×100
    Profile Descriptor List:
      "Handfree Audio Gateway" (0×111f)
        Version: 0×0101

    Service Name: Headset Audio Gateway
    Service RecHandle: 0×10005
    Service Class ID List:
      "Headset Audio Gateway" (0×1112)
      "Generic Audio" (0×1203)
    Protocol Descriptor List:
      "L2CAP" (0×0100)
      "RFCOMM" (0×0003)
        Channel: 29
    Language Base Attr List:
      code_ISO639: 0×454e
      encoding:    0×6a
      base_offset: 0×100
    Profile Descriptor List:
      "Headset" (0×1108)
        Version: 0×0100

    Service Name: Imaging
    Service RecHandle: 0×10006
    Service Class ID List:
      "Imaging Responder" (0×111b)
    Protocol Descriptor List:
      "L2CAP" (0×0100)
      "RFCOMM" (0×0003)
        Channel: 15
      "OBEX" (0×0008)
    Language Base Attr List:
      code_ISO639: 0×454e
      encoding:    0×6a
      base_offset: 0×100
    Profile Descriptor List:
      "Imaging" (0×111a)
        Version: 0×0100

    Service Name: SyncMLClient
    Service RecHandle: 0×10007
    Service Class ID List:
      UUID 128: 00000002-0000-1000-8000-0002ee000002
    Protocol Descriptor List:
      "L2CAP" (0×0100)
      "RFCOMM" (0×0003)
        Channel: 10
      "OBEX" (0×0008)
    Language Base Attr List:
      code_ISO639: 0×454e
      encoding:    0×6a
      base_offset: 0×100
    Profile Descriptor List:
      "" (0×00000002-0000-1000-8000-0002ee000002)
        Version: 0×0100

    Service Name: OBEX File Transfer
    Service RecHandle: 0×10008
    Service Class ID List:
      "OBEX File Transfer" (0×1106)
    Protocol Descriptor List:
      "L2CAP" (0×0100)
      "RFCOMM" (0×0003)
        Channel: 11
      "OBEX" (0×0008)
    Language Base Attr List:
      code_ISO639: 0×454e
      encoding:    0×6a
      base_offset: 0×100
    Profile Descriptor List:
      "OBEX File Transfer" (0×1106)
        Version: 0×0100

    Service Name: Nokia OBEX PC Suite Services
    Service RecHandle: 0×10009
    Service Class ID List:
      UUID 128: 00005005-0000-1000-8000-0002ee000001
    Protocol Descriptor List:
      "L2CAP" (0×0100)
      "RFCOMM" (0×0003)
        Channel: 12
      "OBEX" (0×0008)
    Language Base Attr List:
      code_ISO639: 0×454e
      encoding:    0×6a
      base_offset: 0×100
    Profile Descriptor List:
      "" (0×00005005-0000-1000-8000-0002ee000001)
        Version: 0×0100

    Service Name: SyncML DM Client
    Service RecHandle: 0×1000a
    Service Class ID List:
      UUID 128: 00000004-0000-1000-8000-0002ee000002
    Protocol Descriptor List:
      "L2CAP" (0×0100)
      "RFCOMM" (0×0003)
        Channel: 13
      "OBEX" (0×0008)
    Language Base Attr List:
      code_ISO639: 0×454e
      encoding:    0×6a
      base_offset: 0×100
    Profile Descriptor List:
      "" (0×00000004-0000-1000-8000-0002ee000002)
        Version: 0×0100

    Service Name: Nokia SyncML Server
    Service RecHandle: 0×1000b
    Service Class ID List:
      UUID 128: 00005601-0000-1000-8000-0002ee000001
    Protocol Descriptor List:
      "L2CAP" (0×0100)
      "RFCOMM" (0×0003)
        Channel: 14
      "OBEX" (0×0008)
    Language Base Attr List:
      code_ISO639: 0×454e
      encoding:    0×6a
      base_offset: 0×100
    Profile Descriptor List:
      "" (0×00005601-0000-1000-8000-0002ee000001)
        Version: 0×0100

  4. The interesting channel for us is Obex File Transfer, thus 11. Let’s browse what telefone has to offer:

    obexftp -b  00:17:E4:82:F4:64 -c / -l

    This command will access the cellular of the given address the "/" (root) directory and will list its contents

Now, once could ask how to send files to the mentioned box. Well, so far I have discovered how to “pull” them from the box from the phone using obexftp command as follows:

obexftp -b 00:17:E4:82:F4:64 -c /<path_on_the_phone> -g picture1.jpg

There should be another way to put the box in listening mode through rfcomm command, but that’s food for another article ;) since I have first to read and “digest” articles like this one


Email this post Email this post

Post a Comment