OBEX File Transfer
import { Aside, Tabs, TabItem } from ‘@astrojs/starlight/components’;
OBEX (Object Exchange) enables file transfer over Bluetooth. mcbluetooth supports four OBEX profiles:
| Profile | Code | Purpose |
|---|---|---|
| OPP | Object Push | Simple file sending |
| FTP | File Transfer | Full file browsing |
| PBAP | Phonebook Access | Read contacts (see Phonebook guide) |
| MAP | Message Access | Read SMS/MMS (see Phonebook guide) |
Prerequisites
Section titled “Prerequisites”OBEX requires the obexd daemon:
Verify installation:
bt_obex_statusIf obexd isn’t running:
bt_obex_start_daemonQuick File Send (OPP)
Section titled “Quick File Send (OPP)”The simplest way to send a file:
bt_obex_send_file address="AA:BB:CC:DD:EE:FF" file_path="~/Documents/report.pdf"- Creates a temporary OPP session
- Sends the file (recipient sees accept prompt)
- Waits for completion
- Closes the session
Non-blocking Send
Section titled “Non-blocking Send”For large files, start transfer without waiting:
bt_obex_send_file address="..." file_path="large_video.mp4" wait=falseReturns a transfer_path to monitor progress:
bt_obex_transfer_status transfer_path="/org/bluez/obex/client/session0/transfer0"Pull Business Card (OPP)
Section titled “Pull Business Card (OPP)”Get the device’s default vCard:
bt_obex_get_vcard address="AA:BB:CC:DD:EE:FF" save_path="~/contact.vcf"File Browsing (FTP)
Section titled “File Browsing (FTP)”For full file system access, create an FTP session:
Create Session
Section titled “Create Session”bt_obex_connect address="AA:BB:CC:DD:EE:FF" target="ftp"Returns:
{ "success": true, "session_id": "ftp_AABBCCDDEEFF", "address": "AA:BB:CC:DD:EE:FF", "target": "ftp"}Browse Folders
Section titled “Browse Folders”# List rootbt_obex_browse session_id="ftp_AABBCCDDEEFF" path="/"
# Navigate to folderbt_obex_browse session_id="ftp_AABBCCDDEEFF" path="DCIM"
# Go upbt_obex_browse session_id="ftp_AABBCCDDEEFF" path=".."Returns:
{ "entries": [ {"name": "DCIM", "type": "folder"}, {"name": "Download", "type": "folder"}, {"name": "document.pdf", "type": "file", "size": 102400} ]}Download Files
Section titled “Download Files”bt_obex_get session_id="ftp_..." remote_path="photo.jpg" local_path="~/Downloads/photo.jpg"Upload Files
Section titled “Upload Files”bt_obex_put session_id="ftp_..." local_path="~/document.pdf" remote_path="document.pdf"Create Folder
Section titled “Create Folder”bt_obex_mkdir session_id="ftp_..." folder_name="Backup"Delete Files
Section titled “Delete Files”bt_obex_delete session_id="ftp_..." remote_path="old_file.txt"Close Session
Section titled “Close Session”Always close when done:
bt_obex_disconnect session_id="ftp_AABBCCDDEEFF"Session Management
Section titled “Session Management”List Active Sessions
Section titled “List Active Sessions”bt_obex_sessionsCheck OBEX Status
Section titled “Check OBEX Status”bt_obex_statusReturns:
{ "status": "ready", "obexd_installed": true, "obexd_running": true, "dbus_accessible": true, "active_sessions": [...]}Transfer Monitoring
Section titled “Transfer Monitoring”Check Progress
Section titled “Check Progress”bt_obex_transfer_status transfer_path="/org/bluez/obex/client/session0/transfer0"Returns:
{ "status": "active", "size": 104857600, "transferred": 52428800, "progress_percent": 50}Cancel Transfer
Section titled “Cancel Transfer”bt_obex_transfer_cancel transfer_path="..."Common Workflows
Section titled “Common Workflows”Backup Phone Photos
Section titled “Backup Phone Photos”# Connect FTP sessionbt_obex_connect address="..." target="ftp"
# Navigate to photosbt_obex_browse session_id="ftp_..." path="/"bt_obex_browse session_id="ftp_..." path="DCIM"bt_obex_browse session_id="ftp_..." path="Camera"
# Download each photobt_obex_get session_id="ftp_..." remote_path="IMG_001.jpg" local_path="~/backup/"bt_obex_get session_id="ftp_..." remote_path="IMG_002.jpg" local_path="~/backup/"
# Close sessionbt_obex_disconnect session_id="ftp_..."Share Document
Section titled “Share Document”# Simple sendbt_obex_send_file address="..." file_path="~/report.pdf"Device Compatibility
Section titled “Device Compatibility”| Device Type | OPP | FTP |
|---|---|---|
| Android phones | ✓ | Varies |
| iPhones | ✓ | ✗ |
| Feature phones | ✓ | ✓ |
| Windows PCs | ✓ | ✓ |
| macOS | ✓ | ✗ |
Troubleshooting
Section titled “Troubleshooting””Device rejected connection”
Section titled “”Device rejected connection””- Ensure device is paired first
- Check device has OBEX enabled in Bluetooth settings
- Some devices require explicit file sharing permission
”NotSupported”
Section titled “”NotSupported””The device doesn’t support the requested profile. Try OPP instead of FTP.
Transfer Stuck at 0%
Section titled “Transfer Stuck at 0%”The receiving device may be showing an accept prompt. Check its screen.
Session Disappeared
Section titled “Session Disappeared”Sessions are tied to obexd. If it restarts, create a new session.