Sending Bluetooth Advertising Packets and Getting Some Answers

Viewed 373

I want to build something with Raspberry Pi Zero and write in Go,

I never tried bluetooth before and my goal is; Sending a dynamic packet which it will change every second, an iOS app will expand this message and with a button, client will send a message back without a connection.

Is Bluetooth Advertising what I am looking for and do you know any GoLang library for it? Where should I start?

1 Answers

There are quite a lot of parts to your question. If you want to be connection-less then the BLE roles are Broadcaster (beacon) and Observer (scanner). There are a number of "standard" beacon formats out there. They are summarized nicely on this cheat sheet

Of course you can create your own format as these are using either the Service Data or Manufacturing Data in a BLE advertisement.

On Linux (Raspberry Pi) the official Bluetooth stack is BlueZ which documents the API's available at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc

If you want to be connection-less then each device is going to have to change it's role regularly. This requires a bit of careful thought on how long each is listening and broadcasting as you don't want them always talking at the same time and listening at the same time.

You might find the following article of interest to get you started with BLE and Go Lang: https://towardsdatascience.com/spelunking-bluetooth-le-with-go-c2cff65a7aca

Related