• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Trouble scanning for peripherals - iOS 8 + Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Trouble scanning for peripherals - iOS 8 + Swift


  • Subject: Trouble scanning for peripherals - iOS 8 + Swift
  • From: Peter Watkins <email@hidden>
  • Date: Thu, 25 Sep 2014 20:26:11 -0700

I wrote a dirt-simple single view app to scan for peripherals and NSLog them. LightBlue sees the peripheral, by the way. This is on an iPhone 5s running iOS 8.0.

CoreBluetooth goes to the PowerOn state and start the scan, but didDiscoverPeripheral is never called. Everything is in my view controller, so here's the entire code: Any idea why didDiscoverPeripheral is never called? Did I miss something obvious?

import UIKit

import CoreBluetooth


class ViewController: UIViewController, CBCentralManagerDelegate {

    

    var centralManager: CBCentralManager!


    override func viewDidLoad() {

        super.viewDidLoad()

        // Do any additional setup after loading the view, typically from a nib.

        

        self.centralManager = CBCentralManager(delegate:self, queue:nil)

    }

    

    func centralManagerDidUpdateState(central: CBCentralManager!) {

        NSLog("\(central.state)");

        

        if (central.state == CBCentralManagerState.PoweredOn) {

            centralManager.scanForPeripheralsWithServices(nil, options:[CBCentralManagerScanOptionAllowDuplicatesKey:true])

        }

    }

    

    func didDiscoverPeripheral(peripheral: CBPeripheral!, advertisementData: [NSObject : AnyObject]!, RSSI: NSNumber!) {

        NSLog("Discovered \(peripheral.description)")

    }


    override func didReceiveMemoryWarning() {

        super.didReceiveMemoryWarning()

        // Dispose of any resources that can be recreated.

    }

}


Thanks,

Peter
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Trouble scanning for peripherals - iOS 8 + Swift
      • From: Tian Zhang <email@hidden>
  • Prev by Date: Can't connect to peripheral from Background in iOS 8
  • Next by Date: Re: Trouble scanning for peripherals - iOS 8 + Swift
  • Previous by thread: Can't connect to peripheral from Background in iOS 8
  • Next by thread: Re: Trouble scanning for peripherals - iOS 8 + Swift
  • Index(es):
    • Date
    • Thread