New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bluetooth LE not available or calling scan and/or connect before available #11
Comments
Hi there. In that case your device probably doesn't support Bluetooth LE. Which device do you have? |
I'm using an Iphone 6 and an Ipad 2 |
The iPad 2 doesn't support Bluetooth LE. iPhone 6 does, please ensure that Bluetooth is on. |
Same problem here on iPhone6. Plus, when I'm using the UUID 6E400001-B5A3-F393-E0A9-E50E24DCCA9E , it gives me a nil. |
@cguotju Which error do you get? |
Same problem on iPhone 6 iOS 9.3.1
Error:
|
same problem. iPhone6 iOS 9.3
|
If this is true I should add a completion handler to the start method. Thanks for the information. |
I had this same issue and adding a brief delay also worked! |
@jessepollak |
It looked something like this: let central = BKCentral()
do {
let serviceUUID = NSUUID(UUIDString: "6E6B5C64-FAF7-40AE-9C21-D4933AF45B23")!
let characteristicUUID = NSUUID(UUIDString: "477A2967-1FAB-4DC5-920A-DEE5DE685A3D")!
let configuration = BKConfiguration(dataServiceUUID: serviceUUID, dataServiceCharacteristicUUID: characteristicUUID)
try central.startWithConfiguration(configuration)
let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(2 * Double(NSEC_PER_SEC)))
dispatch_after(delayTime, dispatch_get_main_queue()) {
central.scanContinuouslyWithChangeHandler({ changes, discoveries in
print(discoveries.map { $0.localName } )
}, stateHandler: { newState in
print("State: ", newState)
}, errorHandler: { error in
print("Error from scanning: \(error)")
})
}
} catch let error {
print(error)
} |
@jessepollak |
This isn't what you're supposed to do guys. You need to add yourselves as availability observers before calling start, once the Bluetooth stack is available for use after calling start, you will be notified. Waiting like you propose there is a hack and it is never guaranteed to become available because it relies on the underlying Bluetooth stack. |
In addition, this question has evolved a bit. Originally tastyapp asked why it failed for him, it did so because he was using a device without support for Bluetooth LE. Most of you others are experiencing the same kind of issue because you don't use the availability observation functionality. |
Corrected readme, sorry guys. See commit b5751f1 |
Error from scanning: internalError(Optional(BluetoothKit.BKCentralStateMachine.BKError.transitioning(BluetoothKit.BKCentralStateMachine.State.scanning, [BluetoothKit.BKCentralStateMachine.State.available]))) same problem in 0.4.0 version. Could you please give a hand to this problem. |
Ok i found the problem is still there because you left scan() in viewDidAppear |
@ibrahimuslu Correct. The thing is, it isn't actually a problem, because the error doesn't cause anything to fail. |
Just as @rhummelmose said, we should start scan operation when BLE is available.
|
same issue on iPhone XS Max |
I really appreciate that you share this amazing looking library. I downloaded the example project and ran it on a real device. But there is an issue with the bluetooth "Unsupported" or "Unavailable". The bluetooth on the device is active and the error says:
Error from scanning: InternalError(Optional(BluetoothKit.BKCentralStateMachine.Error.Transitioning(BluetoothKit.BKCentralStateMachine.State.Unavailable(BluetoothKit.BKUnavailabilityCause.Unsupported), [BluetoothKit.BKCentralStateMachine.State.Available])))
If you can help me, I would be thankful
tastyapp
The text was updated successfully, but these errors were encountered: