How to use go-ble to connect from android to linux


I’m trying to implement a BLE connection between two devices:

  • A Linux app, as the server, that must advertise services and characteristics
  • An Android smartphone, as the client, that must connect to the server and read characteristics

The issue comes from my Linux app. When I connect my smartphone to my laptop using my android app and bluetoothctl, it works like a charm. However, when I do the same with my Linux app instead of bluetoothctl, it doesn’t works (it actually does, but very rarely).

As my Linux app is written in Go, I use go-ble as the bluetooth package. I have the same issue with their minimal code sample, this is the reason I don’t write more code here, but I can’t figure out why.

I think I just don’t know how to use their library correctly, but the documentation isn’t very explicit, so if anyone could help…


On my smartphone, when using my apps, I see the laptop when scanning, so The HCI device is up. But when attempting to connect with connectGatt(), I get a 133 status code, which is GATT_ERROR.

One probable issue, is I’m not closing the connection, see this thread, but then how could it works with bluetoothctl?


Bluetoothctl is a bluetooth client working either with BLE and BR\EDR bluetooth. It was working because my android app was connecting through "Classic Bluetooth" with gattConnect.

I solved it by specifying the transport protocol to use, replacing:

device.connectGatt(context, false, gattCallback)


device.connectGatt(context, false, gattCallback, BluetoothDevice.TRANSPORT_LE)

Answered By – lfalkau

Answer Checked By – Dawn Plyler (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.