Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raspberry Pi 4 support? #3

Closed
radokristof opened this issue Jan 14, 2020 · 13 comments
Closed

Raspberry Pi 4 support? #3

radokristof opened this issue Jan 14, 2020 · 13 comments

Comments

@radokristof
Copy link

radokristof commented Jan 14, 2020

I read the documentation, but I'm not sure I understand everything fully.
The uhubctl README says that it supports Pi 4 but it is buggy, so if you connect the Bluetooth Adapter directly to the main hub (eg.: one of the provided USB ports), it will power down all ports.

So my main questions are:

  • Does this will work even if I use an external hub supported by uhubctl? No modification is needed in the code? How it will know where it is plugged in and which port should be powered down?
  • Has anyone tried this with a RPi 4? How it works if you don't use an external hub?
@radokristof radokristof changed the title Raspberry Pi 4 support< Raspberry Pi 4 support? Jan 14, 2020
@MynahPL
Copy link

MynahPL commented Jan 16, 2020

I am trying to make it run on RPi4, but unsuccessfully so far... I guess I just do not understand everything as well.
My ASUS bluetooth USB dongle is connecting to other LE devices, but I cannot figure out how to make it work with this. I have tried connecting the dongle to RPi4 directly as well as to a USB hub (no difference in error messages below; works with other devices in both configurations).

While I try to run node app.js I get the below error:

Connected to MQTT Broker
{ dongleConfig:
{ hciDevice: 'hci0',
mode: 'le',
services: [],
devices: [ [Object] ] },
error:
{ message: 'Failed to fetch adapter Interface for hci0',
error:
[ 'Rejected send message, 2 matched rules; type="method_call", sender=":1.21" (uid=1000 pid=1991 comm="node app.js ") interface="org.freedesktop.DBus.Introspectable" member="Introspect" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=366 comm="/usr/lib/bluetooth/bluetoothd ")' ] } }

Also, not sure that I edited the config the right way:

{
"mqtt": {
"url": "mqtt://broker.ip:1883"
},
"dongles": [
{
"hciDevice": "hci0",
"mode": "le",
"services": [],
"devices": [
{
"type": "MiKettleDevice",
"friendlyName": "Mi Kettle",
"mac": "my:ma:ca:dd:re:ss",
"productId": 275
}
]
}
]
}

@radokristof
Copy link
Author

Are you sure that hci0 is your Bluetooth device?

@MynahPL
Copy link

MynahPL commented Jan 16, 2020

I believe so... It is even a Broadcom chip. Unless I am mistaken?

hciconfig
hci0: Type: Primary Bus: USB
BD Address: 5C:F3:70:xy:zx:yz ACL MTU: 1021:8 SCO MTU: 64:1
UP RUNNING
RX bytes:13891 acl:189 sco:0 events:685 errors:0
TX bytes:7648 acl:75 sco:0 commands:404 errors:0

hcitool dev
Devices:
hci0 5C:F3:70:xy:zx:yz

lsusb
Bus 001 Device 004: ID 0b05:17cb ASUSTek Computer, Inc. Broadcom BCM20702A0 Bluetooth

@Hypfer
Copy link
Owner

Hypfer commented Jan 16, 2020

Your user is most likly not in the bluetooth group.

I should probably add that to the documentation

@Hypfer
Copy link
Owner

Hypfer commented Jan 16, 2020

Does this will work even if I use an external hub supported by uhubctl? No modification is needed in the code? How it will know where it is plugged in and which port should be powered down?

It doesn't. You need to specify the correct command manually
https://github.com/Hypfer/Cybele/blob/master/docs/index.md#troubleshooting

@radokristof
Copy link
Author

Ahh that makes sense! Sorry for not reading it through carefully...

@Hypfer Hypfer closed this as completed Jan 20, 2020
@radokristof
Copy link
Author

Ok, just for testing, I got it running with a RPi 3B with the internal bluetooth.
The range is not so good and I don't know how about you, but I don't have an RPi in the Kitchen yet :)
Yes the Bluetooth will stuck after a few hours, but it seems that it can be restarted by uhubctl (and I couldn't even notice it in terms of Ethernet connectivity that the internet is lost - as it should be because that port will power-cycle Ethernet and Wi-Fi theoretically).

However it seems that after the power cycle is not enough, I also needed to do a sudo hciconfig hci0 up for the Bluetooth to work again. Can I concatanate these two commands with && in the recoveryCommand option @Hypfer ?

Looking at the child_process documentation, this might not work out-of-the-box as it is right now...
Could this be added to the code? It is also great if you want to call any other script, etc... when this happens.

@Hypfer
Copy link
Owner

Hypfer commented Jan 30, 2020

Hm. Apparently AutoEnable=true is not set in your /etc/bluetooth/main.conf
I think that it is default true on new installations. Still something to note somewhere in the documentation.

If you for some reason need to run more than one command, I'd suggest wrapping those in a script and using that as the recoveryCommand since child_process.exec is not a shell.

@radokristof
Copy link
Author

radokristof commented Jan 30, 2020

Unfortunately AutoEnable is set to true.
I also experienced that if I do an lescan I can see the device (and it has a pretty good signal), but Cybele will not connect to it.
No logs, only 'Startup complete' and I can't see it trying to connect to the device or any other output...

Ps.: It seems like that the hciconfig down & up are still needed even if lescan works...

@Hypfer
Copy link
Owner

Hypfer commented Jan 30, 2020

I think the power cycling isn't fully working then. iirc that's also what I saw when trying the 3b.

USB Bluetooth seems to be the only viable option, sadly :(

@radokristof
Copy link
Author

@Hypfer Yes I know I just wanted to try out, and my USB Bluetooth haven't arrived yet.
Also I hope that the range will be a little bit better... I can't place the RPi closer to the Kettle.
One quick question: you can't disable the beeping sound when the handshake happens right?
It is really annoying, if I could disable it, then this performance would be enough for me... It only loses connection sometimes for a few secs, but then it beeps again...

@Hypfer
Copy link
Owner

Hypfer commented Jan 31, 2020

Unless you find a way to flash a custom firmware to the kettle sadly no

@stek29
Copy link

stek29 commented Mar 19, 2020

I'm using it on RPi 4B with builtin adapter on Ubuntu Server without any issues so far (it's been working for ~5 hours without any issues).
It took some time to get built-in bluetooth adapter working (adding modules to be loaded on boot, adding hciuart, disabling console).

I've been running it in docker with docker-compose.
Sharing my setup here since it might help others.

Dockerfile:

FROM node:12-alpine

WORKDIR /app
ARG VERSION=master
RUN set -ex; \
    apk add --no-cache --virtual .build-deps \
        wget \
        tar \
        git \
        python2 \
        alpine-sdk \
    ; \
    wget https://github.com/Hypfer/Cybele/archive/${VERSION}.tar.gz -O cybele.tar.gz; \
    tar --strip-components=1 -xf cybele.tar.gz; \
    rm cybele.tar.gz; \
    npm install; \
    apk del .build-deps; \
    cp config.default.json config.json

ENTRYPOINT ["/usr/local/bin/node", "app.js"]

/var/run/dbus/system_bus_socket should be mounted from host.

AppArmor can be configured with custom profile to allow DBus access to bluez only, I didn't think it was worth the time and effort and just have made Cybele container "privileged" (with security_opt: [apparmor=unconfined])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants