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
dbern
I’m excited to announce that TaxJar has developed and open-sourced DateTimeParser. We developed it because we found a need to parse user ...
New
bryanjos
Hi, I just published version 0.23.0 of Elixirscript. https://github.com/bryanjos/elixirscript/blob/master/CHANGELOG.md Most of the chan...
New
zorbash
I created Kitto a framework for dashboards inspired by Dashing. The distributed characteristics of Elixir and the low memory footprint...
New
type1fool
WebAuthnLiveComponent WebAuthnComponents See this post about renaming the package. Passwordless authentication for Phoenix LiveView app...
New
treble37
Just looking for a little feedback on a tiny helper library I built - Sometimes I find the need to convert maps with atom keys to maps w...
New
versilov
Could not wait for the missing Elixir ML libraries to appear, so, I wrote one myself, taking https://github.com/sdwolfz/exlearn as a foun...
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
marcuslankenau
I feel kind of stuck with the absence of a proper xml library for Elixir. Currently I use SweetXML which was ok for me more or less to pa...
New
devonestes
Introducing assertions, the library that helps you write really great test assertions! GitHub: GitHub - devonestes/assertions: Helpful a...
New

Other popular topics Top

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
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
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
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement