Failed to update position: Error Domain=com.estimote Code=2

Hello All,
We are using the iOS Indoor SDK (from Github), latest version (v2.2.1) for a geoloc project with specifics needs.

iOS version is 9.1 on iPhone 6S.

In fact, we had compiled a Unity3D project (Obj-C), and we add Swift Class into the Objective-C project to control Unity scene movments.
We had also the SDK into project: no problem with that!

We can build the App but we have an issue with localization :slight_smile:
failed to update position: Error
Domain=com.estimote Code=2 "Magnetometer not able to initialize."
UserInfo={NSLocalizedDescription=Magnetometer not able to initialize.}

This class is loaded at the main.mm function, at the beggining of starting code.

See below the simple Swift code…


import UIKit
import AVFoundation@objc class EstimoteSwift: UIViewController, EILIndoorLocationManagerDelegate {
    let locationManager = EILIndoorLocationManager()
    
    var location: EILLocation!
    
    func start() {
        
        NSLog("Hello Start \n");
        
        
        self.locationManager.delegate = self
        
        NSLog("Hello Delegate \n");
        
        let locationBuilder: EILLocationBuilder = EILLocationBuilder()
        
        locationBuilder.setLocationBoundaryPoints([
            EILPoint(x: 0, y: 0),
            EILPoint(x: 0, y: 3.71),
            EILPoint(x: 4.84, y: 3.71),
            EILPoint(x: 4.84, y: 0)
            ]);
        
        NSLog("Hello LocationBuilder \n");
        
        //BLUEBERRY 2
        locationBuilder.addBeaconWithIdentifier("eeeb103116b2",
                                                atBoundarySegmentIndex: 0,
                                                inDistance: 1.67,
                                                fromSide: .LeftSide
        )
        //MINT 1
        locationBuilder.addBeaconWithIdentifier("e3b05df00c70",
                                                atBoundarySegmentIndex: 1,
                                                inDistance: 3.08,
                                                fromSide: .LeftSide
        )
        //ICE 2
        locationBuilder.addBeaconWithIdentifier("c350dfe2a606",
                                                atBoundarySegmentIndex: 1,
                                                inDistance: 0.88,
                                                fromSide: .LeftSide
        )
        //BLUEBERRY 1
        locationBuilder.addBeaconWithIdentifier("da40b8bc0dcc",
                                                atBoundarySegmentIndex: 2,
                                                inDistance: 2.08,
                                                fromSide: .RightSide
        )
        //ICE 1
        locationBuilder.addBeaconWithIdentifier("cd12f3916744",
                                                atBoundarySegmentIndex: 3,
                                                inDistance: 2.75,
                                                fromSide: .LeftSide
        )
        //MINT 2
        locationBuilder.addBeaconWithIdentifier("d6aca1c590aa",
                                                atBoundarySegmentIndex: 3,
                                                inDistance: 1.38,
                                                fromSide: .LeftSide
        )
        
        
        locationBuilder.setLocationOrientation(30);
        
        NSLog("Hello LocationBuilderOrientation \n");
        
        self.location = locationBuilder.build()
        self.locationManager.startPositionUpdatesForLocation(self.location)
    }
    
    func indoorLocationManager(manager: EILIndoorLocationManager, didFailToUpdatePositionWithError error: NSError) {
        NSLog("location: %@", self.location.toDictionary());
        print("failed to update position: \(error)")
    }
    

    func indoorLocationManager(manager: EILIndoorLocationManager, 
didUpdatePosition position: EILOrientedPoint, withAccuracy 
positionAccuracy: EILPositionAccuracy, inLocation location: EILLocation)
 {
        var accuracy: String!
        switch positionAccuracy {
        case .VeryHigh: accuracy = "+/- 1.00m"
        case .High:     accuracy = "+/- 1.62m"
        case .Medium:   accuracy = "+/- 2.62m"
        case .Low:      accuracy = "+/- 4.24m"
        case .VeryLow:  accuracy = "+/- ? :-("
        default: break
        }

        print(String(format: "x: %5.2f, y: %5.2f, orientation: %3.0f, 
accuracy: %@", position.x, position.y, position.orientation, accuracy))
        
//        let parameters = [
//            "x": position.x,
//            "y": position.y,
//            "orientation": position.orientation
//        ]
        
    }
}

Someone have an idea please?
thanks very much!

Adrien

Hi Adrien!

“Magnetometer not able to initialize.” - means that the SDK did not receive any updates from the magnetometer. It can be either due to temporary error or permament failure of mangetometer in phone.

To check it:
0. Unplug from the phone any cables.

  1. Make sure the compass app is killed.
  2. Run the compass app.
  3. The calibration circle should appear.
  4. If the compass is working the error was temporary and positioning should run ok. If not it means that unfortunately the magnetometer is broken in your device.

Hope this is just a temporary error!

Hi,
We found this morning…
In fact we add a little timer at the beginning of process… Probably we aked the ressources too soon…

All works fine now!
Hope could help someone;)

-Closed
Adrien