ejpcmac

ejpcmac

I am using Bluex to communicate with a BLE device from an Elixir application. It works great on a Linux host with a Bluetooth dongle, but I have troubles to get it work on a Raspberry Pi with the same dongle.

So far, I have built a custom Nerves system, including Bluetooth support in the Kernel and bluez-utils. Using the CLI utils, I am able to scan and view my device, so the system is OK. Now, the issue is that Bluex is not finding the DBus socket. There is effectively no /run/dbus/system_bus_socket.

Is there something I can do to have the DBus socket present? As Nerves systems are really minimalistic, I assume nothing is started apart from the BEAM, so I should start DBus and bluetoothd myself, isn’t it? If you have hints on how I should do that properly, I’m all ears!

Showing Posts 1 to 9

ConnorRigby

ConnorRigby

Nerves Core Team

Great to see some bluetooth love.

You are on the right track. You will have to start dbus and bluetoothd manually as part of your supervision tree. Check out muontrap

ejpcmac

ejpcmac OP

Yes, I am writing a tiny app to test that a BLE device works properly, and Elixir is a great language to get things done quickly.

Thanks for the tip, I’ll check muontrap and see what I can do from that.

OvermindDL1

OvermindDL1

Ooo, this looks awesome, many uses for it! Deserves it’s own post!

ConnorRigby

ConnorRigby

Nerves Core Team

I believe it was announced on the forum here a while back. Its really useful for this kind of thing.

OvermindDL1

OvermindDL1

Hmm, I checked the forum via a quick search and there was no result, did a bigger google search on the site and no result, so not yet. :slight_smile:

ConnorRigby

ConnorRigby

Nerves Core Team

hm maybe i made that up then. I’ll poke Frank :slight_smile:

atoncetti

atoncetti

Hey there :wave:. I’m on the footsteps of @ejpcmac in setting up bluetooth an I’m following @ConnorRigby 's advice of using muontrap. I am stuck at creating the /run/dbus directory that dbus-daemon --system needs. I’ve tried multiple approaches:

  • Creating the directory in post-build.sh with mkdir -p /run/dbus
  • Creating the directory through rootfs_overlay
  • Creating the directory with a new config file in /etc/dbus.config with content -d /run/dbus

All of them failed in providing a /run/dbus directory at boot time.

Can someone steer me back on the right path? :grinning_face_with_smiling_eyes:
Your help is much appreciated! Thanks!

fhunleth

fhunleth

Co-author of Nerves

In your Elixir application’s start function, call File.mkdir("/run/dbus").

Here’s the longer answer:

The default Nerves configuration mounts several different filesystems. The main one, /, is read-only and contains OTP, Linux programs, and your Elixir application and all of its dependencies. You can add to that one via the rootfs_overlay. However, some directories are made writable at runtime. Anything placed in those directories at compile-time isn’t accessible at runtime and that’s what you’re running into. Examples are the /tmp, /dev, /run, and /root directories. In the case of /tmp, /dev, and /run, Nerves mounts small in-memory filesystems. They’ll lose their contents on reboots so if you’re going to create a directory in them, you need to do it each boot. This is generally desirable since if something gets messed up in them, a reboot returns you to a good state. In the case of /root, a writable filesystem is mounted there so that iex prompt history and other things survive reboots.

As a general rule of thumb, I try to avoid using the rootfs_overlay feature. Usually Linux programs have a way to tell them where their configuration files are. That lets me put the config file in a more convenient location - like in my OTP application’s priv directory and tell it to read it from there. If programs need to write data, I can redirect them some place on /data, etc. Of course, it’s nice to see things work once before moving paths around, so this might be something to consider after the dust settles.

atoncetti

atoncetti

Thanks for the great answer! That explains everything. Happy New Year, cheers!

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews