     
     
     /// Send a string to the device
-    func sendMessageToDevice(var message: String) {
+    func sendMessageToDevice(message: String) {
         
         if centralManager.state != .PoweredOn || connectedPeripheral == nil { return }
         
+        let writeType: CBCharacteristicWriteType = writeWithResponse ? .WithResponse : .WithoutResponse
+        
         // write the value to all characteristics of all services
-        for service in connectedPeripheral!.services as! [CBService] {
-            for characteristic in service.characteristics as! [CBCharacteristic] {
-                connectedPeripheral!.writeValue(message.dataUsingEncoding(NSUTF8StringEncoding), forCharacteristic: characteristic, type: .WithResponse)
+        for service in connectedPeripheral!.services! {
+            for characteristic in service.characteristics! {
+                connectedPeripheral!.writeValue(message.dataUsingEncoding(NSUTF8StringEncoding)!, forCharacteristic: characteristic, type: writeType)
             }
         }
         

        }
    }
    
    func centralManager(central: CBCentralManager!, didFailToConnectPeripheral peripheral: CBPeripheral!, error: NSError!) {
        if delegate.respondsToSelector(Selector("serialHandlerDidFailToConnect:error:")) {
            // just send it to the delegate
            delegate.serialHandlerDidFailToConnect!(peripheral, error: error)
        }
    }
    
    func centralManagerDidUpdateState(central: CBCentralManager!) {
        if delegate.respondsToSelector(Selector("serialHandlerDidChangeState:")) {
            // just send it to the delegate
            delegate.serialHandlerDidChangeState!(central.state)

    optional func serialHandlerDidConnect(peripheral: CBPeripheral)
    
    /// Called when a peripheral disconnected
    optional func serialHandlerDidDisconnect(peripheral: CBPeripheral, error: NSError?)
    
    /// Called when a pending connection failed
    optional func serialHandlerDidFailToConnect(peripheral: CBPeripheral, error: NSError?)
    
    /// Called when a peripheral is ready for communication
    optional func serialHandlerIsReady(peripheral: CBPeripheral)
