         }
     }
     
-   
 }

        }
    }
    
    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)

    }
    
    
    //MARK: CBPeripheralDelegate functions
    
    func peripheral(peripheral: CBPeripheral, didDiscoverServices error: NSError?) {
        // discover all characteristics for all services
        for service in peripheral.services! {
            peripheral.discoverCharacteristics(nil, forService: service)
        }
    }
    
    func peripheral(peripheral: CBPeripheral, didDiscoverCharacteristicsForService service: CBService, error: NSError?) {
        // check whether the characteristic we're looking for (0xFFE1) is present
        for characteristic in service.characteristics! {
            if characteristic.UUID == CBUUID(string: "FFE1") {
                connectedPeripheral = peripheral
                // subscribe to this value (so we'll get notified when there is serial data for us..)
