Flic Home

    Community

    • Login
    • Search
    • Popular
    • Users

    Unable to Get RSSI from Flic 2 Using fliclib-linux-hci on Raspberry Pi

    Developers
    2
    3
    53
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Wand7698
      Wand7698 last edited by

      I’m working with a Flic 2 button and a Raspberry Pi Zero 2 W, using the fliclib-linux-hci Git SDK.

      I successfully built my own Debian package from the SDK and installed it on the Pi:

      Package:
      flicd_1.0-1_arm64.deb

      The daemon installs and runs correctly. Below is the systemd service I’m using:

      cat /etc/systemd/system/flicd.service

      [Unit]
      Description=Flic Button Daemon
      After=bluetooth.target
      Requires=bluetooth.target

      [Service]
      Type=simple
      ExecStart=/usr/bin/flicd -f /var/lib/flicd/flic.sqlite3
      Restart=always
      RestartSec=3
      User=root

      [Install]
      WantedBy=multi-user.target

      Pairing and button events work fine, so communication with the button is confirmed.

      Issue

      I’m trying to read RSSI (signal strength) from the Flic 2 button, or otherwise estimate distance between the Pi and the button.

      I’ve tried multiple code variants (both modifying the SDK and external BLE approaches), but I’m unable to retrieve:

      RSSI values

      Any distance-related data

      It seems like RSSI is either not exposed through the SDK, or not available during normal operation.

      Questions

      Is RSSI data available at all from Flic 2 via fliclib-linux-hci?

      If not, is there an alternative supported way to estimate proximity or distance?

      Does the Flic firmware intentionally block RSSI access for power or privacy reasons?

      Has anyone successfully retrieved RSSI from a Flic 2 on Linux/Raspberry Pi?

      Any guidance, confirmation, or examples would be greatly appreciated.
      Thanks in advance!

      1 Reply Last reply Reply Quote 0
      • Wand7698
        Wand7698 @Emil last edited by

        @Emil Ya it be a great help write now i am using a python progame on pi to run 24/7 to recive signal for flic device i have provide the code below

        #!/usr/bin/env python3
        import fliclib
        from datetime import datetime
        
        button_rssi = {}
        
        def now_ts():
            return datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
        
        # Advertisement RSSI (best-effort)
        def on_advertisement_packet(scanner, bd_addr, name, rssi, is_private,
                                   already_verified, already_connected_to_this_device,
                                   already_connected_to_other_device):
            button_rssi[bd_addr] = rssi
            print(f"{now_ts()} ADV {bd_addr} RSSI={rssi} dBm")
        
        def on_button_event(channel, click_type, was_queued, time_diff):
            click_name = str(click_type).split(".")[-1]
            rssi = button_rssi.get(channel.bd_addr, "N/A")
            print(f"{now_ts()} BUTTON {channel.bd_addr} {click_name} RSSI={rssi}")
        
        def got_button(bd_addr):
            print(f"{now_ts()} Found verified button {bd_addr}")
            cc = fliclib.ButtonConnectionChannel(bd_addr)
            cc.on_button_single_or_double_click_or_hold = on_button_event
            client.add_connection_channel(cc)
        
        # ---- MAIN ----
        client = fliclib.FlicClient("localhost")
        #scanner = fliclib.ButtonScanner(client)
        scanner = fliclib.ButtonScanner()
        scanner.on_advertisement_packet = on_advertisement_packet
        client.add_scanner(scanner)
        client.on_new_verified_button = got_button
        client.handle_events()
        dietpi@DietPi:~$ 
        
        1 Reply Last reply Reply Quote 0
        • Emil
          Emil FlicTeam last edited by

          If you want to get the RSSI value on a connected button, we must send a HCI command to the Bluetooth controller and ask to get the latest value. Do you have a suggestion for how such an API should look like from the client side?

          Wand7698 1 Reply Last reply Reply Quote 0
          • First post
            Last post