ios - CoreBluetooth : only discovering one peripheral whereas the native bluetooth feature discovers three -
i'm implementing os x app uses bluetooth connect raspberry pi. problem app can't discover rpi whereas can see on mac's native bluetooth panel. app discovers 1 device has "null" name ( whereas every devices can see on mac's bluetooth panel have name ).
any idea problem ?
here implementation of bluetooth manager singleton :
static let sharedinstance = knkbluetoothmanager() var centralmanager : cbcentralmanager! var remoteperipheral : cbperipheral? var bluetoothready = false func startupcentralmanager() { print("initializing central manager") centralmanager = cbcentralmanager(delegate: self, queue: nil) } func discoverdevices() { print("discovering devices") centralmanager.scanforperipheralswithservices(nil, options: nil) } func centralmanager(central: cbcentralmanager, diddiscoverperipheral peripheral: cbperipheral, advertisementdata: [string : anyobject], rssi: nsnumber) { print("discovered \(peripheral)") if (peripheral.name == "rpi") { self.remoteperipheral = peripheral self.centralmanager.stopscan() self.remoteperipheral?.delegate = self centralmanager.connectperipheral(peripheral, options: nil) } } func centralmanagerdidupdatestate(central: cbcentralmanager) { print("checking state") switch (central.state) { case .poweredoff: print("corebluetooth ble hardware powered off") bluetoothready = false case .poweredon: print("corebluetooth ble hardware powered on , ready") bluetoothready = true; case .resetting: print("corebluetooth ble hardware resetting") case .unauthorized: print("corebluetooth ble state unauthorized") case .unknown: print("corebluetooth ble state unknown"); case .unsupported: print("corebluetooth ble hardware unsupported on platform"); } if bluetoothready { discoverdevices() } }
the diddiscoverperipheral
method finds same peripheral :
discovered <cbperipheral: 0x6080000aada0 identifier = 36844111-01e4-4d00-926b-aaf089c04305, name = "(null)", state = disconnected>
it's pointing out fact have same problem same implementation on ios app ( using iphone 5 ).
Comments
Post a Comment