Skip to content

Commit

Permalink
Implements swift start(). Refs #37.
Browse files Browse the repository at this point in the history
  • Loading branch information
gradha committed Jun 2, 2015
1 parent 0d17117 commit 684d839
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/Er recorder adhoc-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
// Use this file to import your target's public headers that you would like to expose to Swift.
//


#import "DB.h"
1 change: 1 addition & 0 deletions src/Record_my_position-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
// Use this file to import your target's public headers that you would like to expose to Swift.
//

#import "DB.h"
2 changes: 2 additions & 0 deletions src/Record_my_position_appstore-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
// Use this file to import your target's public headers that you would like to expose to Swift.
//


#import "DB.h"
30 changes: 26 additions & 4 deletions src/SGPS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ enum Accuracy
private var mGpsIsOn = false
private var mManager: CLLocationManager
private var mAccuracy: Accuracy
private var mNoLog = false

static func get() -> SGPS
{
Expand Down Expand Up @@ -69,14 +70,14 @@ enum Accuracy
}
}

func start()
func stop()
{
println("Starting!")
println("Stopping, not implemented!")
}

func stop()
func pingWatchdog()
{
println("Stopping")
println("Pinging watchdog, not implemented!");
}

/** Converts a coordinate from degrees to decimal minute second format.
Expand Down Expand Up @@ -110,4 +111,25 @@ enum Accuracy
return String(format: "%ddeg %dmin %0.2fsec %@",
degrees, minutes, seconds, letter)
}

/** Starts the GPS tracking.
* Returns false if the location services are not available.
*/
func start() -> Bool
{
if CLLocationManager.locationServicesEnabled() {
if (!mGpsIsOn && !mNoLog) {
DB.get().log("Starting to update location")
}

pingWatchdog()

mManager.startUpdatingLocation()
gpsIsOn = true
return true
} else {
gpsIsOn = false
return false
}
}
}

0 comments on commit 684d839

Please sign in to comment.