Bluetooth File Transfer
Pairing with Bluetooth device
To send files to each other two bluetooth devices should be paired first. Use bluetoothctl tool to manage the pairing
# bluetoothctl [bluetooth]# power on [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
For example when pairing with a PC the following is done:
# bluetoothctl [NEW] Controller 96:93:E0:47:39:89 Variscite [default] [bluetooth]# power on [CHG] Controller 96:93:E0:47:39:89 Class: 0x300100 Changing power on succeeded [CHG] Controller 96:93:E0:47:39:89 Powered: yes [bluetooth]# pairable on Changing pairable on succeeded [bluetooth]# scan on Discovery started [CHG] Controller 96:93:E0:47:39:89 Discovering: yes [bluetooth]# random: nonblocking pool is initialized [NEW] Device B8:6C:E8:60:C0:8F Galaxy S5 [NEW] Device 00:1A:7D:DA:71:0B Ubuntu-PC [bluetooth]# scan off [CHG] Device 38:BC:1A:20:14:5D RSSI is nil [CHG] Device 00:1A:7D:DA:71:0B RSSI is nil [CHG] Device B8:6C:E8:60:C0:8F RSSI is nil [CHG] Controller 96:93:E0:47:39:89 Discovering: no Discovery stopped [bluetooth]# pair 00:1A:7D:DA:71:0B Attempting to pair with 00:1A:7D:DA:71:0B [CHG] Device 00:1A:7D:DA:71:0B Connected: yes [CHG] Device 00:1A:7D:DA:71:0B UUIDs: 00001104-0000-1000-8000-00805f9b34fb [CHG] Device 00:1A:7D:DA:71:0B UUIDs: 00001105-0000-1000-8000-00805f9b34fb [CHG] Device 00:1A:7D:DA:71:0B UUIDs: 00001106-0000-1000-8000-00805f9b34fb [CHG] Device 00:1A:7D:DA:71:0B UUIDs: 0000110a-0000-1000-8000-00805f9b34fb [CHG] Device 00:1A:7D:DA:71:0B UUIDs: 0000110b-0000-1000-8000-00805f9b34fb [CHG] Device 00:1A:7D:DA:71:0B UUIDs: 0000110c-0000-1000-8000-00805f9b34fb [CHG] Device 00:1A:7D:DA:71:0B UUIDs: 0000110e-0000-1000-8000-00805f9b34fb [CHG] Device 00:1A:7D:DA:71:0B UUIDs: 00001112-0000-1000-8000-00805f9b34fb [CHG] Device 00:1A:7D:DA:71:0B UUIDs: 0000112f-0000-1000-8000-00805f9b34fb [CHG] Device 00:1A:7D:DA:71:0B UUIDs: 00001132-0000-1000-8000-00805f9b34fb [CHG] Device 00:1A:7D:DA:71:0B UUIDs: 00001133-0000-1000-8000-00805f9b34fb [CHG] Device 00:1A:7D:DA:71:0B UUIDs: 00001200-0000-1000-8000-00805f9b34fb [CHG] Device 00:1A:7D:DA:71:0B UUIDs: 00001800-0000-1000-8000-00805f9b34fb [CHG] Device 00:1A:7D:DA:71:0B UUIDs: 00001801-0000-1000-8000-00805f9b34fb [CHG] Device 00:1A:7D:DA:71:0B UUIDs: 00005005-0000-1000-8000-0002ee000001 [CHG] Device 00:1A:7D:DA:71:0B Paired: yes Pairing successful [CHG] Device 00:1A:7D:DA:71:0B Connected: no [bluetooth]# trust 00:1A:7D:DA:71:0B [CHG] Device 00:1A:7D:DA:71:0B Trusted: yes Changing 00:1A:7D:DA:71:0B trust succeeded [bluetooth]# quit [DEL] Controller 96:93:E0:47:39:89 Variscite [default] #
Sending files using OBEX Protocol
To send a file to a paired device use obexctl tool.
# DBUS_SESSION_BUS_ADDRESS=unix:path=/var/run/dbus/system_bus_socket obexctl [obex]# connect <mac address> [obex]# send <file> [obex]# quit
Please when running send command remember to provide absolute path
For example, to send /etc/fstab file to a paired PC from the example above:
# DBUS_SESSION_BUS_ADDRESS=unix:path=/var/run/dbus/system_bus_socket 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.