     (.startService context intent)
     (toast activity "Started GPS" :long)))
 
-
 ;; Send Data
 
-
-(defn send-chunk [a-chunk]
-  (let [body (pr-str (assoc {} :coords a-chunk))]
+(defn send-chunk [endpoint secret-key a-chunk]
+  (let [body (pr-str (assoc {} :coords a-chunk
+                               :password (str secret-key)))]
     (def resp
-      (future (client/post "http://10.0.0.6:3000/api/routes/"
+      (future (client/post (str endpoint)
                            {:body body
                             :content-type :edn
                             :socket-timeout 10000

  (:import com.benbrittain.petrarch.GPSbackground)
  (:import android.widget.TextView)
  (:import [android.content Context]))


;; GPS Service Control

(defn stop-background-gps [context activity]

                            :accept :edn})))))

(defn send-data [context activity]
  (let [^TextView secret-key (.getText (find-view activity ::secret-key))
        ^TextView endpoint (.getText (find-view activity ::endpoint))
        file-name (str (.dataDir (.getApplicationInfo context)) "/files/gpsdata.edn")]
    (do
      (stop-background-gps context activity)
      (with-open [rdr (clojure.java.io/reader file-name)]
        (doseq [lines (partition-all 50 (line-seq rdr))]
          (send-chunk endpoint secret-key (->> lines
                                               (map #(read-string %))))))
      (toast activity "Sent GPS data to server" :long)
      (io/copy (io/file file-name)
               (io/file (str file-name ".bk")))
      (io/delete-file (io/file file-name))
      (start-background-gps context activity))))

(defactivity com.benbrittain.petrarch.MainActivity
  :key :main
