iOS Telemetry Packets

Hi all,

So Trying to create a iOS application to pick up telemetry packets that are flagged as in motion and then update a DB. I’m also just learning swift and don’t have a real good grasp on the langue just yet. The SDK ReadMe that heyPitor updated on GitHub, explains how to pull the temp from the packet. I’m confused as to

  1. how to enable the Telemetry packets first off?
  2. how to setup the rest of the code to pick up on the motion flag?

I’m using my AppDelegate because the app is doing nothing but seeing the motion flag then updating firebase so I don’t need anything up on screen

class AppDelegate: UIResponder, UIApplicationDelegate, ESTDeviceManagerDelegate  {

    override init() {
        FIRApp.configure()
        FIRDatabase.database().persistenceEnabled = true
    }

    var window: UIWindow?

    lazy var database = FIRDatabase.database()
    let deviceManager = ESTDeviceManager()
    
    // Copied code from ReadMe except I don't need the print() statement
    let movementNotification = ESTTelemetryNotificationMotion { (motion) in motion.motionState}

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        
        //again same as ReadMe code 
        deviceManager.register(forTelemetryNotification: movementNotification)
       
        //updates the Firebase DB
        database.reference().childByAutoId().setValue(movementNotification)
        return true
    }

I don’t think I have the code setup correctly at all, if anyone could help me with this that be greatly appreciated. I was able to do this exact idea with the Nearables but I don’t understand the code for the Telemetry Packets.

Thanks,
DaveM

This:

ESTTelemetryNotificationMotion { (motion) in motion.motionState}

is your handler function for whenever the SDK detects a Telemetry packet. So you need to do the handling here, instead of doing it in the didFinishLaunching method. So I believe you rather need something like:

let movementNotification = ESTTelemetryNotificationMotion { (motion) in 
    database.reference().childByAutoId().setValue(motion.motionState)
}
deviceManager.register(forTelemetryNotification: movementNotification)

As for enabling the Telemetry packet, you can do that with the Estimote iOS/Android app.