Closed jkichline closed 4 years ago
Ok this is strange, but I think I understand what is going on. The scanner will automatically stop once you have either discovered a button, or if it times out. You do not need to (and should not) call stopScan inside the completion handler. However, I would consider it a bug (in the framework) that it is allowed to call stopScan even after it has completed.
So what I thin is happening (please confirm) is that you call stopScan inside the completion handler, but calling stopScan then generates another completion with the code FLICButtonScannerErrorCodeUserCanceled
. Thus this will result in an infinite loop of completion handler -> stopScan. Am I correct?
That sounds like what is happening. I guess it's not clear that it stops scanning once it's completed and not a continual scan. So I'll just need to update the UI (the method I'm calling is updating the UI and also calling stopScan). So yes, it may be good to just ignore a stop scan and not call a completion handler.
Ok good. Yes, it is one scan for one Flic only. But I will fix it so that the framework will not send more than one completion per each scan, to avoid similar issues in the future. Thanks for your help!
Thanks! Also, I haven't heard back fro Ludvig on this... but can you add to the documentation how to physically reset the pairing on the Flic? For instance, if the host iOS device disappears completely, how can I use the Flic on a different device? I had thought it involved removing the battery, pressing the buttons etc... we just need to know to let users know. Thanks!
A Flic 2 button can have pairings with multiple devices at the same time. I can't remember exactly how many, but it is more than 10. So, if you need to use the Flic 2 with a different iOS device then you can just press and hold it for 6 seconds and it will be discovered in the scan by the new phone.
However, if you for some reason really need to reset a button (delete all pairings) then you can do so by removing the battery. Then insert the battery again and within 5 seconds press down on the Flic and keep it pressed for at least 10 seconds. However, we never recommend this to our users, since the pairings on the Flic are in a circular buffer, so you will always be able to add new pairings.
Is there a particular case where this is not working for you?
That's great info. We will test that out. Just need to let people know if they ask, etc.
I'm working on troubleshooting the discovery and connection process because it was appearing that once one Flic is found and paired/cancelled, that this method would not find anymore Flics. So after I hear back from the completion handler, I'm calling stopScan. This is then repeatedly calling the completion handler every few milliseconds with the FLICButtonScannerErrorCodeUserCanceled error code.
It's not clear in the documentation if scanForButtons should continually scan for buttons until it's stopped, but right now it appears to find one and then done... it just stops working. If I attempt to stop the scan, it then throws errors out the wazoo and still doesn't work and doesn't let me restart scanning.