I'm not sure what you mean by 'return to setScan'?
What you're doing seems like it'll cause big problems though. setScan's callback can get called really often - probably several times a second for every device - so that'd mean that setState could get called really often, which would probably cause issues as each NRF.connect will take a few seconds to complete
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I'm not sure what you mean by 'return to setScan'?
What you're doing seems like it'll cause big problems though. setScan's callback can get called really often - probably several times a second for every device - so that'd mean that
setState
could get called really often, which would probably cause issues as eachNRF.connect
will take a few seconds to complete