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-menuconfigNetworking 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
Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
jaybe78
Hello, I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter). The diffic...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
aseigo
ICal is a library for interacting with iCalendar data. It parses iCalendars into typed Elixir structs via ICal.from_ics, and can prepare ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews