ImNotAVirus

ImNotAVirus

For my first Nerves project, I would like to create a Phoenix application that would be available only via Bluetooth Personal Area Network (PAN).

I’ve never done this before, but from what I could understand it would be feasible.

During my researches, I came across this stackoverflow post explaining in detail how to setup a Bluetooth PAN on Raspbian.

So I tried to reproduce the steps for Nerves :

  • First, I created a new system based on nerves_system_rpi3
  • On this system I installed bluez-tools and bluez-utils packages
  • I’ve also activated the Bluetooth subsystem support in make linux-menuconfig → Networking Support

Once the firmware burn on my SD card and the Raspberry started, I executed the following commands :

# Run D-Bus & Bluetoothd daemons
mkdir -p /var/run/dbus
/usr/bin/dbus-daemon --system
/usr/libexec/bluetooth/bluetoothd &

# Create PAN interface
ip link add pan0 type bridge

# Configure interface
ifconfig pan0 192.168.50.1 netmask 255.255.255.0 up

Until then, no problem.
But when I tried to execute bt-agent -c NoInputNoOutput or bt-network -s nap pan0, I got the following error:

bt-agent: bluez service is not found
Did you forget to run bluetoothd?

However, when I display the list of processes, I can see bluetoothd running.

I would like to know if anyone has ever had this problem or if anyone has ever succeeded in setting up a Bluetooth PAN.

Thanks in advance.

Showing Posts 1 to 8

fhunleth

fhunleth

Co-author of Nerves

You’re following the steps that I’d take if I were doing this. As a sanity check, does this work on Raspbian? And I wonder if dmesg shows any errors?

Also, not that this is a bad thing, but this is an ambitious first project. I think that you’ll be the first person to get Bluetooth PANs working with Nerves, so I’m very curious to hear your progress.

ImNotAVirus

ImNotAVirus OP

First of all, thank you for your answer.

I just tried this afternoon on Raspbian and I was able to setup a working PAN.
For dmesg, there is no error.

I like to have ambitious projects when I try out a technology. It allows me to really try to understand how it works, especially when I’m trying to do something and there is little documentation on the topic ^^

I will try again and I will update this post if I manage to get the NAP working on Nerves.

ImNotAVirus

ImNotAVirus OP

Small progress: After several hours of debugging, it seems that the problem comes from bluetoothd.

When I run it on Raspbian with debug mode (bluetoothd -nd) it finds my Bluetooth controller:

bluetoothd[1249]: src/adapter.c:read_index_list_complete() Number of controllers: 1

but he doesn’t find it on Nerves:

bluetoothd[279]: src/adapter.c:read_index_list_complete() Number of controllers: 0

So I tried to attach it manually by following the documentation on the Alpine website with

btattach -B /dev/ttyAMA0 -P bcm -S 115200 -N &

But I now have the following errors (dmesg):

[  139.810619] Bluetooth: Core ver 2.22
[  139.823002] NET: Registered protocol family 31
[  139.835931] Bluetooth: HCI device and connection manager initialized
[  139.851048] Bluetooth: HCI socket layer initialized
[  139.864618] Bluetooth: L2CAP socket layer initialized
[  139.878279] Bluetooth: SCO socket layer initialized
[  226.396734] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[  226.410839] Bluetooth: BNEP socket layer initialized
[  724.174859] Bluetooth: HCI UART driver ver 2.3
[  724.187883] Bluetooth: HCI UART protocol H4 registered
[  724.201545] Bluetooth: HCI UART protocol BCSP registered
[  724.215564] Bluetooth: HCI UART protocol Broadcom registered
---> [  726.312378] Bluetooth: hci0: command 0x0c03 tx timeout
---> [  734.552396] Bluetooth: hci0: BCM: Reset failed (-110)
outlog

outlog

think you need to comment out dtoverlay=pi3-miniuart-bt in config.txt

can’t really grasp it all - but believe that overlay moves BT to tttyS0 aka the mini-uart, so it’s not on ttyAMA0 - see https://github.com/raspberrypi/documentation/blob/master/configuration/uart.md

ImNotAVirus

ImNotAVirus OP

Thanks! You were right! My controller is now properly detected.

Unfortunately, I always get the same errors when I run bt-agent -c NoInputNoOutput and bt-network -s nap pan0:

(bt-agent:361): GLib-CRITICAL **: 22:56:40.140: PCRE library is compiled without UTF8 support   
(bt-agent:361): GLib-CRITICAL **: 22:56:40.140: PCRE library is compiled without UTF8 properties support
bt-agent: bluez service is not found
Did you forget to run bluetoothd?

It seems that bluetoothd wants to write to /var/lib/bluetooth but it can’t (read-only partition):

bluetoothd[333]: Unable to open adapter storage directory: /var/lib/bluetooth/XX:XX:XX:XX:XX:XX

I’ll keep digging.

GregMefford

GregMefford

Great work figuring that out so far! :rocket:

It’s been a while since I’ve done it, but I believe if you want to make that directory be writable, you can either configure the application to write to somewhere that is writable, mount a writable partition there, or use a symlink to redirect that directory to a place that is writable.

Advanced Configuration — nerves v1.14.3

I thought we used to have an example of doing that e.g. for making the /etc/resolv.conf file and friends be writable, but I’m having trouble finding a link to that now. Maybe someone else knows what I’m talking about and/or can fill in the gap.

ImNotAVirus

ImNotAVirus OP

Thanks for your help!

I think I’ll create a symlink to /tmp/bluetooth because I don’t think it’s necessary to make this folder persistent.

Currently I don’t really understand how to do it and I would be happy to have some documentation on the subject or a code to study.

ImNotAVirus

ImNotAVirus OP

Small progress: I added a symbolic link from /var/lib/bluetooth to /tmp/bluetooth (via rootfs_overlay) but I still have the same error.

(bt-agent:363): GLib-CRITICAL **: 13:30:51.254: PCRE library is compiled without UTF8          
(bt-agent:363): GLib-CRITICAL **: 13:30:51.255: PCRE library is compiled without UTF8 properties support
bt-agent: bluez service is not found
Did you forget to run bluetoothd?

Now I don’t understand what the problem is since I don’t have any error anymore (neither from dmesg nor from bluetoothd).

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
water
I’m aware of 2 such projects, are there others? git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
peck
Hi everyone. My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
bradley
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
unaware8150
Hello folks! So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
Alvinkariuki
How Can I Optimise Compile Time Dependencies I have been building an elixir application for about 2 years now. Many modules and files ha...
New

Other Trending Topics Top

KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
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
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews