Giter Site home page Giter Site logo

Comments (6)

troystribling avatar troystribling commented on August 16, 2024

That is the way it is implemented. You can stop the scan anytime after you connect.

from bluecap.

romansavrulin avatar romansavrulin commented on August 16, 2024

@troystribling But the scan is stopped right after discovery. Why the second scan attempt doesn't employ timeout?

from bluecap.

romansavrulin avatar romansavrulin commented on August 16, 2024

@troystribling Quick follow-up sequence

  1. disable the peripheral you are trying to discover
  2. start scanning for it with timeout
  3. you will get timeout as expected
  4. enable the peripheral you are trying to discover
  5. start scanning for it with timeout
  6. you will successfully connect and stop scanning in the future
  7. disconnect
  8. disable the peripheral you are trying to discover
  9. start scanning for it with timeout
  10. you won't get timeout for that discovery attempt

Am I missing something?

from bluecap.

troystribling avatar troystribling commented on August 16, 2024

Did not follow. That sounds like a bug. Start looking here. https://github.com/troystribling/BlueCap/blob/master/BlueCapKit/Central/CentralManager.swift#L212. The code is not that complicated. I do not have the time available now to look into this but will be will ing to accept a PR.

from bluecap.

romansavrulin avatar romansavrulin commented on August 16, 2024

@troystribling Ok, thank you. Will dive into this, once we will be working on new maintenance release of our App

from bluecap.

romansavrulin avatar romansavrulin commented on August 16, 2024

Quick try to fix the timeout inside the library wasn't successful, so I've worked-around this by the following code

 func startDiscovery(uuid:String){

     scanTimeoutTimer = Timer.scheduledTimer(withTimeInterval: 10.0, repeats: false) { _ in
            log.info("Scan timeout has passed")
            if self.manager.isScanning {
                self.manager.stopScanning()
                //trigger timeout event here
            }
            self.scanTimeoutTimer?.invalidate()
        }
                
        let discoveryFuture = manager.startScanning(forServiceUUIDs: [CBUUID(string:uuid)]).flatMap { peripheral -> FutureStream<Void> in
                log.info("scanFuture: Found peripheral UUID: \(peripheral.identifier.uuidString). Trying to connect")
                self.manager.stopScanning()
                self.scanTimeoutTimer?.invalidate()
                return peripheral.connect(connectionTimeout: 10, capacity: 1)
            }
}

from bluecap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.