Code Monkey home page Code Monkey logo

fliclib-linux-hci's Introduction

Flic SDK for Linux

With this SDK you can connect to and interact with Flic buttons. PbF, Flic 1 as well as Flic 2 buttons are supported.

Previous SDK

Previously we had an implementation for Linux that made use of the Bluez bluetooth stack. There were several complications however about that one. The first is that all the BLE functionality is marked as experimental, meaning you have to compile and run a specialized version of Bluez. The other one is that there are breakages between different Bluez versions. The third reason is that we find many things unintuitive and problematic with their current BLE implementation that currently makes it unusable for the Flic concept. Therefore we have decided to change to a new approach.

High level description

This library is built on top of the HCI_CHANNEL_USER capability of the Linux kernel. This gives the library an exclusive access to directly access the bluetooth controller, which means no Bluetooth stack (like Bluez) is needed on the host side. This way we can (hopefully) guarantee stability compared to other solutions but also optimize the protocol to only exchange the packets that are needed for the Flic buttons to communicate. The downside however is that you will not be able to use that dedicated bluetooth controller for other bluetooth connections, such as streaming audio. If you need to use bluetooth for something else, you can always plug in an extra bluetooth dongle and dedicate that for Flic instead. The library consists of a client - server solution. The server is a software that runs and interacts with the bluetooth controller to connect to Flic buttons. Client programs can connect to this server using a simple well-documented API over a TCP socket to scan and connect Flic buttons and get their button events.

What's included

  • flicd - This is the central daemon that manages all buttons. Run it with ./flicd -f flic.sqlite3
  • clientlib/java - A library that implements the protocol that should be very easy to use. Two example programs are included as well. Open it up in IntelliJ.
  • clientlib/python - A library for python 3.3 or higher, very similar to the Java library. Some example programs included.
  • clientlib/websocket - A websocket proxy and a demo client in html/javascript which you can use to scan and connect buttons.
  • clientlib/nodejs - A library for nodejs and examples.
  • clientlib/csharp - A library for C# with a GUI example that uses Windows Forms.
  • simpleclient - A simple command line client with source code that can be used to test the protocol.
  • client_protocol_packets.h - C/C++ structs for all packets that can be included in a C/C++ program.

Supported platforms

Binaries and libraries has been compiled for x86_64, i386 and armv6l. The minimum Linux kernel supported is 3.13. All code has been compiled and tested on Ubuntu 15.10 for desktop and Raspbian Jessy. This means it should be compatible with desktop systems and Raspberry Pi 1, 2 & 3. I have tried to make the binaries as portable as possible.

If you have compiled your own kernel you must make sure to include support for Bluetooth. In kernel config, enable at least Networking support -> Bluetooth subsystem support -> Bluetooth device drivers -> HCI USB driver and HCI UART driver.

Bluetooth controllers

All Bluetooth controllers with support for Bluetooth 4.0 and Bluetooth Low Energy (Bluetooth Smart) that have Linux support should work. Generally small cheap USB dongles seem to have shorter range than those integrated inside computers. We have tested compatibility with some common Bluetooth controllers. The following devices have been tested and confirmed:

Plugable USB Bluetooth 4.0 Low Energy Micro Adapter / Asus USB-BT400 (Broadcom BCM20702 Bluetooth 4.0)

  • Supports 14 concurrent connections and in total 32 pending connections.

Cambridge Silicon Radio CSR8510 A10 based controllers (Bluetooth 4.0)

  • Supports 5 concurrent connections and in total 25 pending connections.

Raspberry Pi 3 model B (Broadcom BCM43438 Bluetooth 4.1)

  • Supports 10 concurrent connections and in total 128 pending connections.

Intel Centrino Advanced-N 6235 (Bluetooth 4.0)

  • Supports 3 concurrent connections and in total 25 pending connections.

Intel Wireless 7260 (Bluetooth 4.0)

  • Supports 7 concurrent connections and in total 32 pending connections.

IMC Networks Atheros AR3012 Bluetooth (Bluetooth 4.0)

  • Supports 10 concurrent connections and in total 128 pending connections. Can be a bit buggy sometimes, like dropping and duplicating BLE packets. Also sometimes "forgets" to disconnect a BLE link when instructed to. Should however work ok in most cases.

Sena Technologies Parani-UD100-G03 (Cambridge Silicon Radio, Bluetooth 4.0)

  • Supports 5 concurrent connections and in total 25 pending connections. This one is recommended if you need large range. Other budget bluetooth dongles seem to have very short range. Note that the BLE part of the Microsoft Windows driver for this controller currently does not work, in case you are using https://github.com/50ButtonsEach/fliclib-windows.

Quick start

Packages

There are no dependencies except the standard C/C++ libraries, which should be installed by default on most Linux distributions.

Running

It might be a good idea to disable a currently running bluez daemon (bluetoothd) to avoid interference, although not necessary. To see if it's running, run ps aux | grep bluetoothd. If it's running, try to disable it through the system's tools service bluetooth stop or systemctl stop bluetooth on Ubuntu, or just kill the process.

The server process needs to have access to the Bluetooth HCI channel. There are two ways to get this. Either run the daemon as root or give the process permissions by executing sudo setcap cap_net_admin=ep ./flicd which enables you to run it later as a normal user.

Now start the daemon in one terminal by executing ./flicd -f flic.sqlite3. Additional options are listed if you leave out the database argument.

In another terminal open the simpleclient directory, compile it with make and run with ./simpleclient localhost. You will be shown the available commands. Type startScanWizard and press enter to scan and add a button. Then press and hold down your flic button (and make sure it is disconnected to any other devices such as a smartphone) and follow the instructions in the console. After your button has been added, enter the command connect <BDADDR> <id> where <BDADDR> is the address that appeared during scan. For <id>, put any integer that will be used later to refer to this connection. The button should now connect and you will see click events appear. Type disconnect <id> to later disconnect.

You can also try out the websocket example. Run both the daemon and the websocket proxy. Then open up the client html page.

Usage of flicd

Usage: ./flicd -f sqlite_db_file.db [options]


    --help          Prints this text and exits.

-f  --db-file       Sqlite3 db file to use. In this file bonding information is stored for verified Flic buttons.
                    If the file doesn't exist, it is created.
                    
-b  --my-bdaddr     Static random bdaddr to use for the bluetooth controller.
                    Use this optional argument to assign a custom bdaddr instead of using the one burnt-in into the controller.
                    It's useful for scenarios where you want to use previously set up Flic bonding information
                    with a different bluetooth controller. Then simply use the same bdaddr for both controllers.
                    Must be of the form xx:xx:xx:xx:xx:xx (6 hexadecimal numbers) where the first byte is between 0xc0 and 0xff.
                    
    --app-id        App ID for PbF customers.
                    
    --app-secret    App secret for PbF customers.
                    
-s  --server-addr   Server IP address to bind to. 127.0.0.1 is the default which means only clients on this computer
                    can connect to the server. Use 0.0.0.0 if you want the server to be accessible from the outside.
                    
-p  --server-port   Server port to bind to. The default is 5551.
                    
-h  --hci-dev       HCI device to use. The default is hci0.

-d  --daemon        Run flicd as a Linux daemon.

-l  --log-file      Specify a log file name instead of using stderr.

-w  --wait-for-hci  When starting flicd, wait for hci endpoint to become available instead of exiting with failure status.

-n  --no-fw-updates Disable firmware updates. Not recommended.

Troubleshooting

To see the available HCI available bluetooth controllers, run the hciconfig command. If it prints nothing, Linux can't find it. Run dmesg to see if there are any kernel error messages. If for some reason your bluetooth controller is powered off, power it on by executing the sudo bluetoothctl command and in that type power on.

You can also use run sudo btmon - an HCI packet monitor by Bluez, to see exactly what is going on.

Documentation

The full specification for the protocol that is used to talk to the server deamon can be found in ProtocolDocumentation.md.

Documentation for the Java implementation is included as javadoc.

Feedback

Be sure to post a Github issue if you find a bug, something you don't like or if something is wrong or should be changed. You can also submit a Pull request if you have a ready improvement.

License

To allow for easy integration, we have released the source code and documentation under CC0. The flicd binary is released under a separate license which allows you to use it almost without restrictions.

fliclib-linux-hci's People

Contributors

antonmeier avatar claudiapfeiffer avatar emill avatar fabianbergmark avatar frawau avatar mikeboehm avatar snargledorf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fliclib-linux-hci's Issues

Flic client disconnecting

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.

Error Timeout HCI after start of Daemon

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

Best BT dongle for long range

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.

start flicd as a deamon on boot

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 :

  • I have added the following line in rc.local right above exit 0:
    $ /home/pi/Applications/flic/fliclib-linux-hci-master/bin/armv6l/./flicd -d -f flic.sqlite 3 &
  • when I run rc.local manually, it works: flicd is started as a deamon
  • simple scripts in rc.local work on reboot (such as $ "test" > /home/pi/Documents/testrclocal)

crontab

  • I edit the crontab with $crontab -e
  • I add the following line at the bottom:
    $@reboot /home/pi/Applications/flic/fliclib-linux-hci-master/bin/armv6l/./flicd -d -f flic.sqlite 3 &
  • simple scripts in crontab work on reboot (such as date >>/home/pi/Documents/hueapi/hue_server.log

Am I missing something here?
Thanks in advance for your support.

License?

We would like to re(use) examples, libraries and binaries but I cant find any licensing information.
What licence applies to this components?

How to handle events

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

Issue with different Linux version

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

Add a button 'name' field to the database

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.

[Solved] Issue with BCM20702-based dongle

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

Any chance to not take over the bluetooth controller?

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.

Removal of an Already Paired Button?

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 .

publish on npm?

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.

Web Bluetooth lib

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?

Add Battery level to messages

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? :-(

Support earlier Linux versions with HCI_CHANNEL_RAW

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).

Python fliclib.ScanWizard() not receiving events from MacOS FlicServiceBeta

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?

Connection refused when connecting from other IPs

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?

le_set_scan_enable_handler Assertation '!status' failed

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.

Flic working on C.H.I.P

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 :-)

Support for raspbian testing on Raspberry Pi 3?

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?

problem with one button

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?

Has anybody tried to implement LIFX ?

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 ?

Health checking

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!

running on Synology 415play

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?

Good call on moving away from bluez

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.

Mac OS Implementation

Hi,

Wondering if this can be installed on macOS. Have downloaded the flic linux dependencies. Down have linux running on mac though.

Thanks

Websocket client

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?

node client retry connection to daemon

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...

Emptying the stream of events

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.

Optionnaly Disable Double Click when connecting to a button

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.

button led & color

Hi,
is there any way to:

  1. control (actuate) the LED on the flic button?
  2. get the actual external color of the button (since i noticed that the android app actually shows the correct button color!)

Both (especially no.1 obviously) would greatly improve the end user experience!
thanks,
Nikos

Stop / Restart daemon?

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.

Logging to stdout

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.

Handling ButtonHold correctly

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:

  1. Single click
  2. Double click
  3. Button Hold (without any other event fired on release)

and low level callbacks

  1. Button Down
  2. Button Up (incl. the Time the button was pressed)

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.

Node Red Node updated for flic button

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.

Battery Lasts only a few weeks

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.

Source for flicd?

Providing source code for flicd would be great!

  • Allow users to write single purpose programs without needing to keep a server running.
  • Could build flicd for arm7 or aarch64.
  • Could build with an up-to-date libcurl (Currently fails to run on arch with libcurl.so.4: version CURL_OPENSSL_3' not found`)
  • Audit the source code, suggest security and performance improvements
  • Use GitHub for its intended purpose ;)

Publish clientlibs in the proper package repositories

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

Disconnected BondingKeysMismatch

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

Can the api utilize the IFTTT integration?

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.

Really pleased so far

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.

Pairing procedure with simpleclient needs fixes or clarifications, and some suggestions.

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:

  1. run simpleclient to "connect" all the buttons, which adds them all to the flicd database. I should be able to do this with a brand-new button by just typing "connect" and clicking the button (and if it doesn't work, I should ideally get an explanation of why not and what to do about it)
  2. quit simpleclient and fire up my own client. The state of each button and the fact they're connected to flicd is unaffected by quitting simpleclient.
  3. when I press one of my previously connected buttons, have the press registered by flicd and reported to my client.
  4. Have all this continue to work after reboot, without having to manually reconnect the buttons, because the list of connected buttons is stored in the flicd SQLlite database, and because each button remembers which device they're connected to.

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.

  1. More detail on what the various commands in simpleclient do, and how they relate to the actions in the phone app: "forceDisconnect", is that the same as delete? I have no idea, but the app is quite understandable so drawing an analogy between that and the CLI would help.
  2. When you type a command in simpleclient, I'm unclear if it's worked. If I enter a bad command I get no response, not an error message. If I enter the right command, do I always get a response? I'm not sure. Even just "OK" and "ERROR" would help here.
  3. I have no idea how the state machine of these buttons works. Are they always scanning for the device they're connected to, or only when I press the button? The pulsing glow, does it mean they are not connected or the device they're connected to is out of range?
  4. When I quit flicd, it brings down my local hci0 device. This is annoying (particularly if I'm quitting to run "hcitool lescan"). Can I suggest if hci0 is left in the same state it was when flicd starts - if flicd brings the device up, it can bring it down, but if it was already up it is left unchanged.
  5. Finally, a suggestion - if you're going to require a user-identifiable ID for each button when connecting, how about making it a string? That way I can do "connect XXX green" and give the button an identifier I can recognise, rather than just a number. I'm not clear if these identifies are part of the client protocol or not - if they are, I appreciate this might require a change. If not, why do we need them at all?

Deleting a button from SQLite DB (Python3)

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.