RPi-Distro / pi-bluetooth

Loads BCM43430A1 firmware on boot
42 stars 34 forks source link

[help wanted] Make snap with bluetooth for Ubuntu Core 20.04 on Raspberry Pi 4 #31

Closed Rturoz closed 2 years ago

Rturoz commented 2 years ago

Hi, i'm trying to do a snap for Ubuntu Core 20.04.3 that must run on a Raspberry Pi 4 Model B. This snap is based on a python script that use the python library 'bleak'. When i run the snap on Ubuntu desktop there isn't problem. The problem is when i try to run the snap on Ubuntu Core 20.04 because there is the following error:

OSError: [Errno 8] Exec format error: 'bluetoothctl'.

I understood that to use the bluetooth on Ubuntu Core with the Raspberry Pi i must use the pi-bluetooth snap, but i don't know how to use this with my snap. More precisely, I don't know how to make my snap in such a way as to be able to use bluetooth on the Raspberry Pi.

This is my current snapcraft file to realize the snap:

name: iot-band
base: core20 
version: '1.0' 
summary: Iot band app
description: |
  Iot band app

grade: devel 
confinement: devmode 

architectures:
  - build-on: amd64
    run-on: arm64

apps:
  iot-band:
    environment:
      PYTHONPATH: $SNAP/lib/python3.8/site-packages/iot-band
    command: bin/iot_band.py
    plugs:
      - bluez

parts:
  iot-band:
    # See 'snapcraft plugins'
    source: .
    plugin: python
    python-packages:
      - .
  bluez:
    plugin: nil
    stage-snaps: [bluez]

How can i realize correctly the snap (using the "snap pi-bluetooth") to resolve this problem with the bluetooth?

pelwell commented 2 years ago

This seems to be all about snaps and almost nothing about Bluetooth, and unfortunately I know nothing about snaps and their creation. You might be lucky and catch the eye of someone more knowledgeable, but don't hold your breath.

ukBaz commented 2 years ago

Not very familiar with snaps either but couple of thoughts came to mind so I thought I'd throw them in the mix in case they help (and apologies it they are misdirection).

Having bluetoothctl in the error message is a little strange. Is that installed in the snap on Ubuntu Core?

Could it be this line?

https://github.com/RPi-Distro/pi-bluetooth/blob/23af66cff597c80523bf9581d7f75d387227f183/usr/bin/bthelper#L41

Is btmgmt installed? Could it be changed to this?

(sleep 5; /usr/bin/btmgmt power off; /usr/bin/btmgmt power on) &

Or is this a D-Bus issue? There are lots of things that rely on D-Bus on the Desktop but minimal system often don't have it installed.

Rturoz commented 2 years ago

Thank you for the answer, but with your advice i don't resolve the problem.

Rturoz commented 2 years ago

Hi @waveform80, i saw that you did the snap pi-bluetooth, you could answer my issues stated above?