Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/Ztkent/pi-bluetooth

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/Ztkent/pi-bluetooth

  • v0.1.1
  • Source
  • Go
  • Socket score

Version published
Created
Source

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
  • Go 1.21 or later

To initally setup the Raspberry Pi, you can follow the steps below:

## Setup Golang
wget https://go.dev/dl/go1.21.11.linux-armv6l.tar.gz
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.21.11.linux-armv6l.tar.gz && rm go1.21.11.linux-armv6l.tar.gz
echo "export PATH=\$PATH:/usr/local/go/bin" >> ~/.bashrc

## Add obexd
sudo apt install bluez-obexd
echo 'export PATH=$PATH:/usr/libexec/bluetooth/' >> ~/.bashrc
source ~/.bashrc

## [iwgetid]
echo 'export PATH=$PATH:/usr/sbin' >> ~/.bashrc 
source ~/.bashrc

Usage

As a tool

## 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

As a library

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.

FAQs

Package last updated on 24 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc