     func centralManager(central: CBCentralManager!, didDisconnectPeripheral peripheral: CBPeripheral!, error: NSError!) {
         println("Called did Disconnect Peripheral: \(peripheral)")
         
-        nc.postNotificationName("btStateChangedNotification", object: "Disconnected", userInfo: ["peripheral": peripheral])
-        
-        // when activePeripheral is set to nil we know we don't need to reconnect.
-        if (peripheral == self.activePeripheral) {
-            self.resetConnection()
-            self.startScanning()
+        nc.postNotificationName(
+            "btStateChangedNotification",
+            object: "Disconnected",
+            userInfo: ["peripheral": peripheral]
+        )
+        
+        delay(2.0) {
+            // wait two seconds before trying to connect again.
+            // when activePeripheral is set to nil we know we don't need to reconnect.
+            if (peripheral == self.activePeripheral) {
+                self.resetConnection()
+                self.startScanning()
+            }
         }
     }
     

        nc.postNotificationName("btStateChangedNotification", object: "Scanning")
        
        if let central = self.centralManager {
            central.scanForPeripheralsWithServices([CBUUID(string: btConst.SERVICE_UUID)], options: nil)
        }
    }
    

    override init() {
        super.init()
        
        nc.addObserver(
            self,
            selector: Selector("appDidEnterBackground"),
            name: UIApplicationDidEnterBackgroundNotification,
            object: nil)
        
        nc.addObserver(
            self,
            selector: Selector("appWillEnterForeground"),
            name: UIApplicationWillEnterForegroundNotification,
            object: nil
        )
        
        let queue = dispatch_queue_create("no.malt", DISPATCH_QUEUE_SERIAL)
        centralManager = CBCentralManager(delegate: self, queue: queue)
        
        rssiTimer = NSTimer.scheduledTimerWithTimeInterval(
            2.0,
            target: self,
            selector: Selector("doReadRSSI"),
            userInfo: nil,
            repeats: true
        )
    }
    
    func sayHello() -> String {
