https://github.com/ztkent/pitooth
Bluetooth manager for Raspberry Pi
https://github.com/ztkent/pitooth
bluetooth go raspberry-pi
Last synced: 6 months ago
JSON representation
Bluetooth manager for Raspberry Pi
- Host: GitHub
- URL: https://github.com/ztkent/pitooth
- Owner: ztkent
- License: mit
- Created: 2024-06-23T17:08:52.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-01-12T00:51:38.000Z (about 1 year ago)
- Last Synced: 2025-09-14T06:32:15.289Z (6 months ago)
- Topics: bluetooth, go, raspberry-pi
- Language: Go
- Homepage:
- Size: 39.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PiTooth
Go Bluetooth manager for Raspberry Pi devices.
Quickly enable simple Bluetooth connectivity and file transfer capabilities.
You can import it into your projects, or use it as a standalone tool.
## Features
- Manage the bluetooth service on the Raspberry Pi.
- Accept incoming Bluetooth connections.
- Discover nearby and connected Bluetooth devices.
- Control the OBEX server to support file transfers.
## Requirements
- Any Raspberry Pi device with Bluetooth
- Enable [Bluez ObexD](https://github.com/bluez/bluez)
## Usage
### CLI
```bash
## Build the tool
cd pitooth/cmd
go build -v -o pitooth
## Accept incoming connections with a specified window:
./pitooth -alias=PiToothDevice -acceptConnections -connectionWindow=60 -log=debug
## Enable OBEX server with a path to store received files:
./pitooth -enableObex -obexPath=/path/to/obex/files
## Disable OBEX server:
./pitooth -disableObex
```
### Library
```go
import (
"log"
"time"
"github.com/ztkent/pitooth"
)
// Validate bluetooth functionality, then create a new Bluetooth Manager
btm, err := NewBluetoothManager("YourDeviceName")
if err != nil {
log.Fatalf("Failed to create Bluetooth Manager: %v", err)
}
// Become discoverable, and accept incoming connections for 30 seconds
connectedDevices, err := btm.AcceptConnections(time.Second * 30)
if err != nil {
log.Fatalf("Failed to accept connections: %v", err)
}
// Enable the obexd server, and set the file transfer directory
if err := btm.ControlOBEXServer(true, "/home/sunlight/sunlight-meter"); err != nil {
log.Fatalf("Failed to start OBEX server: %v", err)
}
// At this point, any connected devices can send files to the Raspberry Pi.
```