General Puck connection question.

Posted on
  • Hello,

    I am new to the Puck-js world, so far I am very impressed with how it all works and have been able to accomplish most tasks but I am struggling to get it to stay connected in the background of an android app.

    GOAL: Keep the puck alive in the background and update a characteristic on button press (from the puck) to trigger an event. Essentially using the puck as a panic button. All of the functionality works up until the point where it has been anywhere from minutes to an hour after the first connection (while the app is in the background) that it disconnects and the app no longer sees any characteristic changes.

    QUESTION: Is this possible? Can I keep the puck connected to the app indefinitely while the app is running in the background on my phone (android or IOS)

    Any direction on this would be greatly appreciated, Thanks!

  • Yes, that should all be fine - Gadgetbridge handles that great with Bangle.js for example.

    What you may be hitting is actually your phone's power saving. It can be super aggressive and is the biggest cause of issues with Gadgetbridge. So much so that someone made a nice website with instructions for how to try and make it work on specific phone types:

    Having said that, sometimes you may well get a disconnect - maybe someone has a badly sealed microwave oven on and it basically makes the 2.4ghz radio band unusable while it's on, or they leave the Puck behind and it goes out of range for a bit. So your app will have to handle the disconnect event and reconnect.

    One way to maybe help with that without having to fiddle with your app is to make your Puck a HID device (eg a keyboard) using something like - it could then send out a fake keypress which maybe your app would be able to handle.

    By making the Puck look like a keyboard, Android will then 'take ownership' of it, so it should then automatically reconnect whenever it sees the device.

  • Awesome! Thanks for the quick reply, I will dive right in and try.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

General Puck connection question.

Posted by Avatar for yewcode @yewcode