Linux Bluetooth Obex

From Variscite Wiki
Revision as of 15:30, 9 February 2017 by Admin (talk | contribs)
Bluetooth File Transfer

Pairing with Bluetooth device

Before sending files bluetooth devices should be paired. You can manage bluetooth with bluetoothctl, type 'bluetoothctl' and enter the CLI. Type help to show commands.
For pairing a device do the following:

$ bluetoothctl
[bluetooth]# power on
[bluetooth]# agent on
[bluetooth]# default-agent
[bluetooth]# pairable on
[bluetooth]# scan on

Copy mac address

[bluetooth]# scan off
[bluetooth]# pair <mac address>

Approve pairing on Device if required

[bluetooth]# trust <mac address>
[bluetooth]# quit

Sending files using OBEX Protocol

To send a file to a paired device use obexctl tool.

root@imx6ul-var-dart:~# obexctl 
[NEW] Client /org/bluez/obex 
[obex]# connect 00:1A:7D:DA:71:0B
Attempting to connect to 00:1A:7D:DA:71:0B
[NEW] Session /org/bluez/obex/client/session0 [default]
[NEW] ObjectPush /org/bluez/obex/client/session0 
Connection successful
[00:1A:7D:DA:71:0B]# send /etc/fstab
Attempting to send /etc/fstab to /org/bluez/obex/client/session0
[NEW] Transfer /org/bluez/obex/client/session0/transfer0 
Transfer /org/bluez/obex/client/session0/transfer0
        Status: queued
        Name: fstab
        Size: 637
        Filename: /etc/fstab
        Session: /org/bluez/obex/client/session0
[CHG] Transfer /org/bluez/obex/client/session0/transfer0 Status: complete
[DEL] Transfer /org/bluez/obex/client/session0/transfer0 

Receiving files using OBEX Protocol

No special action is required to receive a file that was sent from a paired device. The file will be stored under /tmp/bluetooth-inbox.