Open CheapB opened 8 years ago
Great! Can I copy this to a separate guide file?
Yes, that's fine. I suggest we keep this issue open so people can post any issues or questions that may prompt updates to the document.
some areas I know I would like to improve on are: 1) a few PY examples 2) possible access to blueZ binaries - 3) bluetoothd configuration as a service and ability to bring up the adapter if needed 4) autostart of the flic deamon as a service
If anyone create code samples, feel free to make a pull request
The button led works as follows: If the button is connected the led never glows. If the button is disconnected, it glows two times when pressed then it remains off until pressed again. The button is in public mode if it hasn't yet been connected to any device, or for 30 seconds if it is pressed for 8 seconds while disconnected. During these 30 seconds the led doesn't glow constantly. Does your button behaves like this?
It seems like it is hit or miss if it goes into public mode. after 8 sec. I will do some more testing.
The readme should be corrected as it states "Hold your Flic button for 8 seconds to make it public, and make sure that it glows "
I want to get started on updating the howto with getting the environment with bluez and the flic deamon as services. Can someone post a working /etc/bluetooth/main.conf file. Ideally from an RPI with Jessie and a policy section, but I will take anything :-)
should line 96 scanStart be startScan?
Absolutely - good catch
I updated the guide
In both this issue and the committed guide, first link to Raspbian Jessie actually points to Wheezy. Direct link to Nov-2015 Jessie image is https://downloads.raspberrypi.org/raspbian/images/raspbian-2015-11-24/2015-11-21-raspbian-jessie.zip
@KaiboshOz thanks it's fixed now
@CheapB It would be helpful to have a howto for running the flic deamon as a service. Also I need some more details to put actions (single / double / long click for different buttons) in the main.py file. Everything is working on it's own, but it is not yet userfriendly and "out of the box" .
Thanks! Left some credit to both you and this repo http://blog.lextoc.com/quinten-will-stop-wiggling-his-foot/
@RobZe89 IF you start out with the provided test.py script you can edit to call a webservice depending on what has been pressed. Remember to import requests
class ButtonEventListener(flic.ButtonEventListener):
def getHash(self):
return "main"
def onButtonSingleOrDoubleClickOrHold(self, deviceId, queued, timeDiff, isSingleClick, isDoubleClick, isHold):
manager = client.getManager()
button = manager.getButton(deviceId)
if isSingleClick :
r = requests.post("http://IP:port", json={ })
print r.status_code
elif isDoubleClick :
r = requests.post("http://IP:port", json={ })
print r.status_code
else :
r = requests.post("http://IP:port", json={ })
print r.status_code
nano /lib/systemd/system/bluetooth.service
put a -E options at the commandline to enable experimental mode
ExecStart=/usr/local/libexec/bluetooth/bluetoothd -E
sudo systemctl enable bluetooth
sudo crontab -e
Add follweing line
@reboot sudo hciconfig hci0 up
It would be helpful to have a howto for running the flic deamon as a service
I've modified this into an automated installer and some scripts to run each of the components, but I'm hitting the connect/disconnect loop issues that others are reporting.
I've been using it with a Pi 3, but I was having the same issue with a Pi 1 B before that when I was following the original instructions.
https://github.com/mikeboehm/flic-installer
Do they work for anyone else?
Header says it all.. A couple of notes before we begin: 1) I am not an expert by any means, so feel free to comment or improve as you see fit 2) Do not attach your BT dongle before the instructions call for it.
3) It would be great if anyone have info on blueZ binaries pre-complied for RPI/Jessie. It is pretty painful to compile every time there is an update
Lets get started:
Download jessie (https://downloads.raspberrypi.org/raspbian/images/raspbian-2015-11-24/2015-11-21-raspbian-jessie.zip) and install (https://www.raspberrypi.org/documentation/installation/installing-images/README.md)
Configure network connection etc - what you normally will do or google it. Do NOT attach your BT dongle yet! :-)
Install Putty or similar on your regular PC for SSH access to the RPI
via SSH or on the CLI:
update all system packages: sudo apt-get update
update all installed packages: sudo apt-get upgrade
optional: clean out installation files: sudo apt-get clean
install Adafruit WebIDE (https://learn.adafruit.com/webide/installation)
Backup your SD card with Win32DiskImager (for windows) or similar if you are on a different platform. This will save you a lot of time if you want a clean install when the next beta is out
install needed packages for blueZ:
sudo apt-get install libglib2.0-dev sudo apt-get install libdbus-1-dev sudo apt-get install libudev-dev sudo apt-get install automake sudo apt-get install libtool sudo apt-get install libical-dev sudo apt-get install libreadline-dev
Install BlueZ:
git clone git://git.kernel.org/pub/scm/bluetooth/bluez.git
cd bluez
./bootstrap
./configure --enable-experimental --enable-library
make
sudo make install
sudo shutdown -h now
Insert the BT dongle and restart
login
cd bluez/src
sudo ./bluetoothd -nEd
This should be kept active
Open a new SSH session mkdir flic cd flic
sudo wget https://github.com/50ButtonsEach/fliclib-linux-dist/releases/download/1-beta3/fliclib-linux.tar.gz
sudo tar -zxvf fliclib-linux.tar.gz
cd armv6l
sudo ./daemon -l -f flic.sqlite3
This should be kept active
Open a new SSH session
cd flic/armv6l/fliclib-cpp
sudo hciconfig hci0 up
sudo ./flic
startScan press your button wait for button discovered message stopScan press and hold the button for 8 sec and select
connect
This may take a few tries as my button never glows in public mode. You know it was successfull when is says connected and start track button presses..
exit flic with ctrl-C
install Flic Python lib: cd ~/flic/armv6l/fliclib-cpp/ffi/python/flic/dist sudo easy_install flic-0.1-py2.7.egg
Test: start your AdaFruit WebIDE
create a new python file
copy and paste the attached test into your file and execute main.txt
Test by pressing the button
Have fun!