bbangert

bbangert

bluez - bluez over d-bus library

I’ve been working on some Elixir based projects for awhile now, slowly spinning out libraries from the project as they stabilize some and thought this one might be useful for the community. My project is Nerves based and needed bluetooth support, so I originally tried blue_heron, then evaluated whether Bluex had the support I needed, but eventually ended up building this out with claude.

Features

  • One supervisor that brings up dbus-daemon, bluetoothd -E, and (optionally) bluealsad, with crash-isolation and restart ordering (:rest_for_one) already worked out — an audio fault never restarts scanning, a bus restart rebuilds everything above it.
  • Passive and active BLE scanning, runtime-switchable. Passive mode uses BlueZ’s AdvertisementMonitor1 (no scan requests — peripherals don’t burn battery answering); active mode collects SCAN_RSP data.
  • Advertisement reconstruction — BlueZ only exposes parsed properties; they’re re-serialized into AD byte structures, emit-gated (first sighting / payload change / RSSI heartbeat) and LRU-capped, then fanned out through your on_advertisement: fun.
  • Handle-keyed GATT client — connect / service discovery / read / write / notify / pair / unpair / clear-cache, with a documented, host-agnostic event contract delivered through your on_gatt_event: function. Generation-stamped so late replies can’t corrupt replaced connections.
  • Pairing agent that authorizes exactly the pairings your code initiated.
  • bluez-alsa integration (optional) — enumerates ready-to-open A2DP playback PCMs and signals your app when the set changes.
  • No host coupling — configuration flows exclusively through start_link/1 opts (functions, a PubSub, child specs); no Application.get_env, no callbacks into named host modules.

While this library is built for Nerves, it should work on a normal linux host. The passive scanning required some additional changes to the rebus library that I’ve opened a PR to upstream, the current 0.1 release of bluez vendors it in. This passive scanning mode is extremely efficient which was the primary reason I went with this approach.

I’ve been using this in deployed code for weeks now where its been very stable, the early version is mainly to reflect that it might still need changes.

For this project I’ve mainly been building out features with the Elixir Phoenix plugin for claude code, with manual and AI reviews as well as frequent audits to try and prevent any AI sloppiness from manifesting. :crossed_fingers:

Most Liked

quatermain

quatermain

Hi, creator of that plugin for Elixir/Phoenix development with Agents here. Thanks for using it and mentioning it here. Happy to see users of it. Fyi if you want help to contribute to plugin and even improve experience with Nerves and others, there is way how you (we) can retrospectively analyze your sessions and generate improvements for plugin or new skills at all. Whole framework is (hidden) inside the plugin.

Where Next?

Popular in Announcing Top

wmnnd
Hi there, for my project DBLSQD, I needed a file storage solution that is a bit more flexible than Arc. Because I thought others might f...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 43487 311
New
mischov
import Meeseeks.CSS html = HTTPoison.get!("https://news.ycombinator.com/").body for story <- Meeseeks.all(html, css("tr.athing")) do...
New
josevalim
Yes, yet another parser combinator library! Most of the parser combinators in the ecosystem are either compile-time, often using AST tra...
159 19417 141
New
riverrun
I’ve just released version 3 of Comeonin, a password hashing library. The following small changes have been made: changes to the NIF c...
New
blatyo
The best overview for how things are tied together is this presentation. Modules and functions are pretty well documented at this point, ...
New
mbuhot
Leverage Open Api 3.0 (Swagger) to document, test, validate and explore your Plug and Phoenix APIs. Generate and serve a JSON Open API ...
New
RobertDober
Earmark is a pure-Elixir Markdown converter. It is intended to be used as a library (just call Earmark.as_html), but can also be used as...
239 12645 134
New
aditya7iyengar
Rummage.Ecto and Rummage.Phoenix provide ways to perform Searching, Sorting and Pagination over Ecto queries and Phoenix collections. Fo...
New
josevalim
Hello everyone, We have just released NimbleCSV which is a small and fast CSV parsing library for Elixir. It allows developers to define...
New

Other popular topics Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement