Home › Forums › Ask the Flomies › Start and stop FloBle reader
Tagged: FloBLE Plus
-
AuthorPosts
-
July 12, 2018 at 9:29 am #63404
I have a screen with a few buttons. I only want the reader to start detecting tags on selection of a button. That button will then call a function and stop the reader thereafter.
When I initialise flomioSDK in my viewDidLoad, it starts reading straight away i.e. before I call startReaders(). Is there any way to avoid this?
I need to be able to toggle on and off the polling and detection of tags depending on user button press
import FlomioSDKPro class TestVC: UIViewController { lazy var flomioSDK : FmSessionManager = FmSessionManager() lazy var defaultConfiguration: FmConfiguration = FmConfiguration() override func viewDidLoad() { super.viewDidLoad() defaultConfiguration = FmConfiguration() defaultConfiguration.deviceType = .kFloBlePlus defaultConfiguration.transmitPower = .highPower defaultConfiguration.scanSound = true defaultConfiguration.scanPeriod = 1000 defaultConfiguration.powerOperation = .autoPollingControl defaultConfiguration.allowMultiConnect = false self.flomioSDK = FmSessionManager.init(configuration: self.defaultConfiguration) self.flomioSDK.delegate = self } @IBAction func startScan(_ sender: UIButton) { self.flomioSDK.startReaders() } func stopScan(){ //stuff and things, network call self.flomioSDK.stopReaders() } }
- This topic was modified 6 years, 4 months ago by Roseanne.
July 12, 2018 at 9:51 am #63406Hi Roseanne,
There’s no default way to do this. You will have to call
stopReaders
when theCommunicationStatus
iskScanning
the first time.July 12, 2018 at 10:37 am #63407Hi Scott,
I added the following to the FMSessionManagerDelegate:
func didChange(_ status: CommunicationStatus, fromDevice device: String!) { switch status { case .scanning: if first { flomioSDK.stopReaders() first = false } default: break } }
and this had no effect i.e. The findtag is still called before I press the button to call startReaders, is there a different delegate, I need to add this method into?
July 13, 2018 at 3:59 pm #63411Ok, that was worth trying. Maybe try delaying the stopReader call until the connection event settles. Dealing with the as asynchronous nature of the reader can sometimes cause issues like this.
Let me know if that works for you, wish there was a cleaner solution I could recommend.
-
AuthorPosts
You must be logged in to reply to this topic.