Skip to content

Commit

Permalink
Quick cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
robbiet480 committed Sep 18, 2016
1 parent b69f564 commit 1840902
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 91 deletions.
2 changes: 1 addition & 1 deletion HomeAssistant.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@
B6F02BEC1CB46E810029ABE7 /* HA API Responses */,
B6F02BE81CB46AF40029ABE7 /* Entity.swift */,
B6767A501D0234E700F2A08B /* SwitchableEntity.swift */,
B62A679F1D80E933009E46F9 /* IdentifyRequest.swift */,
);
name = Classes;
sourceTree = "<group>";
Expand All @@ -832,7 +833,6 @@
B6F02BFB1CB4800C0029ABE7 /* Services.swift */,
B66428111CF7A83200903804 /* PushConfiguration.swift */,
B6FBE3961D46A4E500EE0E36 /* Beacons.swift */,
B62A679F1D80E933009E46F9 /* IdentifyRequest.swift */,
);
name = "HA API Responses";
sourceTree = "<group>";
Expand Down
90 changes: 0 additions & 90 deletions HomeAssistant/HAAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -916,96 +916,6 @@ class Bonjour {

}

class Location {
let locationManager = CLLocationManager()
init(){
locationManager.requestAlwaysAuthorization()
locationManager.delegate = LocationDelegate()
if let uuid = NSUUID(uuidString: "B9407F30-F5F8-466E-AFF9-25556B57FE6D") {
let beaconRegion = CLBeaconRegion(proximityUUID: uuid as UUID, identifier: "iBeacon")
beaconRegion.notifyOnEntry = true
beaconRegion.notifyOnExit = true
locationManager.startMonitoring(for: beaconRegion)
// locationManager.startRangingBeaconsInRegion(beaconRegion)
locationManager.requestState(for: beaconRegion)
}
}
}

class LocationDelegate: NSObject, CLLocationManagerDelegate {

func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
print("Auth status", status)
// if status == .AuthorizedAlways {
// if CLLocationManager.isMonitoringAvailableForClass(CLBeaconRegion.self) {
// if CLLocationManager.isRangingAvailable() {
// let uuid = NSUUID(UUIDString: "B9407F30-F5F8-466E-AFF9-25556B57FE6D")!
// let beaconRegion = CLBeaconRegion(proximityUUID: uuid, major: 60042, minor: 43814, identifier: "MyBeacon")
//
// manager.startMonitoringForRegion(beaconRegion)
// manager.startRangingBeaconsInRegion(beaconRegion)
// }
// }
// }
// switch status {
// case .Denied, .Restricted:
// let err = LocationError.AuthorizationDidChange(newStatus: status)
// self.cancelAllGeographicLocationMonitors(err)
// break
// case .AuthorizedAlways, .AuthorizedWhenInUse:
// self.startAllPendingGeographicLocationMonitors()
// break
// default:
// break
// }
}

func locationManager(_ manager: CLLocationManager, didDetermineState state: CLRegionState, for region: CLRegion) {
print("State determined for region", region.identifier, "is", state)
// if let request = self.monitoredGeoRegions.filter({ request in request.region == region }).first {
// switch state {
// case .Inside:
// request.onRegionEntered?()
// case .Outside:
// request.onRegionExited?()
// default:
// break
// }
// }
}

func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {
print("Region entered!", region.identifier)
}

func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) {
print("Region exited!", region.identifier)
}

func locationManager(_ manager: CLLocationManager, monitoringDidFailFor region: CLRegion?, withError error: Swift.Error) {
print("Monitoring failed for region", region!.identifier, "with error", error)
}

func locationManager(_ manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], in region: CLBeaconRegion) {
print("didRangeBeacons", beacons, "for region", region.identifier)
// if let request = self.monitoredBeacons.filter({request in return request.beaconRegion == region}).first {
// request.onRangeDidFoundBeacons?(beacons)
// }
if beacons.count > 0 {
print("Got beacons", beacons)
} else {
print("No beacons found!")
}
}

func locationManager(_ manager: CLLocationManager, rangingBeaconsDidFailFor region: CLBeaconRegion, withError error: Swift.Error) {
// if let request = self.monitoredBeacons.filter({request in return request.beaconRegion == region}).first {
// request.onRangeDidFail?(LocationError.LocationManager(error: error))
// self.stopMonitorForBeaconRegion(request)
// }
}
}

enum LocationUpdateTypes {
case RegionEnter
case RegionExit
Expand Down

0 comments on commit 1840902

Please sign in to comment.