50buttonseach / fliclib-linux-hci Goto Github PK
View Code? Open in Web Editor NEWFlic SDK for Linux
Flic SDK for Linux
Given that the flic app is already has an ifttt service interface I am wondering if this library can be used to trigger.
I want to write a client that triggers ifttt but not sure how to implement the ifttt side of things.
Hi All
I have an issue that's been annoying me (and more importantly my wife) for the last few weeks.
I have a bunch of flics connected to 2 Raspberry Pis. I have livingRoomPi and bedroomPi. NodeRed runs on livingroomPi and connects to Daemons running on livingRoomPi and bedroomPi.
Both Daemons are started the same way using the boot script with logging ect.
All flics paired with the livingroomPi seem fine.
Buttons connected to the bedroomPi sometimes stop working.
When pressed the button glows red and nothing happens. When looking at the node-red dashboard it still seems to be connected to the daemon running on bedroom Pi.
if I log into bedroomPi and run the example node client, when I press a button I see it in the console. However as soon as I press this first button nodeRed starts to get events as well. It gets the "new" button press as well as previous, missed button presses.
I assume these are the events that did not get through before and are queued. The result is that lights come on then go off and all sorts of odd stuff happens...
I also see these queued events in the example client log output.
Any idea what is going on here? It seems as though the daemon on bedroomPi forgets that livingroomPi is connected to it and stops sending events until another client is connected to it then it sends events to all clients.
I currently have 4 Flic buttons setup with my raspberry pi and the batteries only last for about 2-4 weeks. Let me know what type of information I should provide so we can troubleshoot.
Hi,
is there any way to:
Both (especially no.1 obviously) would greatly improve the end user experience!
thanks,
Nikos
I'm trying to run the Server on a Raspberry Pi2 B and get:
Available HCI devices found:
hci0
Trying hci0
Successfully bound HCI socket
Flic server is now up and running!
Initialization of Bluetooth controller done!
flicd: flicd.cpp:1395: void le_set_scan_enable_handler(uint8_t): Assertion `!status' failed.
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.
I've attempted to pair/register more than one client to the same bluetooth controller and always receive the "InternetBackendError" error message. Can you please explain the error code?
Not really an issue but I don't think there's any other way of leaving feedback...
I had a play with this last night on Raspberry Pi 3 and got it up and running with the simple client.
How sure are we that this will carry on being supported (unlike the last library which I assume is being unsupported now).
I want to create a Node based client for it and don't want to put the work in if this library is not going to be maintained.
It's a shame that the server only talks in binary. It would be much easier (for me) to write a client if it was string based - or even just a REST api.
Thanks for the good work.
Hi
Loving this library now, got it connected to my Pi3 last night and all is good.
Could we add the option to disable double click when we connect to a button? The button in my living room does nothing when double clicked but there is still the delay when clicking as the system is waiting to see if there is another click. If we could optionally disable double click on a per-button basis this would make the click more responsive.
One of the challenges with the setup is you need a computer pretty close to all your buttons, so the price of each computer becomes important if you want to deploy a lot of buttons. Because of this I tested out the $9 computer https://www.getchip.com/pages/chip and it seems to be working well with Flic.
When comparing with RPI and other platforms it becomes even more compelling. the Chip includes wifi and bluetooth and does nto need a SD card, where as those items are all extra on RPI.
I am not associated with C.H.I.P - jut a happy customer :-)
I have my flic button working with node red - I've written a simple node that allows the button to be included in flows.
Node red starts at system boot as does my daemon.
As far as I know there is nothing that guarantees that node-red starts after the daemon.
Could the node client attempt to connect to the daemon every n seconds (possibly passed as optional argument in constructor) when it is not connected to the daemon.
I could probably do this myself when I get a bit of time so you might get a pull request...
Can we add the battery level of the flic to the message that the library sends?
I saw in the phone app that battery level is now reported and this would be useful - we can send an email when battery level gets below a certain level for example.
I assume though that this might only work with the buttons with update-able firmware? :-(
Hello,
Please could you add a 'name' field to the button database and setup wizard?
This would make it much easier to identify buttons and avoid having to store button names separately.
The Node-RED node currently stores a button name to device ID association in JSON.
Thanks,
nick.
Are you planning on publishing this on NPM?
My node project will depend on it and it'll make it easier to re-distribute it if this project is published on npm.
Hello,
I am using daemontools as my process supervisor for flicd. It provides a mechanism to process the output of stdout and write it to disk (with timestamps, log rotation etc).
Passing -
to the -l
/ --log-file
argument of flicd causes it to write to a file called '-'. Please can you make it write to stdout instead, as is common behaviour?
I would submit a Pull Request, but....
Thanks,
nick.
Hi
Not an issue really but I thought that people might find this useful.
I've finished my node-red nod for the new flic lib as it all seems to be working pretty well on my set up at home. I am hoping that the publisher of the original library will accept my pull request and publish on npm but you can always get hold of the code from my repo here:
https://github.com/Roaders/node-red-contrib-flic-buttons
I have node-red running on one Raspberry Pi which actually connects to 2 flic daemons and responds to clicks from flic buttons throughout the house. I needed 2 Pis as some of the buttons were out of range.
I hope that people find it useful.
I'm having trouble using the websocket client on a Raspberry Pi 3.
In one terminal:
sudo ./flicd -f flic.sqlite3
In the other:
./websocketproxy localhost 5551 0.0.0.0 5553
Which outputs
1 0.0.0.0 5553
waiting for client
I connect to the Pi in my browser, which returns a 404 with the text Not Found
Meanwhile, the websocket server has output the following
accept done
started thread
waiting for client
client_function
read request
client_function stopped
What am I missing?
Providing source code for flicd would be great!
libcurl.so.4: version
CURL_OPENSSL_3' not found`)I used the python clientlib to integrate flic buttons and got an issue with the events passed to channel.on_button_single_or_double_click_or_hold
When a Button is hold down, the callback is called with a type fliclib.ClickType.ButtonHold
but when the button is released an additional call with fliclib.ClickType.ButtonSingleClick
is fired. This requires me to have some timing logic which is rather unstable to filter those single clicks.
I would like to have callbacks on a highlevel:
and low level callbacks
My question do I get the API wrong or is this the way the current implementation works? In the latter case I think it would be an improvement to have the callbacks as described.
By the way, very easy to use lib. Worked great out of the box.
The readme says:
The downside however is that you will not be able to use that dedicated bluetooth controller for other bluetooth connections, such as streaming audio
I find this to be a big limitation of this implementation. Are there any plans to fix this / any workarounds to make the bluetooth controller available for other devices?
Thanks.
Hey Guys,
first of all thank you for the new SDK!
Connecting the client running on localhost works like a charm!
But I have encountered a problem when trying to connect to your daemon from another device running on the local network. The connection gets refused.
Is it a security feature or am i doing something wrong?
Hi,
I have a dongle that's based on the BCM20702 chipset which, according to the README, should be supported. However, I'm getting really erratic behavior. The clicks don't register properly and I get the following messages sometimes:
104
client read failed: Connection reset by peer
A client was disconnected
A client was disconnected
A client was disconnected
A client was disconnected
A client was disconnected
A client was disconnected
Accepted new client
Warning: Non-standard-compliant or buggy bluetooth controller, sent 2 complete packets event, but there were only 1 outstanding for conhdl 64
Accepted new client
♥Received signal 2
A client was disconnected
A client was disconnected
This is running on a RPi (first edition) with the said dongle. If I run exactly the same thing on an RPi 3 with the built-in bluetooth, then I can get it to work.
Any ideas how can I make the dongle work? Have you heard of anything similar?
Thanks,
@etiago
One of my buttons stopped working and it is flashing red twice when I am pressing it.
I have tried to add it again with the startScanWizard and it does not see it. Even buttons in private mode normally shows and I am directed to press the button for 7 seconds, but not this one.
Removing the battery didnt change anything.
Any ideas?
Hi,
I had problem with running the server code.
Here is my Linux platform information:
Linux OpenWrt 3.10.14 #301 SMP Tue May 17 13:37:45 EDT 2016 mips GNU/Linux
When I compile x86-64 version, I got Error Code:
./flicd: 1: ./flicd: Syntax error: word unexpected (expecting ")")
Is there anyway I can compile and run the server code?
Thank you.
Kyle
I'm getting this error message after sarting the daemon. The error appears directly after starting with no client connected. Plattform ist RaspberryPi Model B running jessie and disabled bluez daemon.
Available HCI devices found:
hci0
Trying hci0
Successfully bound HCI socket
Flic server is now up and running!
Error: Timeout while initializing HCI, exiting. Try restart the program or replug your Bluetooth controller.
Exited
I'd love to incorporate the flic buttons on websites using web bluetooth - from what I can make out, when you connect to the flic button you have to send X values to the flic for the connection to stay open etc but with none of this info being available (well at least I can't find it) trying to figure this out myself isn't easy. I could run a bt snoop session on android etc to get access to some info but would you be open to providing any of this info?
Or am I missing vital bits of info and developing it as a web bluetooth lib just wouldn't work? I see you create a server of some description on the host and send tcp data between the two devices - so is it not just characteristic changes on a service?
This is way more robust than the bluez version. I have been running this w/o issues for 10 days now and the bluez version could rarely keep working for 24 hours w/o restarting.
Dear team
Glad to see, that there is a new linux release for the flic button. I'm using the old fliclib quite a long time with the known problems. My problem now is that I'm not as good as many of you. I want to migrate to the new version, but I didn't get to find out the way to handle the events coming from the flic button. Maybe some of you can show / write a sample for the 3 types of "actions", short, double, long click on a flic button. Like in this comment for the old fliclib.
It could be in python or nodejs, doesn't matter.
Best Regards
Rob
Hi,
Wondering if this can be installed on macOS. Have downloaded the flic linux dependencies. Down have linux running on mac though.
Thanks
I plan to get nexus 4 or 7, where I could install ubuntu touch (a mobile version of the Ubuntu operating system).
http://www.pcadvisor.co.uk/how-to/linux/how-install-ubuntu-touch-image-3531970/
I would like to use flic button with fliclib on that phone.
Sorry for my noobish question...
mr. Vares
Hi there !
First of all, thanks a lot for releasing this lib for linux. It is very useful and works very well.
I have a simple question concerning a behavior a bit surprising.
I modified the code from the examples to detect simple, double clicks and holds and display "SimpleClick", "DoubleClick" or "Hold" on the corresponding event. It works very well, but the weird thing is when I click the button having neither the flicd nor the TestClient launched and the bluetooth off. When I launch both after having clicked a bit the button, the lines corresponding to the clicks I performed are displayed, as if the events were kept in memory by the button itself.
I checked on my processes and I am pretty sure the flicd is not running when I click the button.
Is this behavior normal? If it is, is there a way to manually "empty" the stored events ?
Thanks in advance for your answer.
Hello,
I had flicd up and running fine on a stock raspbian jessie (stable) with 5 paired buttons in my Raspberry Pi.
I recently upgraded raspbian to testing via apt-get dist-upgrade
(after changing the sources list) and the buttons don't work anymore. If I connect to the flic daemon with simpleclient
and issue getInfo
I get a message saying I have no verified buttons.
getInfo
Got info: Attached, aa:aa:aa:aa:aa:aa (PublicBdAddrType), max pending connections: 128, max conns: -1, current pending conns: 0, currently no space: n
No verified buttons yet
I verified the sqlite3 file and the buttons table has all the buttons in it.
Can you provide some pointers on how to solve this?
I am using c# sdk. How can I totally remove an already paired button?
I tried to send CmdRemoveConnectionChannel, CmdForceDisconnect but the flicclient just stops receiving events from this button. What I need is to fully remove it from the slqite database, so as to be able to reuse the button .
Hi Flic team,
I'd love to see the client libraries published in the proper artifact repository depending on the language they're written. E.g. the java clientlib to maven central, python to PyPI etc.
BR
Patrick
We would like to re(use) examples, libraries and binaries but I cant find any licensing information.
What licence applies to this components?
Will Flic Single buttons [1] be supported?
I've been attempting to sort out a way to check the 'health' of the daemon while it is running. On rare occasion, the daemon seems to forget the contents of the database, causing the buttons to fail to connect. When I grep out the process, it appears to be running normally. The closest I can get is to launch the simpleclient and use the getInfo command to see if the buttons are listed. I'd love to be able to have this same interaction from the node-red context so I can restart services etc. Time and skill are preventing me from fully writing my own...Mostly wondering if anyone out there has built something that fits this need.
Any guidance is appreciated. Thank you!
I'm running the MacOS FlicServiceBeta v0.0.2 from 31 May, 2016 (the latest) like this:
$ /Applications/FlicServiceBeta.app/Contents/MacOS/FlicServiceBeta --interface localhost
2016-08-20 11:13:27.740 FlicServiceBeta[63756:2194025] Flic service started on port 5551, interface: localhost
My python program is:
#!/usr/bin/env python3
#
# Test to get flic presses.
#
import fliclib
import logging
def main():
rootLogger = logging.getLogger()
consoleHandler = logging.StreamHandler()
rootLogger.setLevel(logging.DEBUG)
rootLogger.addHandler(consoleHandler)
client = fliclib.FlicClient("localhost")
wizard = fliclib.ScanWizard()
def wiz_on_found_private_button(scan_wizard):
print('shittlesticks, a private button was found')
def wiz_on_found_public_button(scan_wizard, bd_addr, name):
print('found public button: {} ({})'.format(bd_addr, name))
def wiz_on_button_connected(scan_wizard, bd_addr, name):
print('found public button: {} ({})'.format(bd_addr, name))
def wiz_on_completed(scan_wizard, result, bd_addr, name):
print('complete: {} {} ({})'.format(result, bd_addr, name))
client.close()
wizard.on_found_private_button = wiz_on_found_private_button
wizard.on_found_public_button = wiz_on_found_public_button
wizard.on_button_connected = wiz_on_button_connected
wizard.on_completed = wiz_on_completed
print('adding wizard')
client.add_scan_wizard(wizard)
print('starting event loop')
client.handle_events()
if __name__ == '__main__':
main()
I've also modified fliclib to add some logging in _handle_one_event
:
def _handle_one_event(self):
self._logger.debug('waiting for event')
if len(self._timers.queue) > 0:
current_timer = self._timers.queue[0]
[...]
self._logger.debug('read event')
self._dispatch_event(data)
return True
When I run the program, I get:
adding wizard
starting event loop
waiting for event
And in the FlicServiceBeta output I see:
2016-08-20 11:13:57.439 FlicServiceBeta[63756:2194554] Accepted client ::1:49243
And that's it, regardless of how many times I press the button.
When I run scan_wizard.py
, that works fine but it doesn't use the ScanWizard
object provided by the library.
Thoughts?
I have the nodejs sample client up and running and got it connected to 2 buttons no problem. They both show button clicks and up and down events.
One of the buttons disconnected shortly after a button click with the message Disconnected BondingKeysMismatch
.
Everything still works though and when I click the button again it re-connects no problem.
I didn't think that it was a problem until I noticed that the other button doesn't do it.
Should I be worried about this message?
Thanks
I run into a problem where my buttons will not respond after some time of inactivity. The only way to get them to begin responding again is to restart my unit. Bluetooth service is continue to run, but I assume the daemon hangs or something. With the option to restart or stop daemon without killing process, I can safely start/stop.
I am really struggling to get my buttons working with flicd reliably. I have had one working, and have had all working with the phone app. But the procedure doesn't seem to be repeatable or predictable.
I have verified all of them can be paired with the phone app, and then once paired I have deleted the pairing and removed the device from the list of paired bluetooth devices on the phone. I believe this leaves the buttons in an "unpaired" state.
I then run flicd and start simpleclient, and type "connect XXX N" to pair - the BT address I have found previously by running startScan. This typically gives me no response, or a response about the button being private (without documentation I have to presume this means the button is paired to something else, but it happens even with buttons that had been explicitly deleted from the phone app, or brand new buttons that have never been paired with anything).
The method which finally seemed to work for me was "forceDisconnect XXXX", then hold the button down for 10s, then "connect XXX 0" to pair the button. Finally at this point I could see the button presses, and with this procedure I was able to connect and see presses from all four buttons.
I then quit simpleclient, leaving flicd running, and suddenly my buttons are no longer working! Pressing them gave the "pulsing glow" I have come to realise means they are not paired, and when I fired up simpleclient again I can not see any of their presses.
Here's the current output of "getInfo" from simpleclient:
getInfo
Got info: Attached, b8:27:eb:e1:f8:XX (PublicBdAddrType), max pending connections: 128, max conns: 10, current pending conns: 4, currently no space: n
Verified buttons:
80:e4:da:71:3b:XX
80:e4:da:71:78:XX
80:e4:da:71:79:XX
80:e4:da:71:86:XX
So I can see they are known to the daemon as "verified buttons". Does this mean they're connected now? They are in the database but aren't currently connected? I have four pending connections, what does that mean? I have no idea what to do next.
The frustrating part is that I have had this working - my initial testing with one button in my own client worked, but when I tried with more than one button I had great difficulty pairing them or and getting them to stay paired. I can't really give more detail I'm afraid, because I was trying dozens of things and buttons I had connected and working would suddenly stop working when I tried something else. It was very hard to identify exactly what was going on.
What I am expecting to be able to do here is:
Are these expectations valid?
I'm filing this is an issue, not just a request for support, because either the simpleclient needs a fix, flicd needs a fix or the documentation needs a fix to correct my expectations.
Regardless of the above, I also have some suggestions which would have made the last few hours trying to figure this out a lot easier.
I want to use my Raspberry Pi 3's Bluetooth adapter not only for flicd but also for another tool to control my window shades.
https://bitbucket.org/jeremynoel476/smartblinds-diy/overview
Isn't it possible to work with other Bluetooth devices when flicd is running?
# hcitool lescan
Enable scan failed: Connection timed out
# python control.py -t TH:EE:MA:CC:AD:DR:ES -c move_target -a 80
Can't down device hci0: Device or resource busy (16)
Hi, I've been trying to run on my Synology 415play. I'm not sure if that platform is supported?
admin@DS415play:~$ uname -mrs Linux 3.2.40 i686
When I try to run it:
admin@DS415play:/volume1/homes/gabriel/fliclib-linux-hci$ ./bin/x86_64/flicd -f flic.sqlite3
-sh: ./bin/x86_64/flicd: cannot execute binary file: Exec format error
If not supported, is there any change you could add binaries that work on this platform?
This will remove the requirement of Linux >= 3.13.
It's possible to use HCI_CHANNEL_RAW for older Linux kernels but will need some modifications to handle as good as possible the cases where somebody else uses the HCI at the same time (normally the kernel itself when it resets the controller).
use asyncio in the python lib
Hi,
I've been poking around with my RPi 3 trying to make a flic-to-LIFX bridge, but as I only have a basic understanding of coding I've not been very successful. Especially since LIFX doesn't maintain any sort of Java or Python SDK...
So I was wondering if anybody had had any success with it ?
Hey, I'd like to ask how I would properly remove a button from the database (and best of course to reset the button to be public again). Something like a disconnect wizard-script would be wonderful: start del-client-wizard, push button to be removed from database and let it be resetted and removed from database.
Simply deleting a row in the database would be a first step, but even that seems to be blocked as long as the flicd is running.
Maybe I have overlooked something very obvious. Any hint appreciated.
Right now my use case is creating a UI to set up buttons and I cannot buy for every test a fresh button ;)
Cheers,
Ulf
I am using Flic to control my Sonos and it is working, however I cannot get the needed range with the bluetooth dongle I am using. Are you aware of dongles with better range than others? or if it is possible to adjust the signal strength via sw.
Could you please explain how to install flicd on rasberry pi ,I am very new on Rasberry pi.So could you please explain it
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.