Problem: didDiscoverDevices() function of ESTDeviceManager returns null “devices” array
Background: I’m trying to gather temperature and ambient light sensor info from multiple beacons (using Swift)
Info: I’m pretty sure I’m using the beaconManager class correctly, and am using the startDeviceDiscoveryWithFilter() to search for a particular beacon. However, when the didDiscoverDevices function fires, it returns a null “devices” array. I think there are two possible scenarios:
Scenario 1: startDeviceDiscoveryWithFilter() did not find any beacons (or I inputted the beacon identifier incorrectly for the filter, but these would have the same outcome). Shouldn’t this fire the deviceManagerDidFailDiscovery() function if it doesn’t find any beacons matching the filter?
Scenario 2: startDeviceDiscoveryWithFilter() found the beacon, but is not passing their info to the “devices” array in the didDiscoverDevices() function, resulting in “devices” being a null array
Here is my code for AppDelegate.swift:
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, ESTDeviceManagerDelegate, UIApplicationDelegate {
var window: UIWindow?
var deviceManager: ESTDeviceManager!
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
/*(My setupAppID function is correct in my actual code, but the values are replaced with "[redacted]" here for privacy) */
ESTConfig.setupAppID("[redacted]", andAppToken: "[redacted]")
self.deviceManager = ESTDeviceManager()
print("created device manager")
self.deviceManager.delegate = self
print ("set device manager delegate to self")
//the filter identifier is correct in my actual code, replaced with [redacted] here for privacy. I used the "identifier" value from the beacon on the Estimote Cloud site.
print("creating filter for identifier")
let filter = ESTDeviceFilterLocationBeacon(identifier: “[redacted]”)
print("starting device discovery with filter")
self.deviceManager.startDeviceDiscoveryWithFilter(filter)
return true
}
//no devices found
func deviceManagerDidFailDiscovery(manager: ESTDeviceManager) {
print("discovery failed!")
}
//device discovery
func deviceManager(manager: ESTDeviceManager, didDiscoverDevices devices: [ESTDevice]) {
print("Discovered devices!")
print(devices)
}
}
The app builds and runs fine on my iPhone from XCode, and all the outputs are correct up until the didDiscoverDevices. The Estimotes are also verified to work, as they work fine with the other apps I’ve tested today.
The output from the didDiscoverDevices() function looks like this:
Discovered devices!
[ ]
Discovered devices!
[ ]
Discovered devices!
[ ]
etc. etc., repeating for the set interval.
Is there something wrong with my code? Or is this a bug with the ESTDeviceManager class or its didDiscoverDevices() and startDeviceDiscoveryWithFilter() functions?
Thanks in advance!