Open gnoe8307 opened 8 years ago
You should specify a log file with the --log-file option since stderr is not available when running in daemon mode. A Linux daemon changes the current directory to /, where you probably not have permissions. You should therefore specify the full path of the db file.
hi Emil, thanks for your feedback. After some new tests, it occurs that the rc.local method I used is working properly.
Guillaume
Can you give a bit more detail on how you got this to work? Was it just changing the path of the sql file?
I think that this would be really useful as part of the readme as I imagine most people would want to do this.
ok, I'm a bit confused actually. It worked without changing anything and stopped working again.
So I followed Emil's recommendations:
Error: No HCI devices are available. Make sure you have a Bluetooth controller plugged into the computer
I guess rc.local is launched at reboot before HCI. Flicd considers there 's no bluetooth controller because it's not launched yet.
Any idea on how to proceed?
thanks in advance
very simple solution actually:
I added sleep 60 &&
in my rc.local file before the the flicd script launch. Flicd is launched 1 minute after reboot, giving time to bluetooth to launch first.
Rc.local looks like:
sleep 60 && cd /etc/init.d/ ./flicd -d -f /etc/init.d/flic.sqlite3 -l /tmp/log_flicd &
(I moved flicd and flic.sqlite3 in /etc/init.d, but it could be any other rep)
I noticed this as well that it takes about 4 seconds from the rc.local script is run until the hci becomes ready on the Raspberry Pi 3. We'll add a command line option that will make flicd wait until the hci becomes available.
I got this working last night. At the weekend I'll try and add it to the readme and submit a pull request.
Did you do another approach than @gnoe8307? I have implemented a -w flag that waits until the specified hci becomes ready that I was going to push soon. Den 8 jun 2016 09:30 skrev "Roaders" notifications@github.com:
I got this working last night. At the weekend I'll try and add it to the readme and submit a pull request.
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/50ButtonsEach/fliclib-linux-hci/issues/15#issuecomment-224511312, or mute the thread https://github.com/notifications/unsubscribe/ABlXau-xZhl4yd5GzvjbXrhABbOwz12jks5qJm-rgaJpZM4Itdpz .
no, I used the same method with a sleep. a -w flag would be better.
Any progress on getting the "best practice" deamon readme written up? looking forward..
@Emill I'm also interested in this, when can we get the -w flag?
I'm also super keen for a 'recommended approach'.
I'll probably make a release in the upcoming days
Ok great. Thanks!
@Emill any news on the -w
flag?
Hi. It will be released on Wednesday.
I've now released a new version that has the wait option.
@Emill I can confirm that the -w flag works wonderfully, thanks!
I am very successfully using DJB's Daemon Tools to keep flicd running: https://cr.yp.to/daemontools.html
This is my run script:
#!/bin/sh
exec /usr/local/bin/flicd \
--wait-for-hci \
--log-file /dev/stdout \
--db-file sqlite_db_file.db
I am not sure but I think adding the -w flag to my start command in rc.local might have stopped wither of my Pi's booting properly. Over the last few days since I did this both of my Pi's go unresponsive and do not respond when rebooted. When I plugged a monitor in there was an error from flicd in the boot script and other errors later and I didn't even get a prompt to login with. I am very new to linux so am pretty confused by what could be causing this. One thing I changed recently was the flic daemon startup command. The only other thing I have done was try to install a mqtt broker which didn't work so I then deleted it.
What was the error from flicd?
If you use the -w option the bash execution of the program should either fail or return (when the daemon mode has been entered), it should never hang since there is no loop that would do that. Possibly if some syscall hangs which I doubt.
Just FWIW the -w option works perfectly for me on Raspbian (RPi 1).
-w option is working perfectly on my side too, thanks a lot
my rc.local looks like that now:
cd /etc/init.d/
./flicd -d -f /etc/init.d/flic.sqlite3 -l /tmp/log_flicd -w &
I use the following systemd
script to start flicd
as a proper service...
/etc/systemd/system/flicd.service
[Unit]
Description=flicd Service
After=bluetooth.service
Requires=bluetooth.service
[Service]
TimeoutStartSec=0
ExecStart=/usr/local/bin/flicd -f /home/pi/.flic/flic.sqlite3 -s 0.0.0.0 -h hci0 -w
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
I have a strange issue. On my raspberry pi 3 I get from running dmesg:
[ 38.002559] Bluetooth: Core ver 2.21
[ 38.003478] NET: Registered protocol family 31
[ 38.003497] Bluetooth: HCI device and connection manager initialized
[ 38.003521] Bluetooth: HCI socket layer initialized
[ 38.003536] Bluetooth: L2CAP socket layer initialized
[ 38.003577] Bluetooth: SCO socket layer initialized
[ 38.018145] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[ 38.018159] Bluetooth: BNEP filters: protocol multicast
[ 38.018174] Bluetooth: BNEP socket layer initialized
If I then try to start (sudo) flicd this driver disappears because the exec says
Error: No HCI devices are available. Make sure you have a Bluetooth controller plugged in into the computer.
Does anyone know what is happening here?
On my Raspberry Pi 3, bluetooth and bluealsa were interfering with the flic service detection of the hci0 device.
Since I'm only doing flic here, I was able to fix the issue by masking the bluetooth services completely (disabling was still allowing them to start via bluetooth.target, thanks systemd):
systemctl mask bluetooth.service
systemctl mask bluealsa.service
Then my systemd service worked. Note that I key off hciuart.service which brings up hci0. flicd.service:
[Unit]
AssertPathExists=/home/flicd/data
After=hciuart.service
[Service]
User=flicd
TimeoutStartSec=0
ExecStart=/home/flicd/fliclib-linux-hci/bin/armv6l/flicd -f flic.sqlite3 -s 0.0.0.0 -h hci0 -w
Restart=always
RestartSec=3
WorkingDirectory=/home/flicd/data
PrivateTmp=true
AmbientCapabilities=CAP_NET_ADMIN
NoNewPrivileges=true
[Install]
WantedBy=default.target
CAP_NET_ADMIN is added just incase the binary gets stripped of capabilities.
After reboot, it detects the hci0 device and can initialize it:
# journalctl -u flicd -u hciuart
-- Logs begin at Thu 2016-11-03 13:16:42 EDT, end at Sun 2018-07-08 23:14:32 EDT. --
Jul 08 23:12:43 rpi-flicd systemd[1]: Starting Configure Bluetooth Modems connected by UART...
Jul 08 23:12:48 rpi-flicd btuart[365]: bcm43xx_init
Jul 08 23:12:48 rpi-flicd btuart[365]: Flash firmware /lib/firmware/brcm/BCM43430A1.hcd
Jul 08 23:12:48 rpi-flicd btuart[365]: Set BDADDR UART: xx:xx:xx:xx:xx:xx
Jul 08 23:12:48 rpi-flicd btuart[365]: Set Controller UART speed to 921600 bit/s
Jul 08 23:12:48 rpi-flicd btuart[365]: Device setup complete
Jul 08 23:12:48 rpi-flicd systemd[1]: Started Configure Bluetooth Modems connected by UART.
Jul 08 23:12:48 rpi-flicd systemd[1]: Started flicd.service.
Jul 08 23:12:48 rpi-flicd flicd[542]: Available HCI devices found:
Jul 08 23:12:48 rpi-flicd flicd[542]: hci0
Jul 08 23:12:48 rpi-flicd flicd[542]: Trying hci0
Jul 08 23:12:48 rpi-flicd flicd[542]: Successfully bound HCI socket
Jul 08 23:12:48 rpi-flicd flicd[542]: Flic server is now up and running!
Jul 08 23:12:48 rpi-flicd flicd[542]: Initialization of Bluetooth controller done!
hi there,
I can't find a way to launch flicd as a deamon on boot (I'm a on Raspberry PI3).
I have tried the following things (logged in admin) without success so far:
- rc.local :
$ /home/pi/Applications/flic/fliclib-linux-hci-master/bin/armv6l/./flicd -d -f flic.sqlite 3 &
$ "test" > /home/pi/Documents/testrclocal
)crontab
$crontab -e
$@reboot /home/pi/Applications/flic/fliclib-linux-hci-master/bin/armv6l/./flicd -d -f flic.sqlite 3 &
date >>/home/pi/Documents/hueapi/hue_server.log
Am I missing something here? Thanks in advance for your support.