50ButtonsEach / flic2lib-android

Flic2 SDK for Android
Other
17 stars 8 forks source link

NO_NEW_BUTTONS_FOUND #11

Open arlomedia opened 3 years ago

arlomedia commented 3 years ago

I've implemented the Flic 2 library as shown in the tutorial. After scanning for buttons, Flic2ScanCallback.onComplete() always returns result 4, or RESULT_FAILED_NO_NEW_BUTTONS_FOUND.

I started with the button new out of the box and this happened, then I installed the latest Flic app and paired the button with that and it still happened. I can see the button light turn green and hear the Flic app beep when I press the button, so it is successfully connected to the Flic app, but my app doesn't connect to it.

I do have the FINE_LOCATION permission, and I don't see anything interesting in the console. Here's the console output from the moment I run Flic2Manager.startScan():

D/onItemClick: do action connectFlic2Button D/BluetoothAdapter: isLeEnabled(): ON D/BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=8 mScannerId=0 D/BluetoothAdapter: isLeEnabled(): ON D/BluetoothAdapter: isLeEnabled(): ON D/BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=8 mScannerId=0 D/BluetoothAdapter: isLeEnabled(): ON D/BluetoothAdapter: isLeEnabled(): ON D/BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=8 mScannerId=0 D/BluetoothAdapter: isLeEnabled(): ON D/connectFlic2Button: error 4

My app has over 100 remote controllable functions, so I want to use my existing app interface to assign Flic actions, rather than set up my actions in the Flic app. This is the approach I took with the first-generation Flic buttons and it worked well for my users. I assume I can follow the same approach with Flic 2.

Am I misunderstanding how this is supposed to work? What else could cause the constant NO_NEW_BUTTONS_FOUND error?

Emill commented 3 years ago
  1. Do you have Location turned on in the phone's settings?
  2. Do you hold down the button for at least 7 seconds?
arlomedia commented 3 years ago
  1. Yes.
  2. I did when pairing with the Flic app, when the Flic app told me to. I just did that again when pairing with my app, and then my app connected (Flic2ScanCallback.onComplete() returned 0).

So that's the step I was missing. I didn't see that mentioned in the developer or the user docs, so I'll add an instruction to my app for my users.

I went back and removed the button from the Flic app, and the connection still worked in my app. Does this mean my users don't need to connect the button in the Flic app if they're only using it with my app? Do they need the Flic app installed at all?

Emill commented 3 years ago

The document https://github.com/50ButtonsEach/flic2-documentation/wiki/Technical-Overview-and-Terminology states that you need to hold down the button. We will update the readme here to remind developers of this.

Your users don't need to have the Flic app installed. In fact, the Flic app uses this library just like any other app would.

arlomedia commented 3 years ago

Thanks for clarifying. That document is helpful -- linking to that document the ReadMe would be nice.

arlomedia commented 3 years ago

P.S. While updating the ReadMe, another suggestion is to clarify what steps need to be repeated when the app restarts. Currently it says, "When the application starts, the buttons are always in the disconnected state, and you need to explicitly call connect on the buttons you want connected." But that part is easy to miss at the bottom of the section, and doesn't mention recreating the listeners, which my app also needed to do.

nckshr commented 3 years ago

P.S. While updating the ReadMe, another suggestion is to clarify what steps need to be repeated when the app restarts. Currently it says, "When the application starts, the buttons are always in the disconnected state, and you need to explicitly call connect on the buttons you want connected." But that part is easy to miss at the bottom of the section, and doesn't mention recreating the listeners, which my app also needed to do.

Agreed, the readme could be more clear in terms of the connection process, especially for those of us coming from Flic1 where the flic app was required and there was the whole "grabbing" process that needed to happen that is now obsolete. The code examples are great, having at least some sort of explanation of the process or a link to one would make it even better. I was able to get up and running with Flic2 (after successfully working with the original Flic library) only after reading this thread.