Closed LateralSolutions closed 8 years ago
I'm getting the same issue. Did you manage to resolve it by any chance?
Hi Guys
You are right 👍 I made a mistake in a sample code and this is the reason for your issue.
KTKDeviceConnection
should be class var or it will be deallocated before reading configuration is complete.
Code should be as follows:
var connection: KTKDeviceConnection?
func devicesManager(manager: KTKDevicesManager, didDiscoverDevices devices: [KTKNearbyDevice]?) {
for device in devices! {
if (device.name == selectedBeacon?.beaconName) {
self.kontaktNearBy = device
kontaktManager!.stopDevicesDiscovery()
self.tableView.reloadData()
connection = KTKDeviceConnection( nearbyDevice: self.kontaktNearBy!)
connection?.connectionTimeout = NSTimeInterval(10)
var config : KTKDeviceConfiguration // = KTKDeviceConfiguration()
var error : NSError
connection?.readConfigurationWithCompletion { config, error in
if (error == nil) {
// OK
//self.tableView.reloadData()
}
}
}
}
}
Please note that next update of the SDK 1.2.1 will allow you to use KTKDeviceConnection
without defining class var so exactly like you are trying to use it now.
Thanks for the update, I moved the KTKDeviceConnection scope to class level as you suggested and the error is now nil on the readConfigurationWithCompletion {} block
However the config is also returned nil, I tried moving that also to the class scope with no luck.
@LateralSolutions I guess you have beacons with firmware 4.0 or newer. If that's the case it explains everything – Kontakt.io SDK currently can't properly read configuration of such beacons. It will get a current config from a beacon, but it doesn't have a way to decrypt it, that's why an error is nil
, same as the configuration.
As far as I know this should be fixed one of the future versions.
OK, I will wait for a future fix. Testing on a 3.1 firmware results in the original error, FW 4.0, Error Nil
Please not this is fixed in 1.2.1
release. Closing issue for now :)
Hi, I can't seem to read the beacon configuration using the following code, It always return an NSError 5.
Here is the code, I've tried this with firmware 3.1 and 4.1 with the same results. The admin App is working.
In AppDelegate.swift Kontakt.setAPIKey(Constants.BeaconAPI.kontakt)
Scanning for devices works and in the delegate I'm trying to read the config however it already returns an error