Go Bluetooth

The USB BLE adapter for Go

Dongl is a USB Bluetooth Low Energy adapter you drive from Go with SimpleGoBLE. Scan, connect, and pair through its own radio on Windows, macOS, and Linux, with no cgo and no C compiler.

Kober Engineering
InsuLearn
Meta
Fender
Honeywell
Bionic Labs
Sona
SWT
Moon Smart Focus
Lewitt
Medra
Desko
g.tec
IXI
Innovision
Moonlighting Industries
Kober Engineering
InsuLearn
Meta
Fender
Honeywell
Bionic Labs
Sona
SWT
Moon Smart Focus
Lewitt
Medra
Desko
g.tec
IXI
Innovision
Moonlighting Industries
Kober Engineering
InsuLearn
Meta
Fender
Honeywell
Bionic Labs
Sona
SWT
Moon Smart Focus
Lewitt
Medra
Desko
g.tec
IXI
Innovision
Moonlighting Industries
Get started

Set up in three steps

  1. Get an adapter

    Pre-order a Dongl, or flash the free Dongl firmware onto a Nordic nRF52840 Dongle or DK you already own.

  2. Install SimpleGoBLE

    Run go get github.com/simpleble/simplegoble.

  3. Select the adapter

    A plugged-in Dongl appears as its own adapter, next to the computer's Bluetooth. Take the adapters of the Dongl backend and your code runs on the Dongl.

Select the Dongl, then scan, connect, and read. This is the code for each step.

import ble "github.com/simpleble/simplegoble"

dongl, err := ble.GetDonglBackend()
if err != nil {
    return err
}
defer dongl.Close()
adapters, err := dongl.Adapters() // Close each adapter when finished.
if err != nil {
    return err
}
if len(adapters) == 0 {
    return errors.New("no Dongl found")
}

adapter := adapters[0]
name, _ := adapter.Identifier()
address, _ := adapter.Address()
fmt.Println(name, address)
In Go today

What Go uses today

Go's BLE packages reach a second adapter on Linux. On Windows and macOS, they use the computer's default radio.

TinyGo Bluetooth

On Linux, NewAdapter selects a BlueZ adapter such as hci1. On Windows and macOS, only the default adapter is available, and selecting a secondary one is an open issue.

go-ble

go-ble selects an HCI device by number on Linux. Its README notes that the macOS portion is not actively maintained, and it does not run on Windows.

go-bluetooth

go-bluetooth wrapped BlueZ over D-Bus on Linux. Its repository is archived.

Why Dongl

What a Dongl gives your Go code

Builds

No cgo, no C compiler

go get and go build. The native library comes with the module, and Dongl support with it.

Adapters

One goroutine per Dongl

Each Dongl is another adapter with its own radio. Drive each from its own goroutine to test devices in parallel.

Addresses

Real addresses on macOS

Scans report each device's real address, so a Mac test station matches devices by the address on their label.

Pairing

Pairing from your Go code

Your code answers passkey and numeric-comparison prompts, with no system dialog. Bonds stay on the Dongl.

Platforms

Windows, macOS, and Linux

The same Go program drives a Dongl on all three desktops, and in a Docker container on Linux.

Support

A direct line to the engineers

Commercial customers work directly with the team that builds SimpleBLE and the Dongl firmware.

Plug in a Dongl and run your Go code

Dongl hardware ships with the firmware installed and includes a commercial license to use SimpleBLE through the Dongl backend.

Frequently
asked questions

Plug in a Dongl, add SimpleGoBLE with go get, and take the adapters of the Dongl backend with ble.GetDonglBackend(). Each Dongl is an adapter with its own radio, and it works through the same API as the computer's Bluetooth.

No. SimpleGoBLE carries the native SimpleBLE library for each platform and loads it without cgo, so no C compiler is needed to build your program.

Yes. Each Dongl is a separate adapter with its own address, stable across restarts and USB ports. Drive each one from its own goroutine to scan, connect, and read in parallel.

On Linux, yes. The Dongl needs only a USB port, so it works without BlueZ running, such as inside a Docker container with the Dongl passed through.

No. The free Dongl firmware runs on a Nordic nRF52840 Dongle or DK for prototyping, testing, and non-commercial validation. Dongl hardware ships with the firmware installed and includes a commercial license to use SimpleBLE through the Dongl backend.

SimpleBLE is source-available under the Business Source License 1.1 and free for non-commercial use. Evaluation needs no license. Commercial use needs a license, and one agreement covers your whole company, with no per-seat, per-device, or royalty fees. Each Dongl hardware unit includes a commercial license to use SimpleBLE through the Dongl backend.