2015-12-04 10:26:56 +00:00
|
|
|
//
|
|
|
|
// ViewController.swift
|
|
|
|
// ClockTurn
|
|
|
|
//
|
|
|
|
// Created by Lukas on 04/12/15.
|
|
|
|
// Copyright © 2015 LBS. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
class ViewController: UIViewController {
|
|
|
|
|
2016-01-03 10:44:36 +00:00
|
|
|
|
2015-12-04 10:26:56 +00:00
|
|
|
override func viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
|
|
|
// Do any additional setup after loading the view, typically from a nib.
|
|
|
|
}
|
|
|
|
|
|
|
|
override func didReceiveMemoryWarning() {
|
|
|
|
super.didReceiveMemoryWarning()
|
|
|
|
// Dispose of any resources that can be recreated.
|
|
|
|
}
|
|
|
|
|
2016-01-03 10:44:36 +00:00
|
|
|
@IBAction func forward(sender: AnyObject) {
|
|
|
|
self.sendClock("forward")
|
|
|
|
}
|
2015-12-04 10:26:56 +00:00
|
|
|
|
2016-01-03 10:44:36 +00:00
|
|
|
|
|
|
|
@IBAction func normal(sender: AnyObject) {
|
|
|
|
self.sendClock("normal")
|
|
|
|
}
|
|
|
|
|
|
|
|
@IBAction func backward(sender: AnyObject) {
|
|
|
|
self.sendClock("backward")
|
|
|
|
}
|
|
|
|
|
|
|
|
@IBAction func ignite(sender: AnyObject) {
|
|
|
|
self.sendClock("ig3") //does an ignite for 5 seconds in the clock....
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func sendClock(macro: String){
|
|
|
|
let request = NSMutableURLRequest(URL: NSURL(string: "http://192.168.0.205:8080/" + macro)!)
|
|
|
|
request.HTTPMethod = "POST"
|
|
|
|
//let postString = "" // the body, empty in our case
|
|
|
|
//request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding)
|
|
|
|
let task = NSURLSession.sharedSession().dataTaskWithRequest(request) {
|
|
|
|
data, response, error in
|
|
|
|
|
|
|
|
if error != nil {
|
|
|
|
print("error=\(error)")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
print("response = \(response)")
|
|
|
|
|
|
|
|
let responseString = NSString(data: data!, encoding: NSUTF8StringEncoding)
|
|
|
|
print("responseString = \(responseString)")
|
|
|
|
}
|
|
|
|
task.resume()
|
|
|
|
}
|
2015-12-04 10:26:56 +00:00
|
|
|
}
|
|
|
|
|